//Cookies setting
var hideWindowedControls = true;

expireDate = new Date;
expireDate.setMonth(expireDate.getMonth()+12); 

function SetCookie(sName, sValue)
{ delete_cookie (sName);
  date = new Date();
  document.cookie = sName + "=" + escape(sValue) + "; expires=" + expireDate.toGMTString() + "; path=/"   +
		( ( secure ) ? ";secure" : "" );
}

function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

function hidestatus() {
	window.status='';
	return true;
}

if (document.layers)
document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT | Event.MOUSEMOVE | Event.MOUSEDOWN | Event.MOUSEUP | Event.CLICk)
document.onmouseover=hidestatus
document.onmouseout=hidestatus
document.onmousemove=hidestatus
document.onmousedown=hidestatus
document.onmouseup=hidestatus
document.onkeydown=hidestatus
document.onclick=hidestatus
 
function Ltrim(strValue){
    while (strValue.length>0){
       if(strValue.charAt(0)==' '){
           strValue=strValue.substring(1,strValue.length);              
	   }
       else
          return strValue;	    
    }
	return strValue;
}

function Rtrim(strValue){
    while (strValue.length>0){
       if(strValue.charAt(strValue.length-1)==' '){
           strValue=strValue.substring(0,strValue.length-1);              
	   }
       else
           return strValue;	    
   }
   return strValue;
}

function Trim(strValue){
   strValue = Ltrim(strValue);
   strValue = Rtrim(strValue);
   return strValue;
} 

function ValidDate(y, m, d) {
  with (new Date(y, m, d))
    return (getMonth()==m && getDate()==d) }
    
function checkDate(data)
{	var T = data.split('/')
	if (!ValidDate(T[2], T[0]-1, T[1]) || Trim(T[2]).length != 4) { return "Invalid date format.\nPlease enter mm/dd/yyyy format." ; } // bad value
	else {return "" ;}
}

function showdiv(tarobj,showdiv) {
	var el = document.getElementById(tarobj);  
	var tgdiv = document.getElementById(showdiv);  
	var p = getAbsolutePos(el);
	tgdiv.style.left = p.x + "px";
	tgdiv.style.top = p.y + "px";
	tgdiv.style.zIndex	= 1000;
	tgdiv.style.visibility="visible" 
	return false;
}

function getAbsolutePos(el) {
	var SL = 0, ST = 0;
	var is_div = /^div$/i.test(el.tagName);	
	if (is_div && el.scrollLeft)
		SL = el.scrollLeft;
	if (is_div && el.scrollTop)
		ST = el.scrollTop;
	var r = { x: el.offsetLeft - SL, y: el.offsetTop - ST };
	if (el.offsetParent) {
		var tmp = this.getAbsolutePos(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}
	return r;
}

//This function si used for hiding windowed controls because they interfere with the menus
function showSelect(isOn,divName) {
   var theSelect = null;
   if(document.getElementById) {
      theSelect=document.getElementById(divName);
      if(theSelect) theSelect.style.visibility = isOn ? "visible" : "hidden";
   } else if (document.all) {
      theSelect=document.all(divName);
      if(theSelect) theSelect.style.visibility = isOn ? "visible" : "hidden";
   } else if (document.layers) {
      theSelect=document[divName];
      if(theSelect) theSelect.visibility = isOn ? "show" : "hide";
   }
}


