Menu = {timer:null, current:null};
Menu.getStyle = function (name) {
   return document.getElementById(name).style;
}
Menu.show = function (name) {
   if (this.timer) clearTimeout(this.timer);
   this.getStyle('sub_'+name).display = 'block';
   this.getStyle('nav_'+name).background = '#F89D3F';
   this.current = name;
   
   // hide the area mgr and service rep dropdowns on the choose_account.cfm page whenever the submenu is displayed.  this fixes the overlap issue. (QE)
   if ( name == 'practice' )
   {
	   if ( document.search_frm )
	   {
		   if ( document.search_frm.area_mgr ) document.search_frm.area_mgr.style.visibility = 'hidden';
		   if ( document.search_frm.sales_rep ) document.search_frm.sales_rep.style.visibility = 'hidden';
	   }
   }
}
Menu.hide = function () {
   this.timer = setTimeout("Menu.doHide()", 300);
}
Menu.doHide = function () {
   if (this.current) {
	   // hide the area mgr and service rep dropdowns on the choose_account.cfm page whenever the submenu is displayed.  this fixes the overlap issue. (QE)
	   if ( this.current == 'practice' )
	   {
		   if ( document.search_frm )
		   {
			   if ( document.search_frm.area_mgr ) document.search_frm.area_mgr.style.visibility = 'visible';
			   if ( document.search_frm.sales_rep ) document.search_frm.sales_rep.style.visibility = 'visible';
		   }
	   }

	  this.getStyle('sub_'+this.current).display = 'none';
      this.getStyle('nav_'+this.current).background = '#1E4188';
      this.current = null;

   }
}


// Select Menu
function changeLocation(select){
	var value = select.options[select.selectedIndex].value;
	if (value == "") return;
	window.location.href = value;
}

// Popup
function popup(target) {
	window.open(target.href, target.title, 'width=800,height=600,scrollbars,resizable,status').focus();
}

function Trim(TRIM_VALUE){
    if (TRIM_VALUE.length < 1){
        return"";
    }
    TRIM_VALUE = RTrim(TRIM_VALUE);
    TRIM_VALUE = LTrim(TRIM_VALUE);
    if (TRIM_VALUE==""){
        return "";
    }
    else{
        return TRIM_VALUE;
    }
} //End Function

function RTrim(VALUE){
    var w_space = String.fromCharCode(32);
    var v_length = VALUE.length;
    var strTemp = "";
    if (v_length < 0){
        return"";
    }
    var iTemp = v_length -1;
    
    while (iTemp > -1){
        if (VALUE.charAt(iTemp) == w_space){
        }
        else{
            strTemp = VALUE.substring(0,iTemp +1);
            break;
        }
        iTemp = iTemp-1;
    
    } //End While
    return strTemp;

} //End Function

function LTrim(VALUE){
    var w_space = String.fromCharCode(32);
    if (v_length < 1){
        return"";
    }
    var v_length = VALUE.length;
    var strTemp = "";
    
    var iTemp = 0;
    
    while (iTemp < v_length){
        if (VALUE.charAt(iTemp) == w_space){
        }
        else{
            strTemp = VALUE.substring(iTemp,v_length);
            break;
        }
        iTemp = iTemp + 1;
    } //End While
    return strTemp;
} //End Function

