﻿document.write('<script src="' + location.protocol + '//www.hawkeslearning.com/Scripts/superfish.js" type="text/javascript"></script>');
document.write('<script src="' + location.protocol + '//www.hawkeslearning.com/Scripts/supersubs.js" type="text/javascript"></script>');

var pageCount = 0;
function getLiveChat() {
    var divButton = document.createElement("div");
    divButton.id = "liveChatButton";
    divButton.className = "liveChat";
    var buttonCode = "<!-- LiveZilla Chat Button Link Code (ALWAYS PLACE IN BODY ELEMENT) -->";
    buttonCode += "<a href=\"javascript:void(window.open('http://chat.hawkeslearning.com/chat/chat.php','','width=590,height=825,left=0,top=0,resizable=yes,menubar=no,location=no,status=yes,scrollbars=yes'))\"><img src=\"http://chat.hawkeslearning.com/chat/image.php?id=12&amp;type=inlay\" width=\"170\" height=\"50\" border=\"0\" alt=\"LiveZilla Live Help\"></a>";
    buttonCode += "<!-- http://www.LiveZilla.net Chat Button Link Code -->";
    buttonCode += "<!-- LiveZilla Tracking Code (ALWAYS PLACE IN BODY ELEMENT) -->";
    buttonCode += "<div id=\"livezilla_tracking\" style=\"display:none\"></div>";
    buttonCode += "<script type=\"text/javascript\"> var script = document.createElement(\"script\");script.async=true;script.type=\"text/javascript\";var src = \"http://chat.hawkeslearning.com/chat/server.php?request=track&output=jcrpt&nse=\"+Math.random();setTimeout(\"script.src=src;document.getElementById('livezilla_tracking').appendChild(script)\",1);</script>";  
    buttonCode += "<noscript><img src=\"http://chat.hawkeslearning.com/chat/server.php?request=track&amp;output=nojcrpt\" width=\"0\" height=\"0\" style=\"visibility:hidden;\" alt=\"\"></noscript>";    
    buttonCode += "<!-- http://www.LiveZilla.net Tracking Code -->";
    divButton.innerHTML = buttonCode;
    $("#liveSupport").html(divButton);
}

function loadContent() {
    $("head").append("<link rel='shortcut icon' href='http://www.hawkeslearning.com/Images/WebIcon.ico' />");
    $('#Sidebar').load(location.protocol + '//' + location.hostname + "/Sidebar/" + $("#sidebarType").val() + ".htm" + ' #Sidebar', function () {
        
        var path = document.location.pathname;
        path = path.substr(1);
        if (path.indexOf('/') == -1) {
            $(".sidebarquote").css("display", "");
        }
    });
        $('#Footer').load(location.protocol + '//' + location.hostname + '/Footer.htm' + ' #Footer');
    if (location.protocol != "https:") {
      $('#Header').load(location.protocol + '//' + location.hostname + '/Header.htm' + ' #Header', function () {
            updateHeader();
        });
    }
    else {
        $('#Header').load(location.protocol + '//www.hawkeslearning.com/SecureHeader.htm' + ' #Header', function () {
            updateHeader();
        });
    }
}

function updateHeader() 
{
    $(document).ready(function () {
        $("ul.sf-menu").supersubs(
            {
                minWidth: 8,   // minimum width of sub-menus in em units 
                maxWidth: 27,   // maximum width of sub-menus in em units 
                extraWidth: 1     // extra width can ensure lines don't sometimes turn over 
                // due to slight rounding differences and font-family 
            }).superfish();  // call supersubs first, then superfish, so that subs are 
        // not display:none when measuring. Call before initialising 
        // containing tabs for same reason. 

        /*
        //Snippet portion of the header
        var snippetText = "<span style='font-size:12px' >You are here: ";
        var url = document.URL;
        var suburl = url.replace('http://www.hawkeslearning.com/', '');
        var urlCount = 0;
        var word = '';
        var prevWord = '';
        for (i = 0; i < suburl.length; i++) 
        {
        if (suburl.charAt(i) == '/') 
        {
        if (urlCount == 0) 
        {
        snippetText = snippetText + "<a href='http://www.hawkeslearning.com/" + word.replace(/ /g, "") + ".htm" + "'>" + word + "</a>&nbsp > ";
        if (word == "Tech Support")
        document.getElementById("Support").className = "selectedMenu";
        else if (document.getElementById(word) != null)
        document.getElementById(word).className = "selectedMenu";
        prevWord = prevWord + word.replace(/ /g, "") + '/';
        }
        else 
        {
        snippetText = snippetText + "<a href='http://www.hawkeslearning.com/" + prevWord + word.replace(/ /g, "") + ".htm" + "'>" + word + "</a>&nbsp > ";
        if (document.getElementById(word) != null)
        document.getElementById(word).className = "selectedSubmenu";
        prevWord = prevWord + word.replace(/ /g, "") + '/';
        }
        urlCount++;
        word = '';
        }
        else if (suburl.charAt(i) == '.') 
        {
        for (j = i; j < suburl.length; j++)
        if (suburl.charAt(j) == '?')
        suburl = suburl.slice(0, j);
        if (word == "Makacode" || word == "makacode")
        word = "Request For Access Code";
        else if (word == "Find Your Course I D")
        word = "Find Your Course ID";
        else if (word == "Abby Mc Bride")
        word = "Abby McBride";
        else if (word == "Tess Di Filippo")
        word = "Tess DiFilippo";
        else if (word == "Whats New For Fall2010")
        word = "Whats New For Fall 2010";
        else if (word == "Press Release T S T C")
        word = "Press Release TSTC";
        else if (word == "Berkely College E Book")
        word = "Berkely College eBook";
        else if (word == "Sign Up For A Demonstration Confirmation") {
        word = "Sign Up For A Demonstration";
        suburl = "Instructors/SignUpForADemonstration.aspx";
        }
        else if (word == "Training Request Confirmation") {
        word = "Training Request";
        suburl = "Instructors/ScheduleATraining/TrainingRequest.aspx";
        }

        snippetText = snippetText + "<a href='http://www.hawkeslearning.com/" + suburl + "'>" + word + "</a>";
        if (urlCount == 0) {
        if (word == "Tech Support")
        document.getElementById("Support").className = "selectedMenu";
        if (document.getElementById(word) != null)
        document.getElementById(word).className = "selectedMenu";
        if (document.getElementById("sidebarquote") != null)
        document.getElementById("sidebarquote").style.visibility = 'visible';
        }
        else {
        if (document.getElementById(word) != null)
        document.getElementById(word).className = "selectedSubmenu";
        }
                        
        word = '';
        }
        else 
        {
        //&& (suburl.charAt(i - 1) != 'I' && suburl.charAt(i) != 'D')
        if (suburl.charAt(i).toLowerCase() != suburl.charAt(i) && i != 0 && suburl.charAt(i - 1) != '/')
        word = word + ' ' + suburl.charAt(i);
        else
        word = word + suburl.charAt(i);
        }
        }
        snippetText = snippetText + "</span>";
        $("#snippet").html(snippetText);
        */


              if (document.URL.toLowerCase() == (location.protocol + '//' + location.hostname + "/default.htm")
            || document.URL.toLowerCase() == (location.protocol + '//' + location.hostname + "/")) {
            var guts = $(document).find('div[id="HomeBannerHidden"]').first().html();
            $('div[id="HomeBannerHidden"]').empty();
            $(guts).appendTo('div[id="HomeBanner"]');
            $('#Home').addClass("selectedMenu");
        }
        else {
            $("#" + $("#sidebarType").val()).addClass("selectedMenu");
            $("a[href$='" + document.URL + "']").addClass("selectedSubmenu");
            if (location.protocol != "https:")
                getLiveChat();
        }
    });
}

