﻿// drop_down.js 
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  };
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   };
   }
  }
 }
};
window.onload=startList;

//================================================
// mailthis.js 
function MailThis(){
    document.frmSend.elements["hidTitle"].value=document.title;
    var metaContent = "";
    var allMetas = document.getElementsByTagName("meta");
    for(var i = 0; i < allMetas.length; i++) {
        if(allMetas[i].name == "description") {
            metaContent = allMetas[i].content;
            document.frmSend.elements["hidTeaser"].value=metaContent;
            break;
        }
}
document.forms["frmSend"].submit();
}
//=================================================
// searchgo.js 
function searchgo(){
    var flag=0;
    if ((document.getElementById("searchtext").value==null)||(document.getElementById("searchtext").value=="")) {
	    flag=1;
    }
    if (flag==1){ 
	    return false;
    }else{
    var address = "/search/default.aspx?search=" + document.getElementById("searchtext").value;
    window.location = address;
    }
}

//=================================================
// textcounter.js 
function textCounter(field, countfield, maxlimit) {
var fld = document.getElementById(field);
var ctrfld = document.getElementById(countfield);
//alert(fld.value.length);
if (fld.value.length > maxlimit) // if too long...trim it!
{fld.value = fld.value.substring(0, maxlimit);}
// otherwise, update 'characters left' counter
else 
{ctrfld.innerText = maxlimit - fld.value.length;}
}

// format phone
function FormatPhone(phNoField, ev) {
    var phNo = phNoField.value;
    var tmp = "";
    if (ev.keyCode != 8 && ev.keyCode != 46 && ev.keyCode != 37 && ev.keyCode != 39) {
        for (i = 0; i < phNo.length; i++) {
            if (phNo.substring(i, i + 1) >= 0 && phNo.substring(i, i + 1) <= 9) {
                tmp = tmp + phNo.substring(i, i + 1);
                if (tmp.length == 3 || tmp.length == 7) {
                    tmp = tmp + "-";
                }
            }
        }
        phNoField.value = tmp;
    }
}
