/*
**************************************************************************
ResortSearchForm.js
JS Functions used on the Resort Search Form
**************************************************************************
*/
/*function Load()
	{
	frm = document.basic;
	//document.getElementById('quicksearch').style.display ='block';
    //document.getElementById('advsearch').style.display ='none';
	}*/

function checkRequests(){
var strRequestMessage;
var intRequestCount;
var intCounter;
	
	/*
		strRequestMessage = "U kunt maximaal 6 wensen aangeven";
		intRequestCount = 0
	for(intCounter =1;intCounter <13;intCounter++)
	{
		strCurrentField = "chkPref" + intCounter; 
		if (document.basic(strCurrentField).checked==true)
			intRequestCount++;
	}
		if (intRequestCount > 6)
		
				alert(strRequestMessage);*/
	}
	
function Warn(url)
	{
	msg = "Do you wish to cancel your current selection of parc stays?";
	if (confirm(msg))
		{
		document.location.href = url;
		}
	else
		{
		return false;	
		}
	}

function submitForm()
{ 
var intNights = (parseInt(document.basic.nights.value))
var theRegion = document.basic.region.value
var intparty = 	(parseInt(document.basic.adults.value) + parseInt(document.basic.children.value) + parseInt(document.basic.infants.value));
var intpets = 	(parseInt(document.basic.pets.value))
var d = new Date();//Get today's date
var dd = d.getDate();//This is the day
var mm = (d.getMonth() + 1);//This is the month (javascript uses 0 - 11)
var yy = d.getYear();//This is the year
var tyy = document.basic.arrivalYear.value;
var tmm = document.basic.arrivalMonth.value;
var tdd = document.basic.arrivalDate.value;
var startDate = new Date();//Create a new year variable to test minimum number of days a booking can be made.
startDate.setMonth(document.basic.arrivalMonth.value - 1);// Remember Javascript uses 0 - 11
startDate.setDate(document.basic.arrivalDate.value);
startDate.setYear(document.basic.arrivalYear.value);
var ONE_DAY = 1000 * 60 * 60 * 24 ;// Converts milliseconds into days
var dz = ((startDate)-(d));
var dzdiff = (dz/ONE_DAY);
var dzmess = ("It is not possible to book online within 3 days of departure. \n"+
	          "Please call our sales department on 0870 9019 410.")
/*alert (dd);
alert(mm);
alert (yy);
alert (tdd);
alert(tmm);
alert (tyy);*/
if (dd < 10)
	   {
	    dd = "0" + dd;
	   }
if (tdd < 10)
	   {
	    tdd = "0" + tdd;
	   }	   
if (mm < 10)
	   {
	    mm = "0" + mm;
	   }	
//if (tmm < 10)
//	{
//	tmm = "0" + tmm;
//	}
if ((tmm < mm)&&(tyy == yy))
	   {
	    alert ("This date is in the past, please amend your search date.");
		
		return false;   
	    }
else
{
	if ((tyy == yy)&&(tmm == mm)&&(tdd <= dd))
	   {
	   	alert ("This date is in the past, please amend your search date.");
		
		return false;
		} 
/*
else
	 if ((tyy == yy)&&(tmm >10))
		{
	   alert("Our latest holiday parc opening date is 27th October 2008. Please amend your search date.");
       return false;
		}
else
	if ((tyy != yy)&&(tmm < 2))
		{
	   alert("Our earliest holiday parc opening date is 9th February 2008. Please amend your search date.");
       return false;
		}
else
	if ((tyy != yy)&&(tmm > 10))
		{
	   alert("Please note that arrivals are possible from 9th February until 27th October. Please amend your search date.");
       return false;
		}
*/
else
	if (intparty >8)
  		{alert ("A maximum of 8 people are allowed. Please amend your search criteria.");
   		return false;
 	}
else
	if ((intNights <7)&&(theRegion==42))
  		{alert ("The minimum number of nights for holidays in Florida is 7");
   		return false;
 	}

	else
	if (dzdiff <= 3)
	   {alert (dzmess);
	   return false;
	   }
	
else
		{
	
	document.forms.basic.submit();
	document.getElementById('searchForm').style.display = 'none'; 
    document.getElementById('pleaseWaitDiv').style.display = 'block';
	return true;
		}
	}
}


function submitAmendSearch()

{  

// Hide the code in first div tag  
//	document.getElementById('formDiv').style.display = 'none';  
// Display code in second div tag  
//	document.getElementById('pleaseWaitDiv').style.display = 'block'; 
var d = new Date();//Get today's date
var dd = d.getDate();//This is the day
var mm = (d.getMonth() + 1);//This is the month (javascript uses 0 - 11)
var yy = d.getYear();//This is the year
var tyy = document.basic.arrivalYear.value;
var tmm = document.basic.arrivalMonth.value;
var tdd = document.basic.arrivalDate.value;
var startDate = new Date();//Create a new year variable to test minimum number of days a booking can be made.
startDate.setMonth(document.basic.arrivalMonth.value - 1);// Remember Javascript uses 0 - 11
startDate.setDate(document.basic.arrivalDate.value);
startDate.setYear(document.basic.arrivalYear.value);
var ONE_DAY = 1000 * 60 * 60 * 24 ;// Converts milliseconds into days
var dz = ((startDate)-(d));
var dzdiff = (dz/ONE_DAY);
var dzmess = ("Online bookings cannot be made within 7 working days of departure.\n"+
	          "Please call our Reservations Team on 0870 9019 401 who will be happy to check availability.")

if (dd < 10)
	   {
	    dd = "0" + dd;
	   }
if (mm < 10)
	   {
	    mm = "0" + mm;
	   }	
/*if (tmm < 10)
		{
		tmm = "0" + tmm;
		}*/
if (document.basic.region.value == 0)
  {alert("Please choose a region");
  return false;
	}
else
	{
	if ((tyy == yy)&&(tmm < mm))
	   {alert ("This date is in the past. Please enter a valid date.");
		return false;	   
	    }
  	else
	if ((tyy == yy)&&(tmm == mm)&&(tdd <= dd))
	   {alert ("This date is in the past. Please enter a valid date.");
		return false;
		} 
/*
else
	 if ((tyy == yy)&&(tmm >10))
		{
	   alert("Sorry. Our holiday parc opening dates range from 09/02/2008 to 27/10/2008");
       return false;
		}
	else
	if ((tyy != yy)&&(tmm < 4))
		{
	   alert("Sorry. Our holiday parc opening dates range from 09/02/2008 to 27/10/2008");
       return false;
		}
	else
	if ((tyy != yy)&&(tmm > 10))
		{
	   alert("Sorry. Our holiday parc opening dates range from 09/02/2008 to 27/10/2008");
       return false;
		}
	else
	if (dzdiff <= 7)
	   {alert (dzmess);
	   return false;
	   }
*/
	else
	if (document.basic.nights > 21)
	   {
	   alert ("Sorry it is only possible to book up to 21 nights online.");
	   }
	else{
	/*document.basic.arrivalDate.value = document.basic.ResortDate.value.substr(0, 2)
    document.basic.arrivalMonth.value = document.basic.ResortDate.value.substr(3, 2)
	document.basic.arrivalYear.value = document.basic.ResortDate.value.substr(6, 4)*/
	document.forms.basic.submit();
	return true;
		}
	}
}

function submitForm2()
{  
// Hide the code in first div tag  
//	document.getElementById('formDiv').style.display = 'none';  
// Display code in second div tag  

//	document.getElementById('pleaseWaitDiv').style.display = 'block'; 
var intparty = 	(parseInt(document.basic2.adults.value) + parseInt(document.basic2.children.value) + parseInt(document.basic2.infants.value));
var d = new Date();//Get today's date
var dd = d.getDate();//This is the day
var mm = (d.getMonth() + 1);//This is the month (javascript uses 0 - 11)
var yy = d.getYear();//This is the year
var tyy = document.basic2.arrivalYear.value;
var tmm = document.basic2.arrivalMonth.value;
var tdd = document.basic2.arrivalDate.value;
var startDate = new Date();//Create a new year variable to test minimum number of days a booking can be made.
startDate.setMonth(document.basic2.arrivalMonth.value - 1);// Remember Javascript uses 0 - 11
startDate.setDate(document.basic2.arrivalDate.value);
startDate.setYear(document.basic2.arrivalYear.value);
var ONE_DAY = 1000 * 60 * 60 * 24 ;// Converts milliseconds into days
var dz = ((startDate)-(d));
var dzdiff = (dz/ONE_DAY);
var dzmess = ("Online bookings cannot be made within 7 working days of departure.\n"+
	          "Please call our Reservations Team on 0870 9019 401 who will be happy to check availability.")
if (dd < 10)
	   {
	    dd = "0" + dd;
	   }
if (mm < 10)
	   {
	    mm = "0" + mm;
	   }	
if (intparty >8)
  {alert ("Er zijn max. 8 personen toegestaan. Verander uw selectiecriteria.");
   return false;
  }
if (document.basic2.region.value == 0)
  {alert("Kies een land/streek.");
  return false;
	}
else
	{
	if ((tyy == yy)&&(tmm < mm))
	   {alert ("Vul een geldige aankomstdatum in (aankomst mogelijk tussen 08/04 en 28/10)");
		return false;	   
	    }
  	else
	if ((tyy == yy)&&(tmm == mm)&&(tdd <= dd))
	   {alert ("Vul een geldige aankomstdatum in (aankomst mogelijk tussen 08/04 en 28/10)");
		return false;
		} 
	 else
	 if ((tyy == yy)&&(tmm >10))
		{
	   alert("Vul een geldige aankomstdatum in (aankomst mogelijk tot 28/10");
       return false;
		}
	else
	if (dzdiff <= 7)
	   {alert (dzmess);
	   return false;
	   }
	else{
	/*document.basic2.arrivalDate.value = document.basic2.ResortDate.value.substr(0, 2)
    document.basic2.arrivalMonth.value = document.basic2.ResortDate.value.substr(3, 2)
	document.basic2.arrivalYear.value = document.basic2.ResortDate.value.substr(6, 4)*/
	document.forms.basic2.submit();
	return true;
		}
	}
}


function SwapAdvance()
{  
// Hide the code in first div tag
document.getElementById('quicksearch').style.display ='none';
document.getElementById('advsearch').style.display ='block';
/*document.QuickSearchAccomm.traveloption[0].checked = false; //flight
document.QuickSearchAccomm.traveloption[1].checked = true; //accom

}
function divSwapFlt()
{  
// Hide the code in first div tag
document.getElementById('flightaccom').style.display ='block';
document.getElementById('accomonly').style.display ='none';
document.basic2.traveloption[0].checked = true; //flight
document.basic2.traveloption[1].checked = false; //accom
}*/
}
function popurl(url, w, h)
{
	if (w==0)
	{
	  w = 800; //default width
	}
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width='+ w + ',height=' + h +'');
	self.name = "mainWin";
	sealWin.focus()
}

function popurl2(url, w, h)
{
	if (w==0)
	{
	  w = 800; //default width
	}
	sealWin=window.open(url,"win",'scrollbars=1,resizable=1,width='+ w + ',height=' + h +'');
	self.name = "mainWin";
	sealWin.focus()
}

function SetAccom()
{
var intpets = 	(parseInt(document.basic.pets.value))
if (intpets > 0)
	{alert("In een stacaravan zijn honden niet toegestaan. Verander uw selectiecriteria.");
	}
}

function SetAccomT()
{
var intparty = 	(parseInt(document.basic.adults.value) + parseInt(document.basic.children.value) + parseInt(document.basic.infants.value));
if (intparty > 6)
	{alert("In een bungalowtent zijn max. 6 personen toegestaan. Verander uw selectiecriteria.");
	}
}

function setTravelOptionA()
{
document.basic.traveloption.value= "A";
//alert(document.basic.traveloption.value);
}

function setTravelOptionS()
{
document.basic.traveloption.value = "S";
//alert(document.basic.traveloption.value);
}

function setHolidayType(holidayType)
{
if (holidayType=='ap') 
	{
		document.basic.holidayType.value = 'ap';
		resetRegions('ap');
		resetMonths('ap');
	}
	else
	{
		document.basic.holidayType.value = 'camp';
		resetRegions('camp');
		resetMonths('camp');
	}

return; 
}


function resetRegions(product) {
var sel = document.basic.region;
	while (sel.firstChild) {
		sel.removeChild(sel.firstChild);
			}
	if (product=='ap') 
		{
				var regionList = [['04','France - Brittany'],['07','France - Gascony'],['08','France - Languedoc Roussillon'],['01','France - Picardy and Normandy'],['09','France - Riviera'],['06','France - Vendee'],['20','Italy - Lake Garda'],['13','Spain - Costa Brava and Dorada']];

			}
		else
			{
				var regionList = [['21','France - Alps'],['19','France - Ardeche'],['04','France - Brittany North'],['06','France - Brittany South'],['05','France - Brittany West'],['18','France - Burgundy'],['12','France - Dordogne'],['10','France - Gascony'],['09','France - Gironde'],['20','France - Jura and Vosges'],['13','France - Languedoc and Roussillon'],['11','France - Loire'],['03','France - Normandy'],['02','France - Paris'],['01','France - Picardy'],['16','France - Provence'],['17','France - Pyrenees'],['14','France - Riviera'],['07','France - Vendee North'],['08','France - Vendee South'],['15','France/Italy - Mediterranean Islands'],['25','Italy - Italian Lakes'],['24','Italy - Tuscany'],['26','Italy - Venetian Coast (Adriatic) and Croatia','S'],['23','Spain - Costa Brava'],['22','Spain - Costa Verde'],['38','Spain - Costa Del Sol'],['37','Portugal'],['27','Germany'],['29','Holland'],['28','Austria and Switzerland'],['36','Slovenia']];

			}
	var optG;
	var opt;
	for (var i=0; i < regionList.length; i++)
		{
			if(regionList[i][0]=='G')
				{
					optG = document.createElement("optgroup");
					optG.label = regionList[i][1];
					sel.appendChild(optG);
				}
				else
				{
					opt = document.createElement("option");
					opt.value = regionList[i][0];
					opt.text = regionList[i][1];
					
					sel.options[i] = opt;
					
				}
		}
		if (product=='ap') 
				{
				sel.options[4].selected = true;
				}
			else
				{
				sel.options[22].selected = true;
				}

}

function resetMonths(product) {
var sel = document.basic.arrivalMonth;
	while (sel.firstChild) {
		sel.removeChild(sel.firstChild);
			}
	if (product=='ap') 
		{
				var dateList = [['01','Jan'],['02','Feb'],['03','Mar'],['04','Apr'],['05','May'],['06','Jun'],['07','Jul'],['08','Aug'],['09','Sep'],['10','Oct'],['11','Nov'],['12','Dec']];

			}
		else
			{
				var dateList = [['03','Mar'],['04','Apr'],['05','May'],['06','Jun'],['07','Jul'],['08','Aug'],['09','Sep'],['10','Oct']];

			}
	var optG;
	var opt;
	for (var i=0; i < dateList.length; i++)
		{
			if(dateList[i][0]=='G')
				{
					optG = document.createElement("optgroup");
					optG.label = dateList[i][1];
					sel.appendChild(optG);
				}
				else
				{
					opt = document.createElement("option");
					opt.value = dateList[i][0];
					opt.text = dateList[i][1];
					
					sel.options[i] = opt;
					
				}
		}
	if (product=='ap') 	
      {
	  sel.options[06].selected = true;
	  }
	 else
	 {
	 sel.options[06].selected = true;
	 } 
}


function weatherAlert(){

	msg	=		'Please note:\n';
	msg	+=	'Due to severe weather our call centre is currently closed.\n';
	msg	+=	'Please book via the website or alternatively call tomorrow morning.\n'
	msg	+=	'We apologise for any inconvenience.\n'

	alert(msg);

}