﻿

function hidHeaderMenus() {
    $("#MyAccountInfo").hide();
    $("#MarketingToolsInfo").hide();
    $("#KeepInTouchInfo").hide();
    $("#OrdersClientsInfo").hide();
    $("#ContactAlliedInfo").hide();
    $("#publicHeaderLoginRequestService").hide();
    $("#ServiceRequest").hide();
}


$(document).ready(function() {
    hidHeaderMenus();

    $("#ServiceRequest_click").bind("mouseover", function() {
        hidHeaderMenus();
        var curPosition = $(this).position();
        $("#ServiceRequest").css("left", curPosition.left - 1);
        $("#ServiceRequest").css("top", 107);
        $("#ServiceRequest").show();
    });


    $("#ServiceRequest_click").bind("mouseout", function() {
        hidHeaderMenus();
    });

    $("#ServiceRequest").find("div").each(function() {
        $(this).hover(function() { $(this).addClass("index_Mdown_li2"); }, function() { $(this).removeClass("index_Mdown_li2"); });
    });

    /*----------------------------------------------------------------------------*/
    $("#MyAccount").bind("mouseover", function() {
        hidHeaderMenus();
        var curPosition = $(this).position();
        $("#MyAccountInfo").css("left", curPosition.left - 1);
        $("#MyAccountInfo").css("top", 107);
        $("#MyAccountInfo").show();
    });
    $("#MyAccount").bind("mouseout", function() {
        hidHeaderMenus();
    });
    $("#MyAccountInfo").find("div").each(function() {
        $(this).hover(function() { $(this).addClass("index_Mdown_li2"); }, function() { $(this).removeClass("index_Mdown_li2"); });
    });

    /*----------------------------------------------------------------------------*/
    $("#MarketingTools").bind("mouseover", function() {
        hidHeaderMenus();
        var curPosition = $(this).position();
        $("#MarketingToolsInfo").css("left", curPosition.left - 1);
        $("#MarketingToolsInfo").css("top", 107);
        $("#MarketingToolsInfo").show();
    });
    $("#MarketingTools").bind("mouseout", function() {
        hidHeaderMenus();
    });
    $("#MarketingToolsInfo").find("div").each(function() {
        $(this).hover(function() { $(this).addClass("index_Mdown_li2"); }, function() { $(this).removeClass("index_Mdown_li2"); });
    });

    /*------------------------------------------------------------------------------------*/

    $("#KeepInTouch").bind("mouseover", function() {
        hidHeaderMenus();
        var curPosition = $(this).position();
        $("#KeepInTouchInfo").css("left", curPosition.left - 1);
        $("#KeepInTouchInfo").css("top", 107);
        $("#KeepInTouchInfo").show();
    });
    $("#KeepInTouch").bind("mouseout", function() {
        hidHeaderMenus();
    });
    $("#KeepInTouchInfo").find("div").each(function() {
        $(this).hover(function() { $(this).addClass("index_Mdown_li2"); }, function() { $(this).removeClass("index_Mdown_li2"); });
    });

    /*----------------------------------------------------------------------------------*/

    $("#OrdersClients").bind("mouseover", function() {
        hidHeaderMenus();
        var curPosition = $(this).position();
        $("#OrdersClientsInfo").css("left", curPosition.left - 1);
        $("#OrdersClientsInfo").css("top", 107);
        $("#OrdersClientsInfo").bgiframe();
        $("#OrdersClientsInfo").show().css({ "position": "absolute" });

    });
    $("#OrdersClients").bind("mouseout", function() {
        hidHeaderMenus();
    });

    $("#OrdersClientsInfo").find("div").each(function() {
        $(this).hover(function() { $(this).addClass("index_Mdown_li2"); }, function() { $(this).removeClass("index_Mdown_li2"); });
    });

    $("#ContactAllied").bind("mouseover", function() {
        hidHeaderMenus();
        var curPosition = $(this).position();
        $("#ContactAlliedInfo").css("left", curPosition.left - 1);
        $("#ContactAlliedInfo").css("top", 107);
        $("#ContactAlliedInfo").bgiframe();
        $("#ContactAlliedInfo").show().css({ "position": "absolute" });
    });
    $("#ContactAllied").bind("mouseout", function() {
        hidHeaderMenus();
    });
    $("#ContactAlliedInfo").find("div").each(function() {
        $(this).hover(function() { $(this).addClass("index_Mdown_li2"); }, function() { $(this).removeClass("index_Mdown_li2"); });
    });


    /*----------------------------------------------------------*/
    $("#publicHeaderOrderWarrantyHolderCtl").bind("click", function(event) {
        event.stopPropagation();
        hidHeaderMenus();
        var curPosition = $(this).position();
        $("#publicHeaderLoginRequestService").css("left", curPosition.left - 152);
        $("#publicHeaderLoginRequestService").css("top", 107);
        $("#publicHeaderLoginRequestService").show();
    });

    //disable event bubble to document click event handler
    $("#publicHeaderLoginRequestService").click(function(event) {
        event.stopPropagation();
    })

    $("#publicHeaderOrderRenew").click(function(event) {
        event.stopPropagation();
    })

    //set to hide all header menus after click
    $(document).bind("click", function() {
        hidHeaderMenus();
    });
});


function SetBackGround() {
    var url = document.URL.toLowerCase();
    if (url.indexOf("ProfileEdit.aspx".toLowerCase()) >= 0 || url.indexOf("UploadImg.aspx".toLowerCase()) >= 0 || url.indexOf("ServiceNotice.aspx".toLowerCase()) >= 0) {
        $("#MyAccount").removeClass("").addClass("Menu_tex_2_bj");
    } //profileedit.aspx
    //    else if (url.indexOf("OrderPlace.aspx".toLowerCase()) >= 0) {
    //        $("#PlaceAnOrder").removeClass("").addClass("Menu_tex_2_bj");
    //    }
    else if (url.indexOf("HomeOwnerGuide.aspx".toLowerCase()) >= 0 || url.indexOf("HomeOwnerGuideWebsite.aspx".toLowerCase()) >= 0 || url.indexOf("NewsLetter.aspx".toLowerCase()) >= 0 || url.indexOf("Postcard.aspx".toLowerCase()) >= 0) {
        $("#MarketingTools").removeClass("").addClass("Menu_tex_2_bj");
    }
    else if (url.indexOf("KeepInTouch_AnniversaryPostcards.aspx".toLowerCase()) >= 0 || url.indexOf("KeepInTouch_WelcomePostcards.aspx".toLowerCase()) >= 0 || url.indexOf("KeepInTouch_HVACTuneupPostcards.aspx".toLowerCase()) >= 0) {
        $("#KeepInTouch").removeClass("").addClass("Menu_tex_2_bj");
    }
    else if (url.indexOf("OrderPlace.aspx".toLowerCase()) >= 0 || url.indexOf("PendingOrders.aspx".toLowerCase()) >= 0 || url.indexOf("CurrentClients.aspx".toLowerCase()) >= 0 || url.indexOf("OpenSellers.aspx".toLowerCase()) >= 0 || url.indexOf("ServiceHistory.aspx".toLowerCase()) >= 0) {
        $("#OrdersClients").removeClass("").addClass("Menu_tex_2_bj");
    }
    else if (url.indexOf("SalesExecutive.aspx".toLowerCase()) >= 0 || url.indexOf("ServiceTeam.aspx".toLowerCase()) >= 0 || url.indexOf("RequestMaterials.aspx".toLowerCase()) >= 0) {
        $("#ContactAllied").removeClass("").addClass("Menu_tex_2_bj");
    }
    else if (document.URL.toLowerCase().indexOf(("ServiceRequest_Detail.aspx").toLowerCase()) >= 0 || document.URL.toLowerCase().indexOf("ServiceRequest_List.aspx".toLowerCase()) >= 0 || document.URL.toLowerCase().indexOf("ServiceRequest_Place.aspx".toLowerCase()) >= 0) {
        $("#ServiceRequest_click").removeClass("").addClass("Menu_tex_2_bj");
        $("#ServiceRequest_click>a").removeClass("").addClass("white_bold");
    }
}

function locationURL(url) {
    window.location = url;
}



























(function($) {
    $.fn.bgIframe = $.fn.bgiframe = function(s) {
        // This is only for IE6
        if ($.browser.msie && /6.0/.test(navigator.userAgent)) {
            s = $.extend({
                top: 'auto', // auto == .currentStyle.borderTopWidth
                left: 'auto', // auto == .currentStyle.borderLeftWidth
                width: 'auto', // auto == offsetWidth
                height: 'auto', // auto == offsetHeight
                opacity: true,
                src: 'javascript:false;'
            }, s || {});
            var prop = function(n) { return n && n.constructor == Number ? n + 'px' : n; },
		    html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="' + s.src + '"' +
		               'style="display:block;position:absolute;z-index:-1;' +
			               (s.opacity !== false ? 'filter:Alpha(Opacity=\'0\');' : '') +
					       'top:' + (s.top == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')' : prop(s.top)) + ';' +
					       'left:' + (s.left == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')' : prop(s.left)) + ';' +
					       'width:' + (s.width == 'auto' ? 'expression(this.parentNode.offsetWidth+\'px\')' : prop(s.width)) + ';' +
					       'height:' + (s.height == 'auto' ? 'expression(this.parentNode.offsetHeight+\'px\')' : prop(s.height)) + ';' +
					'"/>';
            return this.each(function() {
                if ($('> iframe.bgiframe', this).length == 0)
                    this.insertBefore(document.createElement(html), this.firstChild);
            });
        }
        return this;
    };

})(jQuery);
