﻿

// Superheader
var shTimeOut         = 300;
var shCloseTimer = null;

function shOpen() {
    var oSuperheader = document.getElementById("superheaderDropdown");
    if (oSuperheader) {
        shCancelClosetime();
        oSuperheader.style.visibility = 'visible';
    }
}

function shCancelClosetime() {
    if (shCloseTimer) {
        window.clearTimeout(shCloseTimer);
        shCloseTimer = null;
    }
}

function shClosetime() {
    shCloseTimer = window.setTimeout(shClose, shTimeOut);
}

function shClose() {
    var oSuperheader = document.getElementById("superheaderDropdown");
    if (oSuperheader) {
        oSuperheader.style.visibility = 'hidden';
    }
}

// Search box
function sbfocus() {
    var oSearchbox = document.getElementById("tdsearchbox");
    if (oSearchbox) {
        oSearchbox.style.backgroundImage = "none";
    }
}

function sbblur() {
    var oSearchbox = document.getElementById("tdsearchbox");
    if (oSearchbox) {
        if (oSearchbox.value == "") {
            oSearchbox.style.backgroundImage = "url('/mhc_images/searchbox.gif')";
        }
    }
}
function submitsearch() {
    if (document.getElementById('tdsearchbox').value.length > 0) {
        var sSearchURL; // = "http://google01.mhhs.org/search?";
        sSearchURL = "site=childrens_collection&";
        sSearchURL += "client=childrens_frontend&";
        sSearchURL += "proxystylesheet=childrens_frontend&";
        sSearchURL += "output=xml_no_dtd&";
        sSearchURL += "filter=0&";
        sSearchURL += "getfields=description&";
        sSearchURL += "q=" + escape(document.getElementById('tdsearchbox').value);

        location.href = "/Search1.aspx?" + sSearchURL;
    }
}
function searchenter(e) {
    if (window.event) {
        e = window.event;
    }
    if (e.keyCode == 13) {
        submitsearch();
        return false;
    }
}
function searchonload() {
    var aURL_QS = window.location.href.split('?');
    if (aURL_QS[1]) {
        window.frames.mhcsearchresult.location.href = "http://google02.mhhs.org/search?" + aURL_QS[1];
    }
    if (findquerystring("q").length > 0) {
        document.getElementById("tdsearchbox").value = unescape(findquerystring("q"));
    }
}
function findquerystring(sName) {
    sName = sName.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + sName + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return results[1];
}
// Newsletter control
function hmnewsletterfocus(strNewsletterboxId) {
    var oNewsletterbox = document.getElementById(strNewsletterboxId);
    if (oNewsletterbox) {
        oNewsletterbox.style.backgroundImage = "none";
    }
}

function hmnewsletterblur(strNewsletterboxId) {
    var oNewsletterbox = document.getElementById(strNewsletterboxId);
    if (oNewsletterbox) {
        if (oNewsletterbox.value == "") {
            oNewsletterbox.style.backgroundImage = "url('/mhc_images/newsletterback.gif')";
        }
    }
}
function hmnewsletterfocus2(strNewsletterboxId) {
    var oNewsletterbox = document.getElementById(strNewsletterboxId);
    if (oNewsletterbox) {
        oNewsletterbox.style.backgroundImage = "none";
    }
}

function hmnewsletterblur2(strNewsletterboxId) {
    var oNewsletterbox = document.getElementById(strNewsletterboxId);
    if (oNewsletterbox) {
        if (oNewsletterbox.value == "") {
            oNewsletterbox.style.backgroundImage = "url('/mhc_images/newsletterback2.gif')";
        }
    }
}
//
function printpage() {
    window.print();
}

