var audioOn = false;
function audioDo(doWhat,toWhat){
   if(audioOn){
      var A = eval('document.'+toWhat);
      if (A != null){
         if (doWhat=='stop') A.stop();
         else{
            if (navigator.appName == 'Netscape') A.play();
            else{
               if (document.M == null){
                  document.M = false; var m;
                  for(m in A) if (m == "ActiveMovie"){
                     document.M = true; break;
                     }
                  }
               if (document.M) A.SelectionStart = 0;
               if (document.M) A.play();
            }
         }
      }
   }
}

function ClearBuffer( objLst )
{
  if( document.all )
  {
    objLst.NextClear = new Date;
    objLst.TypeBuf = "";
    objLst.NextClear.setSeconds( objLst.NextClear.getSeconds() + 2 ); 
  }
}

//*********************************************************************
// TypeAhead
//*********************************************************************
function TypeAhead( objLst )
{
  var objTxt;
  var nKeyCode;
  var bRetVal = true;
  var nIter;
  
  if( document.all )
  { 
    if( !objLst.NextClear )
    {
      ClearBuffer(objLst);
    }
    
    if( (dtNow = new Date()) > objLst.NextClear )
    {
      ClearBuffer(objLst);
    }
    
    nKeyCode = window.event.keyCode;
    objLst.TypeBuf = objLst.TypeBuf + String.fromCharCode(nKeyCode)
  
    if( 27 == nKeyCode )
    {
      ClearBuffer(objLst);
      
      return false;
    }
    else
    if( 13 == nKeyCode)
    {
    ValidateForm2()
    }
    else
    {
      nIter = (objLst.TypeBuf.length > 1) ? objLst.selectedIndex : 0;
      
      for( ; nIter < objLst.length; nIter++ ) 
      {
        strItem = objLst.options[nIter].text;
      
        if( strItem.substr(0, objLst.TypeBuf.length).toLowerCase() == objLst.TypeBuf.toLowerCase() )
        {
          objLst.selectedIndex = nIter;
          objLst.options[nIter].selected = true;
          break;
        }
      }
    }
    
    objLst.NextClear = new Date();
    objLst.NextClear.setSeconds( objLst.NextClear.getSeconds() + 2 ); 
    bRetVal = false;
  }
  
  return bRetVal;
}

function ValidAlphaNum(tocheck) {
  var isalphanum = true;
  if ((tocheck == null) || (tocheck == "")) {
     isalphanum = true;
     return isalphanum;
   }
  else {
    for (j = 0;j < tocheck.length; j++) {
      if ((tocheck.substring(j,j+1) != "0") &&
         (tocheck.substring(j,j+1) != "1") &&
         (tocheck.substring(j,j+1) != "2") &&
         (tocheck.substring(j,j+1) != "3") &&
         (tocheck.substring(j,j+1) != "4") &&
         (tocheck.substring(j,j+1) != "5") &&
         (tocheck.substring(j,j+1) != "6") &&
         (tocheck.substring(j,j+1) != "7") &&
         (tocheck.substring(j,j+1) != "8") &&
         (tocheck.substring(j,j+1) != "9") &&
         (tocheck.substring(j,j+1) != "a") &&
         (tocheck.substring(j,j+1) != "b") &&
         (tocheck.substring(j,j+1) != "c") &&
         (tocheck.substring(j,j+1) != "d") &&
         (tocheck.substring(j,j+1) != "e") &&
         (tocheck.substring(j,j+1) != "f") &&
         (tocheck.substring(j,j+1) != "g") &&
         (tocheck.substring(j,j+1) != "h") &&
         (tocheck.substring(j,j+1) != "i") &&
         (tocheck.substring(j,j+1) != "j") &&
         (tocheck.substring(j,j+1) != "k") &&
         (tocheck.substring(j,j+1) != "l") &&
         (tocheck.substring(j,j+1) != "m") &&
         (tocheck.substring(j,j+1) != "n") &&
         (tocheck.substring(j,j+1) != "o") &&
         (tocheck.substring(j,j+1) != "p") &&
         (tocheck.substring(j,j+1) != "q") &&
         (tocheck.substring(j,j+1) != "r") &&
         (tocheck.substring(j,j+1) != "s") &&
         (tocheck.substring(j,j+1) != "t") &&
         (tocheck.substring(j,j+1) != "u") &&
         (tocheck.substring(j,j+1) != "v") &&
         (tocheck.substring(j,j+1) != "w") &&
         (tocheck.substring(j,j+1) != "x") &&
         (tocheck.substring(j,j+1) != "y") &&
         (tocheck.substring(j,j+1) != "z") &&
         (tocheck.substring(j,j+1) != "A") &&
         (tocheck.substring(j,j+1) != "B") &&
         (tocheck.substring(j,j+1) != "C") &&
         (tocheck.substring(j,j+1) != "D") &&
         (tocheck.substring(j,j+1) != "E") &&
         (tocheck.substring(j,j+1) != "F") &&
         (tocheck.substring(j,j+1) != "G") &&
         (tocheck.substring(j,j+1) != "H") &&
         (tocheck.substring(j,j+1) != "I") &&
         (tocheck.substring(j,j+1) != "J") &&
         (tocheck.substring(j,j+1) != "K") &&
         (tocheck.substring(j,j+1) != "L") &&
         (tocheck.substring(j,j+1) != "M") &&
         (tocheck.substring(j,j+1) != "N") &&
         (tocheck.substring(j,j+1) != "O") &&
         (tocheck.substring(j,j+1) != "P") &&
         (tocheck.substring(j,j+1) != "Q") &&
         (tocheck.substring(j,j+1) != "R") &&
         (tocheck.substring(j,j+1) != "S") &&
         (tocheck.substring(j,j+1) != "T") &&
         (tocheck.substring(j,j+1) != "U") &&
         (tocheck.substring(j,j+1) != "V") &&
         (tocheck.substring(j,j+1) != "W") &&
         (tocheck.substring(j,j+1) != "X") &&
         (tocheck.substring(j,j+1) != "Y") &&
         (tocheck.substring(j,j+1) != "Z") &&
         (tocheck.substring(j,j+1) != ".") &&
         (tocheck.substring(j,j+1) != "-") &&
         (tocheck.substring(j,j+1) != " ") &&
         (tocheck.substring(j,j+1) != "_")) {
         isalphanum = false
         
       }
    }
    return isalphanum;  }
    
    }         

function ValidDate(tocheck) {
  var isdate = true;
  if ((tocheck == null) || (tocheck == "")) {
     isdate = true;
     return isdate;
   }
  else {
    for (j = 0;j < tocheck.length; j++) {
      if ((tocheck.substring(j,j+1) != "0") &&
         (tocheck.substring(j,j+1) != "1") &&
         (tocheck.substring(j,j+1) != "2") &&
         (tocheck.substring(j,j+1) != "3") &&
         (tocheck.substring(j,j+1) != "4") &&
         (tocheck.substring(j,j+1) != "5") &&
         (tocheck.substring(j,j+1) != "6") &&
         (tocheck.substring(j,j+1) != "7") &&
         (tocheck.substring(j,j+1) != "8") &&
         (tocheck.substring(j,j+1) != "9") &&
		 (tocheck.substring(j,j+1) != "/")) {
         isdate = false;
         
       }
    }
    return isdate;  }
    
    }    
	

function ValidNumber(tocheck) {
  var isnum = true;
  if ((tocheck == null) || (tocheck == "")) {
     isnum = true;
     return isnum;
   }
  else {
    for (j = 0;j < tocheck.length; j++) {
      if ((tocheck.substring(j,j+1) != "0") &&
         (tocheck.substring(j,j+1) != "1") &&
         (tocheck.substring(j,j+1) != "2") &&
         (tocheck.substring(j,j+1) != "3") &&
         (tocheck.substring(j,j+1) != "4") &&
         (tocheck.substring(j,j+1) != "5") &&
         (tocheck.substring(j,j+1) != "6") &&
         (tocheck.substring(j,j+1) != "7") &&
         (tocheck.substring(j,j+1) != "8") &&
         (tocheck.substring(j,j+1) != "9")) {
         isnum = false;
         
       }
    }
    return isnum;  }
    
    }         

function ValidAlphaNum(tocheck) {
  var isalphanum = true;
  if ((tocheck == null) || (tocheck == "")) {
     isalphanum = true;
     return isalphanum;
   }
  else {
    for (j = 0;j < tocheck.length; j++) {
      if ((tocheck.substring(j,j+1) != "0") &&
         (tocheck.substring(j,j+1) != "1") &&
         (tocheck.substring(j,j+1) != "2") &&
         (tocheck.substring(j,j+1) != "3") &&
         (tocheck.substring(j,j+1) != "4") &&
         (tocheck.substring(j,j+1) != "5") &&
         (tocheck.substring(j,j+1) != "6") &&
         (tocheck.substring(j,j+1) != "7") &&
         (tocheck.substring(j,j+1) != "8") &&
         (tocheck.substring(j,j+1) != "9") &&
         (tocheck.substring(j,j+1) != "a") &&
         (tocheck.substring(j,j+1) != "b") &&
         (tocheck.substring(j,j+1) != "c") &&
         (tocheck.substring(j,j+1) != "d") &&
         (tocheck.substring(j,j+1) != "e") &&
         (tocheck.substring(j,j+1) != "f") &&
         (tocheck.substring(j,j+1) != "g") &&
         (tocheck.substring(j,j+1) != "h") &&
         (tocheck.substring(j,j+1) != "i") &&
         (tocheck.substring(j,j+1) != "j") &&
         (tocheck.substring(j,j+1) != "k") &&
         (tocheck.substring(j,j+1) != "l") &&
         (tocheck.substring(j,j+1) != "m") &&
         (tocheck.substring(j,j+1) != "n") &&
         (tocheck.substring(j,j+1) != "o") &&
         (tocheck.substring(j,j+1) != "p") &&
         (tocheck.substring(j,j+1) != "q") &&
         (tocheck.substring(j,j+1) != "r") &&
         (tocheck.substring(j,j+1) != "s") &&
         (tocheck.substring(j,j+1) != "t") &&
         (tocheck.substring(j,j+1) != "u") &&
         (tocheck.substring(j,j+1) != "v") &&
         (tocheck.substring(j,j+1) != "w") &&
         (tocheck.substring(j,j+1) != "x") &&
         (tocheck.substring(j,j+1) != "y") &&
         (tocheck.substring(j,j+1) != "z") &&
         (tocheck.substring(j,j+1) != "A") &&
         (tocheck.substring(j,j+1) != "B") &&
         (tocheck.substring(j,j+1) != "C") &&
         (tocheck.substring(j,j+1) != "D") &&
         (tocheck.substring(j,j+1) != "E") &&
         (tocheck.substring(j,j+1) != "F") &&
         (tocheck.substring(j,j+1) != "G") &&
         (tocheck.substring(j,j+1) != "H") &&
         (tocheck.substring(j,j+1) != "I") &&
         (tocheck.substring(j,j+1) != "J") &&
         (tocheck.substring(j,j+1) != "K") &&
         (tocheck.substring(j,j+1) != "L") &&
         (tocheck.substring(j,j+1) != "M") &&
         (tocheck.substring(j,j+1) != "N") &&
         (tocheck.substring(j,j+1) != "O") &&
         (tocheck.substring(j,j+1) != "P") &&
         (tocheck.substring(j,j+1) != "Q") &&
         (tocheck.substring(j,j+1) != "R") &&
         (tocheck.substring(j,j+1) != "S") &&
         (tocheck.substring(j,j+1) != "T") &&
         (tocheck.substring(j,j+1) != "U") &&
         (tocheck.substring(j,j+1) != "V") &&
         (tocheck.substring(j,j+1) != "W") &&
         (tocheck.substring(j,j+1) != "X") &&
         (tocheck.substring(j,j+1) != "Y") &&
         (tocheck.substring(j,j+1) != "Z") &&
         (tocheck.substring(j,j+1) != ".") &&
         (tocheck.substring(j,j+1) != "-") &&
         (tocheck.substring(j,j+1) != " ") &&
         (tocheck.substring(j,j+1) != "_")) {
         isalphanum = false
         
       }
    }
    return isalphanum;  }
    
    }         

function ValidDate(tocheck) {
  var isdate = true;
  if ((tocheck == null) || (tocheck == "")) {
     isdate = true;
     return isdate;
   }
  else {
    for (j = 0;j < tocheck.length; j++) {
      if ((tocheck.substring(j,j+1) != "0") &&
         (tocheck.substring(j,j+1) != "1") &&
         (tocheck.substring(j,j+1) != "2") &&
         (tocheck.substring(j,j+1) != "3") &&
         (tocheck.substring(j,j+1) != "4") &&
         (tocheck.substring(j,j+1) != "5") &&
         (tocheck.substring(j,j+1) != "6") &&
         (tocheck.substring(j,j+1) != "7") &&
         (tocheck.substring(j,j+1) != "8") &&
         (tocheck.substring(j,j+1) != "9") &&
		 (tocheck.substring(j,j+1) != "/")) {
         isdate = false;
         
       }
    }
    return isdate;  }
    
    }    
	
function ValidTime(tocheck) {
  var istime = true;
  if ((tocheck == null) || (tocheck == "")) {
     istime = true;
     return istime;
   }
  else {
    for (j = 0;j < tocheck.length; j++) {
      if ((tocheck.substring(j,j+1) != "0") &&
         (tocheck.substring(j,j+1) != "1") &&
         (tocheck.substring(j,j+1) != "2") &&
         (tocheck.substring(j,j+1) != "3") &&
         (tocheck.substring(j,j+1) != "4") &&
         (tocheck.substring(j,j+1) != "5") &&
         (tocheck.substring(j,j+1) != "6") &&
         (tocheck.substring(j,j+1) != "7") &&
         (tocheck.substring(j,j+1) != "8") &&
         (tocheck.substring(j,j+1) != "9") &&
		 (tocheck.substring(j,j+1) != ":") &&
		 (tocheck.substring(j,j+1) != "a") &&
		 (tocheck.substring(j,j+1) != "A") &&
		 (tocheck.substring(j,j+1) != "p") &&
		 (tocheck.substring(j,j+1) != "P") &&
		 (tocheck.substring(j,j+1) != "m") &&
		 (tocheck.substring(j,j+1) != "M") &&
		 (tocheck.substring(j,j+1) != " ")) {
         istime = false;
         
       }
    }
    return istime;  }
    
    }         

function ValidPhone(tocheck) {
  var isphone = true;
  if ((tocheck == null) || (tocheck == "")) {
     isphone = true;
     return isphone;
   }
  else {
    for (j = 0;j < tocheck.length; j++) {
      if ((tocheck.substring(j,j+1) != "0") &&
         (tocheck.substring(j,j+1) != "1") &&
         (tocheck.substring(j,j+1) != "2") &&
         (tocheck.substring(j,j+1) != "3") &&
         (tocheck.substring(j,j+1) != "4") &&
         (tocheck.substring(j,j+1) != "5") &&
         (tocheck.substring(j,j+1) != "6") &&
         (tocheck.substring(j,j+1) != "7") &&
         (tocheck.substring(j,j+1) != "8") &&
         (tocheck.substring(j,j+1) != "-") &&
         (tocheck.substring(j,j+1) != "9")) {
         isphone = false;
         
       }
    }
    return isphone;  }
      
    }  
    
function ValidEmail(eadd){
	var isemail = true;
	if (eadd.length < 6 ){
         isemail = false;
         return isemail;
        }
          
    if (eadd.indexOf("@") == -1 ){
          isemail = false;
          return isemail;
          }
          
    if (eadd.indexOf(".") == -1 ){
          isemail = false;
          return isemail;
          }
    return isemail;
    }   

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
		anchor.target = "_blank";
		anchor.className = "external";
		}
	}
}

function initDLHide()
{
 var DTs,i,tohide,tohideobj,isexpanded;
// grab all second level headlines and loop over them 
 DTs=document.getElementsByTagName('dt');
 for (i=0;i<DTs.length;i++)
 {
// get next sibling (the element to hide, check that it is an element
  tohide=DTs[i].nextSibling;
  while(tohide.nodeType!=1)
  {
   tohide=tohide.nextSibling;
  }
  DTs[i].tohideobj=tohide;
// add the hover function onmouseover and onmouseout 
  DTs[i].onmouseover=function(){hover(this,this.tohideobj,1);}
  DTs[i].onmouseout=function(){hover(this,this.tohideobj,0);}
// hide next element and add onclick event to the header to show and hide it
  juggleClass(tohide,'DThidden',1);
  juggleClass(DTs[i],'DTnormal',1);
  DTs[i].onclick=function(){collapse(this,this.tohideobj);return false}
 }
}
// hover function, adds the hover colour 
// unless the headline is an active trigger
function hover(o,ho,state)
{
 if(checkClass(ho,'DThidden'))
 {
  if(state==1)
  {
   juggleClass(o,'DTnormal',0);
   juggleClass(o,'DThover',1);
  } else {
   juggleClass(o,'DTnormal',1);
   juggleClass(o,'DThover',0);
  }
 }
}
// collapse function, shows and hides the element and sets the highlight 
// colour of the headline
function collapse(o,ho)
{
 if(checkClass(ho,'DThidden'))
 {
  juggleClass(ho,'DThidden',0);
  juggleClass(o,'DTnormal',0);
  juggleClass(o,'DThighlight',1);
 }else{
  juggleClass(ho,'DThidden',1);
  juggleClass(o,'DThighlight',0);
  juggleClass(o,'DTnormal',1);
 }
}
	function juggleClass(o,c,s)
	{
		if(s==0) 
		{
			o.className=o.className.replace(c,'');	
		}
		if (s==1 && !checkClass(o,c))
		{
			o.className+=' '+c
		}
	}

function checkClass(o,c)
{
	var re=new RegExp('\\b'+c+'\\b');
	return re.test(o.className);
}


function tableChange() {
	var rows = window.document.getElementsByTagName('tr');
	for(var i = 0; i < rows.length; i++) {
		(i%2==0)? rows.item(i).style.backgroundColor = "#ffffff" : rows.item(i).style.backgroundColor = "#f8f8f8"
	}
}

function init() {
	externalLinks();
	initDLHide();
	tableChange();	
}
window.onload=init;