// JavaScript Document
var currentId = "";	
$(document).ready(function(){/*
	$(".scroll").click(function(event){
		//prevent the default action for the click event
		event.preventDefault();

		//get the full url - like mysitecom/index.htm#home
		var full_url = this.href;

		//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
		var parts = full_url.split("#");
		var trgt = parts[1];

		//get the top offset of the target anchor
		var target_offset = $("#"+trgt).offset();
		var target_top = target_offset.top-40;

		//goto that anchor by setting the body scroll top to anchor top
		$('html, body').animate({scrollTop:target_top}, 500);
	});
	*/
		//COMPORTAMENTO LABEL SOPRA INPUT
		$("#frm_search label").click(function() { // bind click event to link
			$(this).addClass("hide");
			$(this).next().focus();
		});
		$("#frm_search input.t-text").focus(function() { // bind click event to link
			$(this).prev().addClass("hide");
		});
		$("#frm_search input.t-text").blur(function() { // bind click event to link
			if(this.value == "") $(this).prev().removeClass("hide");
		});		
	//END
		
		var currentY = 0; 			// Y position is stored when curtain is called
		var diffY = 0; 				// Y difference to detect scroll up or down
		var status_curtain = 0; 	// curtain is open or not		
		var state = "";				// we, love, etc...


		/* ******************************************* 
		*
		*	Curtain: init
		*
		******************************************* */

		function initCurtain() {					
			$("#blackcurtain").css("height",  $(document).height() );	 // height of the curtain			
			// get url
			var source = window.location.toString(); 
			var urlanchor = source.split("#");		
	

			// is there a curtain to load ?	
			if( urlanchor[1] != "") {
				openCurtain( source );			
			}		

		}

		/* ******************************************* 
		*
		*	Curtain: open
		*
		******************************************* */
		
		if( $(".curtainIt").length )
		{
			$("#blackcurtain").css("height",  $(document).height() );	 // height of the curtain	
			$(".curtainIt").click(function(event){
				//prevent the default action for the click event
				event.preventDefault();

				// call the curtain
				openCurtain(this.href);
			});  		
		}
		
		function openCurtain( full_url ) {	
			
			currentY = $(window).scrollTop();
			// Hide content
			$("#slideshow_info").hide();
																	
			// Y position of content		
			$("#blackcurtaincontent").css("top", (currentY+5)+"px");
			
			// Bring the curtain in						
			$("#blackcurtain").animate({ left: "0px" }, '300', bringInfo)
			$("#closeBtn").animate({ left: "455px" }, '300');
				

			window.location = full_url;	// Changes URL
			status_curtain = 1; // Curtain is active
		}


		/* ******************************************* 
		*
		*	Curtain: close
		*
		******************************************* */

		// Actions for the close button
		if( $(".close").length ) 
		{
			$(".close").click(closeCurtain);		
		}
		
		// Actions for the sidemenu buttons
		if($(".scroll").length)
		{
			$(".scroll").click(closeCurtainAndGo);
		}		

		function closeCurtain()
		{
			status_curtain = 0; // Curtain is deactivated
				
			$("#blackcurtain").stop().animate({ left: "-500px" }, '500', hideInfo);
			$("#closeBtn").stop().animate({ left: "-36px" }, '500');	
			
			if( currentY != window.pageYOffset ) {
				$('html, body').animate({scrollTop:currentY}, 400, "easeout");
			}

			currentY = 0;			
		}

		function closeCurtainAndGo()
		{
			currentId = $(this).attr("id");
		
			if ( status_curtain == 1)
			{
				status_curtain = 0; // Curtain is deactivated											
			
				$("#blackcurtain").stop().animate({ left: "-500px" }, '500', hideInfo);
				$("#closeBtn").stop().animate({ left: "-36px" }, '500');		
			}
			
			if(currentId != state) {
				thisMovie("sample").fatStartJump();
			} 			
				
		}		

				
		/* ******************************************* 
		*
		*	Curtain Info: hide
		*
		******************************************* */
		
		function hideInfo() {			
			$("#slideshow_info").fadeOut(200);
			$("#curtainHello").fadeOut(200, emptyInfo);			
		}
		
		function emptyInfo() {
			$("#slideshow-container").empty().append("<div id='slideshow_holder'></div>");
			$("#curtainTitle").empty();
			$("#description").empty();			
		}


});
		function bringInfo() {
			setTimeout(showInfo,300);
			
			//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
			var source = window.location.toString();
			var anchor = source.split("#");			

			// Ajax call		
			$.get(website+"/blocchi.php?dir=pagine&file=sez&id="+anchor[1], function(data){
 				$("#slideshow_info").html(data);
			});	
			

		}

		function showInfo() {
			$("#slideshow_holder").fadeIn(200);
			$("#slideshow_info").fadeIn(200);
			
			var source = window.location.toString(); 
			var urlanchor = source.split("#");
			$("#curtainHello").fadeIn(200);				
			
	

		}

