function popUp(url,w,h,name,resizable,scrollbar,menu,tool,status,directories,x,y){

	this.strUrl = url;
	//x and y for window screen position not required at the moment
	this.intX = x;
	this.intY = y;

	this.strName = "win_"+name;
	this.strResizable = (resizable=="yes" || resizable==1) ? "resizable=yes" : "";
	this.strScroll = (scrollbar=="yes" || scrollbar==1) ? "scrollbars=yes" : "";
	this.strMenu = (menu=="yes" || menu==1) ? "menubar=yes" : "";
	this.strTool = (tool=="yes" || tool==1) ? "toolbar=yes" : "";
	this.strStatus = (status=="yes" || status==1) ? "status=yes" : "";
	this.strDirectories = (directories=="yes" || directories==1) ? "directories=yes" : "";
	this.intW = (!isNaN(w)) ? "width="+w: "";
	this.intH = (!isNaN(h)) ? "height="+h: "";
	
	this.arrOptions = new Array(this.strResizable,this.strScroll,this.strMenu,this.strTool,this.strStatus,this.strDirectories,this.intW,this.intH);
	this.strOptions = "";
	
	//build the options
	for(var i=0;i<this.arrOptions.length;i++){
		if(this.arrOptions[i].length>0){
			this.strOptions+=this.arrOptions[i]+",";
		}
	}
	//remove any trailing ","
	if(this.strOptions.length>0){
		this.strOptions=this.strOptions.substring(0,this.strOptions.length-1);
	}
	
	this.win=window.open(this.strUrl,this.strName,this.strOptions);
	/*if(location.protocol=="http:"){
		if(!isNaN(w) && !isNaN(h)){
			this.win.resizeTo(w,h);
		}
	}*/
	this.win.focus();
}

function genPopUp(url,w,h,name,resizable,scrollbar,menu,tool,status,directories,x,y){
	//no requirement to hold popups in global references at the moment
	new popUp(url,w,h,name,resizable,scrollbar,menu,tool,status,directories,x,y)
	return false;
}


function hideError(){
	document.getElementById("error").style.display="none";
}
function showError(){
	document.getElementById("errorMessage").innerHTML = "<ul><li class=\"errMsg\">"+hiErr+"</li></ul>";
	document.getElementById("error").style.display="";
	window.scrollTo(0,0);
}
function showDest(num){
if(num<11){
	document.getElementById('dest').value=destArr[num-1];
	document.getElementById('hotel').value='';
	}
}
var errorBorder = "#CCCCCC";
function errorCheck(nam,err){
	var check = document.getElementById(nam);
	check.style.borderColor = errorBorder;
	var errorMsg = "";
	if(check.value==""){
		check.focus();
		check.style.borderColor="#FF0000";
		errorMsg +='<li class="mlneg9v11">'+err+'</li>\n';
		}
	if(errorMsg != ""){
		document.getElementById("errorMessage").innerHTML = "<ul>"+errorMsg+"</ul>";
		document.getElementById("error").style.display="";
		window.scrollTo(0,0);
		return false;
	}else{
		//dispHolding();
		setTimeout("dispHolding()",50);
		return true;
		}
	}

function blankIfNotNumeric( obj ){
	//determine if the field contains a numeric value
	var numericPattern	= /(\d)/;
	var objValue 		= obj.value;
	var checkReg 		= objValue.match( numericPattern );
	
	if( checkReg == null ){
		//no, lets blank out the field
		obj.value = "";
		obj.select();
	}

}

/* nuovo calendario voli */
var multi = false;
var serverTime = new Date(1207059100099);
var dapDay = ""
var dapMonth = ""
var repDay = ""
var repMonth = ""				
var calClose = "Close";
var nextMonth = "Next Month";
var prevMonth = "Previous Month";
var firstDate = new Date();
var lastDate = new Date(firstDate);
var monthLengths = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
serverTime.setHours(00);serverTime.setMinutes(00);serverTime.setSeconds(01);
var sevendays = new Date(serverTime.getTime()+(604800000));
var datum = monthLengths[sevendays.getMonth()] -7
var Selecttheright
function isLeapYear(year) {
	return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
}
if(sevendays.getDate() > monthLengths[sevendays.getMonth()]){
	Selecttheright = (datum-sevendays.getDate())
}else{
	Selecttheright = sevendays.getDate()
}
var Maximum = 10;

function changeValue(checkbox){
	if(checkbox.value=="false"){
		checkbox.value="true"
	}else if(checkbox.value=="true"){
		checkbox.value="false"
	}
}
function noenter() 
{
  return !(window.event && window.event.keyCode == 13); 
}
var obj = new Array()
obj[0] = "departureAirportText"
obj[1] = "arrivalAirportText"

function onOff(who)
{
	for(i=0;i<obj.length;i++)
	{
		if(document.getElementById(obj[i]) != who)
		{
			dis = obj[i]
			//document.getElementById(dis).disabled = true
		}
	}
}
function offOn()
{
	for(i=0;i<obj.length;i++)
	{
			dis = obj[i]
			//document.getElementById(dis).disabled = false
	}
}

function calendarclose()
{
closePredictive("departure","");
closePredictive("arrival","");
}

function killEvent(e)
{
	e.cancelBubble = true;
	e.returnValue = false;
	if (e.stopPropagation) 
	{
		e.stopPropagation();
		e.preventDefault();
	}
}
function verifyTab(e, obj)
{
	var code = getCode(e);
	if (code == 9)
	{
		/**
		 * If the predictive text is not open, I leave the tab go
		 * to the next field, if it is open, I kill the tab so we loop
		 * through the predictive text options
		*/
		if (obj.value.length > 3)
		{
			killEvent(e);
			return false;
		}
	}
}

//to override a js error in the header
function addLoadEvent(foo)
{

}

var selectedAirLines = new Array()
function move_item(from, to, removeit){
from = document.getElementById(from)
to = document.getElementById(to)
  var f;
  var SI; /* selected Index */
  if(from.options.length>0){
    for(i=0;i<from.length;i++){
      if(from.options[i].selected){
        SI=from.selectedIndex;
        f=from.options[SI].index;
        to.options[to.length]=new Option(from.options[SI].text,from.options[SI].value);
		if(removeit !="no"){
			removeA(from.options[SI].value,selectedAirLines)
		}else{
			selectedAirLines[selectedAirLines.length] = from.options[SI].value;	
		}
        from.options[f]=null;
        i--; /* make the loop go through them all */
      }
    }
  }
//  document.getElementById('preferredAirlines').value = selectedAirLines
}

function removeA(item,array) {
var x = 0;
while (x < array.length) {
	if (array[x] == item) {
		array.splice(x, 1);
	} else {
		x++;
		}
	}
return true;
}
function addOptions(selectbox,text,value,id,selectedMonth){
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
optn.id = id;
if(value == selectedMonth){
	optn.selected = "selected";
}
var sel = selectbox;
var newOpt = new Option(optn.text,optn.value,optn.id,optn.selected);
sel.options[sel.options.length] = newOpt;
}
		function change(){
			var PreferedArrays = new Array()
			var nopref = document.getElementById("nopref")
			var thatone = document.getElementById("preferred")
				if(thatone.length >= 1 ){
				var x=document.getElementById("preferred")
					if(nopref){
			  		x.remove(nopref)
					}
				}else{
					addOptions(document.getElementById('preferred')  , "nessuna preferenza" , "nessuna preferenza", "nopref");
					document.getElementById("preferred").options[0].id="nopref"
				}	
				var output = ''
				for(i=0; i < document.getElementById("preferred").options.length; i++){
					if (document.getElementById('preferred').options[i].id != 'nopref')
					output += "<input type='hidden' id='preferredAirlines[" + i + "]' name='preferredAirlines[" + i + "]' value='" + document.getElementById('preferred').options[i].value +"' >";
				}
		}

function setOptions(chosen,frm) {
    frm = frm;
    var selbox = frm.numberOfChildren;
    selbox.options.length = 0;
    var selbox2 = frm.numberOfInfants;
    selbox2.options.length = 0;
    var box1 = frm.numberOfAdults.options[frm.numberOfAdults.selectedIndex].value;
    for(q=0;q<=box1;q++){
         selbox2.options[selbox2.options.length] = new Option(q,q);
    }
    for(i=0 ; i < Maximum ; i++){
        if (chosen == i) {
            selbox.options[selbox.options.length] = new Option(0,0);
            for(z=1;z <(Maximum-i) ; z++){
              selbox.options[selbox.options.length] = new Option(z,z);
            }
        }
    }
}

/* my */

// calendario voli
rightnow = new Date();
function month(i,name) {

	var thisyear = rightnow.getFullYear();

	var nextyear = thisyear + 1;

	var a = "<option value=\"";

	(i<rightnow.getMonth()) ? a +=nextyear : a +=thisyear;

	(i<9) ? a += "0"+(i+1) : a +=(i+1);

	a += "\">"+name+" 0";

	(i<rightnow.getMonth()) ? a +=(nextyear-2000) : a +=(thisyear-2000);

	a += "</option>\n";

	this.option = a;

}

var months = new Array(new month(0,"Gen"), new month(1,"Feb"),new month(2,"Mar"),new month(3,"Apr"),new month(4,"Mag"), new month(5,"Giu"), new month(6,"Lug"), new month(7,"Ago"), new month(8,"Set"), new month(9,"Ott"), new month(10,"Nov"), new month(11,"Dic"));

// end calendar

function hideRow(id){
document.getElementById(id).style.display='none';
}
function showRow(id){
document.getElementById(id).style.display='';
}
function _convertGetDay(n){
var w=new Array("Dom", "Lun", "Mar","Mer", "Gio", "Ven", "Sab");
return w[n];
}
function _appendDayOptions(id,m){
	var d = new Date(), sel, limi;

	if(m != 'now'){


		sel = document.getElementById(id).selectedIndex;

		d.setYear(m.substring(0,4));

		if(m.substring(4,5) == '0'){
			d.setMonth(m.substring(5,6)-1);

		} else {
			d.setMonth(m.substring(4,6)-1);
		}


	} else {

		sel = d.getDate()-1;

	}

	var e = document.getElementById(id);
	while (e.firstChild) {
		e.removeChild(e.firstChild);
	}

	limit = monthLengths[d.getMonth()];
	option = '';
	for(var i=1;i<=limit;i++){
		d.setDate(i);
		var option = document.createElement('option');
		option.setAttribute('value',((i<10)?"0"+i:i));
		if( sel == i-1 ){
			option.setAttribute('selected','selected');
		}
		option.appendChild(document.createTextNode(_convertGetDay(d.getDay())+' '+i));
		e.appendChild(option);
	}
}


document.write(
'<', 'script src="http://www.opodo.it/js/locationSearch.js?id=17"', '>', '</', 'script', '>'
);