// JavaScript Document

$(document).ready(function()
{
	//alert("Dcument ready");
		
	// SLIDER
	
	aFormName 	= new Array("risparmia", "hotel", "auto", "vacanze", "attrazioni");
	aFormDiv 	= new Array("risp", "hot", "car", "pac", "tsh");
	
	currentForm = 0;
	
	for (i=0; i<aFormName.length ; i++)
	{
		divName = "#cerca_" + aFormName[i];
		
		if (i != 0)
		{
			//$(aFormDiv[i]).hide();
			contentName = "#" + aFormDiv[i];
			$(contentName).hide();
			
			$(divName).css({'text-decoration' : 'underline', 'cursor' : 'pointer'});
			
		}
	
		$(divName).attr("iValue",i);
		
		$(divName).click(function () 
		{
			tempDiv = "#cerca_" + aFormName[currentForm];
			$(tempDiv).css({'text-decoration' : 'underline', 'cursor' : 'pointer'});	

			iTemp = $(this).attr("iValue");
			tempDiv = "#cerca_" + aFormName[iTemp];
			
			//alert(tempDiv);
			
			$(this).css({'text-decoration' : 'none', 'cursor' : 'auto'});
			
			contentName = "#" + aFormDiv[currentForm];
			contentline = "#line_" + aFormDiv[currentForm];
			$(contentName).hide();
			$(contentline).hide();

			currentForm = $(this).attr("iValue");
			contentName = "#" + aFormDiv[currentForm];
			contentline = "#line_" + aFormDiv[currentForm];

			$(contentName).show();
			$(contentline).show();

			$(".expand").css({'height' : 0});
			//alert($(".homeViaggi").css('height'));
	
			iDivHeight = $("#cols3Left").css('height');
			iDivLenght = iDivHeight.length;
			iDivHeight = iDivHeight.substr(0,(iDivLenght-2));
			
			
			if (iDivHeight < 610)
			{
				newHeight = 610-iDivHeight;
				//alert("Differenza " + newHeight);
				 $(".expand").css({'height' : newHeight});
			}
			else
			{
				 $(".expand").css({'height' : 0});;
			}
			//alert($(".homeViaggi").css('height'));
			
		});		
		
	}
	
	iDivHeight = $("#cols3Left").css('height');
	iDivLenght = iDivHeight.length;
	iDivHeight = iDivHeight.substr(0,(iDivLenght-2));
	newHeight = 610-iDivHeight;
	//alert("Differenza " + newHeight);
	 $(".expand").css({'height' : newHeight});
	
	//alert("Fine Javascript");
	
});
