
var vitrine =
{
	total:null,
	current:null,
	container:null,
	
	back:function()
	{
		vitrine.current = vitrine.loop( vitrine.current - 1 );
		vitrine.update();
	},
	
	next:function()
	{
		vitrine.current = vitrine.loop( vitrine.current + 1 );
		vitrine.update();
	},
	
	loop:function( value )
	{
		return value < 0 ? vitrine.total + value : ( value >= vitrine.total ? value % vitrine.total : value );
	},
	
	update:function()
	{
		vitrine.container.animate( { left:vitrine.current * -359 }, 1000 );
	},
	
	init:function()
	{
		vitrine.current = 0;
		vitrine.container = $( "#band .vitrine ul" );
		vitrine.total = vitrine.container.find( 'li' ).length;
		
		vitrine.container.css( { width:359 * vitrine.total } );
		vitrine.total -=2;
	}
}



var galeria =
{
	total:null,
	current:null,
	container:null,
	
	back:function()
	{
		galeria.current = galeria.loop( galeria.current - 1 );
		galeria.update();
	},
	
	next:function()
	{
		galeria.current = galeria.loop( galeria.current + 1 );
		galeria.update();
	},
	
	loop:function( value )
	{
		return value < 0 ? galeria.total + value : ( value >= galeria.total ? value % galeria.total : value );
	},
	
	update:function()
	{
		galeria.container.animate( { left:galeria.current * -180  }, 300 );
	},
	
	init:function()
	{
		galeria.current = 0;
		galeria.container = $( "#leftBar ul.galeria" );
		galeria.total = galeria.container.find( 'li' ).length;
		
		galeria.container.css( { width:180  * galeria.total } );
		//galeria.total -=9;
		setInterval(galeria.next , 5000);
	}
}

var promocao =
{
	total:null,
	current:null,
	container:null,
	
	back:function()
	{
		promocao.current = promocao.loop( promocao.current - 1 );
		promocao.update();
	},
	
	next:function()
	{
		promocao.current = promocao.loop( promocao.current + 1 );
		promocao.update();
	},
	
	loop:function( value )
	{
		return value < 0 ? promocao.total + value : ( value >= promocao.total ? value % promocao.total : value );
	},
	
	update:function()
	{
		promocao.container.animate( { left:promocao.current * -170  }, 300 );
	},
	
	init:function()
	{
		promocao.current = 0;
		promocao.container = $( "#body ul.promo" );
		promocao.total = promocao.container.find( 'li' ).length;
		
		
		
		promocao.container.css( { width:170  * promocao.total } );
		promocao.total -=4;
		setInterval(promocao.next , 5500);
	}
}

var videos =
{
	total:null,
	current:null,
	container:null,
	
	posPt:function()
	{
		videos.current = 0;
		videos.update();
	},
	posEn:function()
	{
		videos.current = 240;
		videos.update();
	},
	posEsp:function()
	{
		videos.current = 480;
		videos.update();
	},
	update:function()
	{
		videos.container.animate( { left: -videos.current }, 300 );
		
	},
	
	init:function( value )
	{
		videos.current = 0;
		videos.container = $( "#leftBar ul.videos" );
		
		
		
	}
}

$(document).ready(function() {
	
	vitrine.init();
	galeria.init();
	videos.init();
	promocao.init();
	
	$('.promocoes-slider').corner('10px');
	
	$("a.fancy").fancybox({
		'opacity'		: true,
		'overlayShow'	: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'none'
	});

	
});

function openVideo( target )
{
	$.fancybox({
			'titleShow'     : true,
			'transitionIn'  : 'false',
			'transitionOut' : 'elastic',
			'href'			: target.href.replace(new RegExp("watch\\?v=", "i"), 'v/') + '&autoplay=1',
			'type'			: 'swf',
			'swf'			: {'wmode':'transparent','allowfullscreen':'true'}
	});
	
	return false;
}


function formatar(src, mask){
  var i = src.value.length;
  var saida = mask.substring(0,1);
  var texto = mask.substring(i)
	if (texto.substring(0,1) != saida)
  	{
    	src.value += texto.substring(0,1);
  	}
}


function toogle(){
	
	
	$('.hoteis').slideToggle('slow');
	$('.subMenuBack').slideToggle('slow');
	
	if( $('.principal ul li.click').hasClass("sub") ){
		$('.principal ul li.click').removeClass("sub");
	}else{
		$('.principal ul li.click').addClass("sub");	
	}

	preventDefault();
	return false;
};
