function SearchIsValid()
{
	//  Called from the homepage quick search and used in AdvancedSearch
	
	/*	logic checks: 
			Date is valid 
			Within campsite season 
			Party size does not exceed 8 */
	f = document.basic;
	var intNights = (parseInt(document.basic.nights.value))
	var theRegion = document.basic.region.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
	var yy 	= d.getYear();//This is the year
	var tyy = (f.arrivalYear.value);
	var tmm = (f.arrivalMonth.value);
	var tdd = (f.arrivalDate.value);
	var myRegion = (f.region.value);
	intparty = (parseInt(f.adults.value) + parseInt(f.children.value) + parseInt(f.infants.value));
	
	if (dd < 10) dd = "0" + dd;	
	if (mm < 10) mm = "0" + mm;
	if ((tyy == yy)&&(tmm < mm)){
		alert ("Please fill out a valid date");
		return false;
	}
	if ((tyy == yy)&&(tmm == mm)&&(tdd <= dd)){
		alert ("Please fill out a valid date");
		return false;
	} 
	if ((f.arrivalYear.value == 2008)&&(f.arrivalMonth.value == 10)&&(f.arrivalDate.value > 29)){
		alert("Sorry. Our campsite opening dates range from 09/02/2008 to 29/10/2008");
		return false;
	}
	if ((f.arrivalYear.value == 2008)&&(f.arrivalMonth.value == 10)&&(f.arrivalDate.value > 28)){
		alert("Sorry. Our campsite opening dates range from 09/02/2008 to 28/10/2008");
		return false;
	}	
	if ((f.arrivalYear.value == 2008)&&(f.arrivalMonth.value == 03)){
		alert("Sorry. Our campsite opening dates range from 09/02/2008 to 28/10/2008");
		return false;
	}
	if ((f.arrivalYear.value == 2008)&&(f.arrivalMonth.value == 04)&&(f.arrivalDate.value < 8))	{
		alert("Sorry. Our campsite opening dates range from 09/02/2008 to 28/10/2008");
		return false;
	}	
	if ((f.arrivalYear.value == 2008)&&(f.arrivalMonth.value == 02)&&(f.arrivalDate.value < "09"))	{
		alert("Sorry. Our campsite opening dates range from 09/02/2008 to 28/10/2008");
		return false;
	}	
	if ((f.arrivalYear.value == 2008)&&(f.arrivalMonth.value < 02))	{
		alert("Sorry. Our campsite opening dates range from 09/02/2008 to 28/10/2008");
		return false;
	}	
	if ((intNights <7)&&(theRegion==42))
  		{alert ("The minimum number of nights for holidays in Florida is 7");
   		return false;
 	}

	if (intparty > 8){
		alert("Sorry. The maximum party size is 8.");
		return false;
	}
	
	if (document.basic.region.value == 0){
		alert("Please enter a Region");
  	return false;
	}
	
	return true;
}
function submitSearchForm()
//{  
	//var tmm = (f.arrivalMonth.value);
	//var tdd = (f.arrivalDate.value);
	//var myRegion = (f.region.value);

 //  	if (((tmm == 2)||((tmm == 3)&&(tdd <31)))&&(myRegion != 38))
//		{
//			alert("The only region with availability before 31st March is Spain - Andalucia. Please amend your search region.");
	//	}
//else
{
// Hide the code in first div tag  
	document.basic.regionSelected.value = document.basic.region.options[document.basic.region.selectedIndex].text;
	document.basic.dateSelected.value = document.basic.arrivalDate.options[document.basic.arrivalDate.selectedIndex].text + '/' + document.basic.arrivalMonth.options[document.basic.arrivalMonth.selectedIndex].text + '/' + document.basic.arrivalYear.options[document.basic.arrivalYear.selectedIndex].text;
	document.basic.nightsSelected.value = document.basic.nights.options[document.basic.nights.selectedIndex].text;
	document.basic.adultsSelected.value = document.basic.adults.options[document.basic.adults.selectedIndex].text;
	document.basic.childrenSelected.value = document.basic.children.options[document.basic.children.selectedIndex].text;
	document.basic.infantsSelected.value = document.basic.infants.options[document.basic.infants.selectedIndex].text;
	
	document.getElementById('quicksearch').style.display = 'none';  
// Display code in second div tag  
    document.getElementById('searching').style.display = 'block'; 
	document.basic.submit();	

}
function setRegionName() {
	document.basic.regionName.value = document.basic.region.options[document.basic.region.selectedIndex].text;
}

function setActiveTab(tabID,theClass) { 

var currTabElem = document.getElementById(tabID); 

currTabElem.setAttribute("class", theClass); 
currTabElem.setAttribute("className", theClass); 

if (theClass=='hpap_bkg'||theClass=='mapap_bkg') 
	{
		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 = [['G','France'],['03','France - Brittany'],['09','France - Cote d Azur'],['07','France - Gascony'],['11','France - Jura and The Alps'],['08','France - Languedoc'],['02','France - Paris'],['01','France - Picardy and Normandy'],['06','France - Vendee'],['G','Italy'],['20','Italy - Lake Garda'],['24','Italy - Tuscany'],['G','Spain'],['13','Spain - Catalonia'],['G','Portugal'],['25','Portugal']];

			}
		else
			{
				var regionList = [['G','France'],['19','France - Auvergne, Cevennes & Ardeche'],['04','France - Brittany North'],['06','France - Brittany South'],['15','France - Burgundy'],['17','France - Cote d Azur','S'],['14','France - Dordogne'],['12','France - Gascony'],['16','France - Languedoc'],['13','France - Loire'],['03','France - Normandy'],['02','France - Paris'],['01','France - Picardy'],['10','France - Royan'],['07','France - Vendee North'],['08','France - Vendee South'],['20','France - Jura and The Alps'],['G','Italy'],['28','Italy - Adriatic'],['27','Italy - Lake Garda'],['26','Italy - Tuscany'],['35','Italy - Sardinia'],['G','Croatia'],['28','Croatia'],['G','Spain'],['24','Spain - Cantabria'],['25','Spain - Catalonia'],['38','Spain - Andalucia'],['G','Austria'],['31','Austria'],['G','Holland'],['34','Holland'],['G','Switzerland'],['30','Switzerland'],['G','Portugal'],['37','Portugal'],['G','Slovenia'],['36','Slovenia'],['G','USA'],['40','Florida']];

			}
	var optG;
	var opt;
	for (var i=0; i < regionList.length; i++)
		{
				if(regionList[i][0]!=='G') {
					document.basic.region.options[i-1] = new Option(regionList[i][1],regionList[i][0]);
				} else {
					optG = document.createElement("optgroup");
					optG.label = regionList[i][1];
					sel.appendChild(optG);
				}
				
		}
		if (product=='ap') 
				{
				sel.options[7].selected = true;
				}
			else
				{
				sel.options[4].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 = [['01','Jan'],['02','Feb'],['03','Mar'],['04','Apr'],['05','May'],['06','Jun'],['07','Jul'],['08','Aug'],['09','Sep'],['10','Oct'],['11','Nov'],['12','Dec']];

			}
	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[04].selected = true;
	 } 
	 
	while (document.basic.arrivalYear.firstChild) {
		document.basic.arrivalYear.removeChild(document.basic.arrivalYear.firstChild);
	}
	if(product=='ap') { // this is apartments
		document.basic.arrivalYear.options[0] = new Option(2008,2008);
	} else {
		document.basic.arrivalYear.options[0] = new Option(2008,2008);
		document.basic.arrivalYear.options[1] = new Option(2009,2009);
	}
}

function resetmonths(from,to,selected) {
	
}