// macromedia functions
// MM_preloadImages,  MM_swapImgRestore, MM_findObj, MM_swapImage
function MM_preloadImages() { //v3.0
  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];}}
}

function MM_swapImgRestore() { //v3.0
  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) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  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];}
}

function doSubmit(form,selector) {
  if (selector == 1) {
    form.lucky.value = 'lucky'
    form.crs_search.value = ''
  }
  else if (selector == 2) {
    form.lucky.value = ''
    form.crs_search.value = 'search'
  }
  form.submit();
}

function checkEnter(form) {
  if (event.keyCode == 13) {
    form.lucky.value = ''
    form.crs_search.value = 'search'
    form.submit();
  }
}
//-- start postcode -->
function getAddress() {
    msgWindow=open('obj_pls_get_address?pm_11='+regForm.pm_11.value,'win','resizable=no,width=600,height=200');
    if (msgWindow.opener == null) msgWindow.opener = self;
}

function validatePostCode(pv_postcode){ //check postcode format is valid
 test = pv_postcode.value;
 size = test.length
 test = test.toUpperCase(); //Change to uppercase

 validPostCodeChars = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
 s = stripCharsInBag(test,validPostCodeChars);

 if (s != "")
 {
  alert("Please enter a valid Postcode, plus space e.g.W6 0QU.");
  pv_postcode.focus();
  return false;
  }

 while (test.slice(0,1) == " ") //Strip leading spaces
  {test = test.substr(1,size-1);size = test.length
  }
 while(test.slice(size-1,size)== " ") //Strip trailing spaces
  {test = test.substr(0,size-1);size = test.length
  }
 if (size < 6 || size > 8){ //Code length rule
  alert("Please enter a valid Postcode, plus space e.g.W6 0QU.");
  pv_postcode.focus();
  return false;
  }
 if (!(isNaN(test.charAt(0)))){ //leftmost character must be alpha character rule
  alert("Please enter a valid Postcode, plus space e.g.W6 0QU.");
  pv_postcode.focus();
   return false;
  }
 if (isNaN(test.charAt(size-3))){ //first character of inward code must be numeric rule
  alert("Please enter a valid Postcode, plus space e.g.W6 0QU.");
  pv_postcode.focus();
   return false;
  }
 if (!(isNaN(test.charAt(size-2)))){ //second character of inward code must be alpha rule
  alert("Please enter a valid Postcode, plus space e.g.W6 0QU.");
   pv_postcode.focus();
   return false;
  }
 if (!(isNaN(test.charAt(size-1)))){ //third character of inward code must be alpha rule
  alert("Please enter a valid Postcode, plus space e.g.W6 0QU.");
   pv_postcode.focus();
   return false;
  }
 if (!(test.charAt(size-4) == " ")){//space in position length-3 rule
  alert("Please enter a valid Postcode, plus space e.g.W6 0QU.");
   pv_postcode.focus();
   return false;
   }
 count1 = test.indexOf(" ");count2 = test.lastIndexOf(" ");
 if (count1 != count2){//only one space rule
  alert("Please enter a valid Postcode, plus space e.g.W6 0QU.");
   pv_postcode.focus();
   return false;
  }
return true;
}


//-- country -->

function ShowTB(obj,id){
 txt=obj.options[obj.selectedIndex].text;
 if (txt.match('United Kingdom')){
  document.getElementById(id).disable= false;
 }
 else {
  document.getElementById(id).disabled = true;
 }
}

//-- start date script -->
	dayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
	monName = new Array ("January","February","March","April","May","June","July","August","September","October","November","December")

	now = new Date
// end date script -->

// open clearing popup when degree searches used
function openClearing() {
	window.open('http://www.hotcourses.com/clearing/clearing_popup.html','','scrollbars=no,height=130,width=180,left=200,top=300')
}
// end clearing popup -->

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

<!-- // login password input changes to stars

function showBranch(more){
	var objBranch = document.getElementById(more).style;
	if(objBranch.display=="block")
		objBranch.display="block";
	else
		objBranch.display="block";
}
function hideBranch(more){
	var objBranch = document.getElementById(more).style;
	if(objBranch.display=="block")
		objBranch.display="none";
	else
		objBranch.display="none";
}

// end password -->

function radio_button_checker(tempobj)
{
// set var radio_choice to false
var radio_choice = false;
// Loop from zero to the one minus the number of radio button selections
for (counter = 0; counter < tempobj.length; counter++)
{
// If a radio button has been selected it will return true
// (If not it will return false)
if (tempobj[counter].checked)
radio_choice = true; 
}

if (!radio_choice)
{
// If there were no selections made display an alert box 
//alert("Please select an option.")
return (false);
}
return (true);
}

<!-- Begin
function checkrequired(which) {
var pass=true;
if (document.images) {
  for (i=0;i<which.length;i++) { 
    var tempobj=which.elements[i];
    if (tempobj.name.substring(0,8)=="required") {
      if (((tempobj.type=="text"||tempobj.type=="textarea") && tempobj.value=='')
         ||(tempobj.type.toString().charAt(0)=="s" && tempobj.selectedIndex==0)
         ||(tempobj.type=="radio" && !radio_button_checker(which[which[i].name]))) {
          pass=false;
          break;
        }
      }
   }
}
if (!pass) {
shortFieldName=tempobj.name.substring(8,30).toUpperCase();
alert("Please make sure you have answered all the questions.");
return false;
}
else
return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function countOccurances(str, chr){
   var count = 0;
   for (i = 0;  i < str.length;  i++)
   {
      if (chr == str.charAt(i)) count++;
   }
   return count;
}

function isEmailAddressValid(str)
{
  var c, count, domain;
  validEmailChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_@.-`";
     s = stripCharsInBag(str,validEmailChars);

     if (s != "") {
     alert ("Your email address can only include numbers, letters, or _, @, ., ` and -");
     return (false); //email can only include numbers, letters, or _, @, .,` and  -.
     }

     if (str.length < 5) {
     alert ("Your email address needs to be at least 5 characters long");
     return (false); //email has to be at least 5 characters long
     }

     if (countOccurances(str, "@") == 0 || countOccurances(str, "@") > 1) {
     alert ("Your email address can have 1 and only 1 @");
     return (false); //email can have 1 and only 1 @.
     }

     if (countOccurances(str, ".") == 0) {
     alert ("Your email address needs to have at least one dot");
     return (false); //email has to have at least one dot.
     }

     if (((str.length - str.lastIndexOf(".")) > 7) || ((str.length - str.lastIndexOf(".")) < 3)) {
     alert ("Your email address has an incorrect number of characters after the last dot");
     return (false); //After the last dot, there cannot be more than 6 or less than 2 characters
     }

     if (str.charAt(str.indexOf("@") + 1) == "_") {
     alert ("Your email address cannot have an underscore right after the @");
     return (false); //Cannot have an underscore right after the @.
     }

     if (str.charAt(str.indexOf("@") + 1) == ".") {
     alert ("Your email address cannot have a dot right after the @");
     return (false); //Cannot have a dot right after the @.
     }

     return (true);
}
 //  End -->
