    try{
        // cross-browser compatibility
        var isDOM = (document.getElementById ? true : false); 
        var isIE4 = ((document.all && !isDOM) ? true : false);
        var isNS4 = (document.layers ? true : false);
        var isDyn = (isDOM || isIE4 || isNS4);
    }
    catch(e) {
        var isDOM = '?';
        var isIE4 = '?';
        var isNS4 = '?';
        var isDyn = '?';
    }

    // get ref if id by browser type
    function getRef(id) {
        if (isDOM){
            return document.getElementById(id);}
        else if (isIE4) {
            return document.all[id];}
        else if (isNS4) {
            return document.layers[id];}
        else {
            
            return document.getElementById(id);}
    }
    
    // detection
    var detect = navigator.userAgent.toLowerCase();
    var OS,browser,version,total,thestring;

    
    function ToolTipClick(ctrl){
        
        if (browser != "Netscape Navigator") {
            var ctrlTip = getRef(ctrl);    
            alert(ctrlTip.innerText);
        }
        return true;
    }

    function ToolTipOver(ctrl){
    
        var ctrlTip = getRef(ctrl);    
        ctrlTip.style.display = 'block';
        ctrlTip.style.visibility = 'visible';
        ctrlTip.style.zIndex = '10000';
        ctrlTip.style.position = 'absolute';
        return true;
    }

    function ToolTipOut(ctrl){
        var ctrlTip = getRef(ctrl);    
        ctrlTip.style.display = 'none';
        ctrlTip.style.visibility = 'hidden'
        return true;
    }

    function fillcountry(intCountrySelected){

		try{
			var ctrlCountry = getRef('Countries');
			var ctrlState = getRef('States');
			var intEnd = ctrlCountry.length-1;
			var j = 0;
			var i = 0;
			var i = intEnd;
			var strSelectedState = getCookie('selecedStatePK') + '';
	                    
			// reset states
			ctrlState.options.length = 0;
	 
			do {
				if(ctrlCountry[i].selected || ctrlCountry[i].value == intCountrySelected){
					setCookie('selecedCountryPK', ctrlCountry[i].value + '');
					j=CountriesArray[i].length-1;
					do {
						ctrlState.length++;
						strState = CountriesArray[i][j+1]+'';
						intStart = strState.lastIndexOf('-');
	                    
						if(intStart > 0){
							strState = strState.substring(0,intStart)+'';
							intStart = intStart + 1;
							ctrlState.options[ctrlState.length-1].text = strState;
							ctrlState.options[ctrlState.length-1].value = CountriesArray[i][j+1].substring(intStart);
	                        
							if (ctrlState.options[ctrlState.length-1].value + '' == strSelectedState) {
								ctrlState.options[ctrlState.length-1].selected = true;
							}
	                        
						}
					}
					while (--j);
				}
			}
			while (--i);

			//try{
			//    if (ctrlState.options.length > 0){
			//        ctrlState.focus();
			//    }
			//}
			//catch(e) {
			//}
			//return true;                
		}
		catch(e){
		}
    }

    // browser tests
    if (checkIt('konqueror')){
        browser = "Konqueror";
        OS = "Linux";
    }
    else if (checkIt('safari')){browser = "Safari";}
    else if (checkIt('omniweb')){browser = "OmniWeb";}
    else if (checkIt('opera')){browser = "Opera";}
    else if (checkIt('webtv')){browser = "WebTV";}
    else if (checkIt('icab')){browser = "iCab";}
    else if (checkIt('msie')){browser = "Internet Explorer";}
    else if (!checkIt('compatible')){
        browser = "Netscape Navigator";
        version = detect.charAt(8);
    }
    else {
        browser = "An unknown browser";
    }

    if (!version) {
        version = detect.charAt(place + thestring.length);
    }

    if (!OS){
        if (checkIt('linux')){OS = "Linux";}
        else if (checkIt('x11')){OS = "Unix";}
        else if (checkIt('mac')){OS = "Mac"}
        else if (checkIt('win')){OS = "Windows"}
        else{ 
            OS = "an unknown operating system";
        }
    }

    function checkIt(string){
        place = detect.indexOf(string) + 1;
        thestring = string;
        return place;
    }

    // pass the id of the object and what text you want the objects innertext to be set at
    function dynamicInnerText(strCtrlID, strText) {

        if(isNS4){
            getRef(strCtrlID).document.write("");
            getRef(strCtrlID).document.write(strText);
        }
        else if(isIE4){
	        getRef(strCtrlID).innerHTML = "";
	        getRef(strCtrlID).innerHTML = strText;
        }
        else if(isDOM){
	        getRef(strCtrlID).innerHTML = "";
	        getRef(strCtrlID).innerHTML = strText;
        }
        else {
	        getRef(strCtrlID).innerHTML = "";
	        getRef(strCtrlID).innerHTML = strText;
        }
        return true;
        window.status = strText;
        window.document.body.style.cursor = "wait";
    }

    // focus
    function SetFocusToCtrl(strCtrlID){
        try {
            var Ctrl = getRef(strCtrlID)
            Ctrl.focus();
        }
        catch(e) {
        }
    }
    
    // hide ctrl
    function hideCtrl(strCtrlD) {
        
        try {
            var Ctrl = getRef(strCtrlID)
            Ctrl.style.visibility='hidden';
        }
        catch(e) {
        }
    }

    // show ctrl
    function showCtrl(strCtrlD) {

        try {
            var Ctrl = getRef(strCtrlID)
            Ctrl.style.visibility='visible';
            Ctrl.style.display='block';
        }
        catch(e) {
        }
    }

    function showSiteSearchHelp() {
        
        try {
            var Ctrl = getRef('SearchTips');
            Ctrl.style.visibility='visible';
            Ctrl.style.display='block';
        }
        catch(e) {
        }

        try {
            var Ctrl = getRef('lnkShowSiteSe;archHelp');
            Ctrl.style.visibility='hidden';
            Ctrl.style.display='none';
        }
        catch(e) {
        }

    }

    function hideSiteSearchHelp() {
        
        try {
            var Ctrl = getRef('SearchTips');
            Ctrl.style.visibility='hidden';
            Ctrl.style.display='none';
        }
        catch(e) {
        }

        try {
            var Ctrl = getRef('lnkShowSiteSearchHelp');
            Ctrl.style.visibility='visible';
            Ctrl.style.display='inline';
        }
        catch(e) {
        }

    }

    function setCookie(name, value, expires, path, domain, secure) {
        var curCookie = name + "=" + escape(value) +
            ((expires) ? "; expires=" + expires.toGMTString() : "") +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            ((secure) ? "; secure" : "");
        document.cookie = curCookie;
    }

    function getCookie(name) {
        var dc = document.cookie;
        var prefix = name + "=";
        var begin = dc.indexOf("; " + prefix);
        if (begin == -1) {
            begin = dc.indexOf(prefix);
            if (begin != 0) return null;
        } 
        else{
            begin += 2;
        }
        
        var end = document.cookie.indexOf(";", begin);
        if (end == -1){
            end = dc.length;
        }
        return unescape(dc.substring(begin + prefix.length, end));
    }

    function captureKey(e) {
        var key;
        if (e && e.which) {
            key = e.which;
        } 
        else if (window.event && window.event.keyCode) { 
            key = window.event.keyCode;
        } 
        if (key == 13){
            window.form[0].submit;
        }
    }

    
    function FocusedFlyover(ctrl) {
        var ctrlFly = getRef(ctrl);    
        ctrlFly.style.backgroundColor = 'red';
    }
    function FocusedFlyout(ctrl) {
        var ctrlFly = getRef(ctrl);    
        ctrlFly.style.backgroundColor = 'white';
    }

    function ConfirmReset() {
        var bolReset = confirm('Do you really want to reset all fields?');
        if (bolReset == true){
            // reset state and country selections
            setCookie('selecedStatePK', '');
            setCookie('selecedCountryPK', '');
        }
        return bolReset;
    }

    function setSelectedState(){
        var ctrlState = getRef('States');    
        setCookie('selecedStatePK', ctrlState.value);
    }

    function renderCountries(){
        
        try {

            var ctrlState = getRef('States');    
            var ctrlCountry = getRef('Countries');
            var i = 1;
            var strOptions = "";
            var strCountry;
            var intStart;
            var intEnd = CountriesArray.length;

            for(i; i < intEnd; i++) {
                strCountry = CountriesArray[i][0];
                intStart = strCountry.lastIndexOf('-');
                strCountry = strCountry.substring(0,intStart)+'';
                intStart = intStart + 1;
                window.document.writeln('<option value="' + CountriesArray[i][0].substring(intStart) + '">' + strCountry + '</option>');
            }          
        }
        catch(e) {
        }
        intEnd = ctrlCountry.length;
        i = 1;
        
        if (getCookie('selecedCountryPK') != null){
            for(i; i < intEnd; i++) {
                if (ctrlCountry[i].value + '' == getCookie('selecedCountryPK') + '') {
                    ctrlCountry[i].selected = true;
                    fillcountry(ctrlCountry[i].value);
                    break;
                }
            }
        }
    }


    // on load
    function LoadPage() {

		
        try {
            SetFocus();
        }
        catch(e){
        }
        return true;
    }

    var strPleaseWaitMsg='';
    strPleaseWaitMsg = '<div style="margin: 30px 0 30px 0;" align="center">Searching, this may take a few seconds ...'  
    if (browser == "Internet Explorer"){
        strPleaseWaitMsg = strPleaseWaitMsg + '<br><p align=center>' + 
            '<marquee scrollamount=20 scrolldelay=150 direction=right width=100px>' + 
            '<table align=center width=60% height=3 cellspacing=0><tr bgcolor=#660000>' + 
            '<td style="filter:alpha(opacity=0,finishopacity=100,style=1)"></td>' + 
            '<td style="filter:alpha(opacity=100,finishopacity=0,style=1)" width=8></td>' + 
            '</tr></table>' + 
            '</marquee>' + 
            '</td><td>' + 
            '<marquee scrollamount=20 scrolldelay=150 direction=left width=100px>' + 
            '<table align=center width=60% height=3 cellspacing=0><tr bgcolor=#660000>' + 
            '<td style="filter:alpha(opacity=0,finishopacity=100,style=1)" width=8></td>' + 
            '<td style="filter:alpha(opacity=100,finishopacity=0,style=1)"></td>' + 
            '</tr></table>' + 
            '</marquee>' + 
            '</td></tr></table></p>';
    }
    strPleaseWaitMsg = strPleaseWaitMsg + '</div>';
    
    var strPleaseWaitMTMsg = '';
    strPleaseWaitMTMsg='<div style="margin: 30px 0 30px 0;" align="center">Please wait while we refresh this page, this may take a few seconds ...'  
    if (browser == "Internet Explorer"){
        strPleaseWaitMTMsg = strPleaseWaitMTMsg + '<br><p align=center>' + 
            '<marquee scrollamount=20 scrolldelay=150 direction=right width=100px>' + 
            '<table align=center width=60% height=3 cellspacing=0><tr bgcolor=#660000>' + 
            '<td style="filter:alpha(opacity=0,finishopacity=100,style=1)"></td>' + 
            '<td style="filter:alpha(opacity=100,finishopacity=0,style=1)" width=8></td>' + 
            '</tr></table>' + 
            '</marquee>' + 
            '</td><td>' + 
            '<marquee scrollamount=20 scrolldelay=150 direction=left width=100px>' + 
            '<table align=center width=60% height=3 cellspacing=0><tr bgcolor=#660000>' + 
            '<td style="filter:alpha(opacity=0,finishopacity=100,style=1)" width=8></td>' + 
            '<td style="filter:alpha(opacity=100,finishopacity=0,style=1)"></td>' + 
            '</tr></table>' + 
            '</marquee>' + 
            '</td></tr></table></p>';
        
    }
    strPleaseWaitMTMsg = strPleaseWaitMTMsg + '</div>';


    function showCriteria(){
            var Ctrl = getRef('divCriteria');
            Ctrl.style.visibility='visible';
            Ctrl.style.display='block';
    }

    function hideCriteria(){
            var Ctrl = getRef('divCriteria');
            Ctrl.style.visibility='hidden';
            Ctrl.style.display='none';
    }

    function radMbrType_CLK(){


        try {
            var Ctrl = getRef('ucCenter_UTILITIES/UC_MBRDIRSEARCH_pnlResults');
            Ctrl.style.visibility='hidden';
            Ctrl.style.display='none';
        }
        catch(e) {
        }


        try {
            hideCriteria();
        }
        catch(e) {
        }

        try{
            window.scroll(60,0);
            window.scroll(40,0);
            window.scroll(20,0);
            window.scroll(0,0);
        }
        catch(e) {
        }
        dynamicInnerText('md_spanSearching', strPleaseWaitMTMsg);
        return true;
    }
    

    function cmdStartSearch_CLK(){


        try {
            hideCriteria();
        }
        catch(e) {
        }
        
        try {
            var Ctrl = getRef('ucCenter_UTILITIES/UC_MBRDIRSEARCH_pnlResults');
            Ctrl.style.visibility='hidden';
            Ctrl.style.display='none';
        }
        catch(e) {
        }
        
        try {
            var Ctrl = getRef('Ucpagepart_Main__ctl0_/UTILITIES/UC_SITESEARCH_pnlResults');
            Ctrl.style.visibility='hidden';
            Ctrl.style.display='none';
        }
        catch(e) {
        }
        

        try {
            var Ctrl = getRef('ucCenter_UTILITIES/UC_SITESEARCH_pnlResults');
            Ctrl.style.visibility='hidden';
            Ctrl.style.display='none';
        }
        catch(e) {
        }

        try {
            var Ctrl = getRef('ucCenter_UTILITIES/UC_MBRDIRSEARCH_lblTotalTop');
            Ctrl.style.visibility='hidden';
            Ctrl.style.display='none';
        }
        catch(e) {
        }
        
        try{
            window.scroll(60,0);
            window.scroll(40,0);
            window.scroll(20,0);
            window.scroll(0,0);
        }
        catch(e) {
        }
        
        dynamicInnerText('md_spanSearching', strPleaseWaitMsg);
        return true;
    }

    function captureKeyMbrDirSearch(e) {
        var key;
        if (e && e.which) {
            key = e.which;
        } 
        else if (window.event && window.event.keyCode) { 
            key = window.event.keyCode;
        } 
        if (key == 13){
            alert('Due to the complexities of the Member Directory/Buyers Guide search page, you must specifically click one of the Search buttons to begin a search.');
            return false;
        }
    }
