function abreLookBook(){
	window.location.href='./lookbook';
}

function abreSlideShow(){
	$.nyroModalManual({
		url:'./modal_slideshow',
		closeButton: '<a href="#" class="nyroModalClose" id="closeBut" title="Fechar">Fechar</a>',
		forceType:'iframe',
		width:910,
		height:735,
		padding: 0,
		minWidth: 910,
		minHeight: 735,
		resizable: true,
		autoSizable: true
	});
}

$(document).ready(function(){
	// BANNER ROTATORIO NA HOME

	//Get size of the image, how many images there are, then determin the size of the image reel.
	var imageWidth = $(".BannerConteudo").width();
	var imageSum = $(".BannerImagens img").size();
	var imageReelWidth = imageWidth * imageSum;
	var rotateSeconds = '7';

	//Adjust the image reel to its new size
	$(".BannerImagens").css({'width' : imageReelWidth});
	//Backup rotateSeconds default
	var defaultRotateSeconds = rotateSeconds;

	//Paging  and Slider Function
	rotate = function(){
		var triggerID = $active.attr("rel") - 1; //Get number of times to slide
		var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide

		$(".BannerPaginacao a").removeClass('active'); //Remove all active class
		$active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)

		//Slider Animation
		$(".BannerImagens").animate({
			left: -image_reelPosition
		}, 500 );

		//if(rotateSeconds != defaultRotateSeconds){
			rotateSeconds = defaultRotateSeconds;
			clearInterval(play);
			rotateSwitch();
		//}
	}; 

	//Rotation  and Timing Event
	rotateSwitch = function(){
		var rotateMiliseconds = rotateSeconds * 1000;
		play = setInterval(function(){ //Set timer - this will repeat itself every 7 seconds
			$active = $('.BannerPaginacao a.active').next(); //Move to the next paging
			if ( $active.length === 0) { //If paging reaches the end...
				$active = $('.BannerPaginacao a:first'); //go back to first
			}
			rotate(); //Trigger the paging and slider function
		}, rotateMiliseconds); //Timer speed in milliseconds (7 seconds)
	};

	if(imageSum > 1){
		$('.BannerConteudo').append('<div class="BannerPaginacao"></div>');

		for(i=1; i <= imageSum; i++){
			$('.BannerPaginacao').append('<a href="#" rel="'+ i +'">'+ i +'</a>');
		}
		//Show the paging and activate its first link
		$(".BannerPaginacao").show();
		$(".BannerPaginacao a:first").addClass("active");
		
		rotateSwitch(); //Run function on launch
	}

	//On Hover
	$(".BannerImagens img").hover(function() {
		clearInterval(play); //Stop the rotation
	}, function() {
		rotateSeconds = 1;
		rotateSwitch(); //Resume rotation timer
	});	

	//On Click
	$(".BannerPaginacao a").click(function() {
		$active = $(this); //Activate the clicked paging
		//Reset Timer
		clearInterval(play); //Stop the rotation
		rotate(); //Trigger rotation immediately
		rotateSwitch(); // Resume rotation timer
		clearInterval(play);
		return false; //Prevent browser jump to link anchor
	});
});
