var avt_jQuery_1_5_1 = jQuery;
if (typeof(avt) == "undefined") { var avt = {}; }

avt.coreClient_1_5 = {

    $: avt_jQuery_1_5_1,

    options: {
        appPath: "",
        bRunPngFix: true
    },

    init: function (opts) {
        avt.coreClient_1_5.$.extend(this.options, opts);
        this.options.bRunPngFix && this.fixPng();
    },

    fixPng: function () {
        avt.coreClient_1_5.$(document).ready(function () {
            var IE6 = (navigator.userAgent.toLowerCase().indexOf('msie 6') != -1) && (navigator.userAgent.toLowerCase().indexOf('msie 7') == -1)
            if (IE6) { // fix PNG transparency
                var arVersion = navigator.appVersion.split("MSIE")
                var version = parseFloat(arVersion[1])
                if ((version >= 5.5) && (document.body.filters)) {
                    for (var i = 0; i < document.images.length; i++) {
                        var img = document.images[i]
                        var imgName = img.src.toUpperCase()
                        if (avt.coreClient_1_5.$(img).hasClass("pngFix") && imgName.substring(imgName.length - 3, imgName.length) == "PNG") {
                            var imgID = (img.id) ? "id='" + img.id + "' " : ""
                            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
                            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
                            var imgStyle = "display:inline-block;" + img.style.cssText
                            if (img.align == "left") imgStyle = "float:left;" + imgStyle
                            if (img.align == "right") imgStyle = "float:right;" + imgStyle
                            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
                            var strNewHTML = "<span " + imgID + imgClass + imgTitle
                            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
                            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
                            img.outerHTML = strNewHTML
                            i = i - 1
                        }
                    }
                }
            }
        });
    }
}


avt.nxp = {
    $$ : avt.coreClient_1_5, 
    $  : avt_jQuery_1_5_1
}

avt.navxp = {
    core : { $ : avt_jQuery_1_5_1 }
}

if (typeof(NavXp) == "undefined")
    NavXp = {};

NavXp.core = {
    appPath: "",

    init: function (appPath) {
        this.appPath = appPath;
        avt.coreClient_1_5.init({ appPath: appPath, bRunPngFix: true });

        avt.nxp.$(document).ready(function () {
            avt.nxp.$(".NavXpRoot").each(function () {

                var root = avt.nxp.$(this);
                for (var lvl = 0; lvl < 5; lvl++) {
                    var fontFamily = root.find(".nxp-lvl" + lvl + ":first").css("font-family");

                    if (avtNavXpCufonFonts[fontFamily]) {

                        // clone nodes to allow for hover effects
                        root.find(".nxp-lvl" + lvl + "").each(function () {
                            avt.nxp.$(this).after(avt.nxp.$(this).clone());
                            avt.nxp.$(this).next().addClass("nxp-lvl" + lvl + "-hover nxp-hover nxp-init-hide");
                            avt.nxp.$(this).addClass("nxp-normal");
                        });

                        root.find(".nxp-normal").hover(
	                        function () {
	                            root.find(".nxp-hover").hide().prev().show();
	                            avt.nxp.$(this).hide()
			                        .next().removeClass("nxp-init-hide").show();
	                        },
	                        function () { }
                        );

                        root.find(".nxp-hover").hover(
	                        function () { },
	                        function () {
	                            avt.nxp.$(this).hide()
			                        .prev().show();
	                        }
                        );

                        // apply cufon
                        Cufon.replace(root.find('.nxp-normal'), { fontFamily: fontFamily });
                        Cufon.replace(root.find('.nxp-hover'), { fontFamily: fontFamily });
                    }
                }
            });
        });
    },

    includeJs: function (f) {
        var fileref = document.createElement('script')
        fileref.setAttribute("type", "text/javascript")
        fileref.setAttribute("src", f)
        document.getElementsByTagName("head")[0].appendChild(fileref);
    },

    appendStyle: function (css) {
        var styleref = document.createElement('style');
        styleref.setAttribute("type", "text/css");
        styleref.innerHTML = css;
        document.getElementsByTagName("head")[0].appendChild(styleref);
    }
    //,

    //    cufonLoaded: false,

    //    checkCufon: function (root, cl) {
    //        return;
    //        Cufon.replace('a.nxp-lvl0', { fontFamily: "Kingthings Trypewriter" });

    //        root = avt.nxp.$(root);
    //        for (var i = 0; i < cl.length; i++) {
    //            var font = root.find("." + cl[i] + ":first").css("font-family");

    //            if (NavXp.cufonFonts[font]) {

    //                // include cufon
    //                if (!NavXp.core.cufonLoaded) {
    //                    //NavXp.core.includeJs("/DesktopModules/NavXp/js/fonts/cufon/cufon-yui.js");
    //                    NavXp.core.cufonLoaded = true;
    //                }
    //                // inlude font
    //                //NavXp.core.includeJs("/DesktopModules/NavXp/Config/cufon/kingthings-trypewriter.cufonfonts.js");

    //                setTimeout(function () {
    //                    root.find("." + cl[i]).each(function () {
    //                        avt.nxp.$(this).after($(this).clone().addClass("npx-hover"));
    //                        avt.nxp.$(this).addClass("nxp-normal");
    //                    });

    //                    root.find(".npx-normal").hover(
    //						function () {
    //						    root.find(".nxp-hover").hide().prev().show();
    //						    avt.nxp.$(this).hide()
    //								.next().show();
    //						},
    //						function () { }
    //					);

    //                    $(".nxp-hover").hover(
    //						function () { },
    //						function () {
    //						    avt.nxp.$(this).hide()
    //								.prev().show();
    //						}
    //					);
    //                    alert(font);
    //                    Cufon.replace('a', { fontFamily: "Kingthings Trypewriter" }); // Works without a selector engine
    //                    //Cufon.replace(root.find('.nxp-hover'), { fontFamily: 'Kingthings Italique', color: "red"}); // Works without a selector engine
    //                }, 2000);

    //            }
    //        }
    //    }
};
; NavXp.core.init('/DesktopModules/NavXp');/**
* hoverIntent r6 // 2011.02.26 // avt_jQuery_1_5_1 1.5.1+
* <http://cherne.net/brian/resources/avt_jQuery_1_5_1.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne brian(at)cherne(dot)net
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=avt_jQuery_1_5_1.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(avt_jQuery_1_5_1);
if (!NavXp) { var NavXp = {}; }
if (!NavXp.skin) { NavXp.skin = {}; }
if (!NavXp.skins) { NavXp.skins = {}; }

NavXp.skins["HorizontalDropdowns/Windows Standard"] = {
    init : function() {
       
    },
    
    show : function(item, panel) {
    
        if (panel[0] && !panel[0].calcW && avt.nxp.$.browser.msie && avt.nxp.$.browser.version < 8) {
            setTimeout(function() {
                // calculate some widths
                _maxWidth = 0;
                panel.children(".itemLN").each(function() {
                    if (avt.nxp.$(this).width() > _maxWidth) {
                        _maxWidth = avt.nxp.$(this).width();
                    }
                });
                panel.children(".itemLN").css("width", _maxWidth);
                panel[0].calcW = true;
            }, 1);
        }
        
        // let us do some caching
        if (!item.root) { 
            item.root = item.parents(".NavXpRoot:first");
            panel.length && panel.css("top", panel.parents(".navxp_HDD_WindowsStandard:first").position().top + item.outerHeight() + 2 + "px");
        }
        if (!item.parentPanels) { item.parentPanels = item.parents(".child_container"); }
        if (!item.otherPanels) { item.otherPanels = item.root.find(".child_container").not(item.parentPanels).not(panel); }
        if (!item.rootItem) { item.rootItem = item.parentPanels.length > 0 ? item.parentPanels.filter(":last").parent().next("a:first") : item; }
        if (!item.parentItems) { item.parentItems = item.parentPanels.prev("a"); }
        if (!item.otherItems) { item.otherItems = item.root.find(".itemLN:visible").not(item.parentItems); }
        

        // prevent parents from hiding
        item.parentPanels.each( function() {
            clearTimeout(this["timeout"]);
        });

        // prevent this popup from hiding
        if (panel.get(0)) {
            if (item.parentPanels.length > 0) {
				if (item.offset().left + item.outerWidth() + panel.outerWidth() > avt.nxp.$(document).width()) {
					panel.css("left", item.position().left - panel.outerWidth());
				} else {
					panel.css("left", item.position().left + item.outerWidth());
				}
                
                panel.css("top", item.position().top);
            }
            clearTimeout(panel.get(0)["timeout"]);
            panel.css("z-index", "201");
        }
        
        // hide the rest of the popups
        item.otherPanels.filter(":visible").css("z-index", "200").stop(true,true).slideUp("fast");
        
        // keep all parent items marked as selected
        item.parentItems.addClass("selChild");

        // and unselect the rest
        item.otherItems.removeClass("selChild");
        item.root.find(".itemL0Lower").not(item.rootItem).removeClass("itemL0Sel");
        panel.length && item.rootItem.addClass("itemL0Sel");
        
        panel.find(".child_container").show().hide(); // solves IE6 bug
        
        panel.stop(true,true).slideDown("fast", function() {
            
        });
        
        
    },

    hide : function(item, panel) {

        
        // let us do some caching
        if (!item.root) { item.root = item.parents(".NavXpRoot:first"); }
        if (!item.parentPanels) { item.parentPanels = item.parents(".child_container"); }
        if (!item.otherPanels) { item.otherPanels = item.root.find(".child_container").not(item.parentPanels).not(panel); }
        if (!item.rootItem) { item.rootItem = item.parentPanels.length > 0 ? item.parentPanels.filter(":last").parent().next("a:first") : item; }
        if (!item.parentItems) { item.parentItems = item.parentPanels.prev("a"); }
        if (!item.otherItems) { item.otherItems = item.root.find(".itemLN:visible").not(item.parentItems); }

        //item.otherItems.removeClass("selChild");
       // item.removeClass("selChild");
        //item.parentItems.removeClass("selChild");
        
        // let's hide all popups
        var timer = 500;
        var iCall = 0;
        if (item.parentPanels.length == 0) {
            if (panel.get(0)) {
                panel.get(0)["timeout"] = setTimeout(function() { 
                        panel.stop(true,true).slideUp("fast"); 
                        item.rootItem.removeClass("itemL0Sel");
                    }, timer);
            }
        } else {
            for (var i = item.parentPanels.length - 1; i >= 0 ; i--, timer += 200) {
                item.parentPanels.get(i)["timeout"] = setTimeout(function() { 
                    item.parentPanels.eq(iCall).stop(true,true).slideUp("fast"); 
                    iCall++; 
                    if (iCall == item.parentPanels.length) {
                        item.rootItem.removeClass("itemL0Sel");
                    }
                }, timer);
            }
        }
    }
}

if (typeof Sys != "undefined" && typeof Sys.Application != "undefined") {
   Sys.Application.notifyScriptLoaded();
} avt.nxp.$(document).ready(function() { if (NavXp.skins['HorizontalDropdowns/Windows Standard']) NavXp.skins['HorizontalDropdowns/Windows Standard'].init(); });avtNavXpCufonFonts={"FontleroyBrown":"\/DesktopModules\/NavXp\/fonts\/cufon\/fontleroybrown.cufonfonts.js","Indubitably":"\/DesktopModules\/NavXp\/fonts\/cufon\/indubitably.cufonfonts.js","Kingthings Trypewriter":"\/DesktopModules\/NavXp\/fonts\/cufon\/kingthings-trypewriter.cufonfonts.js","MailRayStuff-Regular":"\/DesktopModules\/NavXp\/fonts\/cufon\/mail-ray-stuff.cufonfonts.js","Olde English Regular":"\/DesktopModules\/NavXp\/fonts\/cufon\/olde-english.cufonfonts.js"};
