jQuery(document).ready(function() {

 	jQuery("#command").css({'zIndex': 1000});
 	jQuery(".video-gallery").css({'zIndex': 20});
 	jQuery(".image-gallery").css({'zIndex': 10});

	jQuery('#fiori-at-work').cycle({
		fx: 'fade',
		speed:  1 ,
		timeout:0,
		random:  1 
		 // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});

	jQuery('#gallery').cycle({
		slideExpr: 'img.image-gallery',
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});

	/*MENU*/
	jQuery('.sistemi-pilot, .sistemi-dropdown').hover(function(){
      jQuery('a.sistemi-pilot').addClass("hover").css("zIndex","100");
		jQuery('.sistemi-dropdown').show().css("zIndex","1000");
	}, function(){
    	jQuery('a.sistemi-pilot').removeClass("hover");
		jQuery('.sistemi-dropdown').hide();
	});
	
	jQuery('.soluzioni-pilot, .soluzioni-dropdown').hover(function(){
      jQuery('a.soluzioni-pilot').addClass("hover").css("zIndex","100");
		jQuery('.soluzioni-dropdown').show().css("zIndex","1000");
	}, function(){
    	jQuery('a.soluzioni-pilot').removeClass("hover");
		jQuery('.soluzioni-dropdown').hide();
	});
	
	jQuery('.servizi-pilot, .servizi-dropdown').hover(function(){
      jQuery('a.servizi-pilot').addClass("hover").css("zIndex","100");
		jQuery('.servizi-dropdown').show().css("zIndex","1000");
	}, function(){
    	jQuery('a.servizi-pilot').removeClass("hover");
		jQuery('.servizi-dropdown').hide();
	});
	
	jQuery('.azienda-pilot, .azienda-dropdown').hover(function(){
      jQuery('a.azienda-pilot').addClass("hover").css("zIndex","100");
		jQuery('.azienda-dropdown').show().css("zIndex","1000");
	}, function(){
    	jQuery('a.azienda-pilot').removeClass("hover");
		jQuery('.azienda-dropdown').hide();
	});
	
	jQuery('.contatti-pilot, .contatti-dropdown').hover(function(){
      jQuery('a.contatti-pilot').addClass("hover").css("zIndex","100");
		jQuery('.contatti-dropdown').show().css("zIndex","1000");
	}, function(){
    	jQuery('a.contatti-pilot').removeClass("hover");
		jQuery('.contatti-dropdown').hide();
	});
	
	
	
 	jQuery('.language-pilot, .language-dropdown').hover(function(){
		jQuery('.language-dropdown').show();
	}, function(){
		jQuery('.language-dropdown').hide();
	});

	/*MAP*/
	jQuery('.point, .content-tooltip').hover(function(){

		jQuery(this).children('.content-tooltip').css('zIndex','100000');
		jQuery('.point').css('zIndex','0');
		jQuery(this).css('zIndex','100000');


		jQuery(this).children('.content-tooltip').show();
		}, function(){
		jQuery(this).children('.content-tooltip').hide();
		jQuery('.point').css('zIndex','0');
	});

	/*FORMS*/
	jQuery("#privilege-card-submit").hover(function(){
		jQuery(this).find(".rollout").hide();
		jQuery(this).find(".rollover").css({"display":"block"});
	}, function(){
      jQuery(this).find(".rollout").show();
      jQuery(this).find(".rollover").hide();
	});

 	jQuery('.slideshow').cycle({
		fx: 'fade'
	});

	/*PARAGRAFI ESPANDIBILI*/
   jQuery(".description").find("span").each(function(){
		jQuery(this).attr("height", jQuery(this).innerHeight()+20);
 	});
	jQuery(".description").find("> span:gt(0)").css({"height":"2px"}).attr("status","closed");
	jQuery(".description").find("span:lt(1)").attr("status","opened");
	jQuery(".description.single-page").find("> span").css({"height":"2px"}).attr("status","closed");
	jQuery(".description").find("h2").css({"cursor":"pointer","collapsible":"true"});
   jQuery(".description").find("h2:gt(0)").css({"background-image":"url('"+path+"/images/arrow-r.gif\')"})
   jQuery(".description.single-page").find("h2").css({"background-image":"url('"+path+"/images/arrow-r.gif\')"})

	jQuery('.description h2').click(function(){
	   if(jQuery(this).next().attr('status')=="opened"){
			jQuery(this).css({"background-image":"url('"+path+"/images/arrow-r.gif\')"});
			jQuery(this).next('span').stop().animate({"height":"1px"},1000,"swing");
			jQuery(this).next('span').attr('status','closed');
		} else if(jQuery(this).next('span').attr('status')=="closed"){
			jQuery(this).css({"background-image":"url('"+path+"/images/arrow-b.gif\')"});
			jQuery(this).next('span').stop().animate({"height":jQuery(this).next().attr('height')},1000,"swing").show();
			jQuery(this).next('span').attr('status','opened');
      }
	});
});
