var topNavMouseOverDelay = 250;
var topNavMouseOutDelay  = 750;

var selectedMenu       = null;
var selectTabTimeoutId = null;
function SwitchTab(menuIdName) {
    selectedMenu       = jQuery('#' + menuIdName);
    CancelTabTimeout();
    selectTabTimeoutId = setTimeout('ActualSwitchTab();',topNavMouseOverDelay);
}
function CancelTab() {
    selectedMenu       = null;
    CancelTabTimeout();
    selectTabTimeoutId = setTimeout('ActualSwitchTab();',topNavMouseOutDelay);
}
function CancelTabTimeout() {
    if (selectTabTimeoutId != null) { clearTimeout(selectTabTimeoutId); }
}
function ActualSwitchTab() {
    jQuery('#siteTopNav .menu').slideUp();
    if (selectedMenu != null) {
        selectedMenu.slideDown();
    }
}


function clearFieldValue(obj,fieldValue){
	if(fieldValue=='search'){
		fieldValue="Enter Search Term";
	}
	if(obj.value==fieldValue){
		obj.value='';
	}
}
function setFieldValue(obj,defaultValue){
	if(defaultValue=='search'){
		defaultValue="Enter Search Term";
	}
	if(obj.value==''){
		obj.value=defaultValue;
	}
}

function toggle_div(lnkId) {

	if(lnkId=='locate') {
		document.getElementById('locate_btm').style.display="block";
		document.getElementById('lnk_Locate').className="active";
		document.getElementById('search_btm').style.display="none";
		document.getElementById('lnk_Search').className="inactive";

	} else {
		//document.getElementById('locate_btm').style.display="none";
		//document.getElementById('lnk_Locate').className="inactive";
		document.getElementById('search_btm').style.display="block";
		document.getElementById('lnk_Search').className="active";

	}
}

function showOverlayImage(){
   document.getElementById('overlayConnectComingSoon').style.display="block";
}

function openQHMarketplace() {
    window.open("http://marketplace.qualityhealth.com/index.jsp?partnerID=20001", "QHMarketplace", "menubar=0,resizable=0,scrollbars=1,width=940,height=700");
}

function selectOnChangeJumpToUrl(elemSelect) {
    if (!elemSelect) { return; }
    if (elemSelect.nodeName != 'SELECT') { return; }
    
    var selectedValue = elemSelect.value;
    if (selectedValue == '') { return; }
    document.location.href = selectedValue;
}

//*atc*// The files referred to below, homepage.jspa and sessionKeepAlive.jsp, are not to be found.  Also "Ajax" is undefined.  Therefore, these functions have been disabled //*atc*//

/*
// Redirects to a page that ends the session. This could be any page as long as the correct parameter is passed.
function redirectToPageThatEndsSession() {
    window.location.href = mtsWebContext + '/homepage.jspa?endSession=true';
}

// Keeps the session alive by performing an Ajax call periodically until stopped.
var keepAliveIntervalId = setInterval(
    function sessionKeepAlive() {
        new Ajax.Request(mtsWebContext + '/sessionKeepAlive.jsp');
    },
    2 * 60 * 1000 // 2 minutes
);

// Either end the session right away on this page, or set a timeout to redirect to a page that will end the session.
if (window.endSessionOnThisPage) {
    clearInterval(keepAliveIntervalId);
} 
else {
    setTimeout(
        redirectToPageThatEndsSession, 
        30 * 60 * 1000 // 30 minutes
    );
}*/