// funzione form prenotazioni
function ldm_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.ldm_p) d.ldm_p=new Array();
    var i,j=d.ldm_p.length,a=ldm_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.ldm_p[j]=new Image; d.ldm_p[j++].src=a[i];}}
}


function abilita(x) {

	if (x=='a')   {
     document.all.a.className = "mini"; 
	 document.all.b.className = "mini marr"; 
	 document.all.c.className = "mini marr"; 
	 document.all.d.className = "mini marr"; 
	 document.FormY.RateValue.disabled = false;
	 document.FormY.RateValue.className="input";
		 		 }
	if (x=='b')   {
     document.all.a.className = "mini marr"; 
	 document.all.b.className = "mini"; 
	 document.all.c.className = "mini marr"; 
	 document.all.d.className = "mini marr"; 
 	 document.FormY.RateValue.disabled = false;
	 document.FormY.RateValue.className="input";

	        }
	if (x=='c')   {
     document.all.a.className = "mini marr"; 
	 document.all.b.className = "mini marr"; 
	 document.all.c.className = "mini"; 
	 document.all.d.className = "mini marr"; 
	 document.FormY.RateValue.disabled = false;
	 document.FormY.RateValue.className="input";

	        }
	if (x=='d')   {
     document.all.a.className = "mini marr"; 
	 document.all.b.className = "mini marr"; 
	 document.all.c.className = "mini marr"; 
	 document.all.d.className = "mini"; 
 	 document.FormY.RateValue.disabled = false;
	 document.FormY.RateValue.className="input";

	        }
}

function ldm_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function collega() { //v3.0
  var i, args=collega.arguments; document.returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->

function Decollassa(ID,MENU){
	//alert(ID);
	if (MENU == true){
		//SE CHIAMO LA FUNZIONE DAL MENU IN ALTO, IN OGNI CASO NON COLLASSO IL DIV
		document.getElementById(ID).className='';
	}else{ 
		//SE CHIAMO LA FUNZIONE DAL TITOLO, CONTROLLO SE E' GIA COLLASSATO
		if (document.getElementById(ID).className=='invisibile'){
			document.getElementById(ID).className='';
		}else{
			document.getElementById(ID).className='invisibile';
		}
	}
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
		  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
		  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
		}
	
MM_reloadPage(true);
		
		function BookNow(CODICE,CAPACITY,PRICE)
		{
		//CALCOLO LE NOTTI
		//partenza
		   var G1= parseFloat(document.FormY.arriveDate.value);
		   var M1= parseFloat(document.FormY.arriveMonth.value);
		   var A1= parseFloat(document.FormY.arriveYear.value);
		   
		//Arrivo
		   var G2= parseFloat(document.FormY.startDate.value);
		   var M2= parseFloat(document.FormY.startMonth.value);
		   var A2= parseFloat(document.FormY.startYear.value);
	
		   target = new Date(parseFloat(A1), parseFloat(M1-1), parseFloat(G1), 0, 0, 0);
		   enter = new Date(parseFloat(A2), parseFloat(M2-1), parseFloat(G2), 0, 0, 0);
		   diff = parseFloat((enter - target) / 86400000);
		  
		   if (diff<=0){
			 diff=1
		   }
		
		
		
		if (CODICE != "nullo") {
			document.FormX.ccpSelectHotel.value = CODICE;
			document.FormX.quick.value = document.FormY.quick.value;
		}
		
		
		meseArrivo=document.FormY.arriveMonth.options[document.FormY.arriveMonth.selectedIndex].value
		if (meseArrivo < 10) {
			meseArrivo= '0' + meseArrivo;
		}
		giornoArrivo=document.FormY.arriveDate.options[document.FormY.arriveDate.selectedIndex].value
		if (giornoArrivo < 10) {
			giornoArrivo= '0' + giornoArrivo;
		}
		dataArrival= document.FormY.arriveYear.options[document.FormY.arriveYear.selectedIndex].value + '-' + meseArrivo + '-' + giornoArrivo;
		document.FormX.calArrivalDateField.value = dataArrival;
		
		mesePartenza=document.FormY.startMonth.options[document.FormY.startMonth.selectedIndex].value
		if (mesePartenza < 10) {
			mesePartenza= '0' + mesePartenza;
		}
		giornoPartenza=document.FormY.startDate.options[document.FormY.startDate.selectedIndex].value
		if (giornoPartenza < 10) {
			giornoPartenza= '0' + giornoPartenza;
		}
		dataDeparture= document.FormY.startYear.options[document.FormY.startYear.selectedIndex].value + '-' + mesePartenza + '-' + giornoPartenza;
		document.FormX.calDepartureDateField.value = dataDeparture;
		
		
		document.FormX.yysela.value=document.FormY.startYear.options[document.FormY.startYear.selectedIndex].value;
		document.FormX.mmsela.value=document.FormY.startMonth.options[document.FormY.startMonth.selectedIndex].value;
		document.FormX.ggsela.value=document.FormY.startDate.options[document.FormY.startDate.selectedIndex].value;

		document.FormX.nnights.value = diff;
		
		document.FormX.Id_Hotel.value = document.FormY.HOT_ID.options[document.FormY.HOT_ID.selectedIndex].value;
		
		document.FormX.occupancy.value = document.FormY.adults.options[document.FormY.adults.selectedIndex].value;
		//document.FormX.prsNumChildren.value = document.FormY.children.options[document.FormY.children.selectedIndex].value;
		document.FormX.prsRoomCount.value = document.FormY.rooms.options[document.FormY.rooms.selectedIndex].value;
		
		
		
		//document.FormX.accountType.value = document.FormY.accountType.options[document.FormY.accountType.selectedIndex].value;
		
		var val = 0;
		for( i = 0; i < document.FormY.accountType.length; i++ )
		{
			if( document.FormY.accountType[i].checked == true )
			val = document.FormY.accountType[i].value;
		}
		
		if (val !=0 ) {
			document.FormX.accountType.value = val;
			document.FormX.accountId.value = document.FormY.accountId.value;
			document.FormX.rateAccessCode.value = document.FormY.rateAccessCode.value;
		}
		
		document.FormX.submit();
		
		}
		
		
		
			
		function pop_up(target, center, width, height, left, top) {
			if (center) {
				top = (screen.height - height) /2;	
				left = (screen.width - width) /2;	
			}
	
			if (width == "100%") {
				width = screen.width;
			}
	
			if (height == "100%") {
				height = screen.height;
			}
	
			window.open(target, null, "height="+height+", width="+width+", top="+top+", left="+left);
	
		}
		window.onload = function() {
		link_btn = document.getElementById('link_popup');
		if (link_btn!=null){
			link_btn.onclick = function() {
				pop_up('http://demo.nascar.it/charming-directory/', true, '773', '659');
				return false;
				}
			}
		}

   function Level(X)
	{
		var Y= document.getElementById(X);
		if (Y.style.display=='none')
		{
			Y.style.display='';
		}
		else
		{
			Y.style.display='none'; 
		}
	}



	function GoDest()
	{
		//if (document.Form1.LOCALITA.options[document.Form1.LOCALITA.selectedIndex].value == '' && document.Form1.PROVINCIA.options[document.Form1.PROVINCIA.selectedIndex].value == '' && document.Form1.NAZIONE.options[document.Form1.NAZIONE.selectedIndex].value == 0 && document.Form1.CONTINENTE.options[document.Form1.CONTINENTE.selectedIndex].value == 0)
		//	{
		//	alert('<%=xst(L,12004)%>');
		//	}
		//else
		//	{
			document.Form1.submit();
		//	}
	}

	function GoSearch()
	{
		for (i=0; i < document.forms[1].length ; i++) 
			{
				if (document.forms[1].elements[i].name == 'COM')
				{
					document.forms[1].elements[i].checked = false;
				}
			}
		
		document.Form1.submit();
	}


	
	
	
    function Ricarica2(Tipo)
	{
		//per quicksearch
		
		if (Tipo == 'PROVINCIA')
			{
			document.FormY.LOCALITA.value = '';
			}
		if (Tipo == 'NAZIONE')
			{
			document.FormY.LOCALITA.value = '';
			document.FormY.PROVINCIA.value = '';
			}
		if (Tipo == 'CONTINENTE')
			{
			document.FormY.LOCALITA.value = '';
			document.FormY.PROVINCIA.value = '';
			document.FormY.NAZIONE.value = 0;
			}
		
		document.FormY.submit();	
	}
	function impostaCodiceHotel(val)
	{				
        if (val!=0){
            //HOT_CODICE_WS = CodiceAmadeus
            HOT_CODICE_WS = document.getElementById("HOT_CODICE_WS_"+val).value;
           //HOT_CODICE = Pegasus
			HOT_CODICE = document.getElementById("HOT_CODICE_"+val).value;		
			document.FormY.HOT_CODICE_WS.value = HOT_CODICE_WS;
			document.FormY.HOT_CODICE.value = HOT_CODICE;
			document.FormX.HOT_CODICE_WS.value = HOT_CODICE_WS;
			document.FormX.HOT_CODICE.value = HOT_CODICE;
			
		}
	}	
	

	//Calcolo la data di partenza
	function calcolaNotti()
	{

		 //partenza
		   var G1= parseFloat(document.FormY.arriveDate.value);
		   var M1= parseFloat(document.FormY.arriveMonth.value);
		   var A1= parseFloat(document.FormY.arriveYear.value);
		   
		//Arrivo
		   var G2= parseFloat(document.FormY.startDate.value);
		   var M2= parseFloat(document.FormY.startMonth.value);
		   var A2= parseFloat(document.FormY.startYear.value);
	
		   target = new Date(parseFloat(A1), parseFloat(M1-1), parseFloat(G1), 0, 0, 0);
		   enter = new Date(parseFloat(A2), parseFloat(M2-1), parseFloat(G2), 0, 0, 0);
		   diff = parseFloat((enter - target) / 86400000);
		  
		   //if (diff <= 0){
		   //	 diff=1
		   //}
		   
		   //document.FormX.numberOfNights.value = diff;// solo per NB4
           return(diff);
	}

    function DataParatenza1()
           {
           dataOggi = new Date();
           alert(dataOggi);
           }


	


	
	function Trim(Field) 
	{
		return Field.replace(/\s+$|^\s+/g,"");
	}
	
	
