﻿	
jQuery(document).ready(function() {
	// Featured Products
    jQuery('#featured').jcarousel();
	// FancyBox jQuery
	jQuery("a.group").fancybox({ 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': true }); 	
	// Slider Homepage
	jQuery('#slider').cycle({
        fx: 'fade',
        speed: 2000,
		timeout: 9000,
        pager: '#controls',
		slideExpr: '.panel',
		pagerAnchorBuilder: function(idx, slide) { 
	        // return selector string for existing anchor 
	        return '<a href="#"></a>'; 
		}
    });
	
	// Slider Homepage 2
	jQuery('#slider2')
		.cycle({
	        fx: 'cover',
	        speed: 1,
			timeout: 0,
	        pager: '#menu-slide',
			slideExpr: '.panel2',
			// callback fn that creates a thumbnail to use as pager anchor 
			pagerAnchorBuilder: function(idx, slide) { 
	        // return selector string for existing anchor 
	        return '#menu-slide a:eq(' + idx + ')'; 
	    	} 
    });
	
	// Slider Homepage 
	jQuery('#slider3')
		.cycle({
	        fx: 'cover',
	        speed: 1,
			timeout: 0,
	        pager: '#menu-slide',
			slideExpr: '.panel3',
			pagerEvent: 'mouseover',
			// callback fn that creates a thumbnail to use as pager anchor 
			pagerAnchorBuilder: function(idx, slide) { 
	        // return selector string for existing anchor 
	        return '#menu-slide a:eq(' + idx + ')'; 
	    	} 
    });
	
	
	jQuery(".carrinho-box .cart-abrir").click(function(){
		jQuery("div#carrinho").css('height', 'auto')
		
	});
	
	jQuery(".carrinho-box .cart-fechar").click(function(){
		jQuery("div#carrinho").css('height', '0')
	});
	
	// Show/Hide All
	jQuery("#showhide-all a").click(function (event)		{ 
	     event.preventDefault(); 
	     //here you can also do all sort of things 
	});	
	jQuery("#showhide-all a").toggle(
		function(){
		
			/*fecha tudo*/
			jQuery(".showhide-all-info").css('display', 'none')
			/*abre o clicado*/
			jQuery(this).siblings(".showhide-all-info").css('display', 'block')
		
		},
		function(){
			jQuery(this).siblings(".showhide-all-info").css('display', 'none')
		
		}
	);
	
	// Show/Hide Seletivo
	jQuery("#showhideFAQ a.open, #showhideFAQ a.close").click(function (event)		{ 
	     event.preventDefault(); 
	     //here you can also do all sort of things 
	});	
	jQuery("#showhideFAQ a.open").click(function(){
		
		/*abre o clicado*/
		jQuery(this).siblings(".info").css('display', 'block')
		/*desabilita o botão + e habilita o -*/
		jQuery(this).css('background-position', '-34px -1px')
		jQuery(this).siblings("a.close").css('background-position', '-2px -1px')
		
	});
	jQuery("#showhideFAQ a.close").click(function(){
		
		/*fecha o clicado*/
		jQuery(this).siblings(".info").css('display', 'none')
		/*desabilita o botão + e habilita o -*/
		jQuery(this).css('background-position', '-97px -1px')
		jQuery(this).siblings("a.open").css('background-position', '-65px -1px')
		
	});

	jQuery("a.cart-add").click(function(){
		/* valor do input */
		var valorAtual = parseInt(jQuery(this).siblings(".qty").val())
		jQuery(this).siblings(".qty").val(valorAtual+1)
	});
	
	jQuery("a.cart-sub").click(function(){
		/* valor do input */
		var valorAtual = parseInt(jQuery(this).siblings(".qty").val())
		if (valorAtual>1) {		
			jQuery(this).siblings(".qty").val(valorAtual-1)
		}
	});
	
	jQuery(".toogleBiblioteca").click(
		function(){
			/* Na página Biblioteca virtual esconde ou torna visível a lista de conteúdo */
			var id = jQuery(this).attr('referenceid');
			if (jQuery('#itemPlus' + id).attr('class') == "plusActive") {
				jQuery('#itemPlus' + id).attr('class', 'plusInactive');
				jQuery('#item' + id).show();
				jQuery('#itemMinus' + id).attr('class', 'minusActive');
			} else {
				jQuery('#itemPlus' + id).attr('class', 'plusActive');
				jQuery('#item' + id).hide();
				jQuery('#itemMinus' + id).attr('class', 'minusInactive');	
			}
			return false;
		}
	);
	
	
	jQuery(".plusActive").live('click', function(){
		/* Na página Biblioteca virtual esconde ou torna visível a lista de conteúdo */
		var id = jQuery(this).attr('referenceid');
		jQuery(this).attr('class', 'plusInactive');
		jQuery('#item' + id).show();
		jQuery('#itemMinus' + id).attr('class', 'minusActive');
		return false;
	});
	jQuery(".minusActive").live('click', function(){
		/* Na página Biblioteca virtual esconde ou torna visível a lista de conteúdo */
		var id = jQuery(this).attr('referenceid');
		jQuery(this).attr('class', 'minusInactive');
		jQuery('#item' + id).hide();
		jQuery('#itemPlus' + id).attr('class', 'plusActive');
		return false;
	});
	
	jQuery(".plusInactive").live('click', function(){
		return false;
	});
	
	jQuery(".minusInactive").live('click', function(){
		return false;
	});
	
	jQuery(".tree").toggle(
		function(){
			jQuery("#" + jQuery(this).attr("vId")).slideDown("slow");
			return false;
		},
		function(){
			jQuery("#" + jQuery(this).attr("vId")).slideUp("slow");
			return false;
		}
	);
	
	
	jQuery('.numberField').keypress(function(e){
		if ((e.which>=48 && e.which<=57) || e.which==8 || e.which==0) {
			return true;
		} else {
			//possível alerta
			return false;
		}
	});
});
