var loaded = 0;
defaultText = (document.layers) ? 12 : 11;
IE5 = (navigator.userAgent.indexOf("MSIE 5") > 0) ? 1 : 0;

if (document.all && !IE5) {  //overload document.getElementById for IE4
  document.getElementById = function (name) {
    return document.all(name);
  }
}

function preLoad(imageFile) {
  eval(imageFile + "_on = new Image(); " + imageFile + "_on.src = 'mouseovers/" + imageFile + "_on.gif';");   
}

function imageOn(item) {
  if (loaded) {
    eval("document." + item + "I.src = " + item + "_on.src;");
  }
}

function imageOff(item) {
  eval("document." + item + "I.src = 'mouseovers/" + item + "_off.gif';");
}

function newWindow(url, name, width, height) {
  height += 30;
  photoWindow = window.open(url, name,"location=no,directories=no,menubar=no,statusbar=no,toolbar=no,scrollbars=yes,height=" +height+ ",width=" +width+ ",resizable=yes");
  photoWindow.resizeTo(width,height);
  photoWindow.focus();
  return false;
}

function printWindow(url, name, width, height) {
  photoWindow = window.open(url, name,"location=no,directories=no,menubar=yes,statusbar=no,toolbar=yes,scrollbars=yes,height=" +height+ ",width=" +width+ ",resizable=yes");
  photoWindow.resizeTo(width,height);
  photoWindow.focus();
  return false;
}

function textUp() {
  if (defaultText < 15) {
    defaultText += 1;
    setTextsize(defaultText);
    document.cookie = "textsize="+defaultText+";";
  }
  return false;
}

function textDown() {
  if (defaultText > 10) {
    defaultText -= 1;
    setTextsize(defaultText);
    document.cookie = "textsize="+defaultText+";";
  }
  return false;
}

function setTextsize(defaultText) {
  var agt = navigator.userAgent.toLowerCase();
  this.ie = (agt.indexOf("msie") != -1)
  
  if (this.ie) { // if IE only
    tags = new Array ('div', 'p', 'a', 'td');

    for (j = 0; j < tags.length; j++) {
      var tagElements = document.getElementsByTagName(tags[j]); 
      for (i = 0; i < tagElements.length; i++) {
        currentElement = tagElements[i];                
        currentElement.style.fontSize = defaultText+'px';
      }
    }
  }
}

function cgOption(frm, selected) {
  if (selected == 'TASONLINE') {
    window.open('http://www.tas.gov.au/', 'external');
    frm.cgaction.options.selectedIndex = 0;
  }
  return false;
}

function getResultsPage(frm, i) {
  frm.start.value = i;
  frm.submit();
  return false;
}

function checkPhone(frm) {
  phone = new String(frm.strPhone.value);
  var re_13no = /^13/;
  
  if (phone.length == 6 && phone.search(re_13no) == -1) {
    alert('You must enter the following fields correctly before proceeding:\n\nYour contact phone number must be 6 digits (and begin with "13"), 8 or 10 digits only');
    return false;
  }
  if (phone.length > 0 && phone.length != 6 && phone.length != 8 && phone.length != 10) {
    alert('You must enter the following fields correctly before proceeding:\n\nYour contact phone number must be 6 digits (and begin with "13"), 8 or 10 digits only');
    return false;
  }
  return true;
}

function checkPrivatephone(frm) {
  phone = new String(frm.strPrivatephone.value);
    
  if (phone.length > 0 && phone.length != 8 && phone.length != 10) {
    alert('You must enter the following fields correctly before proceeding:\n\nYour private phone number must be 8 or 10 digits only');
    return false;
  }
  return true;
}

function checkFax(frm) {
  fax = new String(frm.strFax.value);
  
  if (fax.length > 0 && fax.length != 8) {
    alert('You must enter the following fields correctly before proceeding:\n\nYour fax number must be 8 digits only');
    return false;
  }
  return true;
}

function checkMobile(frm) {
  fax = new String(frm.strMobile.value);
  
  if (fax.length > 0 && fax.length != 10) {
    alert('You must enter the following fields correctly before proceeding:\n\nYour mobile number must be 10 digits only');
    return false;
  }
  return true;
}