function FindPosX(obj)
{
  var curleft = 0;
  if (obj.offsetParent) {
    while (obj.offsetParent) {
      curleft+=obj.offsetLeft
      obj=obj.offsetParent;
    }
  }	else if (obj.x) {
    curleft+=obj.x;
  }
  return curleft;
}

function FindPosY(obj)
{
  var curtop = 0;
  if (obj.offsetParent) {
    while (obj.offsetParent) {
      curtop+=obj.offsetTop
      obj = obj.offsetParent;
    }
  } else if (obj.y) {
    curtop += obj.y;
  }
  return curtop;
}  


var current_sub=0;
var current_subsub=0;
  
function ShowSubmenu(main_obj,submenu_id)
{
  if (current_sub != 0) {
    current_sub.style.visibility="hidden";
  }
  var submenu_obj=document.getElementById(submenu_id);  
  var main_obj=document.getElementById(main_obj);
  if (!submenu_obj) {
    current_sub = 0;
    return;
  }
  submenu_obj.style.left=(FindPosX(main_obj)+2)+'px'; 
  submenu_obj.style.top=(FindPosY(main_obj)+25)+'px'; 

  submenu_obj.style.visibility="visible";
  current_sub = submenu_obj;

}


function ShowSubSubmenu(submenu_id,subsubmenu_id)
{
  if (current_subsub!=0) {
    current_subsub.style.visibility="hidden";
  }
  var subsubmenu_obj=document.getElementById(subsubmenu_id);
  var submenu_obj=document.getElementById(submenu_id);
  if (!subsubmenu_obj) {
    current_subsub=0;
    return;
  }
  subsubmenu_obj.style.left=(FindPosX(submenu_obj)+submenu_obj.offsetWidth+1)+'px';
  subsubmenu_obj.style.top=(FindPosY(submenu_obj))+'px';
  subsubmenu_obj.style.visibility="visible";
  current_subsub = subsubmenu_obj;
}

lastHighlightMenu=0;


function HighlightMenu(a_obj,td_id)
{
  a_obj.style.color='red';
}

function LowlightMenu(a_obj,td_id)
{
  a_obj.style.color='#042697';
}

 function HighlightSubmenu(a_obj,td_id)
{
  a_obj.style.color='#000000';
  a_obj.style.backgroundColor='#77AFE8';
  var td_obj = document.getElementById(td_id);
  td_obj.style.backgroundColor='#77AFE8';
}

function LowlightSubmenu(a_obj,td_id)
{
  a_obj.style.color='#ffffff';
  a_obj.style.backgroundColor='#4889D0';
  var td_obj = document.getElementById(td_id);
  td_obj.style.backgroundColor='#4889D0';
}

 function HighlightSubsubmenu(a_obj,td_id)
{
  a_obj.style.color='#ffffff';
  a_obj.style.backgroundColor='#77AFE8';
  var td_obj = document.getElementById(td_id);
  td_obj.style.backgroundColor='#77AFE8';
}

function LowlightSubsubmenu(a_obj,td_id)
{
  a_obj.style.color='#000000';
  a_obj.style.backgroundColor='#A7CFF8';
  var td_obj = document.getElementById(td_id);
  td_obj.style.backgroundColor='#A7CFF8';
}


function SetHeight()
{
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && (document.body.clientWidth ||document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }

  content_obj = document.getElementById('content');

  if (myHeight < 660) {
    content_obj.style.height = 550;
  } else {
    content_obj.style.height = myHeight-200;
  }
}

function ClearStatus()
{
  var __statusObj__=GetObject("status");
  __statusObj__.innerHTML="";
  __statusObj__.style.color="#000000";
}

function DisplayWarning(message)
{
  var __statusObj__=GetObject("status");
  __statusObj__.innerHTML=message;
  __statusObj__.style.color="#ff0000";
  setTimeout("ClearStatus();",5000);
}

function DisplayStatus(message)
{
  var __statusObj__=GetObject("status");
  __statusObj__.innerHTML=message;
  __statusObj__.style.color="#0000ff";
  setTimeout("ClearStatus();",5000);
}

function DisplayTitle(currentTitle)
{
  var __statusObj__=GetObject("status");
  __statusObj__.innerHTML=currentTitle;
  __statusObj__.style.color="#000000";
}

function ClearForm(formObj)
{
  formObj.fullName.value="";
  formObj.company.value="";
  formObj.emailAddress.value="";
  formObj.address1.value="";
  formObj.address2.value="";
  formObj.address3.value="";
  formObj.phoneNo.value="";
  formObj.faxNo.value="";
  formObj.whatSay.value="";

}


function VerifyFeedback(formObj,regex)
{
  StripFormData(formObj);
  
  if (formObj.fullName.value=="") {
    DisplayStatus("Please fill in your name");
    return false;
  }
  
  if (formObj.emailAddress.value=="") {
    DisplayStatus("Please fill in your email address");
    return false;
  }

  if ((formObj.emailAddress.value!="") && (!formObj.emailAddress.value.match(regex["__reEmailAddress__"]))) {
    DisplayStatus("The format of the email address is invalid");
    return false;
  }
 
 if (formObj.address1.value=="") {
    DisplayStatus("Please fill in your address");
    return false;
  }


  if (formObj.phoneNo.value=="") {
    DisplayStatus("Please fill in your phone number");
    return false;
  }

  if ((formObj.phoneNo.value!="") && (!formObj.phoneNo.value.match(regex["__rePhoneFax__"]))) {
    DisplayStatus("The format of the phone number is invalid");
    return false;
  }

  if (formObj.whatSay.value=="") {
    DisplayStatus("Please fill in what you would like to say");
    return false;
  }

  DisplayStatus("Your details are being processed. Please wait");
  formObj.submit();
}


function VerifyEmail(inputObj,formObj,regex)
{
  StripFormData(formObj);

  if (inputObj.value=="") {
   DisplayStatus("Please enter your email address before submitting the form");
    return false;
  }

  if (!inputObj.value.match(regex["__reEmailAddress__"])) {
    DisplayStatus("The format of the email address is invalid");
    return false;
  }

  DisplayStatus("Your request is being processed. Please wait");
  formObj.submit();
}

function VerifyLogin(formObj,regex)
{

  if (formObj.username.value=="") {
    DisplayStatus("Please enter your username before submitting your login credentials");
    return false;
  }


  if (formObj.password.value=="") {
    DisplayStatus("Please enter your password before submitting your login credentials");
    return false;
  }

  DisplayStatus("Your login credentials are being verified.");
  formObj.submit();
}


var current_image=0;
var timerID = null;
var timerRunning = false;

function stopTimer()
{
  if(timerRunning)
    clearInterval(timerID);
  timerRunning = false;
} 
  
function startTimer()
{
  // Make sure the timer is stopped
  stopTimer();
  timerID = setInterval("ChangeImage()",3000);
  timerRunning = true;
}

function VerifyUpdate(formObj,regex)
{
  StripFormData(formObj);

  if (formObj.title.value=="") {
    DisplayStatus("Please fill in your title");
    return false;
  }

  if (formObj.surname.value=="") {
    DisplayStatus("Please fill in your surname");
    return false;
  }

  if (formObj.forenames.value=="") {
    DisplayStatus("Please fill in your forename");
    return false;
  }

  if (formObj.known.value=="") {
    DisplayStatus("Please fill in you are known");
    return false;
  }

  if (formObj.year.value=="") {
    DisplayStatus("Please fill in your year of graduation");
    return false;
  }

  if (formObj.address.value=="") {
    DisplayStatus("Please fill in your address");
    return false;
  }

  if (formObj.phone.value=="") {
    DisplayStatus("Please fill in your phone number");
    return false;
  }

  if (formObj.email.value=="") {
    DisplayStatus("Please fill in your email");
    return false;
  }

  if ((formObj.email.value!="") && (!formObj.email.value.match(regex["__reEmailAddress__"]))) {
    DisplayStatus("The format of the email address is invalid");
    return false;
  }

  if (formObj.business.value=="") {
    DisplayStatus("Please fill in your business name and address");
    return false;
  }

  if (formObj.jobTitle.value=="") {
    DisplayStatus("Please fill in your job title");
    return false;
  }

  DisplayStatus("Your details are being sent to update. Please wait");
  formObj.submit();
}