 function handleHttpResponse_image() {

  if (http.readyState == 4) {

    // Split the comma delimited response into an array


results = http.responseText;
document.getElementById('photo').innerHTML = results;
return false;
  }
if (http.readyState != 4) {
}
document.getElementById('photo').innerHTML = 'Fetching image....';
}

function toggle_image(picID) {
http.open("GET", '/photos/index.php?picID=' + escape(picID), true); 

  http.onreadystatechange = handleHttpResponse_image;

  http.send(null);
 
  return false;

 }
 function toggle_image2(picID) {
http.open("GET", '/photos2/index.php?picID=' + escape(picID), true); 

  http.onreadystatechange = handleHttpResponse_image;

  http.send(null);
 
  return false;

 }
  function handleHttpResponse_email() {

  if (http.readyState == 4) {

    // Split the comma delimited response into an array


results = http.responseText;
document.getElementById('email').value = results;
return false;
  }
if (http.readyState != 4) {
}
document.getElementById('email').innerHTML = 'Fetching email....';
}

function toggle_email(bookREF) {
var selector=document.getElementById('msg_type');
var myindex  = selector.selectedIndex;
var SelValue = selector.options[myindex].value;
var SelText = selector.options[myindex].text;

document.getElementById('email_title').value = "Student Village: "+SelText;
var mailID=SelValue;
http.open("GET", '/booking/mail-templates.php?mailID=' + escape(mailID)+'&bookREF='+ escape(bookREF), true); 

  http.onreadystatechange = handleHttpResponse_email;

  http.send(null);
 
  return false;

 }

function divswap(){

var selector=document.getElementById('RoomPref');
var myindex  = selector.selectedIndex;
var RoomPrefSelection= selector.options[myindex].value;
if (RoomPrefSelection=='ensuite2'){
document.getElementById('secondapplicant').style.display='block';
}else{
document.getElementById('secondapplicant').style.display='none';
}

} 


function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false;}
else {return true}
}
}

function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt);return false;}
else {return true;}
}
}


function validate_form(thisform)
{

with (thisform)
{
alert(document.lform.DateArrival.value.toTimeString());
if (validate_required(firstname,"Please enter your name")==false)
  {firstname.focus();return false;}
  
 if (validate_required(surname,"Please enter your surname")==false)
  {surname.focus();return false;}
  
  if (validate_required(DOB,"Please enter your date of birth")==false)
  {DOB.focus();return false;}
  
  if (validate_required(DateArrival,"Please enter your Arrival Date")==false)
  {DateArrival.focus();return false;}
  
  if (validate_required(DateDepart,"Please enter your Departure Date")==false)
  {DateDepart.focus();return false;}
  
  
	if (validate_email(email,"Not a valid e-mail address!")==false)
  {email.focus();return false;}


	if (!document.lform.terms.checked) {
	alert('You must agree to the terms & conditions');return false;
} 

if (!document.lform.rules.checked) {
alert('You must agree to the rules and regulations');return false;
} 

var selector=document.getElementById('RoomPref');
var myindex  = selector.selectedIndex;
var RoomPrefSelection= selector.options[myindex].value;
if (RoomPrefSelection=='ensuite2'){
if (!document.lform.x2terms.checked) {
alert('Applicant 2 must agree to the terms & conditions');return false;
} 
if (!document.lform.x2rules.checked) {
alert('Applicant 2 must agree to the rules and regulations');return false;
} 
}
}
}

 

 
 
 
 function getHTTPObject() {

  var xmlhttp;

  /*@cc_on

  @if (@_jscript_version >= 5)

    try {

      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

    } catch (e) {

      try {

        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

      } catch (E) {

        xmlhttp = false;

      }

    }

  @else

  xmlhttp = false;

  @end @*/

  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {

    try {

      xmlhttp = new XMLHttpRequest();

    } catch (e) {

      xmlhttp = false;

    }

  }

  return xmlhttp;

}

var http = getHTTPObject(); // We create the HTTP Object