
$(document).ready(function()
{   
  
		//SEMPRE: COMPARIZIONE LOGO

    $(".leftbanner h1 a").show("slow"); 
  

		// SEMPRE: CARRELLO

   	$.ajax(
   	{
   		url: "ec-carrello.asp",
   		cache: false,
   		success: function(html)
   		{
    	  $("#cpanel").append(html);
   		}
 		});
 		
		//SEMPRE: PANEL SUPERIORE
    
     $(".carrello").click(function()
     {
   		  if ($(".login").hasClass("lactive")) 
   		  { 
        	$("#lpanel").slideToggle("slow");
       		$(".login").removeClass("lactive")
    		} 
    		if ($(".lingua").hasClass("liactive"))
    		{ 
       	  $("#lipanel").slideToggle("slow");
         	$(".lingua").removeClass("liactive")
    		} 
    		var mleft = (830-parseInt(jQuery("#cpanel").width()))+"px";
   		  $("#cpanel").animate({marginLeft: mleft, minWidth: "107px" },10);
				$("#cpanel").slideToggle("slow");
				$(this).toggleClass("cactive"); return false;
		 });
		 
		 $(".login").click(function()
		 {
				if ($(".lingua").hasClass("liactive")) 
				{ 
      	  $("#lipanel").slideToggle("slow");
      	  $(".lingua").removeClass("liactive")
    		} 
  			if ($(".carrello").hasClass("cactive")) 
  			{ 
      	  $("#cpanel").slideToggle("slow");
      	  $(".carrello").removeClass("cactive")
   	  	} 
				$("#lpanel").slideToggle("slow");
				$(this).toggleClass("lactive"); return false;
		});
	
		$(".lingua").click(function()
		{
			  if ($(".login").hasClass("lactive"))
			  { 
       			$("#lpanel").slideToggle("slow");
        		$(".login").removeClass("lactive")
    		} 
  			if ($(".carrello").hasClass("cactive"))
  			{ 
      		  $("#cpanel").slideToggle("slow");
       			$(".carrello").removeClass("cactive")
    		} 
				$("#lipanel").slideToggle("slow");
				$(this).toggleClass("liactive"); return false;
		}); 		
		
		
		// SEMPRE: COMPORTAMENTO BUTTONS JQUERY UI

		$(function()
	  {
				//all hover and click logic for buttons
				$(".fg-button:not(.ui-state-disabled)")
				.hover(
								function(){$(this).addClass("ui-state-hover");},
								function(){$(this).removeClass("ui-state-hover");}
							)
				.mousedown(function()
				{
								$(this).parents('.fg-buttonset-single:first').find(".fg-button.ui-state-active").removeClass("ui-state-active");
								if( $(this).is('.ui-state-active.fg-button-toggleable, .fg-buttonset-multi .ui-state-active') )
									{ $(this).removeClass("ui-state-active"); }
								else { $(this).addClass("ui-state-active"); }	
				})
				.mouseup(function()
				{
					if(! $(this).is('.fg-button-toggleable, .fg-buttonset-single .fg-button,  .fg-buttonset-multi .fg-button') )
					{
						$(this).removeClass("ui-state-active");
					}
				});
	  });		
 		  

			//HOMEPAGE: COMPARIZIONE

      $("#boxpage").fadeTo("slow", 1, function()
      {   
        	$(".boxgrid").fadeTo("slow", 1);
        	$("div.struttura").fadeTo("slow", 1);
        	$("h3 a.destinazione").fadeTo("slow", 1);
        	$("#menupage").fadeTo("slow", 1);
        	$(".topbanner").fadeTo("slow", 1);
        	slide("#sliding-navigation", 25, 15, 150, 1.2);
      });

 		  
			// HOMEPAGE: COMPORTAMENTO LISTA OFFERTE   

  	  $('.boxgrid.caption').hover(function()
  	  {
			  	$(".boxcaption", this).stop().animate({top:'116px'},{queue:false,duration:160});
			}, function()
				 {
						$(".boxcaption", this).stop().animate({top:'172px'},{queue:false,duration:160});
				 });
			 
			 
			// HOMEPAGE: COMPORTAMENTO LISTA DESTINAZIONI  
    	
			$('a.destinazione').hover(function()
			{
				  $(this).stop().animate({paddingTop:'122px'},{queue:false,duration:160});
			}, function() 
					{
						$(this).stop().animate({paddingTop:'72px'},{queue:false,duration:160});
					});
      
  
        
			//OFFERTE: COMPARIZIONE PAGINA  
      
    	$("#boxpage_double").fadeTo("slow", 1, function()
    	{             
    	  $("#menupage").fadeTo("slow", 1); //left menu
    	  $(".topbanner").fadeTo("slow", 1); // topmenu
    	  slide("#sliding-navigation", 25, 15, 150, 1.2); //left menu
 			});
      
      
      
     
			// STRUTTURE + OFFERTE: COMPORTAMENTO APRI E CHIUDI LISTE 

      $("div.offerte_list dt a").click(function()
      {
          $(this).parent().next("dd:first").toggle("slow");    
    			return false;
      });
      
  
      
 			//STRUTTURE: COMPARIZIONE 
 
  		$("#boxpage_doubles").fadeTo("slow", 1, function()
  		{  	           
        $("#menupage").fadeTo("slow", 1);
        $(".topbanner").fadeTo("slow", 1);
        slide("#sliding-navigation", 25, 15, 150, 1.2);
      });     
        
        
		//DESTINAZIONI: COMPARIZIONE PAGINA  
    
    $("#boxpage_doubled").fadeTo("slow", 1, function()
    {           
    	$(function() {$("#tabs").tabs();});
    	$("#menupage").fadeTo("slow", 1);
    	$(".topbanner").fadeTo("slow", 1);
    	$(".demo").fadeTo("slow", 1);
    	slide("#sliding-navigation", 25, 15, 150, 1.2);
    });       
    

}); // CHIUDE: document ready
 




	 function acquista(codice)
	 {
  			$("#cpanel").load("ec-acquista.asp?fproductid="+codice+"&amp;fquantity=1");     
			  if ($(".carrello").hasClass("cactive"))
			  {   
			  }else{ 
   					$("#cpanel").slideToggle("slow");    
  					$(".carrello").toggleClass("cactive");       
				}
	 } 

	 function ricalcola()
	 {  
			var mydata ="mode=RICALCOLA";
			for (var i = 0; i < document.carrello.length; i++) mydata=mydata+"&amp;"+(document.carrello.elements[i].name+" = "+document.carrello.elements[i].value);
			AHAHrequest('ec-carrello.asp', 'cpanel', '', '', 'POST', mydata);       
	 }   
