jQuery(document).ready(function(){
	
  	jQuery("#menuSuperior span").css("opacity","0");

	jQuery("#menuSuperior span").hover(function () {
		jQuery(this).stop().animate({
			opacity: 1
		}, "slow");
	},
	function () {
		jQuery(this).stop().animate({
			opacity: 0
		}, "slow");
	});
	
	jQuery('#sideLeft ul li ul li a')
		.css( {backgroundPosition: "0 0"} )
		.mouseover(function(){
			jQuery(this).stop().animate({backgroundPosition:"(0 -250px)"}, {duration:500})
		})
		.mouseout(function(){
			jQuery(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:500})
		})

	jQuery('#sideLeft ul li.selecionado ul').show();
	jQuery('#sideLeft ul li a.accordion').click(function() {
		jQuery('#sideLeft ul li ul').hide('slow');
		jQuery(this).next('ul').toggle('slow');
			return false;
		});
		
	jQuery('#banners').cycle({ 
		    pause:   1,
			pager:  '#nav',
			slideExpr: 'span'
		});
		
	jQuery('.rodaParceiros').cycle();
	
	jQuery(".telefone").mask("(99) 9999-9999");
	
	if(jQuery('#sideLeft').height() < jQuery('#meio').height()) {
		jQuery('#sideLeft').css({ height: jQuery('#meio').height() });
	}
	if(jQuery('#sideRight').height() < jQuery('#meio').height()) {
		jQuery('#sideRight').css({ height: jQuery('#meio').height() });
	}
/*
	jQuery(".banner").hover(function() {
		jQuery(this).children('.descrBanner').animate({
			height: '100%',
			opacity: 'toggle'
		  });
	}, function() {
		jQuery(this).children('.descrBanner').animate({
		   	height: 0,
			opacity: 'toggle'
		  });
	});
	*/
	jQuery("a.fancybox").fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});
	
	jQuery("a.verTodos").hover(function() {
		jQuery(this).children("em").stop(true, true).animate({opacity: "show", top: "25"}, "slow");
	}, function() {
		jQuery(this).children("em").animate({opacity: "hide", top: "0"}, "fast");
	});
	
	jQuery(".imgProd").hover(function() {
		jQuery(this).children("em").stop(true, true).animate({opacity: "show", bottom: "45"}, "slow");
	}, function() {
		jQuery(this).children("em").animate({opacity: "hide", bottom: "45"}, "fast");
	});
	
	jQuery(".spinner").spinner({
			min: 1,
			max: 999
		});

});

var abrirPopup = function() {
	var page_height = jQuery(document).height();

	var fundoTransp = document.createElement("div");
	fundoTransp.style.display = "none";
	fundoTransp.style.background = "url(wp-content/themes/flashstudio/images/black.png)";
	fundoTransp.style.width = "100%";
	fundoTransp.style.height = page_height+"px";
	fundoTransp.style.position = "absolute";
	fundoTransp.style.top = "0";
	fundoTransp.style.left = "0";
	fundoTransp.style.zIndex = "999";
	fundoTransp.id = "fundoTransp";

	var popup = document.getElementById("popupPoster");
	var divPopup = popup;
	var fechar = document.getElementById("fecharPopup");
	var linkFechar = fechar;
	
	var fechar2 = document.getElementById("jaCadastrado");
	var linkFechar2 = fechar2;
	
	divPopup.style.display = "block";

	linkFechar.onclick = function() {
		jQuery(fundoTransp).fadeOut(200, function() { document.body.removeChild(fundoTransp); });
	}
	
	linkFechar2.onclick = function() {
		jQuery(fundoTransp).fadeOut(200, function() { document.body.removeChild(fundoTransp); });
	}

	divPopup.appendChild(linkFechar);
	divPopup.appendChild(linkFechar2);
	fundoTransp.appendChild(divPopup);
	document.body.appendChild(fundoTransp);

	jQuery(fundoTransp).fadeIn(200);

	return false;
}
