

$(document).ready(function(){

	$('#load').animate({'opacity': '0'}, 400, 'linear', function(){
		carrusellTransition();
		rot = setInterval("carrusellTransition()", 10000);
	});

	// loadBanner();
	
});

// global variables
b = -1;



/** cargamos el banner *****************************************

function loadBanner()
{
	x = $(document).width() / 2;
	w = x - 225;
	y = x - 300;
	
	$("body").append("<div id='sbannerpopup'></div>");
	$("#sbannerpopup").css({'position': 'absolute', 'top':'70px', 'left': '-' + (w + 40) + 'px', 'z-index':'1000000', 'display':'block', 'background-color': '#000', 'opacity': '0.75', 'width': '490px', 'height': '755px'});
	$("#sbannerpopup").animate({'left': y + 'px'}, 1000, 'linear', function(){});	
	
	
	//$("body").append("<a href='javascript:closeAd();void(0);' id='bannerpopup'><img src='" + URL + "datos/imagenes/banner_gira2012.jpg' border='0' width='600' height='400' /></a>");
	$("body").append("<a href='javascript:closeAd();void(0);' id='bannerpopup'><img src='" + URL + "datos/imagenes/banner_gira2012.jpg' border='0' width='450' height='715' /></a>");
	$("#bannerpopup").css({'position': 'absolute', 'top':'90px', 'left': '-' + (w + 20) + 'px', 'z-index':'1000001'});
	$("#bannerpopup").animate({'left': (y + 20) + 'px'}, 1000, 'linear', function(){});		
}


function closeAd()
{
	$("#sbannerpopup").animate({'left': '-' + (w + 40) + 'px'}, 1000, 'linear', function(){});		
	$("#bannerpopup").animate({'left': '-' + (w + 20) + 'px'}, 1000, 'linear', function(){});	
}

******************/



// funcion que ejecuta la transicion
function carrusellTransition()
{
	b++;
	b = b%3;
	
	$('.banner').animate({'opacity': 0}, 400, 'linear', function(){
		$('.banner').hide();
		$('.banner').eq(b).show().animate({'opacity': 1}, 400, 'linear', function(){});
		$('.banners a.next').show();
	});
}

// detiene la transicion si es hover en banner
$('.banner, map.ban').live('mouseover mouseout', function(event) {
	if (event.type == 'mouseover') {
		clearInterval(rot);
	}
	else
	{
		rot = setInterval("carrusellTransition()", 10000);
	}
});


// el efecto hover en la flecha de next
$('.banners a').live('mouseover mouseout', function(event) {
	if (event.type == 'mouseover') {
		$('.banners a.next').animate({'opacity': 0.85}, 100, 'linear', function(){});
		clearInterval(rot);
	}
	else
	{
		$('.banners a.next').animate({'opacity': 0.35}, 100, 'linear', function(){});
		rot = setInterval("carrusellTransition()", 10000);
	}
});

// al darle click a next
$('.banners a.next').live('click', carrusellTransition);




