<!--

// support for all collection
var allSupport = document.all!=null;
function setupEventObjects(e)
{
    // Map NS event object to IE
    if(e==null) return; // IE
    window.event = e;
    window.event.fromElement = e.target;
    window.event.toElement = e.target;
    window.event.srcElement = e.target;
    window.event.x = e.x;
    window.event.y = e.y;
    // route the event to original element
    window.event.srcElement.handleEvent(e);
}
function checkName(src)
{
    while((src!=null) && (src._tip==null))
            src = src.parentElement;
    return src;
}
function getElement(elName)
{
    if(allSupport)
            return document.all[elName]
    else
            return document.layers[elName]
}
function writeContents(el,tip)
{
    if(allSupport)
            el.innerHTML = tip
    else
    {
            // NS work around
            el.document.open();
            el.document.write("<TABLE CELLSPACING=0 CELLPADDING=2 WIDTH=120 BORDER=1 bordercolor=#000000><TR><TD width=100% bgcolor=#ffff99 align=center><FONT face='Verdana, arial, Helvetica, sans-serif' point-size=7pt>");
            el.document.write(tip);
            el.document.write("</FONT></TD></TR></TABLE>");
            el.document.close();
    }
}
function getOffset(el,which)
{
    // function for IE to get position of element
    var amount = el["offset"+which];
    if(which=="Top")
            amount+=el.offsetHeight;
    el=el.offsetParent;
    while(el!=null)
    {
            amount+=el["offset"+which];
            el=el.offsetParent;
    }
    return amount;
}
function setPosition(el)
{
    src=window.event.srcElement;
    if(allSupport)
    {
            el.style.pixelTop = window.event.y + 20;
            el.style.pixelLeft = window.event.x;
    }
    else
    {
            el.top = window.event.y + 20;
            el.left = window.event.x;
    }
}
function setVisibility(el,bDisplay)
{
    if(bDisplay)
            if(allSupport)
                    el.style.visibility = "visible";
            else
                    el.visibility = "show";
    else
            if(allSupport)
                    el.style.visibility = "hidden";
            else
                    el.visibility = "hidden";
}
function displayContents(tip)
{
    var el = getElement("tipbox");
    writeContents(el,tip);
    setPosition(el);
    setVisibility(el, true);
}
function doMouseOver(e)
{
    setupEventObjects(e);
    var el,tip;
    if((el = checkName(window.event.srcElement))!=null)
            if(!el.display)
            {
                    displayContents(el._tip);
                    el._display = true;
            }
}
function doMouseOut(e)
{
    setupEventObjects(e);
    var el,tip;     
    if((el = checkName(window.event.srcElement))!=null)
    {
            if(el._display)
            {
                    if((el.contains==null) || (!el.contains(window.event.toElement)))
                    {
                            setVisibility(getElement("tipbox"),false);
                            el._display = false;
                    }
                    else
                    {
                            setVisibility(getElement("tipbox"),false);
                            el._display = false;
                    }
            }
    }
    
}
function doLoad()
{
    // set everything up
    if((window.document.captureEvents==null) && (!allSupport)) return; // not version 4 browser
    
    if(window.document.captureEvents!=null) // NS
            window.document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
    window.document.onmouseover = doMouseOver;
    window.document.onmouseout = doMouseOut;
}
window.onload = doLoad;
function submitForm() {
    var list1 = document.formRegion.selectRegion1;
    var listtext1 = list1.options[list1.selectedIndex].text;
    if (listtext1 == '<None Selected>') {
      window.alert("A Region Must Be Selected.");
    }
    else {
      javascript:document.formRegion.submit();
    }
}
function selectOption (pvalue) {
  if (!isNaN(pvalue)) {
    var tempvalue = "" + pvalue;
    var list1 = document.formRegion.selectRegion1;
    var iVal = 0;
    var i = 0;
    do {
      if (list1.options[i].value == tempvalue) {
        iVal = i;
      }
      i++;
    } while (iVal == 0)
    var listtext1 = list1.options[list1.selectedIndex].value;
    if (listtext1 == tempvalue) {
      window.alert("This Region has already been selected.");
    }
    else if (listtext1 == '0') {
      list1.options[iVal].selected = true;
    }
    else {
      if (listtext1 == '0') {
        list1.options[iVal].selected = true;
      }
      else {
        if (listtext1 == '0') {
          list1.options[iVal].selected = true;
        }
        else {
          window.alert("A Region has already been selected. Please clear and change your selection");
      }
      }
    }
  }
}
function clearSelect (selectNum){
  eval ("document.formRegion.selectRegion" + selectNum + ".options[0].selected=true;");
}
function CheckRegion (selectNum){
  var SelectedRegion, Counter;
  var list1 = document.formRegion.selectRegion1;
  var list2 = document.formRegion.selectRegion2;
  var list3 = document.formRegion.selectRegion3;
  if (selectNum == "1") {
    if (list1.options[list1.selectedIndex].value == '0') {
      return;
    }
    if (list1.options[list1.selectedIndex].value == list2.options[list2.selectedIndex].value || list1.options[list1.selectedIndex].value == list3.options[list3.selectedIndex].value) {
      window.alert("This Region has already been selected.");
      clearSelect(selectNum);
    }
  }
  else if (selectNum == "2") {
    if (list2.options[list2.selectedIndex].value == '0') {
      return;
    }
    if (list2.options[list2.selectedIndex].value == list1.options[list1.selectedIndex].value || list2.options[list2.selectedIndex].value == list3.options[list3.selectedIndex].value) {
      window.alert("This Region has already been selected.");
      clearSelect(selectNum);
    }
  }
  else {
    if (list3.options[list3.selectedIndex].value == '0') {
      return;
    }
    if (list3.options[list3.selectedIndex].value == list1.options[list1.selectedIndex].value || list3.options[list3.selectedIndex].value == list2.options[list2.selectedIndex].value) {
      window.alert("This Region has already been selected.");
      clearSelect(selectNum);
    }
  }
}
function validate_form ( )
{
    valid = true;
     errorStr = "";
    if ( document.vehicle.yrpostcode.value == "" )
    {
        //alert ( "Please fill in the 'Postcode' box." );
          errorStr = errorStr + "Please enter a postcode.\n";
        valid = false;
    }
   
if ( document.vehicle.yrdistance.selectedIndex == 0 )
    {
        //alert ( "Please select your Distance." );
          errorStr = errorStr + "\nPlease select a Distance.";
        valid = false;
    }
     if(!valid)
     {
     alert(errorStr);
     }
 return valid;
}
//-->