function fechaPopUpMae(){
	document.getElementById("fundo-cinza").style.display = "none";
	document.getElementById("pop-up-maes-geral").style.display = "none";
	
}

function fecha()
{
	document.getElementById("nota1").style.display = "none";	
	document.getElementById("nota2").style.display = "none";	
	document.getElementById("nota3").style.display = "none";	
	document.getElementById("popup").style.display = "none";	
	document.getElementById("fundo").style.display = "none";	
	document.getElementById("bloqueio").style.display = "none";	
	document.body.style.overflow = "auto";
}

function fechaIE()
{
	document.getElementById("popup-ie7").style.display = "none";	
	document.getElementById("fundo-ie7").style.display = "none";	
	document.body.style.overflow = "auto";
}

function fadeOut(id, time) {
	target = document.getElementById(id);
	alpha = 100;
	timer = (time*1000)/50;
	var i = setInterval(
			function() {
				if (alpha <= 0)
					clearInterval(i);
				setAlpha(target, alpha);
				alpha -= 2;
			}, timer);
}

//function fadeIn(id, time) {
//	target = document.getElementById(id);
//	alpha = 0;
//	timer = (time*1000)/50;
//	var i = setInterval(
//			function() {
//				if (alpha >= 100)
//					clearInterval(i);
//				setAlpha(target, alpha);
//				alpha += 2;
//			}, timer);
//}

function fadeIn(id, time, e) {
	target = document.getElementById(id);
	total = 100;
	
	if(id == 'fundo')
		total=60;
		
	alpha = 0;
	timer = (time*1000)/50;
	var i = setInterval(
			function() {
				if (alpha >= total)
					clearInterval(i);
				setAlpha(target, alpha, e);
				alpha += 2;
			}, timer);

}

function setAlpha(target, alpha, e) {
	target.style.filter = "alpha(opacity="+ alpha +")";
	target.style.opacity = alpha/100;
	
	if(alpha==100 && e == '1')
	{
		fadeIn('nota2', 1.5, '2')	
	}
	
	if(alpha==100 && e == '2')
	{
		fadeIn('nota3', 1.5, '3')	
	}
	
	if(alpha==100 && e == '3')
	{
		fadeIn('popup', 1.5, '4')	
	}
	
	if(alpha==100 && e == '4')
	{
		fadeIn('fundo', 1.5, '5')	
	}
}

function news()
{

	if(document.getElementById("news").style.display == "block")	
		document.getElementById("news").style.display = "none";
	else
		document.getElementById("news").style.display = "block";	
}

function overBtn(e, url){
	e.src=url;
}

function outBtn(e, url){
	e.src=url;
}

$(document).ready(function(){
	/* The following code is executed once the DOM is loaded */
	
	$('.sponsorFlip').bind("click",function(){
		
		// $(this) point to the clicked .sponsorFlip element (caching it in elem for speed):
		
		var elem = $(this);
		
		// data('flipped') is a flag we set when we flip the element:
		
		if(elem.data('flipped'))
		{
			// If the element has already been flipped, use the revertFlip method
			// defined by the plug-in to revert to the default state automatically:
			
			elem.revertFlip();
			
			// Unsetting the flag:
			elem.data('flipped',false)
		}
		else
		{
			// Using the flip method defined by the plugin:
			
			elem.flip({
				direction:'lr',
				speed: 350,
				onBefore: function(){
					// Insert the contents of the .sponsorData div (hidden from view with display:none)
					// into the clicked .sponsorFlip div before the flipping animation starts:
					
					elem.html(elem.siblings('.sponsorData').html());
				}
			});
			
			// Setting the flag:
			elem.data('flipped',true);
		}
	});
	
});
