// PORTALS defined:
var PORTAL_MDR = 'mdr';
var PORTAL_HITSP = 'hitsp';
var PORTAL_COMMON_FORMATS = 'ps';
var PORTAL_MUMM = 'mum';
var PORTAL_STATE_ALL_PAYERS = 'apcd';

// define the window location and default portal:
var pageURI = new URI(window.location);
var pageSystem = PORTAL_MDR;
// look to the URI to find the system:
if(pageURI.getData('system') != undefined){
    pageSystem = pageURI.getData('system');
} else if(pageURI.getData('System') != undefined){
    pageSystem = pageURI.getData('System');
}

var printable = false;
if(location.search.indexOf('print=1') > 0){
    printable = true;
}
try{
    if(!printable){
        document.write('<div id="ahrqbanner">');
        document.write('<div class="hhsportion">');
        document.write('<a href="#h1" class="skipnav" accesskey="S">Skip Navigation</a>');
        document.write('<a href="http://www.hhs.gov" title="U.S. Department of Health and Human Services">');
        document.write('<img src="images/hhs_banner.gif" alt="U.S. Department of Health and Human Services" />');
        document.write('</a>');
        document.write('<a href="http://www.hhs.gov" title="www.hhs.gov" class="hhsright">');
        document.write('<img src="images/hhs_link.gif" alt="www.hhs.gov" />');
        document.write('</a>');
        document.write('</div>');
        document.write('<div class="ahrqportion">');
        document.write('<a href="http://www.ahrq.gov" title="Agency for Healthcare Research Quality">');
        document.write('<img src="images/ahrq_banner.gif" alt="Agency for Healthcare Research Quality"/>');
        document.write('</a>');

        document.write('<form action="dr.ui.drCriteriaSearch?Referer=Advanced" method="get" id="banner_searchform" name="form1" >');
        if (pageSystem == PORTAL_HITSP){
            document.write('<input name="Search Text" type="text" value=" Search USHIK" size="11" onfocus="this.value=');
            document.write("''");
            document.write('" class="gotext" label="Search" id="searchlabel" />');
            document.write('<input type=hidden name=system value=hitsp /> ');
        }
        else if (pageSystem == PORTAL_COMMON_FORMATS){
            document.write('<input name="Search Text" type="text" value=" Search" size="11" onfocus="this.value=');
            document.write("''");
            document.write('" class="gotext" label="Search" id="searchlabel" />');
            document.write('<input type="hidden" name="system" value="ps" /> ');
        }
        else{
            document.write('<input name="Search Text" type="text" value=" Search USHIK" size="11" onfocus="this.value=');
            document.write("''");
            document.write('" class="gotext" label="Search" id="searchlabel" />');
            document.write('<input type="hidden" name="system" value="mdr" /> ');
        }

        document.write('<input type=hidden name=Referer value="DataElement" />');
        document.write('<input src="images/topbn_gobutton.gif" class="gobtn" name="searchbutton" id="searchbutton" onclick="javascript:document.searchForm.submit();" type="image" alt="Go" />');
        document.write('</form>');
        document.write('<a href="http://www.ahrq.gov" class="ahrqright">www.ahrq.gov</a>');
        document.write('</div>');
        document.write('<div class="ahrqlinks">');
        document.write('<a href="http://www.ahrq.gov">AHRQ Home</a> |');
        document.write('<a href="https://info.ahrq.gov/cgi-bin/ahrq.cfg/php/enduser/std_alp.php?p_sid=fDyU6P3k&amp;p_lva=&amp;p_li=&amp;p_accessibility=0&amp;p_redirect=&amp;p_page=1&amp;p_cv=2.94&amp;p_pv=&amp;p_prods=&amp;p_cats=35%2C94&amp;p_hidden_prods=&amp;cat_lvl1=35&amp;cat_lvl2=94&amp;p_search_text=&amp;srch_btn_submit=%C2%A0%C2%A0%C2%A0Search%C2%A0%C2%A0%C2%A0&amp;p_new_search=1 ">Questions?</a> |');
        document.write('<a href="whats_new.html">What&#39;s New in USHIK</a> |');
        document.write('<a href="registry.html">About USHIK</a>');
        document.write('</div>');
        document.write('</div>');
        document.write('<style type="text/css" media="screen">/*<![CDATA[*/ body {');
        document.write('behavior: url(csshover.htc); /* call hover behaviour file */');
        document.write('font-size: 100%; /* enable IE to resize em fonts */');
        document.write('} #menu ul li {');
        document.write('float: left; /* cure IE5.x "whitespace in lists" problem */');
        document.write('width: 100%;');
        document.write('}');
        document.write('#menu ul li a {');
        document.write('height: 1%; /* make links honour display: block; properly */');
        document.write('} #menu a, #menu h2 {');
        document.write('font: bold 0.7em/1.2em arial, helvetica, sans-serif;');
        document.write('} ');
        document.write('/*]]>*/');
        document.write('</style>');
        document.write('<script src="scripts/chgFont.js" type="text/javascript"></script>');

        document.addEvent('domready', function(e){
            var searchBox = $('searchlabel');
            var originalText = '';
            if(searchBox != null){
                var autoSuggestCSS = new Asset.css('css/autoSuggest.css', { });
                var JSONJavaScript = new Asset.javascript('scripts/json2.js',{});
                var autoSuggestScript = new Asset.javascript('scripts/autoSuggest.js', {
                    id: 'autoSuggest',
                    onload: function(){
                        //new autoSuggest('ushikSearchSuggestionServer', 'searchlabel','');
                        new autoSuggest('ajaxHandler', 'searchlabel','');
                    }
                });
                searchBox.addEvent('focus', function(e){
                    if(originalText == ''){
                        originalText = searchBox.value;
                    }
                    if(searchBox.value == originalText){
                        searchBox.value = '';
                    }
                });
                searchBox.addEvent('blur', function(e){
                    if(searchBox.value == ''){
                        searchBox.value = originalText;
                    }
                });
            }
        });
    }
} catch(err){
    //alert(err + "\n" + err.description);
}
