function hiddens_compact()
{
	var i_sector1_o = eval("document." + formweb + ".sector1_o.selectedIndex");
	var i_sector1_d = eval("document." + formweb + ".sector1_d.selectedIndex");
	var i_sector_1_d = eval("document." + formweb + ".sector_1_d.selectedIndex");
	var i_sector_2_d = eval("document." + formweb + ".sector_2_d.selectedIndex");
	var i_sector_1_m = eval("document." + formweb + ".sector_1_m.selectedIndex");
	var i_sector_2_m = eval("document." + formweb + ".sector_2_m.selectedIndex");
	var i_adult = eval("document." + formweb + ".ADULT.selectedIndex");
	var i_child = eval("document."+ formweb + ".CHILD.selectedIndex");
	var i_infant = eval("document." + formweb + ".INFANT.selectedIndex");
	if(document.getElementById('i_sector1_o')) document.getElementById('i_sector1_o').value = i_sector1_o;
	if(document.getElementById('i_sector1_d')) document.getElementById('i_sector1_d').value = i_sector1_d;
	if(document.getElementById('i_sector_1_d')) document.getElementById('i_sector_1_d').value = i_sector_1_d;
	if(document.getElementById('i_sector_2_d')) document.getElementById('i_sector_2_d').value = i_sector_2_d;
	if(document.getElementById('i_sector_1_m')) document.getElementById('i_sector_1_m').value = i_sector_1_m;
	if(document.getElementById('i_sector_2_m')) document.getElementById('i_sector_2_m').value = i_sector_2_m;
	if(document.getElementById('i_adult')) document.getElementById('i_adult').value = i_adult;
	if(document.getElementById('i_child')) document.getElementById('i_child').value = i_child;
	if(document.getElementById('i_infant')) document.getElementById('i_infant').value = i_infant;
}
function recupera()
{
	var i_sector1_o = document.getElementById('i_sector1_o').value;
	var i_sector1_d = document.getElementById('i_sector1_d').value;
	var i_sector_1_d = document.getElementById('i_sector_1_d').value;
	var i_sector_2_d = document.getElementById('i_sector_2_d').value;
	var i_sector_1_m = document.getElementById('i_sector_1_m').value;
	var i_sector_2_m = document.getElementById('i_sector_2_m').value;
	var i_adult = document.getElementById('i_adult').value;
	var i_child = document.getElementById('i_child').value;
	var i_infant = document.getElementById('i_infant').value;
	eval("document." + formweb + ".sector1_o.selectedIndex") = i_sector1_o;
	eval("document." + formweb + ".sector1_d.selectedIndex") = i_sector1_d;
	eval("document." + formweb + ".sector_1_d.selectedIndex") = i_sector_1_d;
	eval("document." + formweb + ".sector_2_d.selectedIndex") = i_sector_2_d;
	eval("document." + formweb + ".sector_1_m.selectedIndex") = i_sector_1_m;
	eval("document." + formweb + ".sector_2_m.selectedIndex") = i_sector_2_m;
	eval("document." + formweb + ".ADULT.selectedIndex") = i_adult;
	eval("document."+ formweb + ".CHILD.selectedIndex") = i_child;
	eval("document." + formweb + ".INFANT.selectedIndex") = i_infant;
}
function daysinmonth(sdate) 
{
	smonth 	= sdate.substring(4,6);
	syear 	= sdate.substring(0,4);
	var sdays = '31';
	if (smonth == "04" || smonth == "06" || smonth == "09" || smonth == "11")
	{
			sdays = '30';
	}
	else
	{
		if (smonth == "02")
		{
			if ( ((syear % 4 == 0) && (syear % 100 != 0)) || (syear % 400 == 0) )
			{
				sdays = '29';
			}
			else
			{
				sdays = '28';
			}
		}
	}
	return sdays;
}
function swap_icon(icon_name, icon_state)
{
	if (document.images)
	{
		if ( icon_name == 'calendar_1' || swap_icon_ok )
		{
			icon = eval(icon_name + "_icon_" + icon_state + ".src");
			if (icon && document.images[icon_name])
			{
				document.images[icon_name].src = icon;
			}
		}
	}
}
function capturaFechas()
{
	oDay = document.SBform.sector_1_d.options[document.SBform.sector_1_d.selectedIndex].value
	oMonth = document.SBform.sector_1_m.options[document.SBform.sector_1_m.selectedIndex].value.substring(0,2)
	oYear = document.SBform.sector_1_m.options[document.SBform.sector_1_m.selectedIndex].value.substring(2,6)
	rDay = document.SBform.sector_2_d.options[document.SBform.sector_2_d.selectedIndex].value
	rMonth = document.SBform.sector_2_m.options[document.SBform.sector_2_m.selectedIndex].value.substring(0,2)
	rYear = document.SBform.sector_2_m.options[document.SBform.sector_2_m.selectedIndex].value.substring(2,6)
}
function recheck_dates()
{
	capturaFechas()
	if ( rDay != 0 )
	{
		if ( ( rMonth < oMonth ) && ( rYear == oYear ) || ( oYear > rYear ) )
		{
			document.SBform.sector_2_m.options.selectedIndex = document.SBform.sector_1_m.options.selectedIndex + 1;
			document.SBform.sector_2_d.options.selectedIndex = document.SBform.sector_1_d.options.selectedIndex + 1;
		}
		else if ( ( rDay < oDay ) && ( rMonth == oMonth ) )
		{
			document.SBform.sector_2_d.options.selectedIndex = document.SBform.sector_1_d.options.selectedIndex + 1;
		}
	}
}
function checkDates()
{
	var ret = true;
	if (oldCheckSBData)
		ret = oldCheckSBData();
	if (ret)
	{
		var oMonthYear= '' + oYear + oMonth;
		var rMonthYear= '' + rYear + rMonth;
		var origin = document.SBform.sector1_o.value;
		var dest = document.SBform.sector1_d.value;
		var idaVuelta = document.SBform.travel_type[0].checked;
		if ( origin && ((origin.indexOf('LIS') >= 0) || (dest && (dest.indexOf('LIS') >= 0)) || (origin.indexOf('MAH') >= 0) || (dest && (dest.indexOf('MAH') >= 0)) ) && ( ((oDay < 16) && (oMonthYear == 200505)) || (oMonthYear < 200505) || (idaVuelta && (((rDay < 16) && (rMonthYear == 200505)) || (rMonthYear < 200505))) ))
		{
			ret = false;
		}
		if (!ret)
		{
			switch (language)
			{
			case "EN":
				alert ("\nThe dates you have chosen to fly on are\neither invalid or unavailable. Please choose\na different outbound and/or return date.\n")
				break;
			case "FR":
				alert ("\nLes dates que vous avez choisi pour les vols ne sont pas\nvalables ou ne sont pas disponibles. Nous vous prions de choisir \nune date de d?part et/ou retour diff?rente.\n")
				break;
			case "IT":
				alert ("\nLe date che hai selezionato non sono\nvalide o non sono disponibili. Scegli\nuna data di partenza e/o di ritorno diversa.\n")
				break;
			case "CA":
				alert ("\nLes dates que heu escollit per als vols no s?n\nv?lides o no estan disponibles. Si us plau, escolliu\nuna data de sortida i/o tornada diferent.\n");
				break;
			case "PT": 
				alert ("\nLas fechas que has escogido para los vuelos no son\nv?lidas o no est?n disponibles. Escoge\nuna fecha de partida y/o regreso distinta.\n");
			case "ES": default:
				alert ("\nLas fechas que has escogido para los vuelos no son\nv?lidas o no est?n disponibles. Escoge\nuna fecha de partida y/o regreso distinta.\n");
			break;
			}
		}
	}
	return ret;
}
function overwriteCheckSBData(lang)
{
	language = lang;
	oldCheckSBData = checkSBdata;
	checkSBdata = checkDates;
}
function goto_pnr_list()
{
	document.goto_pnr_form.submit();
}
function  abrir_ventana (_url,_alto,_ancho) {
    var URL = _url;
    var alto = _alto;
    var ancho = _ancho;
    var Type = (document.layers)? 'NS':'IE';
    var IEwidth=alto
    var IEheight=ancho;
    var IEleft= (screen.width - ancho - 5)/2;
    var IEtop=(screen.height - alto -10)/2;
    var NSwidth=ancho;
    var NSheight=alto;
    var NSleft=(screen.width - ancho)/2;
    var NStop=(screen.height - alto)/2;
    if (URL!=""){
	if (Type == "NS"){
	  ventana=window.open(URL,'popup','width='+NSwidth+',height='+NSheight+',left='+NSleft+',top='+NStop+',screenX='+NSleft+',screenY='+NStop+',scrollbars=yes');
	  ventana.focus();
	  ventana.location=URL;
	}
	else
		if (Type == "IE") {
	      ventana=window.open(URL,'popup','width='+IEwidth+',height='+IEheight+',left='+IEleft+',top='+IEtop+',screenX='+IEleft+',screenY='+IEtop+',scrollbars=yes');
	      ventana.focus();
	    }
    }
}
function  popupCondicions(lenguaje,modo) {
    var alto = 530;
    var ancho = 400;
    var Type = (document.layers)? 'NS':'IE';
    var IEwidth=alto
    var IEheight=ancho;
    var IEleft= (screen.width - ancho - 5)/2;
    var IEtop=(screen.height - alto -10)/2;
    var NSwidth=ancho;
    var NSheight=alto;
    var NSleft=(screen.width - ancho)/2;
    var NStop=(screen.height - alto)/2;
	if (modo == "0") {
		var URL ="/info/conditions.php?language=" + lenguaje + "&options=1#ico_03";
		}
	else if (modo == "1") {
		var URL ="/info/conditions.php?language=" + lenguaje + "&options=1#ico_01";
		}
	else if (modo == "2") {
		var URL ="/info/conditions.php?language=" + lenguaje + "&options=1#ico_02";
		}
	else if (modo == "3") {
		var URL ="/info/conditions.php?language=" + lenguaje + "&options=1#ico_04";
		}
	else if (modo == "4") {
		var URL ="/info/conditions.php?language=" + lenguaje + "&options=1&idMenu=3&mode=&sid=#16h";
		}
	if (URL!=""){
		if (Type == "NS"){
		  ventana=window.open(URL,'popup','width='+NSwidth+',height='+NSheight+',left='+NSleft+',top='+NStop+',screenX='+NSleft+',screenY='+NStop+',scrollbars=yes');
		  ventana.focus();
		  ventana.location=URL;
		}
		else
		  if (Type == "IE") {
		  ventana=window.open(URL,'popup','width='+IEwidth+',height='+IEheight+',left='+IEleft+',top='+IEtop+',screenX='+IEleft+',screenY='+IEtop+',scrollbars=yes');
		  ventana.focus();
		  }
	    }
}
function f_open_window_max( aURL, aWinName )
{
   var wOpen;
   var sOptions;
   sOptions = 'status=no,menubar=yes,scrollbars=yes,resizable=yes,toolbar=yes';
   sOptions = sOptions + ',width=' + (screen.availWidth - 10).toString();
   sOptions = sOptions + ',height=' + (screen.availHeight - 50).toString();
   sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';
   wOpen = window.open( aURL, aWinName, sOptions );
   wOpen.focus();
   return wOpen;
}
function getParameter(paramName) {
	var currentUrl = window.location.search
	var strBegin = currentUrl.indexOf(paramName) + (paramName.length+1)
	var strEnd = currentUrl.indexOf("&",strBegin)
	if (strBegin==-1)
		return null;
	if (strEnd==-1)
		strEnd = currentUrl.length
	return currentUrl.substring(strBegin,strEnd)
}
 function include(file) {
   if (document.createElement && document.getElementsByTagName) {
     var head = document.getElementsByTagName('head')[0];
     var script = document.createElement('script');
     script.setAttribute('type', 'text/javascript');
     script.setAttribute('src', file);
     head.appendChild(script);
   } else {
   }
 }
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  cookieContainer.cookie = curCookie;
}
function getCookie(name) {
  var dc = cookieContainer.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = cookieContainer.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}
function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    cookieContainer.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}
function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}
function getcookie_city() {
	city=document.cookie.split('origen_ant=');
	if(city.length>1){
		ciudad=city[1].split("*!*");
		if(ciudad.length>0){
			if(ciudad[0].length>0){
				for (var i = 0; i < document.getElementById("from1Select").options.length; i++)	
				{
					if(document.getElementById("from1Select").options[ i ].value==ciudad[0]) document.getElementById("from1Select").selectedIndex=i;
				};
			};
		}
	}
}
function resetAdsStatus()
{
	setCookie(ADS_COOKIE_NAME, "false");
}
function adsSeen()
{
	setCookie(ADS_COOKIE_NAME, "true");
}
function isAdsSeen()
{
	var cookieValue = getCookie(ADS_COOKIE_NAME);
	setCookie(ADS_COOKIE_NAME, cookieValue);
	return (cookieValue == "true");
}
function gotoGroup(obj)
{
	if (obj.value == "+25")
	{
		var gruposweb = "/" + idiomaweb + "/groups/index.php?sid=";
		location.replace(gruposweb);
	}
}
function gotoFareFinder(){	
	document.farefinder.action='/skylights/cgi-bin/skylights.cgi';
	document.farefinder.submit();
}
function imageswap (nombre, conDn ) {
	var path="/img/menu/";
	var myImage="";
	if ( conDn=="0")  {
		myImage = nombre + ".gif" ;
	}
	else
	{
		myImage = nombre + "_dn.gif" ;
	}
	eval ("document.images['" + nombre + "'].src = '" + path + myImage + "' ");
}
function imageswap2 (nombre, conDn ) {
	var path="/img/";
	var myImage="";
	if ( conDn=="0")  {
		myImage = nombre + idiomaweb + ".gif" ;
	}
	else
	{
		myImage = nombre + idiomaweb + "_dn.gif" ;
	}
	eval ("document.images['" + nombre + "'].src = '" + path + myImage + "' ");
}
function checkCalendarDate(mkt,day,month,year)
{
	var okay = true;
	var isLeapYear = ( year % 4 == 0 && ( year % 100 != 0 || year % 400 == 0 ) ) ? true : false;
	if ( month == 2 && day > 29 && isLeapYear )
	{
		okay = correctDay(29,mkt,popup_february_leap_year)
	}
	else if ( month == 2 && day > 28 && !isLeapYear)
	{
		okay = correctDay(28,mkt, popup_february_leap_year)
	}
	else if ( month == 4 && day > 30 )
	{
		okay = correctDay(30,mkt, april)
	}
	else if ( month == 6 && day > 30 )
	{
		okay = correctDay(30,mkt, june)
	}
	else if ( month == 9 && day > 30 )
	{
		okay = correctDay(30,mkt, september)
	}
	else if ( month == 11 && day > 30 )
	{
		okay = correctDay(30,mkt, november)
	}
	return okay;
}
function checkCities()
{
	if (sector1_o == 'XXX')
	{
		alert ("\n" + popup_sector_1_orig_missing  + "\n");
		okay = false;
	}
	else if (sector1_d == 'XXX')
	{
		alert ("\n" + popup_sector_1_dest_missing + "\n");
		okay = false;
	}
	else if ( ( sector2_o == 'XXX' && sector2_d != 'XXX' ) || ( sector2_o != 'XXX' && sector2_d == 'XXX' ) )
	{
		alert ("\n" + popup_sector_2_pair_incomplete + "\n");
		okay = false;
	}
	else if (searchPrefs.OFFER_OPEN_JAW_ROUTES == "true")
	{
		if ( validateOpenJawConnections() == "false" )
		{
			alert ("\n" + popup_illogical_open_jaw + "\n");
			okay = false;
		}
	}
	else
	{
		okay = true;
	}
	return okay;
} 
function items()
				{
					if(document.getElementById('puntos_show') && document.getElementById('puntos_show').checked){
						document.getElementById('icones1').style.display='block';
					}else{
						if(document.getElementById('icones1')){
							document.getElementById('icones1').style.display="none";
						}
					}
				}
function submit_form_comprovar()
{
					if(document.skylightsForm.email_addr)
					{
						if(document.skylightsForm.email_addr.value!="")
						{
							submit_form_select_registered_user();
						}else
						{
							submit_form_select();
						}
					}else
					{
						submit_form_select();
						
					}
}
function submit_form_select_registered_user()
{
					if(document.skylightsForm.email_addr.value == '')
					{
						alert("[% USER.CUSTOM.popup_no_email %]");
					}
					else if( document.skylightsForm.pw.value == '' )
					{
						alert("[% USER.CUSTOM.popup_no_password %]");
					}
					else if(! filterEmailField(document.skylightsForm.email_addr))
					{
						captureFilterEmailText(document.skylightsForm.email_addr);
					}
					else
					{
						document.skylightsForm.log_in.value = '1';
						submit_form_select(true);
					}
}
function show_punto_window () {

					var ventana = window.open('','popup','width=450,height=320,scrollbars=yes');

					var texto = "<strong>[% USER.CUSTOM.label_PUNTOS1; %]</strong><br><br><br>[% USER.CUSTOM.label_PUNTOS2 %]";
					
					ventana.document.write('<html><head><title>vueling.com</title><link rel="stylesheet" href="/css/vueling.css" type="text/css"></head><body><table border="0" cellpadding="0" cellspacing="30"><tr><td>' + texto + '</td></tr><tr><td align=center><a href="javascript:window.close()">[% USER.CUSTOM.label_confirm_close %]</a></td></tr></table></body></html>');

					ventana.document.close();
}
