	// perform JavaScript after the document is scriptable.
	var FADE_TOP=0.5; 
	var FADE_BOTTOM=0.25;
	var SLIDESHOW_SLEEP = 5;
	var SLIDESHOW_FADE = 3; 
	var ART_FADE_TOP=1; 
	var ART_FADE_BOTTOM=0.2;
	
	function attivaSlideShow() {
	    $('#homeimages').crossSlide({
		  fade: 3
		}, [
		  { src: 'artworks/women/3d-woman-8.png',
		  	from:'20% 18% 1x', 
		  	to:'10% 5% 1x', 
		  	time: 6
		  }, { src: 'artworks/women/3d-woman-6.png',
		  	from:'14% 32%', 
		  	to:'18% 47%', 
		  	time: 6
		  }, { src: 'artworks/women/3d-woman-4.png',
		  	from:'20% 65%', 
		  	to:'10% 46%', 
		  	time: 6
		  }, { src: 'artworks/animations/piedi-di-feltro.png',
		  	from:'10% 20%', 
		  	to:'30% 30%', 
		  	time: 6
		  }, { src: 'artworks/realism/cigarettes.png',
		  	from:'10% 30%', 
		  	to:'10% 10%', 
		  	time: 6
		  }, { src: 'artworks/realism/xmas-ball.png',
		  	from:'5% 25%', 
		  	to:'20% 38%', 
		  	time: 6
		  }
		]);
	}
	
	function launchLightbox(idimage) {
		$('#'+idimage).trigger('click');	
	}
	
	function sendmail() {
		var emailaddress = "mailto:"; 
		emailaddress += "info" + "@";
		emailaddress += "fabriziogobbi.com";
		parent.location= emailaddress;
	}
	
	$(function() { 

		//Creo jTools Tabs 
	    $("div.menutabs").tabs("div.menupanes > div",{
	        effect: 'fade', 
	        fadeOutSpeed: "slow",
	        fadeInSpeed: "slow",
	        initialIndex: 0,
	        tabs: "div",

		    onBeforeClick: function(event, tabIndex) {
		        this.getCurrentTab().fadeTo("slow", FADE_BOTTOM);
		    },
		    
		    onClick: function(event, tabIndex) {
		    	this.getPanes().hide();
		    	this.getCurrentPane().show();
		    	this.getCurrentTab().fadeTo("slow", FADE_TOP);
		    	if (this.getCurrentTab().attr("id") == "logotab") {
				    $("a.prevPage").css("visibility","visible");
				    $("a.nextPage").css("visibility","visible");
				    //$("a.prevPage").fadeIn("normal");
				    //$("a.nextPage").fadeIn("normal");
		    	} else {
				    //$("a.prevPage").fadeOut("normal");
				    //$("a.nextPage").fadeOut("normal");
				    $("a.prevPage").css("visibility","hidden");
				    $("a.nextPage").css("visibility","hidden");
		    	}
		    } 
	    }).history();

		//Creo lo slide show della Home Page
		attivaSlideShow();

	    var apitabs = $("div.menutabs").tabs();
		
		//Gestisco l'effetto fade dei menu	    	    	    	    	    	    
    	$("div.menu").mouseover(function () {
	      $(this).fadeTo("slow", FADE_TOP);
	    });
	    
    	$("div.menu").mouseout(function () {
			if ($(this).attr("id") != $("div.menutabs").tabs().getCurrentTab().attr("id")) {
				$(this).fadeTo("slow", FADE_BOTTOM);
			}
	    });
	    
	    //Gestisco le flipbox della sezione ARTWORKS
	    $("div.cj_image_flipbox_block").cjImageFlipBox({});
	    $("div.cj_image_flipbox_block").fadeTo(0,ART_FADE_BOTTOM);

	    $("div.cj_image_flipbox_block").mouseover(function(){
	    	$(this).fadeTo("normal", ART_FADE_TOP);
	    	$(this).next().fadeOut("normal");
	    });
	    
	    $("div.cj_image_flipbox_block").mouseout(function(){
	    	$(this).fadeTo("normal", ART_FADE_BOTTOM);
	    	$(this).next().fadeIn("normal");
	    });

		$("a.prevPage").css("visibility","hidden");
		$("a.nextPage").css("visibility","hidden");
	    $("div.button").fadeTo(0, FADE_BOTTOM);
	    $("div.sendemailpane").fadeTo(0, 0);
	    //apitabs.getCurrentTab().fadeTo(0, FADE_TOP);
	    //apitabs.getPanes().hide();
	    $("#container").show();
	    		
		 $("div.scrollable").scrollable({
		 	size: 1,
		 	clickable: false
		 }).circular().navigator(".dotnavi");
		 
		 var naviwidth = 14 * ($("div.scrollable").scrollable().getItems().length - 2);
		 $(".dotnavi").css("width", naviwidth + "px");


		$("a[rel^='prettyPhoto']").prettyPhoto({
			animationSpeed: 'normal', /* fast/slow/normal */
			padding: 40, /* padding for each side of the picture */
			opacity: 0.35, /* Value betwee 0 and 1 */
			showTitle: true, /* true/false */
			allowresize: true, /* true/false */
			counter_separator_label: 'of', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'dark_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
			hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
			modal: false, /* If set to true, only the close button will close the window */
			changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
			callback: function(){} /* Called when prettyPhoto is closed */
		});
		
		 /* Gestisco il testo della sezione About me*/
		 
		 $("#biopaneTrigger").mouseover(function () {
		 
		 	$(".biopanetext").css("marginLeft","-900px");
		 	$(".biopanetext").animate({
		 		marginLeft: "0px",
		 		opacity: "0.95"
		 	}, 300, "swing");
		 
		 });
	
		 $("#biopaneTrigger").mouseout(function () {
		 
		 	$(".biopanetext").animate({
		 		marginLeft: "900px"
		 	}, 700, "swing");
		 
		 });
	    
		 /* Gestisco i Contatti*/
		 
		 $("#sendemailTrigger").mouseover(function () {
		 
		 	$("div.sendemailpane").fadeTo("normal", FADE_TOP * 1.2);
		 
		 });
	
		 $("#sendemailTrigger").mouseout(function () {
		 
		 	$("div.sendemailpane").fadeTo("normal", 0);
		 
		 });
	    
		 $("#sendemailTrigger").click(function () {
		 
		 	sendmail();
		 
		 });
	    
	});
	

