function MM_preloadImages() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

MM_preloadImages('/ct/images/icon_sendtofriend_on.gif',     
'/ct/images/icon_printpage_on.gif','/ct/images/icon_reserveaplace_on.gif',
'/ct/images/icon_latestnews_on.gif','/ct/images/box_8to17_on.jpg',
'/ct/images/box_youngadults_on.jpg','/ct/images/box_adults_on.jpg',
'/ct/images/box_teachers_on.jpg','/ct/images/box_business_on.jpg',
'/ct/images/arrow_on.gif','/ct/images/button_817_on.gif',
'/ct/images/button_youngadults_on.gif','/ct/images/button_adults_on.gif',
'/ct/images/button_teachers_on.gif','/ct/images/button_business_on.gif',
'/ct/images/mainarrow_on.gif','/ct/images/login_ov.gif',
'/ct/images/sendemail_on.gif','/ct/images/submit_ov.gif',
'/ct/images/reset_ov.gif','/ct/images/next_on.gif','images/click_here_on.gif'

);

function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { 
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//Detect browser and show css accordingly
if((navigator.appName == "Netscape")&& (parseInt(navigator.appVersion) < 5))
	{
		document.write('<link rel="stylesheet" href="/ct/ns.css" type="text/css">'); 
	}
	else
	{
		document.write('<link rel="stylesheet" href="/ct/ie.css" type="text/css">'); 
	}
	
//Function to show tree
function showBranch(branch){
	var objBranch = document.getElementById(branch).style;
	if(objBranch.display=="block")
		objBranch.display="none";
	else
		objBranch.display="block";
}

function formvalidation(frmInput)
{
if(document.frmInput.cboCourse.value==""){alert("You have not selected a course.Please try again");document.frmInput.cboCourse.focus();return false}
}

function form_date(frmInput)
{
if(document.frmInput.cboCourseId.value==""){alert("You have not selected a course arrival date.Please try again");document.frmInput.cboCourseId.focus();return false}
}

function form_accom(frmInput)
{
if(document.frmInput.cboAccom.value==""){alert("You have not selected an accommodation option.Please try again");document.frmInput.cboAccom.focus();return false}
}

function form_misc(frmInput)
{
//if(document.frmInput.cboAirport.value==""){alert("You have not selected an airport transfer option or an insurance option.Please try again");document.frmInput.cboAirport.focus();return false}
if((document.frmInput.radInsOptions[0].checked!=true) && (document.frmInput.radInsOptions[1].checked!=true)){alert("You have not selected an insurance option.Please try again");return false}
}

function form_personal(frmInput)
{
if(Trim(document.frmInput.FamilyName.value)==""){alert("Family Name cannot be blank");document.frmInput.FamilyName.focus();return false}
if(Trim(document.frmInput.FirstName.value)==""){alert("First Name cannot be blank");document.frmInput.FirstName.focus();return false}
if(Trim(document.frmInput.Nationality.value)==""){alert("Nationality cannot be blank");document.frmInput.Nationality.focus();return false}
if(Trim(document.frmInput.MotherTongue.value)==""){alert("MotherTongue cannot be blank");document.frmInput.MotherTongue.focus();return false}

if(Trim(document.frmInput.Address1.value)==""){alert("Address - Line 1 cannot be blank");document.frmInput.Address1.focus();return false}
if(Trim(document.frmInput.Town.value)==""){alert("Town cannot be blank");document.frmInput.Town.focus();return false}
if(Trim(document.frmInput.Postcode.value)==""){alert("Postcode cannot be blank");document.frmInput.Postcode.focus();return false}
if(Trim(document.frmInput.Country.value)==""){alert("Country cannot be blank");document.frmInput.Country.focus();return false}
if(Trim(document.frmInput.txtcountryCode.value)==""){alert("Country Code of telephone cannot be blank");document.frmInput.txtcountryCode.focus();return false}
if(Trim(document.frmInput.txtareaCode.value)==""){alert("Area Code of telephone cannot be blank");document.frmInput.txtareaCode.focus();return false}
if(Trim(document.frmInput.txtphNumber.value)==""){alert("Telephone numebr cannot be blank");document.frmInput.txtphNumber.focus();return false}

}

function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function

function form_emergency(frmInput)
{
if(Trim(document.frmInput.FamilyName.value)==""){alert("Family Name cannot be blank");document.frmInput.FamilyName.focus();return false}
if(Trim(document.frmInput.FirstName.value)==""){alert("First Name cannot be blank");document.frmInput.FirstName.focus();return false}
if(Trim(document.frmInput.Relation.value)==""){alert("Relation with student cannot be blank");document.frmInput.Relation.focus();return false}
if(Trim(document.frmInput.txtcountryCode.value)==""){alert("Country Code of home telephone cannot be blank");document.frmInput.txtcountryCode.focus();return false}
if(Trim(document.frmInput.txtareaCode.value)==""){alert("Area Code of home telephone cannot be blank");document.frmInput.txtareaCode.focus();return false}
if(Trim(document.frmInput.txtphNumber.value)==""){alert("Home telephone numebr cannot be blank");document.frmInput.txtphNumber.focus();return false}
if(Trim(document.frmInput.txtcountryCodeW.value)==""){alert("Country Code of work telephone cannot be blank");document.frmInput.txtcountryCodeW.focus();return false}
if(Trim(document.frmInput.txtareaCodeW.value)==""){alert("Area Code of work telephone cannot be blank");document.frmInput.txtareaCodeW.focus();return false}
if(Trim(document.frmInput.txtphNumberW.value)==""){alert("Work telephone numebr cannot be blank");document.frmInput.txtphNumberW.focus();return false}
if(Trim(document.frmInput.txtcountryCodeM.value)==""){alert("Country Code of mobile cannot be blank");document.frmInput.txtcountryCodeM.focus();return false}
if(Trim(document.frmInput.txtareaCodeM.value)==""){alert("Area Code mobile cannot be blank");document.frmInput.txtareaCodeM.focus();return false}
if(Trim(document.frmInput.txtphNumberM.value)==""){alert("Mobile numebr cannot be blank");document.frmInput.txtphNumberM.focus();return false}

}


function form_funding(frmInput)
{
if(document.frmInput.Funding.value==""){alert("Please select from the list of funding options");document.frmInput.Funding.focus();return false}
}


function form_source(frmInput)
{

/* if(document.frmInput.Source.value==""){alert("Please select from the list of sources");document.frmInput.Source.focus();return false}
*/
	var strData;
	
	strData = document.frmInput.Source.value;
	strDataDetails=document.frmInput.SourceDetails.value;
	
	if (strData=="")
	{
	alert("Please select from the list of sources and fill further details.");
	return false;
	}
		
	if ( ( strData=="Family/Friend (Please give details)" || strData=="Agent (Please give details)" || strData=="Teacher" || strData=="Other (Please give details)" || strData == "" ) && ( strDataDetails == "" ) )
	{
		alert("Please select from the list of sources and fill further details.");
		return false;
	}else
	return true;


}



