﻿$(document).ready(function() {

    $("li").click(function() {
        this.removeClass("blue");
    });

    $("#top_menu li.active_link, a.active_link").bind("mouseenter", function() {
        $(this).addClass("withpointer");
        $(this).addClass("top_menu_over");
        $(this).removeClass("top_menu_out");
    });

    $("#top_menu li.active_link, a.active_link").bind("mouseleave", function() {
        $(this).addClass("top_menu_out");
        $(this).removeClass("top_menu_over");
    });


    $("#nav-fixed li.active_link").bind("mouseenter", function() {
        //$(this).stop();
        $(this).addClass("menu_over");
        $(this).removeClass("menu_out");
    });

    $("#nav-fixed li.active_link").bind("mouseleave", function() {
        $(this).addClass("menu_out");
        $(this).removeClass("menu_over");
    });


    $("#ProgressImage").css({ 'display': 'none' });

    $("#login_label").click(function() {
    $(".right_div_container").animate({ height: '180px', width: '120px', opacity: 1.0 }, 400);
    });

});


function SetContainersEqualHeight() {
    var divh = document.getElementById('page_content').offsetHeight;
    document.getElementById('left_menu_bottom_filler').style.height = (divh - 395) + "px";
}

function replaceQuotes(str) {
    str = str.replace("'", "&quote");
    while (str.indexOf("'") > 1) {
        str = str.replace("'", "&quote");
    }
    return str;
}

function GetContent(pagename) {
    //alert(document.getElementById("CurrentPage").value);
    current_content = pagename;
    $(page_name_hidden_field).val(current_content);
    //$("#ProgressImage").css({ 'display': '' });
    $.ajax({
        type: "POST",
        url: "Default.aspx/GetPageContent",
        contentType: "application/json; charset=utf-8",
        data: "{'pagename': '" + pagename + "'}",
        dataType: "json",
        success: ShowContent,
        error: GetContentFailed
    });
}
function ShowContent(result) {
    $("#ProgressImage").css({ 'display': 'none' });
    //fade in new div
    //$(dynamicContentDiv).fadeOut("1", function() {
    
    $(dynamicContentDiv).html('');
    $(dynamicContentDiv).html(result.d);
    // This function is called when the fadeout is done animating
    //$(dynamicContentDiv).fadeIn("1");
    //});
    SetContainersEqualHeight();
}

function GetContentFailed(result) {
    //alert(result);
    $("#ProgressImage").css({ 'display': 'none' });
    $(dynamicContentDiv).html("failed to load dynamic content");
}

function load() {

    try {

        SetContainersEqualHeight();
        document.execCommand("BackgroundImageCache", false, true);
    }
    catch (err) { }

}

function MenuIn(name) {
    //alert(name.id);
    document.getElementById(name.id).className = 'menu_over';
    document.getElementById(name.id).style.cursor = 'pointer'
}


function MenuOut(name) {
    document.getElementById(name.id).className = 'menu_out';
}

function hide_login() {
    $(".right_div_container").animate({ height: '0px', width: '120px', opacity: 1.0 }, 400);
    $(".errormessage").css("visibility", "hidden");
}
