function NoSpace()
{
	var CompanyID = document.form1.companyid.value.length;
	var I;
	var found = document.form1.companyid.value.indexOf(" ");
	if (found >= 0)
		{
		document.form1.companyid.focus();
		alert("You must not use any spaces there is one in position " + found);
		}
	if ( CompanyID <= 0)
		{
		document.form1.companyid.focus();
		alert("This field must not be blank");
		} 

}

function AddAgentCheck()
{
	if (document.form1.companyname.value == "")
		{
		document.form1.companyname.focus();
		alert("Company Name must be filled in");
		}
	return true;
}


function Capitalise(text, boxNumber)
{
var word;
var index;
var text;
var HoldChar
word = text.charAt(0);
word = word.toUpperCase();
for (index=1; index <= text.length; index++)
	{	
		if(text.charAt(index) == " "  && index < text.length )
		{
			word = word + text.charAt(index);
			index = index + 1;
			HoldChar = text.charAt(index);
			word = word + HoldChar.toUpperCase();	
		}
		else
		word = word + text.charAt(index); 
	}
	document.detail.elements[boxNumber].value =  word;
}

function TurnToUpper(text, boxNumber)
{
	var word;
	word = text.toUpperCase();
	document.detail.elements[boxNumber].value =  word;
}
function CreateDate()
{
	var FromDate;
	var TODate;
	var selectedMonth;
	var selectedDay
	var selectedYear
	selectedDay = document.Dates.fromday.selectedIndex;
	selectedMonth = document.Dates.frommonth.selectedIndex;
	selectedYear = document.Dates.fromyear.selectedIndex;
	FromDate = document.Dates.fromday.options[selectedDay].value + "/" +
		document.Dates.frommonth.options[selectedMonth].value + "/" +
		document.Dates.fromyear.options[selectedYear].value;
	selectedDay = document.Dates.today.selectedIndex;
	selectedMonth = document.Dates.tomonth.selectedIndex;
	selectedYear = document.Dates.toyear.selectedIndex;
	ToDate = document.Dates.today.options[selectedDay].value + "/" +
		document.Dates.tomonth.options[selectedMonth].value + "/" +
		document.Dates.toyear.options[selectedYear].value;
	document.location.href="dates.asp?Fromdate=" + FromDate + "&ToDate=" + ToDate ;
	return false;

}

function CheckSpace(Text)
{

	var found = Text.indexOf(" ");
	if (found > 0 )
	{
		alert("space found");
	}

}


function RemSpace(text, boxNumber)
{
	var word;
	var index;
	word = "";
	index = 0
	//for (index = 0; index <= text.length; index++)
	while (index <= text.length)
	{
		if (text.charAt(index) == " ")
		{
			while (text.charAt(index) == " " && index <= text.length ) 
			index = index + 1;
		}
		else
		{
		word = word + text.charAt(index); 
		index = index + 1;
		}
		
	}	
	document.detail.elements[boxNumber].value =  word;
	//return false;
}

function DetailCheck()
{
 var phone;
 var found;
 var FirstName;
 var SecondName;
 var ReturnType;
 var HouseNum;
 var Street;
 var Town;
 var County;
 var PostCode;
 var PassCode;
 var Paper;
 var Age;
 var Preferreddate;
 FirstName = document.detail.firstname;
 SecondName = document.detail.secondname;
 HouseNum = document.detail.number;
 Street = document.detail.street;
 Town = document.detail.town;
 County = document.detail.county;
 PostCode = document.detail.postcode;
 phone = document.detail.Mobilephone;
 PassCode = document.detail.passcode; 
 Paper = document.detail.paper;
 Age = document.detail.age;
 Preferreddate = document.detail.preferreddate;
 found = phone.value.indexOf(" ");
 if (found > 0 )
 {
	phone.focus();
	alert ("You must Not Included spaces in your mobile number");
	return false;
 }
 if(FirstName.value == "" )
 {
  	FirstName.focus();
	alert ("You must include your first name");
	return false;	
 }
 if(SecondName.value == "")
 {
 	SecondName.focus();
	alert ("You must include your surname");
	return false;
 }
 if(HouseNum.value == "")
 {
 	HouseNum.focus();
	alert ("You must include a house number");
	return false;
 }
 if(Street.value == "")
 {
 	Street.focus();
	alert ("You must include your street");
	return false;
 }
 if(Town.value == "")
 {
 	Town.focus();
	alert ("You must include your town");
	return false;
 }
 if(County.value == "")
 {
 	County.focus();
	alert ("You must include your county");
	return false;
 }				
	if(PostCode.value == "")
 {
 	PostCode.focus();
	alert ("You must include your post code");
	return false;
 }
  if(PassCode.value == "")
 {
 	PassCode.focus();
	alert ("You must enter a memorable word");
	return false;
 }	
  if(Paper.value == "")
 {
 	Paper.focus();
	alert ("You must enter Your Local Paper");
	return false;
 }
   if(Age.value == "")
 {
 	Age.focus();
	alert ("You must enter Your age group");
	return false;
 }
 if(Preferreddate.value == "")
 {
 	Preferreddate.focus();
	alert ("You must enter Your Preferred holiday date");
	return false;
 }			
}



function pickups(target)
{
	
		if (target != "")
	{
	  this.location.href =target;
	}

}

function tofromselect()
{

  document.form1.singledate.value = "";
  document.form1.alldates.checked = false;
}

function singleselect()
{

  document.form1.dateto.value = "";
  document.form1.datefrom.value = "";
  document.form1.alldates.checked = false;

}

function allselect()
{

  document.form1.dateto.value = "";
  document.form1.datefrom.value = "";
  document.form1.singledate.value = "";
}




function deselectall()
{
	var Index;
	for (Index=0; Index < document.form1.elements.length; Index++)
	{
		if (document.form1.elements[Index].type == "submit" || document.form1.elements[Index].type == "reset" )
		{
			Index=Index+1
		}
		else
		{
		document.form1.elements[Index].value = "";
		}	
	}
}


function openwindow(theURL,winName,features)
 { //v2.0
  window.open(theURL,winName,features);
 }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function IsLetters() 
{
	var Letter = document.Form1.LetCompanyID.value;
	var Test;
	if (Letter.length < 5)
		{
		alert("You Must Enter five Letters");
		Test="Fail";
		}
	if (isNaN(Letter) == false)
		{
		alert("You have entered numbers, this field should contain letters");
		Test="Fail";
		}
	if (Test=="Fail")
		{
		document.Form1.LetCompanyID.focus();
		}	

	return true;

}

function IsNumbers() 
{
	var Letter = document.Form1.NumCompanyID.value;
	var Test;
	if (Letter.length < 6)
		{
		alert("You Must Enter six numbers");
		Test="Fail";
		}
	if (isNaN(Letter) ==true)
		{
		alert("You have entered Letters, this field should contain Numbers");
		Test="Fail";
		}
	if (Test=="Fail")
		{
		document.Form1.LetCompanyID.focus();
		}	

	return true;
}

function Dates()  
{
  //var Date=document.Form1.Date.value;
	alert("Date");
return true;

}



