function isDebug()
{
	return false;
}

function isDebugOn()
{
	if(isDebug())
	{
		return "1";	
	}
	else
	{
      return "0";
	}
}
function blockContextMenu()
{
   document.oncontextmenu=new Function("return isDebug()");
}

function blockCopyKey() 
{
   // current pressed key
   var pressedKey = String.fromCharCode(event.keyCode).toLowerCase();

   if (event.ctrlKey && (pressedKey == "c" || 
                        pressedKey == "v")) {
      // disable key press porcessing
      event.returnValue = isDebug();
   }

   if (122 == event.keyCode) {
      // disable key press porcessing
      event.keyCode = 0;
      event.returnValue = isDebug();
   }
}


function checkRequiredFields(roForm) {
  if (roForm.cFirstName.value == "") {
    alert("\nFirst name is required.\n\nPlease enter");
    roForm.cFirstName.focus();
    return (false);
  }
  if (roForm.cLastName.value == "") {
    alert("\nLast name is required.\n\nPlease enter");
    roForm.cLastName.focus();
    return (false);
  }
  if (roForm.cAddress1.value == "") {
    alert("\nThe address is required.\n\nPlease enter");
    roForm.cAddress1.focus();
    return (false);
  }
  if (roForm.cCity.value == "") {
    alert("\nThe suburb/town/province is required.\n\nPlease enter");
    roForm.cCity.focus();
    return (false);
  }
  if (roForm.cPostCode.value == "") {
    alert("\nThe postcode/zipcode is required.\n\nPlease enter");
    roForm.cPostCode.focus();
    return (false);
  }
  if (roForm.cState.value == "") {
    alert("\nThe state/county is required.\n\nPlease enter");
    roForm.cState.focus();
    return (false);
  }
  if (roForm.id271.value == "") {
    alert("\nThe Country is required.\n\nPlease enter");
    roForm.id271.focus();
    return (false);
  }
//  if (roForm.cPhone.value == "") {
//    alert("\nA telephone number is required.\n\nPlease enter");
//    roForm.cPhone.focus();
//    return (false);
//  }
  if (roForm.cEmail.value == "") {
    alert("\nThe e-mail address is required.\n\nPlease enter");
    roForm.cEmail.focus();
    return (false);
  }
  if (!checkEmailAddress(roForm)) {
    return (false);
  }
//  if (roForm.cQuestion1.value == "") {
//    alert("\nQuestion 1 is required.\n\nPlease enter");
//    roForm.cQuestion1.focus();
//    return (false);
//  }
//  if (roForm.cAnswer1.value == "") {
//    alert("\nAnswer 1 is required.\n\nPlease enter");
//    roForm.cAnswer1.focus();
//    return (false);
//  }
//  if (roForm.cQuestion1.value == "") {
//    alert("\nQuestion 2 is required.\n\nPlease enter");
//    roForm.cQuestion1.focus();
//    return (false);
//  }
//  if (roForm.cAnswer1.value == "") {
//    alert("\nAnswer 2 is required.\n\nPlease enter");
//    roForm.cAnswer1.focus();
//    return (false);
//  }

  return (true);
}

function checkEmailAddress(roForm)
{
  var lcEmail = roForm.cEmail.value;
  if (!emailCheck(lcEmail))  {
    roForm.cEmail.focus();
    return (false);
  }
  return (true);
}

function emailCheck (emailStr) {
  var emailPat=/^(.+)@(.+)$/
  var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
  var validChars="\[^\\s" + specialChars + "\]"
  var quotedUser="(\"[^\"]*\")"
  var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
  var atom=validChars + '+'
  var word="(" + atom + "|" + quotedUser + ")"
  var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
  var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
  var matchArray=emailStr.match(emailPat)
  if (matchArray==null) {
    alert("Email address seems incorrect (check @ and .'s)")
    return false
  }
  var user=matchArray[1]
  var domain=matchArray[2]
  if (user.match(userPat)==null) {
    alert("The username doesn't seem to be valid.")
    return false
  }
  var IPArray=domain.match(ipDomainPat)
  if (IPArray!=null) {
    for (var i=1;i<=4;i++) {
      if (IPArray[i]>255) {
        alert("Destination IP address is invalid!")
        return false
      }
    }
    return true
  }
  var domainArray=domain.match(domainPat)
  if (domainArray==null) {
    alert("The domain name doesn't seem to be valid.")
    return false
  }
  var atomPat=new RegExp(atom,"g")
  var domArr=domain.match(atomPat)
  var len=domArr.length
  if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>4) {
    alert("The address must end in a three or four letter domain, or two letter country.")
    return false
  }
  if (len<2) {
    var errStr="This address is missing a hostname!"
    alert(errStr)
    return false
  }
  return true;
}

function openWindow(url,w,h) {
  window.open(url, "",  "status=0,toolbar=0,scrollbars=1,directories=0,menu bar=0,resizable=1,width="+w+",height="+h+"")
}

function getFormMeet001(cCOMRootId)
{
   var id509=document.form_meet001.id509.value
   var id517=''
   var id518=document.form_meet001.id518.value
   var id519=document.form_meet001.id519.value
   var id521=document.form_meet001.id521.value

   window.location = cCOMRootId + '01?m=521_01&id517=' + id517 + '&id509=' + id509 + '&id518=' + id518 + '&id519=' + id519 + '&id521=' + id521;
   return (true);
}

function getFormMeet002(cCOMRootId)
{
   var id509=document.form_meet002.id509.value
   var id517=''
   var id521=document.form_meet002.id521.value
   if (id509 == '')
   {
     alert("\nI am sorry, you did not select a State.\n\nPlease enter");
     document.form_meet002.id509.focus();
     return (false);
   }
   window.location = cCOMRootId + '01?m=511_01&id517=' + id517 + '&id509=' + id509 + '&id521=' + id521;
   return (true);
}

function getFormMeet003(cCOMRootId)
{
   var id509=document.form_meet003.id509.value
   var id517=document.form_meet003.id517.value
   var id521=document.form_meet003.id521.value
   var idx02=document.form_meet003.idx02.value

   window.location = cCOMRootId + '01?m=511_01&id517=' + id517 + '&id509=' + id509 + '&id521=' + id521 + '&idx02=' + idx02;
   return (true);
}

function getFormTrip001(cCOMRootId)
{
   var id509=document.form_trip001.id509.value
   var id517=''
   var id518=document.form_trip001.id518.value
   var id519=document.form_trip001.id519.value
   var id521=document.form_trip001.id521.value

   window.location = cCOMRootId + '01?m=521_02&id517=' + id517 + '&id509=' + id509 + '&id518=' + id518 + '&id519=' + id519 + '&id521=' + id521;
   return (true);
}

function getFormTrip002(cCOMRootId)
{
   var id509=document.form_trip002.id509.value
   var id517=''
   var id521=document.form_trip002.id521.value
   if (id509 == '')
   {
     alert("\nI am sorry, you did not select a State.\n\nPlease enter");
     document.form_trip002.id509.focus();
     return (false);
   }
   window.location = cCOMRootId + '01?m=511_02&id517=' + id517 + '&id509=' + id509 + '&id521=' + id521;
   return (true);
}

function getFormTrip003(cCOMRootId)
{
   var id509=document.form_trip003.id509.value
   var id517=document.form_trip003.id517.value
   var id521=document.form_trip003.id521.value
   var idx02=document.form_trip003.idx02.value

   window.location = cCOMRootId + '01?m=511_02&id517=' + id517 + '&id509=' + id509 + '&id521=' + id521 + '&idx02=' + idx02;
   return (true);
}

function getFormSight001(cCOMRootId)
{
   var id509=document.form_sight001.id509.value
   var id510=''
   var id518=document.form_sight001.id518.value
   var id519=document.form_sight001.id519.value

   window.location = cCOMRootId + '04?m=008&id510=' + id510 + '&id509=' + id509 + '&id518=' + id518 + '&id519=' + id519;
   return (true);
}

function getFormSight002(cCOMRootId)
{
   var b008=document.form_sight002.b008.value

   window.location = cCOMRootId + '01?m=301_01&b008=' + b008;
   return (true);
}

function getFormSight003(cCOMRootId)
{
   var id509=document.form_sight003.id509.value
   var id510=document.form_sight003.id510.value
   var idx02=document.form_sight003.idx02.value

   window.location = cCOMRootId + '04?m=811&id510=' + id510 + '&id509=' + id509 + '&idx02=' + idx02;
   return (true);
}

function getFormSight005(cCOMRootId, roForm)
{
   var id509=roForm.id509.value
   var id505=roForm.id505.value
   if (id509 == '')
   {
     alert("\nI am sorry, you did not select a State.\n\nPlease enter");
     roForm.id509.focus();
     return (false);
   }
   window.location = cCOMRootId + '04?m=811&id505=' + id505 + '&id509=' + id509;
   return (true);
}

function getFormReserve001(cCOMRootId)
{
   var id509=document.form_reserve001.id509.value
   var id524=''

   window.location = cCOMRootId + '04?m=521&id524=' + id524 + '&id509=' + id509;
   return (true);
}

function getFormReserve002(cCOMRootId)
{
   var id509=document.form_reserve002.id509.value
   var id524=''
   if (id509 == '')
   {
     alert("\nI am sorry, you did not select a State.\n\nPlease enter");
     document.form_reserve002.id509.focus();
     return (false);
   }
   window.location = cCOMRootId + '04?m=511&id524=' + id524 + '&id509=' + id509;
   return (true);
}

function getFormReserve003(cCOMRootId)
{
   var id509=document.form_reserve003.id509.value
   var id524=document.form_reserve003.id524.value
   var idx02=document.form_reserve003.idx02.value

   window.location = cCOMRootId + '04?m=511&id524=' + id524 + '&id509=' + id509 + '&idx02=' + idx02;
   return (true);
}

function getFormReport001(cCOMRootId, cType)
{
   switch (cType)
   {
     case 0:
       var id515=0
       break;
     case 1:
       var id515=1
       break;
     default:
       var id515=1
   }
   var url = cCOMRootId + '05?m=001&id515=' + id515;
   window.open(url);
   return (true);
}

function getFormReport002(cCOMRootId, cType)
{
   switch (cType)
   {
     case 0:
       var id515=0
       break;
     case 1:
       var id515=1
       break;
     default:
       var id515=1
   }
   var url = cCOMRootId + '05?m=002&id515=' + id515;
   window.open(url);
   return (true);
}

function getFormReport003(cCOMRootId, cType)
{
   switch (cType)
   {
     case 0:
       var id509=document.form_report003_0.id509.value
       var id515=0
       break;
     case 1:
       var id509=''
       var id515=1
       break;
     default:
       var id509=''
       var id515=1
   }
   var url = cCOMRootId + '05?m=003&id515=' + id515 + '&id509=' + id509;
   window.open(url);
   return (true);
}

function getFormReport004(cCOMRootId, cType)
{
   switch (cType)
   {
     case 0:
       var id509=document.form_report004_0.id509.value
       var id516=document.form_report004_0.id516.value
       var id515=0
       break;
     case 1:
       var id509=document.form_report004_1.id509.value
       var id516=document.form_report004_1.id516.value
       var id515=1
       break;
     default:
       var id509=''
       var id516=1
       var id515=1
   }
   var url = cCOMRootId + '05?m=004&id515=' + id515 + '&id509=' + id509 + '&id516=' + id516;
   window.open(url);
   return (true);
}
function getFormReport005(cCOMRootId)
{
   var x004=document.form_report005.x004.value
   var url = cCOMRootId + '05?m=005&x004=' + x004;
   window.open(url); 
   return (true);
}

function getFormLink001(cCOMRootId)
{
   var id526=''

   window.location = cCOMRootId + '01?m=821&id526=' + id526;
   return (true);
}

function getFormLink002(cCOMRootId)
{
   var id526=''

   window.location = cCOMRootId + '01?m=811&id526=' + id526;
   return (true);
}

function getFormLink003(cCOMRootId)
{
   var id526=document.form_link003.id526.value
   var idx02=document.form_link003.idx02.value

   window.location = cCOMRootId + '01?m=811&id526=' + id526 + '&idx02=' + idx02;
   return (true);
}


function getFormGlossary001(cCOMRootId)
{
   var id533='*'

   window.location = cCOMRootId + '01?m=721&id533=' + id533;
   return (true);
}

function getFormGlossary002(cCOMRootId)
{
   var id533=''

   window.location = cCOMRootId + '01?m=711&id533=' + id533;
   return (true);
}

function getFormGlossary003(cCOMRootId)
{
   var id533=document.form_glossary003.id533.value
   var idx02=document.form_glossary003.idx02.value

   window.location = cCOMRootId + '01?m=711&id533=' + id533 + '&idx02=' + idx02;
   return (true);
}


function getName(cCOMRootId)
{
   var b008=document.form_search001.b008.value
   if (b008.length <= 0)
   {
     alert("\nI am sorry, you did not enter a Name.\n\nPlease enter");
     document.form_search001.b008.focus();
     return (false);
   }
   window.location = cCOMRootId + '02?m=001&b008=' + b008;
   return (true);
}
function getSciName(cCOMRootId)
{
   var b016=document.form_search002.b016.value
   if (b016.length <= 0)
   {
     alert("\nI am sorry, you did not enter a Scientific Name.\n\nPlease enter");
     document.form_search002.b016.focus();
     return (false);
   }
   window.location = cCOMRootId + '02?m=002&b016=' + b016;
   return (true);
}

function getFamily(cCOMRootId)
{
   var b006=document.form_search003.b006.value
   if (b006.length <= 0)
   {
     alert("\nI am sorry, you did not enter a Family.\n\nPlease enter");
     document.form_search003.b006.focus();
     return (false);
   }
   window.location = cCOMRootId + '02?m=003&b006=' + b006;
   return (true);
}

function getSciFamily(cCOMRootId)
{
   var b015=document.form_search004.b015.value
   if (b015.length <= 0)
   {
     alert("\nI am sorry, you did not enter a Scientific Family.\n\nPlease enter");
     document.form_search004.b015.focus();
     return (false);
   }
   window.location = cCOMRootId + '02?m=004&b015=' + b015;
   return (true);
}

function getNumber(cCOMRootId)
{
   var b009=document.form_search009.b009.value
   if (b009.length <= 0)
   {
     alert("\nI am sorry, you did not enter a Number.\n\nPlease enter");
     document.form_search009.b009.focus();
     return (false);
   }
   window.location = cCOMRootId + '02?m=010&b009=' + b009;
   return (true);
}

function getSize(cCOMRootId, cType)
{
   switch (cType)
   {
     case 1:
       var b035=document.form_search005.b035.value;
       var b036=document.form_search005.b036.value;
       break;
     case 2:
       var b035=document.form_search006.b035.value;
       var b036=-1;
       break;
     case 3:
       var b035=-1;
       var b036=document.form_search007.b035.value;
       break;
     default:
       var b035=0;
       var b036=0;
   }
   if (b035 == 0 && b036 == 0)
   {
     alert("\nI am sorry, you did not enter a Size.\n\nPlease enter");
     document.form_search005.b035.focus();
     return (false);
   }
   window.location = cCOMRootId + '02?m=005&b035=' + b035 + '&b036=' + b036;
   return (true);
}
function getState(cCOMRootId)
{
   var b018=document.form_search008.b018.value
//   if (b018.length <= 0)
//   {
//     alert("\nI am sorry, you did not enter a State.\n\nPlease enter");
//     document.form_search008.b018.focus();
//     return (false);
//   }
   window.location = cCOMRootId + '02?m=009&b018=' + b018;
   return (true);
}

function getSearchSize(cCOMRootId)
{
   var i051=document.form_search005c.i051.value;
   var i052=document.form_search005c.i052.value;
   if (i051 == 0 && i052 == 0)
   {
     alert("\nI am sorry, you did not enter a Size.\n\nPlease enter");
     document.form_search005c.i051.focus();
     return (false);
   }
   window.location = cCOMRootId + '02?m=005&i051=' + i051 + '&i052=' + i052;
   return (true);
}

function getSearchAll(cCOMRootId, roForm)
{
   var b035=roForm.b035.value;
   var b036=roForm.b036.value;

   var i001=roForm.i052.value;

alert('go')
   window.location = cCOMRootId + '02?m=005&b035=' + b035 + '&b036=' + b036;
   return (true);
}






function getFormItemMore001(cCOMRootId)
{
   var id505=document.form_itemmore001.id505.value
   var id528=document.form_itemmore001.id528.value
   var id527=''

   window.location = cCOMRootId + '03?m=521&id527=' + id527 + '&id528=' + id528 + '&id505=' + id505;
   return (true);
}

function getFormItemMore002(cCOMRootId)
{
   var id505=document.form_itemmore002.id505.value
   var id528=document.form_itemmore002.id528.value
   var id527=''
   if (id528 == '')
   {
     alert("\nI am sorry, you did not select a Type.\n\nPlease enter");
     document.form_itemmore002.id528.focus();
     return (false);
   }
   window.location = cCOMRootId + '03?m=511&id527=' + id527 + '&id528=' + id528 + '&id505=' + id505;
   return (true);
}

function getFormItemMore003(cCOMRootId)
{
   var id505=document.form_itemmore003.id505.value
   var id528=document.form_itemmore003.id528.value
   var id527=document.form_itemmore003.id527.value
   var idx02=document.form_itemmore003.idx02.value

   window.location = cCOMRootId + '03?m=511&id527=' + id527 + '&id528=' + id528 + '&idx02=' + idx02 + '&id505=' + id505;
   return (true);
}

function insertItemLink(cCOMRootId)
{
   var id900=document.form1.e016.value

   openWindow(cCOMRootId + '01?m=900&id900=' + id900, 400, 300)
   return (true);
}

function getFormResource001(cCOMRootId)
{
   var id536=document.form_resource001.id536.value
   var id535=''

   window.location = cCOMRootId + '01?m=621&id535=' + id535 + '&id536=' + id536;
   return (true);
}

function getFormResource002(cCOMRootId)
{
   var id535=''

   window.location = cCOMRootId + '01?m=611&id535=' + id535;
   return (true);
}

function getFormResource003(cCOMRootId)
{
   var id535=document.form_resource003.id535.value
   var idx02=document.form_resource003.idx02.value

   window.location = cCOMRootId + '01?m=611&id535=' + id535 + '&idx02=' + idx02;
   return (true);
}

function getFormHomeHTML001(cCOMRootId)
{
   var id518=document.form_homehtml001.id518.value
   var id519=document.form_homehtml001.id519.value

   window.location = cCOMRootId + '01?m=091&id518=' + id518 + '&id519=' + id519;
   return (true);
}

function getFormNewsItem001(cCOMRootId)
{
   var id518=document.form_newsitem001.id518.value
   var id519=document.form_newsitem001.id519.value

   window.location = cCOMRootId + '01?m=092&id518=' + id518 + '&id519=' + id519;
   return (true);
}

function getFormDownload001(cCOMRootId)
{
   var id540=''

   window.location = cCOMRootId + '01?m=861&id540=' + id540;
   return (true);
}

function getFormDownload002(cCOMRootId)
{
   var id540=''

   window.location = cCOMRootId + '01?m=851&id540=' + id540;
   return (true);
}

function getFormDownload003(cCOMRootId)
{
   var id540=document.form_download003.id540.value
   var idx02=document.form_download003.idx02.value

   window.location = cCOMRootId + '01?m=851&id540=' + id540 + '&idx02=' + idx02;
   return (true);
}


function getFormArticle001(cCOMRootId)
{
   var id539=''
   var id518=document.form_article001.id518.value
   var id519=document.form_article001.id519.value

   window.location = cCOMRootId + '03?m=043&id539=' + id539 + '&id518=' + id518 + '&id519=' + id519;
   return (true);
}

function getFormArticle002(cCOMRootId)
{

   window.location = cCOMRootId + '03?m=041';
   return (true);
}

function getFormArticle003(cCOMRootId)
{
   var id539=document.form_article003.id539.value
   var idx02=document.form_article003.idx02.value

   window.location = cCOMRootId + '03?m=044&id539=' + id539 + '&idx02=' + idx02;
   return (true);
}

function checkPWQuestionFields(roForm) {
  if (roForm.cQuestion1.value == "") {
    alert("\nQuestion 1 is required.\n\nPlease enter");
    roForm.cQuestion1.focus();
    return (false);
  }
  if (roForm.cAnswer1.value == "") {
    alert("\nAnswer to Question 1 is required.\n\nPlease enter");
    roForm.cAnswer1.focus();
    return (false);
  }
  if (roForm.cQuestion2.value == "") {
    alert("\nQuestion 2 is required.\n\nPlease enter");
    roForm.cQuestion2.focus();
    return (false);
  }
  if (roForm.cAnswer2.value == "") {
    alert("\nAnswer to Question 2 is required.\n\nPlease enter");
    roForm.cAnswer2.focus();
    return (false);
  }
  if (roForm.idx02.value == "") {
    alert("\nCurrent Password is required.\n\nPlease enter");
    roForm.idx02.focus();
    return (false);
  }

  return (true);
}

function checkPWChallengeFields(roForm) {
  if (roForm.cAnswer1.value == "") {
    alert("\nAnswer to Question 1 is required.\n\nPlease enter");
    roForm.cAnswer1.focus();
    return (false);
  }
  if (roForm.cAnswer2.value == "") {
    alert("\nAnswer to Question 2 is required.\n\nPlease enter");
    roForm.cAnswer2.focus();
    return (false);
  }

  return (true);
}

function checkCommentFields(roForm) {
  if (roForm.c001.value == "") {
    alert("\nThe Comment is required.\n\nPlease enter");
    roForm.c001.focus();
    return (false);
  }

  return (true);
}

