    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    var is_nav6 = (is_nav && (is_major == 5));
    var is_nav6up = (is_nav && (is_major >= 5));
    var is_gecko = (agt.indexOf('gecko') != -1);


    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

    // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.
    var is_aol   = (agt.indexOf("aol") != -1);
    var is_aol3  = (is_aol && is_ie3);
    var is_aol4  = (is_aol && is_ie4);
    var is_aol5  = (agt.indexOf("aol 5") != -1);
    var is_aol6  = (agt.indexOf("aol 6") != -1);

    var is_opera = (agt.indexOf("opera") != -1);
    var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
    var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
    var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
    var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);

    var is_webtv = (agt.indexOf("webtv") != -1); 

    var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 
    var is_AOLTV = is_TVNavigator;

    var is_hotjava = (agt.indexOf("hotjava") != -1);
    var is_hotjava3 = (is_hotjava && (is_major == 3));
    var is_hotjava3up = (is_hotjava && (is_major >= 3));

    // *** JAVASCRIPT VERSION CHECK ***
    var is_js;
    if (is_nav2 || is_ie3) is_js = 1.0;
    else if (is_nav3) is_js = 1.1;
    else if (is_opera5up) is_js = 1.3;
    else if (is_opera) is_js = 1.1;
    else if ((is_nav4 && (is_minor <= 4.05)) || is_ie4) is_js = 1.2;
    else if ((is_nav4 && (is_minor > 4.05)) || is_ie5) is_js = 1.3;
    else if (is_hotjava3up) is_js = 1.4;
    else if (is_nav6 || is_gecko) is_js = 1.5;
    // NOTE: In the future, update this code when newer versions of JS
    // are released. For now, we try to provide some upward compatibility
    // so that future versions of Nav and IE will show they are at
    // *least* JS 1.x capable. Always check for JS version compatibility
    // with > or >=.
    else if (is_nav6up) is_js = 1.5;
    // NOTE: ie5up on mac is 1.4
    else if (is_ie5up) is_js = 1.3

    // HACK: no idea for other browsers; always check for JS version with > or >=
    else is_js = 0.0;
var openBinding_parent;
var openBinding;

function clearElement(divId){
  var element=document.getElementById(divId);
  if(element){
    element.innerHTML='';
  }
 } 
function toRemove(id){
 clearElement(id);

}
function bodyNormal(){
 var div=document.getElementById('mask');
  div.innerHTML=''; 
 if(openBinding_parent){
  div=document.getElementById(openBinding_parent);
  var html=div.innerHTML;
  div.innerHTML='<div id="'+openBinding+'" style="display:none;"></div>'+html; 
 }
 div=document.getElementById(openBinding);
 if(div){
  div.innerHTML='';
 }
 openBinding=false;
 openBinding_parent=false;
}
function bodyBack(pressevent){
var charCode = (pressevent.which)? pressevent.which : (event.keyCode);
 if( charCode == 27){
  bodyNormal();
 }
}

function frontRound(){
 $('#EditAjax').corner("12px");
 $('#EditAjax #error').corner("12px");

 $('#masked_content').corner("14px");

}
function toFront(tofront,w,h){
 var div=document.getElementById('masked_content');
 var el=document.getElementById(tofront);
 var html=el.innerHTML;
 el.innerHTML="";
 var rem=document.getElementById(el.parentNode.id);
 openBinding_parent=el.parentNode.id;
 rem.removeChild(el);
 div.innerHTML='<div id="'+tofront+'">'+html+'</div>';
  var div2=document.getElementById('EditAjax');
    div2.style.height=h+'px';
    div2.style.width=w+'px';
get_position('EditAjax');
 $('#EditAjax').corner("12px");
 $('#masked_content').corner("14px");
}

function toFront2(tofront){
  var el=document.getElementById(tofront);
  el.style.position='fixed';
  el.style.zIndex=10000;
  if(is_ie){el.style.position='absolute'; alert('ie');}
}

function bodyBlackWait(w,h){
  var div=document.getElementById('mask');
  if(is_nav || is_gecko){
    document.addEventListener('keydown', bodyBack,true);
  }
  else if(is_opera || is_ie){
    document.attachEvent('onkeydown', bodyBack,true);
  }
  div.innerHTML='<div id="OVERLAY"></div><div id="masked_content"><div id="waiting"></div></div>';
  var div2=document.getElementById('waiting');
  div2.style.height=h+'px';
  div2.style.width=w+'px';
  get_position('waiting');
}
function bodyBlack(tofront,w,h){
  
  var div=document.getElementById('mask');

  if(is_nav || is_gecko){
    openBinding=tofront;
    document.addEventListener('keydown', bodyBack,true);
  }
  else if(is_opera || is_ie){
    openBinding=tofront;
    document.attachEvent('onkeydown', bodyBack,true);
  }
  div.innerHTML='<div id="OVERLAY"></div><div id="masked_content"></div>';
  toFront(tofront,w,h);
  
}
function update_size(div, w, h){
  var div2=document.getElementById(div);
    div2.style.height=h+'px';
    div2.style.width=w+'px';
}

function get_position(div) {
  var divS=document.getElementById(div);
  var w=divS.style.width;
  var h=divS.style.height;
  h=h.replace(/px/ig, '');
  w=w.replace(/px/ig, '');
  var divM=document.getElementById('masked_content');
  divM.style.marginLeft='-'+parseInt((w/2),10)+'px';
  divM.style.width=w+'px';
  divM.style.marginTop='-'+parseInt((h/2),10)+'px';
  divM.style.height=h+'px';
 document.getElementById('masked_content').firstChild.style.height=h+'px';
// $('#'+div).corner("14px");
//$("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px',: TB_WIDTH + 'px'});
//	if ( !(jQuery.browser.msie && typeof XMLHttpRequest == 'function')) { // take away IE6
//		$("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
//	}
}
function autoToggle(divId){
   var element=document.getElementById(divId);
    if(element){
  //  alert(element.style.display);
     var toggle=element.style.display;
     
    if(toggle == 'none'){element.style.display='block';return false;}
    if(toggle == 'block'){element.style.display='none';return false;}
    } 
  }
 

 function otsElmToggle(divId, toggle){
    var element=document.getElementById(divId);
    if(element){
     if(toggle == 'off'){element.style.display='none';return false;}
     if(toggle == 'on'){element.style.display='block';return false;}
    } 
  }
  function doADelete(url,_id){
    id=_id;
    var ProFunction=function(){
    }	
    document.getElementById(id).innerHTML='Retrieving your request.';
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
      req = new XMLHttpRequest();
      req.onreadystatechange = processReqChange;
      req.open("GET", url, true);
      req.send(null);
      // branch for IE/Windows ActiveX version
    } 
    else if (window.ActiveXObject) {
      req = new ActiveXObject("Microsoft.XMLHTTP");
      if (req) {
       req.onreadystatechange = processReqChange;
       req.open("GET", url, true);
       req.send();
      }
    }
  }
  

function loadXMLDocObj(url,_id, string_message,teststring, remoteFunc) {
	this.id=_id;
	this.remoteFunc=remoteFunc;
	this.url=url;
	this.testvalue=false;
	this.teststring=teststring ? teststring : null;
	this.string_message='<div style="border: 1px dashed #CCCCCC; width:90%;"><img src="/ots/imgs/waiting.gif" height="64" width="64"></div>';
	if (this.string_message == ''){
		this.string_message='Retrieving your request.';
	}	
	document.getElementById(this.id).innerHTML=this.string_message;
    // branch for native XMLHttpRequest object
	var _this = this;
	if (window.XMLHttpRequest) {
		this.req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
        this.req = new ActiveXObject("Microsoft.XMLHTTP");
    }
	if (this.req){
		var _this=this;
	   	this.req.onreadystatechange = function(){_this.processReq()};
	   	this.req.open("GET", url, true);
	    	this.req.send(null);
	}
	else{
		return;
	}
}
loadXMLDocObj.prototype.processReq=function() {
    // only if req shows "loaded"
    if (this.req.readyState == 4) {
        // only if "OK"
        if (this.req.status == 200) {
            // ...processing statements go here...
			var s = this.req.responseText;
			if(this.teststring){
			 if(s == this.teststring){
			  this.remoteFunc(true);
  			  this.testvalue=true;
//  			  this.req.onreadystatechange=false;
			   return;
			  }
			}
			document.getElementById(this.id).innerHTML = s;
			if(this.remoteFunc ){this.remoteFunc();}
//alert(  			  this.req.onreadystatechange);
 // 			  this.req.onreadystatechange=false;
			  return;
        } else {
            document.getElementById(this.id).innerHTML ='There was a problem retrieving your request.'+req.statusText;
        }
    }
}
