// Drop-down menu
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_showHideLayers2() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers2.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    obj.display=v; }
}

function changeTabImg(theImg) {
    document.getElementById("hometabs").style.backgroundImage = "url(/img/tabs/"+ theImg +".png)";
} 


// Window openings
function openBackWin(theLoc) {
	backWin = window.open(theLoc,'theWin','left=250,top=200,resize=yes,scrollbars=yes,toolbars=yes,menubar=yes');
	backWin.blur();
}
function openClientWin(clientLoc) {
	cWin = window.open(clientLoc,'cliWin','left=100,top=100,width=800,height=280,resize=yes,scrollbars=yes');
	cWin.focus();
}

function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}

function setOnsite() {
var str = document.form1;
if (document.getElementById('samecontact').checked == true) {
	str.osname.value = str.cname.value ;
	str.ostitle.value = str.ctitle.value ;
	str.phone3a.value = str.phone2a.value ;
	str.phone3b.value = str.phone2b.value ;
	str.phone3c.value = str.phone2c.value ;
	str.phone3d.value = str.phone2d.value ;
	str.cell3a.value = str.cell2a.value ;
	str.cell3b.value = str.cell2b.value ;
	str.cell3c.value = str.cell2c.value ;
	str.email3.value = str.email2.value ;
	
} else { 
	str.osname.value = '' ; 
	str.ostitle.value = '' ; 
	str.phone3a.value = '' ; 
	str.phone3b.value = '' ;
	str.phone3c.value = '' ;
	str.phone3d.value = '' ;
	str.cell3a.value = '' ;
	str.cell3b.value = '' ;
	str.cell3c.value = '' ;
	str.email3.value = '' ; 
}
}

function setPnt2() {
var str = document.form1;
if (document.getElementById('samecontact').checked == true) {
	str.tname.value = str.cname.value ;
	str.ttitle.value = str.ctitle.value ;
	str.phone3a.value = str.phone2a.value ;
	str.phone3b.value = str.phone2b.value ;
	str.phone3c.value = str.phone2c.value ;
	str.phone3d.value = str.phone2d.value ;
	str.cell3a.value = str.cell2a.value ;
	str.cell3b.value = str.cell2b.value ;
	str.cell3c.value = str.cell2c.value ;
	str.email3.value = str.email2.value ;
	
} else { 
	str.tname.value = "" ; 
	str.ttitle.value = "" ;
	str.phone3a.value = "" ;
	str.phone3b.value = "" ;
	str.phone3c.value = "" ;
	str.phone3d.value = "" ;
	str.cell3a.value = "" ;
	str.cell3b.value = "" ;
	str.cell3c.value = "" ;
	str.email3.value = "" ; 
}
}
function setPnt3() {
var str = document.form1;
if (document.getElementById('samecontact2').checked == true) {
	str.ename.value = str.tname.value ;
	str.etitle.value = str.ttitle.value ;
	str.phone7a.value = str.phone3a.value ;
	str.phone7b.value = str.phone3b.value ;
	str.phone7c.value = str.phone3c.value ;
	str.phone7d.value = str.phone3d.value ;
	str.cell7a.value = str.cell3a.value ;
	str.cell7b.value = str.cell3b.value ;
	str.cell7c.value = str.cell3c.value ;
	str.email7.value = str.email3.value ;
	
} else { 
	str.ename.value = "" ; 
	str.etitle.value = "" ;
	str.phone7a.value = "" ;
	str.phone7b.value = "" ;
	str.phone7c.value = "" ;
	str.phone7d.value = "" ;
	str.cell7a.value = "" ;
	str.cell7b.value = "" ;
	str.cell7c.value = "" ;
	str.email7.value = "" ; 
}
}

function togIns2 (it, box) {
 	var vis = (box.checked) ? "block" : "none";
	document.getElementById(it).style.display = vis;
}


var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
  var keyCode = (isNN) ? e.which : e.keyCode; 
  var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
  if(input.value.length >= len && !containsElement(filter,keyCode)) {
    input.value = input.value.slice(0, len);
    input.form[(getIndex(input)+1) % input.form.length].focus();
  }

  function containsElement(arr, ele) {
    var found = false, index = 0;
    while(!found && index < arr.length)
    if(arr[index] == ele)
    found = true;
    else
    index++;
    return found;
  }

  function getIndex(input) {
    var index = -1, i = 0, found = false;
    while (i < input.form.length && index == -1)
    if (input.form[i] == input)index = i;
    else i++;
    return index;
  }
  return true;
}



	