function 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=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function imgReplace() { //v3.0
  var i,j=0,x,a=imgReplace.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function imgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

//check for valid alphas
function checkStr(Str) {
  var testPattern = /[A-Za-z]/;
  if (!testPattern.test(Str)) {
    return false;
  } else {
    return true;
  }
}

function numOnly(e) {
var charCode = (navigator.appName == "Netscape")? e.which : e.keyCode;
	if (charCode > 31 && (charCode <48 || charCode > 57)) {
	alert("Please enter only numbers.");
	return false;
	}
}

// checks if number
function isNum(num) {
  var numSet ="0123456789";
  for (var i = 0; i < num.length; i++) {
    var ltr = num.charAt(i);
    if (numSet.indexOf(ltr) == -1) 
      return false;
  }
  return true;
}

//Checks Email
function checkEmail(email) {
  var testPattern = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
  if (!testPattern.test(email)) {
    return false;
  } else {
    return true;
  }
}

function popPage(url,name,width,height) {
  newwin = window.open(url,name,'width=' + width + ',height=' + height);
}

function popPage2(url,name,width,height,xpos,ypos) {
  newwin = window.open(url,name,'width=' + width + ',height=' + height + ',left=' + xpos + ',top=' + ypos);
}

function popTerms(url,name) {
  newwin = window.open(url,name,'width=600,height=600,scrollbars=1,resizeable=0,left=25,top=25');
}

function getHTTPObject() {
  var xmlhttp;
/*@cc_on
  @if (@_jscript_version >= 5)
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      xmlhttp = false;
    }
  }
  @else
    xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}

var req;

function getHTTPObject2() {
  req = false;
  // branch for native XMLHttpRequest object
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch(e) {
      req = false;
    }
  // branch for IE/Windows ActiveX version
  } else if (window.ActiveXObject) {
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch(e) {
        req = false;
      }
    }
  }
  return req;
}


function getWinHeight() {
  return document.body.clientHeight;
}
function getWinWidth() {
  return document.body.clientWidth;
}

function getObjWidth(el) {
  return (document.getElementById(el).width);
}

function getObjHeight(el) {
  return (document.getElementById(el).height);
}

function getRealLeft(el) {
  xPos = document.getElementById(el).offsetLeft;
  tempEl = document.getElementById(el).offsetParent;
  while (tempEl != null) {
      xPos += tempEl.offsetLeft;
      tempEl = tempEl.offsetParent;
  }
  return xPos;
}

function getRealTop(el) {
  yPos = document.getElementById(el).offsetTop;
  tempEl = document.getElementById(el).offsetParent;
  while (tempEl != null) {
      yPos += tempEl.offsetTop;
      tempEl = tempEl.offsetParent;
  }
  return yPos;
}

