//preload image menu
    if (document.images)
    {
        image1 = new Image(172, 19);
        image1.src = "../img/bkg_mnusx.gif";

        image2 = new Image(172, 19);
        image2.src = "../img/bkg_mnusx_att.gif";
		
		image3 = new Image(172, 19);
        image3.src = "../img/bgs_bkg_mnusx.gif";
		
		image4 = new Image(172, 19);
        image4.src = "../img/bgs_bkg_mnusx_att.gif";
		
		image5 = new Image(172, 19);
        image5.src = "../img/vg_bkg_mnusx_att.gif";
		
		image6 = new Image(172, 19);
        image6.src = "../img/vg_bkg_mnusx_att.gif";
    }

// per linkare banner home direttamente alle schede hotel usando fatwire
/*
function vaiHotel(codHotel,dataIn,codLingua,stelle,localita)
{

    document.forms['PROMO'].codHotel.value=codHotel;
    document.forms['PROMO'].hotStars.value=stelle;
  	document.forms['PROMO'].localityId.value="";
	  document.forms['PROMO'].COMBO_INIZIOMM_AA.value=dataInizio(dataIn);
     document.forms['PROMO'].pagename.value='BoscoloSite/Page/HotelPrenotaDispo';
	  document.forms['PROMO'].combo_finemm_aa.value=nextDay(dataInizio(dataIn));
	  document.forms['PROMO'].submit();
}
*/
	
	function jsGet(queryString)
	{
		document.location = '/cs/ContentServer?' + queryString;
	}	
	
// ShowHide element
	function ShowHide(id) {
    obj = document.getElementsByTagName("div");
    if (obj[id].style.display == 'block'){
    obj[id].style.display = 'none';
    }
    else {
    obj[id].style.display = 'block';
    }
	}

// openClose element
	function openClose(imgElem, divId, imgOff, imgOn) { 		
	   if(document.getElementById(divId)) { 
	      var divElem = document.getElementById(divId); 
			//alert(divElem.className);
	      if(divElem.className == "hidden") { 
	         imgElem.src = imgOn; 
	         divElem.className = "block"; 
             setBoxStatus(divElem.id,"open");
	      } else { 
	         imgElem.src = imgOff; 
	         divElem.className = "hidden"; 
             setBoxStatus(divElem.id,"closed");
	      } 
	   } 
	}
	
	
	

	
	
	function openCloseWithText(imgElem, divId, imgOff, imgOn, textOff, textOn, textSpanId) { 
	   if(document.getElementById) { 
	      var divElem = document.getElementById(divId); 
	      var spanElem = document.getElementById(textSpanId); 
			//alert(divElem.className);
	      if(divElem.className == "hidden") { 
	         imgElem.src = imgOn;
	         spanElem.innerHTML = textOn;
	         divElem.className = "block"; 
             setBoxStatus(divElem.id,"open");
	      } else { 
	         imgElem.src = imgOff; 
	         spanElem.innerHTML = textOff;
	         divElem.className = "hidden"; 
             setBoxStatus(divElem.id,"closed");
	      } 
	   } 
	}
    
    function setAllBox() {
        var boxList = new Array('mieiviaggi');
        //alert("setAllBox:: boxList -> "+ boxList);       
        for(var i=0;i < boxList.length;i++){
            var boxName = boxList[i];
            //alert("setAllBox:: box -> "+ boxName);
            var boxElem = document.getElementById(boxName);
            //alert("setAllBox:: boxElem -> "+ boxElem);
            if(boxElem!=null) {
                var boxStatus = getBoxStatus(boxName);
                if(boxStatus=="open"){
                    //imgElem.src = imgOn; 
                    boxElem.className = "block";
                    //alert("setAllBox:: box -> "+ boxName + "= open" );
                } else {
                    //imgElem.src = imgOff; 
                    boxElem.className = "hidden";
                    //alert("setAllBox:: box -> "+ boxName + "= close" );
                }
            }
        }
	}
    
    function setMyBox(boxName,imgName,imgOff, imgOn) {
        var boxElem = document.getElementById(boxName);
        var imgElem = document.getElementById(imgName);
        //alert("setAllBox:: boxElem -> "+ boxElem);
        if(boxElem!=null) {
            var boxStatus = getBoxStatus(boxName);
            if(boxStatus=="open"){
                imgElem.src = imgOn; 
                boxElem.className = "block";
                //alert("setAllBox:: box -> "+ boxName + "= open" );
            } else {
                imgElem.src = imgOff; 
                boxElem.className = "hidden";
                //alert("setAllBox:: box -> "+ boxName + "= close" );
            }
        }
    }

    function setBoxStatus(boxId,status)
    {
        var boxList = loadBoxList();
        var addedbox = null;
        if(boxList!=null){
            var found = false;
            for(var i=0; i<boxList.length;i++){
                var box = boxList[i];
                if(box.indexOf(boxId)==0) {
                    found=true;
                    //alert("setBoxStatus:: found box -> "+ box);
                    boxList[i] = boxId + ":" + status;
                    //alert("setBoxStatus:: setted box -> "+ boxList[i]);
                }        
            }
            if(!found){
                addedbox = boxId + ":" + status;
                //alert("setBoxStatus:: added box -> "+ addedbox);
            } 
        } else {
            addedbox = boxId + ":" + status;
            //alert("setBoxStatus:: added box -> "+ addedbox);
        }
        saveBoxList(boxList,addedbox);   
    }
    
    function getBoxStatus(boxId)
    {
        //alert("getBoxStatus:: START");
        var status = "";
        var boxList = loadBoxList();
        //alert("getBoxStatus:: boxList ["+boxList+"]");
        if(boxList!=null) {
            for(var i=0; i<boxList.length;i++){
                var box = boxList[i];
                //alert("getBoxStatus:: '" + box + "'");
                //alert("getBoxStatus:: INDEX=" + box.indexOf(boxId));
                if(box.indexOf(boxId)==0) {
                    status = box.split(":")[1];
                    //alert("getBoxStatus:: " + boxId + "=" + status);
                    return status;
                }        
            }
        }
        return "closed";
    }
    
    
    function loadBoxList() {
     //alert("loadBoxList:: START")
     if (document.cookie.length > 0)
     {
      var cookies = unescape(document.cookie).split(";");
      for (var i = 0; i < cookies.length; i++){
       var cookie = cookies[i];
       if (cookie.indexOf("BOXLIST") != -1){
            //alert("loadBoxList:: cookie-> "+ cookie);
            cookie = cookie.split("=")[1];
            return cookie.split(",");
       }
      }
     }
     
    }
    
    function saveBoxList(boxList,addedbox){
        var cookie="BOXLIST=";
        if(boxList!=null){
            for(var i=0; i<boxList.length;i++){
                var box = boxList[i];
                cookie += box;                
                if(i!=boxList.length-1){
                    cookie += ",";
                }
            }
        }
        if(addedbox!=null){
            if(boxList!=null){
                cookie += ",";
            }
            cookie += addedbox;
        }
        cookie += "; path=/cs/";
        //alert("saveBoxList:: cookie -> "+ cookie);
        document.cookie=cookie;
    } 
	
//confronta hotel
	function toggleCells(el, col1){
	for (i = 0; i < el.parentNode.childNodes.length; i++)
	if (el.parentNode.childNodes[i].tagName)
	el.style.background=col1
	}
	
	function hideConf(){
	document.getElementById('flashconf').style.display = "none"
	document.getElementById('htmlconf').style.display = "block"
	}
	
	function passHotel(){
	
	}	
	
//iframe
function copyFrame() {
		document.getElementById('divframe').innerHTML = document.getElementById('hotel_result').contentWindow.document.body.innerHTML;
	}

function copyFrameTo(iframeName, divName) {
		document.getElementById(divName).innerHTML = document.getElementById(iframeName).contentWindow.document.body.innerHTML;
	}
	
//show popup commissioni
function hideLayer(whichLayer) {
if (document.getElementById(whichLayer)) {
document.getElementById(whichLayer).style.visibility = "hidden";
}
}

function showLayer(whichLayer) {
if (document.getElementById(whichLayer)) {
document.getElementById(whichLayer).style.visibility = "visible";
}
}


function removeLayer(whichLayer) {
if (document.getElementById(whichLayer)) {
document.getElementById(whichLayer).style.display = "none";
}
}

function displayLayer(whichLayer) {
if (document.getElementById(whichLayer)) {
document.getElementById(whichLayer).style.display = "block";
}
}


function handleClick(whichClick, str) {
	
if (whichClick == "hide it") {
hideLayer("comm" + str);
}
else if (whichClick == "show it") {
showLayer("comm" + str);
}
}


function handleClickPolicy(whichClick, str) {
if (whichClick == "hide it") {
hideLayer("policy" + str);
}
else if (whichClick == "show it") {
showLayer("policy" + str);
}
}


function handleClickBest(whichClick, str) {
if (whichClick == "hide it") {
hideLayer("commBest" + str);
}
else if (whichClick == "show it") {
showLayer("commBest" + str);
}
}


function onreqClick(whichClick, str) {
	
if (whichClick == "hide it") {
hideLayer("onreq" + str);
}
else if (whichClick == "show it") {
showLayer("onreq" + str);
}
}

function simpleHandleClick(whichClick, str) {
    if (whichClick == "hide it") {
        hideLayer(str);
    }
    else if (whichClick == "show it") {
        showLayer(str);
    }
}

//somma checkbox
function abcTotal(obj,id,tid){

            	abct=document.getElementById(tid);
            	if (!abct.ary){ abct.ary=new Array(); }
            	    abcbs=obj.getElementsByTagName('INPUT');
            	    
            	    for (abc0=0;abc0<abcbs.length;abc0++){
            		if (abcbs[abc0].type=='checkbox'&&abcbs[abc0].checked){
            		    document.getElementById(id).value=abcbs[abc0].value;
            		       if (!abcbs[abc0].set){
                                   abcbs[abc0].set=true;
                                   abct.ary[abct.ary.length]=abcbs[abc0];
            		       }
            		}
            	}
            	abcv=0
            	
            	for (abc1=0;abc1<abct.ary.length;abc1++){
            	     if (abct.ary[abc1].checked){
            		abcv+=parseFloat(abct.ary[abc1].value);
            	     }
            	}
            	abct.value=abcv;
            }
/*function abcTotal(obj,id,tid){

		abct=document.getElementById(tid);
        if (!abct.ary){ abct.ary=new Array(); }
        abcbs=obj.getElementsByTagName('INPUT');
            	    
        for (abc0=0;abc0<abcbs.length;abc0++){
        if (abcbs[abc0].type=='checkbox'&&abcbs[abc0].checked){
        document.getElementById(id).value=abcbs[abc0].value;
        if (!abcbs[abc0].set){
        abcbs[abc0].set=true;
        abct.ary[abct.ary.length]=abcbs[abc0];
        }
        }
        }
        abcv=0
        for (abc1=0;abc1<abct.ary.length;abc1++){
        	if (abct.ary[abc1].checked){
            abcv+=parseFloat(abct.ary[abc1].value);
            	     }
            	}
            	abct.value=abcv;
            } 
*/

//scrollable area
function verifyCompatibleBrowser(){ 
    this.ver=navigator.appVersion 
    this.dom=document.getElementById?1:0 
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
    this.ie4=(document.all && !this.dom)?1:0; 
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
 
    this.ns4=(document.layers && !this.dom)?1:0; 
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) 
    return this 
} 
bw=new verifyCompatibleBrowser() 
 
 
var speed=200 
 
var loop, timer 
 
function ConstructObject(obj,nest){ 
    nest=(!nest) ? '':'document.'+nest+'.' 
    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 
    this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
    this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight 
    this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight 
    this.up=MoveAreaUp;this.down=MoveAreaDown; 
    this.MoveArea=MoveArea; this.x; this.y; 
    this.obj = obj + "Object" 
    eval(this.obj + "=this") 
    return this 
} 
function MoveArea(x,y){ 
    this.x=x;this.y=y 
    this.css.left=this.x 
    this.css.top=this.y 
} 
 
function MoveAreaDown(move){ 
	if(this.y>-this.scrollHeight+objContainer.clipHeight){ 
    this.MoveArea(0,this.y-move) 
    if(loop) setTimeout(this.obj+".down("+move+")",speed) 
	} 
} 
function MoveAreaUp(move){ 
	if(this.y<0){ 
    this.MoveArea(0,this.y-move) 
    if(loop) setTimeout(this.obj+".up("+move+")",speed) 
	} 
} 
 
function PerformScroll(speed){ 
	if(initialised){ 
		loop=true; 
		if(speed>0) objScroller.down(speed) 
		else objScroller.up(speed) 
	} 
} 
 
function CeaseScroll(){ 
    loop=false 
    if(timer) clearTimeout(timer) 
} 
var initialised; 
function InitialiseScrollableArea(){ 
    objContainer=new ConstructObject('divContainer') 
    objScroller=new ConstructObject('divContent','divContainer') 
    objScroller.MoveArea(0,0) 
    objContainer.css.visibility='visible' 
    initialised=true; 
}

//open popup destination
function getRefToDivMod( divID, oDoc ) {
	if( !oDoc ) { oDoc = document; }
	if( document.layers ) {
		if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
			for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
				y = getRefToDivNest(divID,oDoc.layers[x].document); }
			return y; } }
	if( document.getElementById ) { return oDoc.getElementById(divID); }
	if( document.all ) { return oDoc.all[divID]; }
	return document[divID];
}

function openPerfectPopup(oW,oTitle,oContent) {
	var x = window.open('','windowName','width=413,height=200,resizable=1');
	if( !x ) { return true; }
	x.document.open();
	x.document.write('<html><head><title>'+oTitle+'<\/title><\/head><body>'+
	  (document.layers?('<layer left="0" top="0" width="'+oW+'" id="myID">')
	    :('<div style="position:absolute;left:0px;top:0px;display:table;width:'+oW+'px;" '+
	    'id="myID">'))+
	  oContent+(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
	x.document.close();
	var oH = getRefToDivMod( 'myID', x.document ); if( !oH ) { return false; }
	var oH = oH.clip ? oH.clip.height : oH.offsetHeight; if( !oH ) { return false; }
	x.resizeTo( oW + 200, oH + 200 );
	var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;
	if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }
	else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }
	else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }
	if( window.opera && !document.childNodes ) { myW += 16; }
	x.resizeTo( oW + ( ( oW + 200 ) - myW ), oH + ( (oH + 200 ) - myH ) );
	if( x.focus ) { x.focus(); }
	return false;
}

//show hide layer MM
function hideObj(objId){
  if (parent.document.getElementById){
    parent.document.getElementById(objId).style.visibility = 'hidden';
  }
  else{
    if (document.layers){
      document.objId.visibility = 'hidden';
    }
    else{
      document.all.objId.style.visibility = 'hidden';
    }
  }
}

function showObj(objId, localityVal, srcPath){
  var path = srcPath + localityVal;

//alert(path);
  frames['scrollerIF'].location = path;
  if (document.getElementById){
    document.getElementById(objId).style.visibility = 'visible';
  } 
  else{
    if (document.layers){
      document.objId.visibility = 'visible';
    }
    else{
      document.all.objId.style.visibility = 'visible';
    }
  }
}

/*
function showObj(objId){
  if (document.getElementById){
    document.getElementById(objId).style.visibility = 'visible';
  } 
  else{
    if (document.layers){
      document.objId.visibility = 'visible';
    }
    else{
      document.all.objId.style.visibility = 'visible';
    }
  }
}
*/

//mostra nascondi commissioni
function commisShow(numRow)
	{
	var i =0;
	while (i<numRow)
		{	
		showHideElement("COMM_"+i);
		i++;
		}
	}
	
	/********************************
   * Mostra/Nasconde elemento
   */
  function showHideElement(id)
    {
    var element;

    element = document.getElementById(id);
    if (element.style.display=="none" )  
      {
      element.style.display="block"; 
      return false;
      } 
    element.style.display="none";
    }

//open generic popup
function openPopup(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
/*
function trim(inputString) {
	   
	   if (typeof inputString != "string") { return inputString; }
	   var retValue = inputString;
	   var ch = retValue.substring(0, 1);
	   while (ch == " ") { // Check for spaces at the beginning of the string
	      retValue = retValue.substring(1, retValue.length);
	      ch = retValue.substring(0, 1);
	   }
	   ch = retValue.substring(retValue.length-1, retValue.length);
	   while (ch == " ") { // Check for spaces at the end of the string
	      retValue = retValue.substring(0, retValue.length-1);
	      ch = retValue.substring(retValue.length-1, retValue.length);
	   }
	   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
	      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
	   }
	   return retValue; // Return the trimmed string back to the user
} 
*/

//Trim 
function trim(stringa)
{
  re=/\s+$|^\s+/g;
  var ret = stringa.replace(re,"");
  return ret;
}

function emptySelect(selObj) {
	document.getElementById(selObj).options.length = 0;
}

function fillSelect(selObj,label_str,value_str, current_val){
    //alert("current_val:: " + current_val);
	selObj = document.getElementById(selObj);
//	alert('sel=' + selObj);
	var label_array = label_str.split(",");
	if(value_str) var value_array = value_str.split(",");
	var idx = 0;
	for(i=0;i<label_array.length;i++){
		var tmpOption = new Option(label_array[i]);
		if(value_array) tmpOption.value = value_array[i];
		tmpOption.setAttribute("width",150);
		if (current_val == value_array[i]) {
//			alert('val=' + value_array[i]);
//			alert('1sel=' + tmpOption.selected);
			tmpOption.selected = true;
			idx = i;
//			alert('2sel=' + tmpOption.selected);
		} else {
			tmpOption.selected = false;
		}
		selObj.options[i] = tmpOption;
	}
	selObj.selectedIndex = idx;
}

function fillSelectCountry(selObj,label_str,value_str,codici_paesi,current_val){
	//alert("fillSelect");
	selObj = document.getElementById(selObj);
//	alert('sel=' + selObj);
	var label_array = label_str.split(",");
	//alert("label_array=" + label_array);
	//alert("value_str=" + value_str);
	//alert("codici_paesi=" + codici_paesi);
	if(value_str) var value_array = value_str.split(",");
	if(codici_paesi) var codici_paesi_array = codici_paesi.split(",");
	var idx = 0;
	for(i=0;i<label_array.length;i++){
		//alert(i);
		var tmpOption = new Option(label_array[i]);
		//alert(value_array[i] + "-" + codici_paesi_array[i]);
		if(value_array && codici_paesi) tmpOption.value = value_array[i] + "-" + codici_paesi_array[i];
		tmpOption.setAttribute("width",150);
		if (current_val == value_array[i]) {
//			alert('val=' + value_array[i]);
//			alert('1sel=' + tmpOption.selected);
			tmpOption.selected = true;
			idx = i;
//			alert('2sel=' + tmpOption.selected);
		} else {
			tmpOption.selected = false;
		}
		selObj.options[i] = tmpOption;
	}
	selObj.selectedIndex = idx;
}


// gently offered from tadia
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

//data
function dateToday(lang){
 var current_date = new Date ( );
 
  var month_names_it = new Array ( );
 month_names_it[month_names_it.length] = "Gennaio";
 month_names_it[month_names_it.length] = "Febbraio";
 month_names_it[month_names_it.length] = "Marzo";
 month_names_it[month_names_it.length] = "Aprile";
 month_names_it[month_names_it.length] = "Maggio";
 month_names_it[month_names_it.length] = "Giugno";
 month_names_it[month_names_it.length] = "Luglio";
 month_names_it[month_names_it.length] = "Agosto";
 month_names_it[month_names_it.length] = "Settembre";
 month_names_it[month_names_it.length] = "Ottobre";
 month_names_it[month_names_it.length] = "Novembre";
 month_names_it[month_names_it.length] = "Dicembre";

 var month_names_en = new Array ( );
 month_names_en[month_names_en.length] = "January";
 month_names_en[month_names_en.length] = "February";
 month_names_en[month_names_en.length] = "March";
 month_names_en[month_names_en.length] = "April";
 month_names_en[month_names_en.length] = "May";
 month_names_en[month_names_en.length] = "June";
 month_names_en[month_names_en.length] = "July";
 month_names_en[month_names_en.length] = "August";
 month_names_en[month_names_en.length] = "September";
 month_names_en[month_names_en.length] = "October";
 month_names_en[month_names_en.length] = "November";
 month_names_en[month_names_en.length] = "December";

 var month_names_de = new Array ( );
 month_names_de[month_names_de.length] = "januar";
 month_names_de[month_names_de.length] = "februar";
 month_names_de[month_names_de.length] = "mä";
 month_names_de[month_names_de.length] = "april";
 month_names_de[month_names_de.length] = "mai";
 month_names_de[month_names_de.length] = "juni";
 month_names_de[month_names_de.length] = "juli";
 month_names_de[month_names_de.length] = "august";
 month_names_de[month_names_de.length] = "september";
 month_names_de[month_names_de.length] = "oktober";
 month_names_de[month_names_de.length] = "november";
 month_names_de[month_names_de.length] = "dezember";

 var month_names_fr = new Array ( );
 month_names_fr[month_names_fr.length] = "Janvier";
 month_names_fr[month_names_fr.length] = "F&eacute;vrier";
 month_names_fr[month_names_fr.length] = "Mars";
 month_names_fr[month_names_fr.length] = "Avril";
 month_names_fr[month_names_fr.length] = "Mai";
 month_names_fr[month_names_fr.length] = "Juin";
 month_names_fr[month_names_fr.length] = "Juillet";
 month_names_fr[month_names_fr.length] = "Aout";
 month_names_fr[month_names_fr.length] = "Septembre";
 month_names_fr[month_names_fr.length] = "Octobre";
 month_names_fr[month_names_fr.length] = "Novembre";
 month_names_fr[month_names_fr.length] = "D&eacute;cembre";

 var month_names_es = new Array ( );
 month_names_es[month_names_es.length] = "enero";
 month_names_es[month_names_es.length] = "febrero";
 month_names_es[month_names_es.length] = "marzo";
 month_names_es[month_names_es.length] = "abril";
 month_names_es[month_names_es.length] = "mayo";
 month_names_es[month_names_es.length] = "junio";
 month_names_es[month_names_es.length] = "julio";
 month_names_es[month_names_es.length] = "agosto";
 month_names_es[month_names_es.length] = "septiembre";
 month_names_es[month_names_es.length] = "octubre";
 month_names_es[month_names_es.length] = "noviembre";
 month_names_es[month_names_es.length] = "diciembre";

 var month_names_pt = new Array ( );
 month_names_pt[month_names_pt.length] = "Janeiro";
 month_names_pt[month_names_pt.length] = "Fevereiro";
 month_names_pt[month_names_pt.length] = "Marco";
 month_names_pt[month_names_pt.length] = "Abril";
 month_names_pt[month_names_pt.length] = "Maio";
 month_names_pt[month_names_pt.length] = "Junho";
 month_names_pt[month_names_pt.length] = "Julho";
 month_names_pt[month_names_pt.length] = "Agosto";
 month_names_pt[month_names_pt.length] = "Setembro";
 month_names_pt[month_names_pt.length] = "Outubro";
 month_names_pt[month_names_pt.length] = "Novembro";
 month_names_pt[month_names_pt.length] = "Dezembro";

 var month_names = new Array ( );
 
 month_names["IT"] = month_names_it;
 month_names["EN"] = month_names_en;
 month_names["DE"] = month_names_de;
 month_names["FR"] = month_names_fr;
 month_names["ES"] = month_names_es;
 month_names["PT"] = month_names_pt;
 month_names["CN"] = month_names_en;
 month_names["JP"] = month_names_en;
 month_names["TR"] = month_names_en;
 month_names["KP"] = month_names_en;
 month_names["RU"] = month_names_en;
 month_names["RO"] = month_names_en;
 
 var s = current_date.getDate() + " " + month_names[lang][current_date.getMonth()] + " " + current_date.getFullYear();
 return s;
}

function changeLanguage(selObj) {
	//alert("changeLanguage");
	selObj = document.getElementById(selObj);
	var codici_lingua_paese=selObj.options[selObj.selectedIndex].value;
	//alert("codici_lingua_paese=" + codici_lingua_paese);
	if(codici_lingua_paese) 
	{
		var codici_lingua_paese_array = codici_lingua_paese.split("-");
  	document.langForm.lang.value = codici_lingua_paese_array[0];
  	document.langForm.country.value = codici_lingua_paese_array[1];	
	  document.langForm.submit();
  }	
}

function changeCurrency(selObj) {
	//alert("changeCurrency");
	selObj = document.getElementById(selObj);
	var codici_valute=selObj.options[selObj.selectedIndex].value;
	//alert("codici_valute=" + codici_valute);
	if (codici_valute) 
	{
		document.currencyForm.currencyCode.value = codici_valute;	
		document.currencyForm.submit();
	}	
}

//swap image
function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	
	function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}
	
	function MM_findObj(n, d) { //v4.0
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && document.getElementById) x=document.getElementById(n); return x;
	}
	
	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	
	
	function nextDay(dayStr)
  {
    var splitDayStr = dayStr.split("/");
	  var tmpDate = new Date(splitDayStr[2],Number(splitDayStr[1])-1,Number(splitDayStr[0])+1);
	  var tmpDay = ((tmpDate.getDate()<10)?("0"):("")) + tmpDate.getDate();
	  var tmpMonth = ((tmpDate.getMonth()+1<10)?("0"):("")) + (tmpDate.getMonth()+1);
	  return tmpDay+"/"+tmpMonth+"/"+tmpDate.getFullYear();
  }
	
  function dataInizio(stringaData)
  {
    var oggi = new Date();
    var splitDayStr = stringaData.split("/");
	  var tmpDate = new Date(splitDayStr[2],Number(splitDayStr[1])-1,Number(splitDayStr[0]));
    if(oggi.getTime()>=tmpDate.getTime()) 
    {
      var dayOggi = ((oggi.getDate()<10)?("0"):("")) + oggi.getDate();
	    var monthOggi = ((oggi.getMonth()+1<10)?("0"):("")) + (oggi.getMonth()+1);
	    var stringaOggi= dayOggi + "/" + monthOggi + "/" + oggi.getFullYear();
  	  return stringaOggi;
    }
    else return stringaData;
  }	







  
  
  
  function validateUserRegistration(fieldsUser,fieldsCompany,msgMandatory,msgPrivacy)
  {
    
    var missing = false;
    var foundCompany = false;
    for (var i = 0; i < fieldsUser.length; ++i)
    {
        var field = fieldsUser[i];
        var elem = document.getElementById(field);
        if (elem == null || elem.value == '')
        {
            missing = true;
            elem.style.background = '#c00';
            elem.style.color = '#fff';
        }
    }
    
    for (var i = 0; i < fieldsCompany.length; ++i)
    {
        var field = fieldsCompany[i];
        var elem = document.getElementById(field);
        elem.style.background = '#fff';
        elem.style.color = '#000';
        if (elem != null && elem.value != '')
        {
            foundCompany = true;
        }
    }
    
    if(foundCompany) 
    {
        for (var i = 0; i < fieldsCompany.length; ++i)
        {
            var field = fieldsCompany[i];
            var elem = document.getElementById(field);
            if (elem == null || elem.value == '')
            {
                missing = true;
                elem.style.background = '#c00';
                elem.style.color = '#fff';
            }
        }
    }
    
    if(missing) {
        alert(msgMandatory);
        return false;
    }
    
    var privacy = document.getElementById('privacy');
    var auth = (privacy.checked && (privacy.value=='S'));
    if (!auth) {
        alert(msgPrivacy);
        return false;
    }
    
    if(!auth)
        return false;
        
    return true;
  }
    
    function updateUserRegistrationText(name)
    {
        var elem = document.getElementById(name);
        elem.style.background = '#fff';
        elem.style.color = '#000';
    }
    



function submitFreeFlight()
{
        if (radioIsCheck(document.forms['FFLIGHT'].inbound_flight_str)  && radioIsCheck(document.forms['FFLIGHT'].outbound_flight_str))
        {
                document.forms['FFLIGHT'].submit();toggleLink(this,"");
        }
        else
        {
                alert("Entrambi i voli devono essere selezionati.");
        }
        document.getElementById('imgPrenotaFreeFlight').style.display = 'none'
        
}

/**
*
* Serve per testare se i radio sono attivati
*
*/
function radioIsCheck(radio) {
  var length=0;
  if (radio) {
    if (!radio.length && radio.value) {
      if (radio.checked)
        return(true);
    }
    else
      if (radio.length)
        length=radio.length;
      else
        return(false);

    for (i=0; i<length; i++ ) {
      if (radio[i].checked)
        return(true);
    }
  }
  return(false);
}

function scrollUp()
{
	self.scrollTo(0,0);
}

function controllaEtaBambini(maxRooms)
{
  var esito=true;
  for(roomCounter=1;roomCounter<=maxRooms;roomCounter++)
  {
    for(kidCounter=1;kidCounter<=3;kidCounter++)
    {    
      var nomeCampo = "combo_bambini_eta" + roomCounter + kidCounter;
      try
      {
        //alert("nomeCampo=" + nomeCampo);
        var valoreCampo = document.forms['FHOTEL'].elements[nomeCampo].value;
        //alert("valoreCampo=" + valoreCampo);
        if(valoreCampo == '-1') esito=false;
      }
      catch(e){}
    }    
  }
  return esito;
}

function controllaEtaBambiniFlight(maxRooms)
{
  var esito=true;
  for(roomCounter=1;roomCounter<=maxRooms;roomCounter++)
  {
    for(kidCounter=1;kidCounter<=10;kidCounter++)
    {    
      var nomeCampo = "combo_bambini_eta" + roomCounter + kidCounter;
      try
      {
        //alert("nomeCampo=" + nomeCampo);
        var valoreCampo = document.forms['FHOTEL'].elements[nomeCampo].value;
        //alert("valoreCampo=" + valoreCampo);
        if(valoreCampo == '-1') esito=false;
      }
      catch(e){}
    }    
  }
  return esito;
}

 function HideElement (id) {

    obj = document.getElementById(id);
    obj.style.display = 'none';
}

    function ShowElement (id) {
    obj = document.getElementById(id);
    obj.style.display = 'inline';
}


function openWindow(pageToOpen, title, width, height)
{
    scH=screen.availHeight;
    scW=screen.availWidth;
    t=(scH/2)-(height/2);
    l=(scW/2)-(width/2);
    var w = window.open(pageToOpen, title, 'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+width+',height='+height+',left='+l+',top='+t);
    //var w = window.open(pageToOpen, title, 'toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width='+width+',height='+height+',left='+l+',top='+t); //
    w.focus();
    //return w;
}


function isValidCF(cf)
{
    var validi, i, s, set1, set2, setpari, setdisp;
    if( cf == '' )  return false;
    cf = cf.toUpperCase();
    if( cf.length != 16 )
            return false;
    validi = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    for( i = 0; i < 16; i++ ){
            if( validi.indexOf( cf.charAt(i) ) == -1 )
                    return false;
    }
    set1 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    set2 = "ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ";
    setpari = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    setdisp = "BAKPLCQDREVOSFTGUHMINJWZYX";
    s = 0;
    for( i = 1; i <= 13; i += 2 )
            s += setpari.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
    for( i = 0; i <= 14; i += 2 )
            s += setdisp.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
    if( s%26 != cf.charCodeAt(15)-'A'.charCodeAt(0) )
            return false;
    return true;
}

function isValidPIVA(pi)
{
    if( pi == '' )  return false;
    if( pi.length != 11 )
            return false;
    var validi = "0123456789";
    for( i = 0; i < 11; i++ ){
            if( validi.indexOf( pi.charAt(i) ) == -1 )
                    return false;
    }
    var s = 0;
    for( i = 0; i <= 9; i += 2 )
            s += pi.charCodeAt(i) - '0'.charCodeAt(0);
    for( i = 1; i <= 9; i += 2 ){
            c = 2*( pi.charCodeAt(i) - '0'.charCodeAt(0) );
            if( c > 9 )  c = c - 9;
            s += c;
    }
    if( ( 10 - s%10 )%10 != pi.charCodeAt(10) - '0'.charCodeAt(0) )
            return false;
    return true;
}


function disableAnchor(obj, disable){
  if(disable=='true'){
    var href = obj.getAttribute("href");
    if(href && href != "" && href != null){
       obj.setAttribute('href_bak', href);
    }
    obj.removeAttribute('href');
    //obj.style.color="gray";
  }
  else{
    obj.setAttribute('href', obj.attributes['href_bak'].nodeValue);
    //obj.style.color="blue";
  }
}
