var isIE6=/msie|MSIE 6/.test(navigator.userAgent);function swapFromDestinationsSunSky(id){if(id==0){fillSunSelect();document.getElementById("choice").value="pack";}else{fillSkySelect();document.getElementById("choice").value="ski";}}
function fillSunSelect(){var arrayFrom=new Array(7);var arrayFromCode=new Array(7);var arrayDest=new Array(39);var arrayDestCode=new Array(39);arrayFromCode[0]="any";arrayFrom[0]="Any Airport";arrayFromCode[1]="DUB";arrayFrom[1]="Dublin";arrayFromCode[2]="BFS";arrayFrom[2]="Belfast";arrayFromCode[3]="SNN";arrayFrom[3]="Shannon";arrayFromCode[4]="ORK";arrayFrom[4]="Cork";arrayFromCode[5]="DUB,BFS";arrayFrom[5]="Dublin and Belfast";arrayFromCode[6]="Any Irish Republic";arrayFrom[6]="DUB,SNN,ORK";arrayDestCode[0]="any";arrayDest[0]="Any Destination";arrayDestCode[1]="FAO";arrayDest[1]="Algarve, Portugal";arrayDestCode[2]="ALC";arrayDest[2]="Alicante, Spain";arrayDestCode[3]="BGI";arrayDest[3]="Bulgaria (Bourgas)";arrayDestCode[4]="VAR";arrayDest[4]="Bulgaria (Varna)";arrayDestCode[5]="ALC";arrayDest[5]="Costa Blanca, Spain";arrayDestCode[6]="GRO";arrayDest[6]="Costa Brava, Spain";arrayDestCode[7]="AGP";arrayDest[7]="Costa del Sol, Spain";arrayDestCode[8]="LEI";arrayDest[8]="Costa de Almeria, Spain";arrayDestCode[9]="REU";arrayDest[9]="Costa Dorada, Spain";arrayDestCode[10]="HER";arrayDest[10]="Crete, Greece";arrayDestCode[11]="DBV";arrayDest[11]="Croatia";arrayDestCode[12]="LCA";arrayDest[12]="Cyprus";arrayDestCode[13]="SSH";arrayDest[13]="Egypt (Sharm El Sheikh)";arrayDestCode[14]="FUE";arrayDest[14]="Fuerteventura, Canaries";arrayDestCode[15]="NCE";arrayDest[15]="French Riveria";arrayDestCode[16]="LPA";arrayDest[16]="Gran Canaria, Canaries";arrayDestCode[17]="IBZ";arrayDest[17]="Ibiza, Spain";arrayDestCode[18]="EFL";arrayDest[18]="Kefalonia, Greece";arrayDestCode[19]="ACE";arrayDest[19]="Lanzarote, Canaries";arrayDestCode[20]="LIS";arrayDest[20]="Lisbon, Portugal";arrayDestCode[21]="FNC";arrayDest[21]="Madeira, Portugal";arrayDestCode[22]="PMI";arrayDest[22]="Majorca, Spain";arrayDestCode[23]="MLA";arrayDest[23]="Malta";arrayDestCode[24]="DBV";arrayDest[24]="Montenegro";arrayDestCode[25]="AGA";arrayDest[25]="Morocco";arrayDestCode[26]="MAH";arrayDest[26]="Menorca, Spain";arrayDestCode[27]="RHO";arrayDest[27]="Rhodes, Greece";arrayDestCode[28]="VAR";arrayDest[28]="Salou, Spain";arrayDestCode[29]="AHO";arrayDest[29]="Sardinia, Italy";arrayDestCode[30]="CTA";arrayDest[30]="Sicily, Italy";arrayDestCode[31]="TFS";arrayDest[31]="Tenerife, Canaries";arrayDestCode[32]="MIR";arrayDest[32]="Tunisia";arrayDestCode[33]="AYT";arrayDest[33]="Turkey (Antalya)";arrayDestCode[34]="BJV";arrayDest[34]="Turkey (Bodrum)";arrayDestCode[35]="ADB";arrayDest[35]="Turkey (Dalaman)";arrayDestCode[36]="DLM";arrayDest[36]="Turkey (Izmir)";arrayDestCode[37]="VRN";arrayDest[37]="Verona, Italy";arrayDestCode[39]="ZTH";arrayDest[39]="Zakinthos, Greece";var objFrom=document.getElementById("dep");var objDest=document.getElementById("dest");objDest.options.length=0;objFrom.options.length=0;for(i=0;i<arrayDest.length;i++){objDest.options[i]=new Option(arrayDest[i],arrayDestCode[i],false,false);}
for(i=0;i<arrayFrom.length;i++){objFrom.options[i]=new Option(arrayFrom[i],arrayFromCode[i],false,false);}}
function fillSkySelect(){var arrayFrom=new Array(7);var arrayFromCode=new Array(7);var arrayDest=new Array(8);var arrayDestCode=new Array(8);arrayFromCode[0]="any";arrayFrom[0]="Any Airport";arrayFromCode[1]="DUB";arrayFrom[1]="Dublin";arrayFromCode[2]="BFS";arrayFrom[2]="Belfast";arrayFromCode[3]="SNN";arrayFrom[3]="Shannon";arrayFromCode[4]="ORK";arrayFrom[4]="Cork";arrayFromCode[5]="DUB,BFS";arrayFrom[5]="Dublin and Belfast";arrayFromCode[6]="Any Irish Republic";arrayFrom[6]="DUB,SNN,ORK";arrayDestCode[0]="any";arrayDest[0]="Any Destination";arrayDestCode[1]="ANDORRA-any";arrayDest[1]="Andorra";arrayDestCode[2]="AUSTRIA-any";arrayDest[2]="Austria";arrayDestCode[3]="FRANCE-any";arrayDest[3]="France";arrayDestCode[4]="ITALY-any";arrayDest[4]="Italy";arrayDestCode[5]="NORWAY-any";arrayDest[5]="Norway";arrayDestCode[6]="SLOVENIA-any";arrayDest[6]="Slovenia";arrayDestCode[7]="SWITZERLAND-any";arrayDest[7]="Switzerland";var objFrom=document.getElementById("dep");var objDest=document.getElementById("dest");objDest.options.length=0;objFrom.options.length=0;for(i=0;i<arrayDest.length;i++){objDest.options[i]=new Option(arrayDest[i],arrayDestCode[i],false,false);}
for(i=0;i<arrayFrom.length;i++){objFrom.options[i]=new Option(arrayFrom[i],arrayFromCode[i],false,false);}}
function subSunSkyHolidaysPage(){if(fillDate()){setSunSkyHolidaysPageCookies();document.search_form.submit();}}
function setSunSkyHolidaysPageCookies(){createCookie('sunSkyHolidaySearchSunSkySwitch',getCheckedValue(document.search_form.sunSkySwitch),1);createCookie('sunSkyHolidaySearchChoice',document.getElementById("choice").value,1);createCookie('sunSkyHolidaySearchDep',document.getElementById("dep").value,1);createCookie('sunSkyHolidaySearchDest',document.getElementById("dest").value,1);createCookie('sunSkyHolidaySearchDepartDateSun',document.getElementById("DepartDateSun").value,1);createCookie('sunSkyHolidaySearchPax',document.getElementById("pax").value,1);createCookie('sunSkyHolidaySearchDur',document.getElementById("dur").value,1);createCookie('sunSkyHolidaySearchPrc',document.getElementById("prc").value,1);}
function getSunSkyHolidaysPageCookies(){if(readCookie('sunSkyHolidaySearchSunSkySwitch')!=null){var id=readCookie('sunSkyHolidaySearchSunSkySwitch');swapFromDestinationsSunSky(id);}
if(readCookie('sunSkyHolidaySearchChoice')!=null){document.getElementById("choice").value=readCookie('sunSkyHolidaySearchChoice');}
if(readCookie('sunSkyHolidaySearchDep')!=null){changeDefaultSelectedValue(document.getElementById("dep"),readCookie('sunSkyHolidaySearchDep'));}
if(readCookie('sunSkyHolidaySearchDest')!=null){changeDefaultSelectedValue(document.getElementById("dest"),readCookie('sunSkyHolidaySearchDest'));}
if(readCookie('sunSkyHolidaySearchDepartDateSun')!=null){document.getElementById("DepartDateSun").value=readCookie('sunSkyHolidaySearchDepartDateSun');}else{fillCurrentDate();}
if(readCookie('sunSkyHolidaySearchSunSkySwitch')!=null){changeDefaultRadioSelectedValue(document.search_form.sunSkySwitch,readCookie('sunSkyHolidaySearchSunSkySwitch'));}
if(readCookie('sunSkyHolidaySearchPax')!=null){changeDefaultSelectedValue(document.getElementById("pax"),readCookie('sunSkyHolidaySearchPax'));}
if(readCookie('sunSkyHolidaySearchDur')!=null){changeDefaultSelectedValue(document.getElementById("dur"),readCookie('sunSkyHolidaySearchDur'));}
if(readCookie('sunSkyHolidaySearchPrc')!=null){changeDefaultSelectedValue(document.getElementById("prc"),readCookie('sunSkyHolidaySearchPrc'));}}
function changeDefaultSelectedValue(objSelect,value){try{for(var i=0;i<objSelect.options.length;i++){if(objSelect.options[i].value==value){objSelect.options[i].selected=true;break}}}catch(e){}}
function IsNumeric(value){var objRegExp=/^[0-9]*$/;try{return(objRegExp.test(value));}catch(e){return false;}}
function fillDate(){if((document.search_form.DepartDateSun!=null)&&(document.search_form.DepartDateSun.value!="")){var leavingDate=document.search_form.DepartDateSun.value;try{if(IsNumeric(leavingDate.substring(0,2))){document.getElementById("holiday_date_day").value=leavingDate.substring(0,2);}else{alert("Incorrect Departure date");return(false);}
if(IsNumeric(leavingDate.substring(3,5))){document.getElementById("holiday_date_month").value=leavingDate.substring(3,5);}else{alert("Incorrect Departure date");return(false);}
if(IsNumeric(leavingDate.substring(6,10))){document.getElementById("holiday_date_year").value=leavingDate.substring(6,10);}else{alert("Incorrect Departure date");return(false);}}catch(e){alert("Incorrect Departure date");return(false);}
return(true);}else{alert("Departure date cannot be empty.");return(false);}}
function fillCurrentDate(){var currentDate=new Date();currentDate=new Date(currentDate.getFullYear(),currentDate.getMonth(),currentDate.getDate()+7);var day=currentDate.getDate();var month=currentDate.getMonth()+1;if(parseInt(day)<10){day="0"+day;}
if(parseInt(month)<10){month="0"+month;}


var currentDateStr=day+"/"+month+"/"+currentDate.getFullYear();document.getElementById("DepartDateSun").value=currentDateStr;}
function formatInputDate(value){var dateToFormat=new Date(value);var day=dateToFormat.getDate();var month=dateToFormat.getMonth()+1;if(parseInt(day)<10){day="0"+day;}
if(parseInt(month)<10){month="0"+month;}
var DateStr=day+"/"+month+"/"+dateToFormat.getFullYear();return(DateStr);}
function changeDefaultRadioSelectedValue(objRadio,value){try{if(value==0){objRadio[0].checked=true;objRadio[1].checked=false;}else{objRadio[0].checked=false;objRadio[1].checked=true;}}catch(e){}}
function getCheckedValue(radioObj){if(!radioObj)
return"";var radioLength=radioObj.length;if(radioLength==undefined)
if(radioObj.checked)
return radioObj.value;else
return"";for(var i=0;i<radioLength;i++){if(radioObj[i].checked){return radioObj[i].value;}}
return"";}
function hideFixFirstDate(){if(isIE6){document.getElementById('pax').style.visibility='hidden';document.getElementById('prc').style.visibility='hidden';}}
function showFixFirstDate(){if(isIE6){document.getElementById('pax').style.visibility='visible';document.getElementById('prc').style.visibility='visible';}}

function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/";}
function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
function eraseCookie(name){createCookie(name,"",-1);}
