﻿function printPage(idarray){
  //sample call to function --> printPage(['header','menu','footer']);
  if(document.getElementById){
    for (var i=0; i<idarray.length; i++) {
      if(document.getElementById(idarray[i])){
        document.getElementById(idarray[i]).style.display='none';
          //alert(idarray[i]);
      }
    }
  }
  window.print();
  if(document.getElementById){
    for (var i=0; i<idarray.length; i++) {
      if(document.getElementById(idarray[i])){
        document.getElementById(idarray[i]).style.display='block';
      }
    }
  }
}
function getXmlHttpObject() {
  var xmlHttp = null;
  try{xmlHttp = new XMLHttpRequest();} // Firefox, Opera 8.0+, Safari
  catch(e){  // Internet Explorer
    try{xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");}
    catch(e){
      try{xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}
    }
  }
  return xmlHttp;
}
function clickButton(e, buttonid){ 
      var evt = e ? e : window.event;
      var bt = document.getElementById(buttonid);
      if (bt){ 
          if (evt.keyCode == 13){ 
                //alert("enter")
                bt.click(); 
                
                return false; 
          } 
      } 
}
function popup(code){
  window.open(code,"info","top=0,left=0,width=500,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=yes,status=no,directories=no,toolbar=no");
}
function popuplg(code){
  window.open(code,"info","top=0,left=0,width=850,height=500,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=yes,status=no,directories=no,toolbar=no");
}
function popup2(code){
  window.open(code,"info","top=0,left=0,width=750,height=600,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no");
}
function popupSmall(code){
  window.open(code,"info","top=0,left=0,width=350,height=500,buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no");
}
function jumpPage(newLoc){
  newPage = newLoc.options[newLoc.selectedIndex].value
  if (newPage != "") {
    window.location.href = newPage
  }
}
function goToNextBox(e, thisboxid, maxlength, nextboxid){ 
      var thisbox = document.getElementById(thisboxid);
      var nextbox = document.getElementById(nextboxid);
      if (thisbox){ 
          if (thisbox.value.length == maxlength -1){ 
                //get value entered
                var keynum
                if(window.event) // IE
                  {keynum = e.keyCode}
                else if(e.which) // Netscape/Firefox/Opera
                  {keynum = e.which}
                //add value to textbox and reset focus
                thisbox.value = thisbox.value + String.fromCharCode(keynum)
                if (nextbox) {nextbox.focus();} 
                return false; 
          }
      } 
}
function stripHTML(){
  var numberForms = document.forms.length;
  var formIndex =0;
  var myvalue="";
  for (formIndex=0; formIndex<numberForms; formIndex++){
    for(x=0;x<document.forms[formIndex].length;x++){
      if(document.forms[formIndex].elements[x].type=='textarea'||document.forms[formIndex].elements[x].type=='text'){
        myvalue = document.forms[formIndex].elements[x].value;
        
        document.forms[formIndex].elements[x].value=myvalue.replace(/(<([^>]+)>)/ig,""); 
      }
    }
  }
}
function stripCharacter(words,character) {
	 var spaces = words.length;
	 for(var x = 1; x<spaces; ++x){
	   words = words.replace(character, "");   
	 }
	 return words;
}
function isAlphaNumeric(thisboxid){
  var regex=/^[0-9A-Za-z]+$/;
  if(regex.test(thisboxid.value)){
    return true;
  } else {
    return false;
  }
}
function stripNonNumeric(thisboxid){
  thisboxid.value=thisboxid.value.replace(/[^0-9]+$/,"");
}
function testThenStripNonNumeric(thisboxid){
  if(/[^0-9]+$/.test(thisboxid.value)){
    thisboxid.value=thisboxid.value.replace(/[^0-9]+$/,"");
  }
}
function stripNonAlphaNumeric(thisboxid){
  thisboxid.value=thisboxid.value.replace(/[^0-9A-Za-z]+$/,"");
}
function testThenStripNonAlphaNumeric(thisboxid){
  if(/[^0-9A-Za-z]+$/.test(thisboxid.value)){
    thisboxid.value=thisboxid.value.replace(/[^0-9A-Za-z]+$/,"");
  }
}
function showText(textboxid, newvalue) {
  if (!document.getElementById) return;
  var tbx = document.getElementById(textboxid);
  if(tbx){
    tbx.value=newvalue;
  }
}
function showLabel(labelid, newvalue) {
  if (!document.getElementById) return;
  var lbl = document.getElementById(labelid);
  if(lbl){
    lbl.innerHTML=newvalue;
  }
}
function changeColor(linkid, newcolor) {
  if (!document.getElementById) return;
  var lnk = document.getElementById(linkid);
  if(lnk){
    lnk.style.backgroundColor=newcolor;
  }
}

