// function openWindow(theURL,winName,features) { window.open(theURL,winName,features); }
function getElement(elementId){return document.layers ? document.layers[elementId] : document.getElementById ?  document.getElementById(elementId) : document.all[elementId]; }
function pageWidth() {return window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null;}
function pageHeight() {return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;}
function toggleElement(elementId, state) // 1 visible, 0 hidden
{
  var obj = getElement(elementId);
  if(state!=null)
    obj.style.visibility = document.layers ? (state ? "show" : "hide") : (state ? "visible" : "hidden");
  else{
    if(obj.style.visibility==''||obj.style.visibility=='hidden'||obj.style.visibility=='hide')
      obj.style.visibility = document.layers ? "show" : "visible";
    else
      obj.style.visibility = document.layers ? "hide" : "hidden";
  }
}
function aToggleElement(elementId){
  var obj = getElement(elementId);
  switch (obj.style.display)
  {
  case 'none' :
    obj.style.display = 'block';
    break;
  case '':
    obj.style.display = 'block';
    break;
  case 'block':
    obj.style.display = 'none';
    break;
  case 'inline':
    obj.style.display = 'none';
    break;
  default :
    obj.style.display = 'none';
  }
}
function goToUrl(url) {	document.location = url; }
function showDiv(elementId,className,value,timeout){
  var obj=getElement(elementId);
  obj.style.display="block";
  obj.className=className;
  if(value!=null)
    obj.innerHTML=value;
  if(timeout!=null||timeout>0)
    setTimeout("hideDiv('"+elementId+"')" , timeout);
}
function hideDiv(elementId){
  var obj = getElement(elementId);
  obj.style.display="none";
  obj.innerHTML='';
}
function hideDiv2(elementId){
  var obj = getElement(elementId);
  obj.style.display="none";
}
function clearValue(elementId, newText){
  var obj=getElement(elementId);
  obj.value=newText!=null?newText:"";
}
function addLoadEvent(func){
  var oldonload = window.onload;
  if (typeof window.onload != 'function')
    window.onload = func;
  else {
    window.onload = function() {
      if(oldonload)
        oldonload();
      func();
    }
  }
}
function pause(millis){
  date = new Date();
  var curDate = null;
  do { var curDate = new Date(); } 
  while(curDate-date < millis);
}
function mform(){
  var f = document.forms[0];
  i = f.action.lastIndexOf('/');
  if(i>-1)
    f.action = f.action.slice(i,f.action.length);
  else
    f.action = '/'+f.action;
}
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
