var VIRTUALBASE = location.protocol+"//"+location.hostname; //."/"
var UA = navigator.userAgent.toLowerCase();
var KHTML = /(khtml)|(safari)|(konqueror)/i;
var ieXpr = /(.*)(msie\s)([0-9]+\.[0-9]+)(.*)/i;
var IEVersion =  UA.replace(ieXpr, "$3");	
var isDom = (document.getElementById && !document.all) ? 1 : 0;
var cDate = new Date();
var currentYear = (cDate.getFullYear()) ? cDate.getFullYear() : cDate.getYear();
var Gecko=(navigator.userAgent.indexOf("Gecko")>=0) ? 1 : 0; // Netscape 6,7, etc. / Mozilla ....
var NetscapeCompat=(Gecko || document.layers || (navigator.appName == "Netscape" && navigator.appVersion<4) || navigator.userAgent.indexOf("Opera") >=0) ? 1 : 0;
var message="";
var ieWidth = (document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.clientWidth;
var ieHeight = (document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;
var winWidth = (window.innerWidth) ? window.innerWidth : ieWidth;
var winHeight = (window.innerHeight) ? window.innerHeight : ieHeight;

//=================================================================================================
function getElement(iVal){
 return (document.all) ? document.all[iVal] : document.getElementById(iVal);
}
//=================================================================================================
function elementExists(iVal){
 return (getElement(iVal) != "undefined") ? 1 : 0;
}
//=================================================================================================
function getFormElement(iVal,frmNum){ 
 var frm = (frmNum) ? frmNum : 0;
 var Ele = document.forms[frm].elements[iVal];
 var type = (Ele) ? Ele.type : "";
 return (type == "select-one") ? Ele.options[Ele.selectedIndex] : Ele;
} // end function
//=================================================================================================
function FormElement(iVal,frmNum){ 
 var frm = (frmNum) ? frmNum : 0;
 var Ele = document.forms[frm].elements[iVal];
 return Ele;
} // end function
//=================================================================================================
function getFileName(iVal){	   
 return iVal.replace(/(.*[\/\\\\])(.*)/ig,"$2");
}
//=================================================================================================
function setAttr(iVal,attr,val){
 var r = (attr == "required" && val == "y") ? " required" : "";
 var tReq = (r.indexOf("required") >= 0 || r.indexOf("req") >= 0) ? 1 : 0;
 var oldClass = getElement(iVal).className;
 document.getElementById(iVal).setAttribute(attr,val);  //added "required=" attribute/(required)|(req)/i.test(r)
 getElement(iVal).className = (tReq) ? oldClass.replace(/required/ig,"") : oldClass+r; 
  // Set's the class name
}
//=================================================================================================
function getAttr(ele,attr){ // This needs required= to be added to input's for required to work.
 return getElement(ele).getAttribute(attr);
}
//=================================================================================================
function getIEAttr(ele,attr){ // better get Attribute - ?? this Can use Class to store required, but crashes.
 var iEle = getElement(ele);
 var out = "";
 for (i=0;i<iEle.attributes.length;i++){
  if (iEle.attributes[i].nodeName == attr) out = iEle.attributes[i].nodeValue
 }
 return out;
}
//=================================================================================================
function getFrmAttr(ele,attr){
 return (document.all) ? getIEAttr(ele,attr) : getAttr(ele,attr);
}
//=================================================================================================
function opacity(iObj,iOpacty){
 if (document.all) getElement(iObj).style.filter = "alpha(opacity:"+iOpacty+")";  
 if (Dom) getElement(iObj).style.opacity = iOpacty/100;  
 if (KHTML) getElement(iObj).style.KHTMLOpacity = iOpacty/100;
}
//=================================================================================================
function reptStr(iVal,rpt){
 var out = "";
 for (i=1;i<=rpt;i++) out += iVal;
 return out; 
}
//=================================================================================================
function hilight(iVal){
 var Frm = document.forms[0];
 var dLen = Frm.length-1;
 var Xpr = /(text)|(select)|(check)|(radio)/i;
 var fType = "", fName = "", fID = "";
 //alert("iVal.name: "+iVal.name);
 for (i=0;i<=dLen;i++){ // turn them all off 1st.
  fType = Frm.elements[i].type;
  fName = Frm.elements[i].name;
  fID = Frm.elements[i].id;
  if (Xpr.test(fType) && fType) {
   //getElement(fID).style.backgroundColor = "#ffffff";
   FormElement(fName).style.backgroundColor = "#ffffff";
  }
 }		 //iVal.style
 
 if (iVal.name) {  
  //getElement(iVal.name).style.backgroundColor = "#ffff99";
  FormElement(iVal.name).style.backgroundColor = "#ffff99";
 }
}
//=================================================================================================
function addListener(iElement, eType, expression, bubbling){
 bubbling = bubbling || false;
 var RetVal = false;
 if (window.addEventListener) iElement.addEventListener(eType, expression, bubbling); // DOM
 if (window.attachEvent) iElement.attachEvent('on'+eType, expression); // IE
    
 RetVal = (window.addEventListener || window.attachEvent) ? true : false;
 return RetVal;
}  //addListener(window, 'mouseout', myFunction);
//=================================================================================================
function tOver(iVal){
 //<?= $txt ?>
 window.status = (iVal) ? iVal : "";
 return true;
}
//=================================================================================================
function noRtClick(e){ // Doesn't work in Opera
 if (!document.all) {  // NetscapeCompat // Netscape, Mozilla, Opera(?)  .....
  if (e.which==2 || e.which==3) {
   (message);
   return false;
  }
 else {
  //if (document.all) {
  // IE
  (message);
  return false;
  }
 }//

} // end function

// Set other browser stuff.
//requires browser.js
document.konqueror = (myBrowser.isKonqueror()) ? 1 : 0;
//document.opera is set in NEWER versions of opera (7+)
document.safari = (myBrowser.isSafari()) ? 1 : 0;
document.ie4 = (UA.indexOf("msie 4.")>=0) ? 1 : 0;
document.ie5 = (UA.indexOf("msie 5.")>=0) ? 1 : 0;
document.ie6 = (UA.indexOf("msie 6.")>=0) ? 1 : 0;
document.ie7 = (UA.indexOf("msie 7.")>=0) ? 1 : 0;
document.gecko = (UA.indexOf("gecko")>=0) ? 1 : 0;
document.mozilla = (myBrowser.isMozilla()) ? 1 : 0;
document.firefox = (myBrowser.isFireFox()) ? 1 : 0;
document.seamonkey = (myBrowser.isSeamonkey()) ? 1 : 0;
document.browser = myBrowser.FullBrowserName; 


//window.status = "document.konqueror: "+document.konqueror+" -- document.safari: "+document.safari+" -- document.ie4: "+document.ie4+" -- document.ie5: "+document.ie5+" -- document.ie6: "+document.ie6+" -- document.ie7: "+document.ie7+" -- document.gecko: "+document.gecko;

//=================================================================================================

document.oncontextmenu = function(){return false;}  // Doesn't work in Opera

