/*---------------------------------------------- cookies_oper.js  --------------------------------------------------------- */

// JavaScript Document
function getCookie(name) {
    var cookieValue = "";
    var search = name + "=";
    if (document.cookie.length > 0) {
        offset = document.cookie.indexOf(search);
        if (offset != -1) {
            offset += search.length;
            end = document.cookie.indexOf(";", offset);
            if (end == -1) end = document.cookie.length;
            cookieValue = unescape(document.cookie.substring(offset, end))
        }
    }
    return cookieValue;
}

function setCookie(cookieName, cookieValue, DayValue) {
    var expire = "";
    var day_value = 1;
    if (DayValue != null) {
        day_value = DayValue;
    }
    expire = new Date((new Date()).getTime() + day_value * 86400000);
    expire = "; expires=" + expire.toGMTString();
    document.cookie = cookieName + "=" + escape(cookieValue) + ";path=/" + expire;
}

function delCookie(cookieName) {
    var expire = "";
    expire = new Date((new Date()).getTime() - 1);
    expire = "; expires=" + expire.toGMTString();
    document.cookie = cookieName + "=" + escape("") + ";path=/" + expire;
    //path=/
}

/*--hoverIntent--*/
(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 p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget; while (p && p != this) { try { p = p.parentNode; } catch (e) { p = this; } } if (p == this) { return false; } var ev = jQuery.extend({}, e); var ob = this; if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } if (e.type == "mouseover") { 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.mouseover(handleHover).mouseout(handleHover); }; })(jQuery);
/*---------------------------------------------- site_nav.js  --------------------------------------------------------- */

/***This File forbidden relative  path，please use variable 'window.www'***/
if (!window.www) window.www = "";

$(document).ready(function() {
    if ($('#Head').html() == "") {
        $.ajax({
            async: true
            , cache: false
            , type: "GET"
            , dataType: "text"
            /*由于分站会跨域，因此此路径必须为相对路径,在分站建立该文件镜像*/
            , url: "/public/common.aspx"
            , success: function(html) {
                var element = document.createElement("DIV");
                element.innerHTML = html;
                var $element = $(element);
                var $head = $element.find("#Head");
                $('#Head').html($head.children());
                $('#footer').html($element.find("#bottom"));
                setLoginInfo(); renderMenu();
            }
            , error: function(data) { alert(data); }
        });
    } else {
        setLoginInfo();
        renderMenu();
    }
});


function renderMenu(e) {
    $("#floor_nav ul.floors li").each(function(i) {

        menu = $('#sub_' + this.id);
        $('#sub_' + this.id).css("width", "0px")
        menu.css("left", "0px");
        menu.css("top", "31px");
        $(this).dropdown({ menu: menu, type: 'simple' });
    });
}

(function($) {
    $.fn.dropdown = function(opt) {

        var defaults = {
            speed: 0,
            delay: 50,
            type: 'slide',
            transIn: { opacity: 'show' },
            transOut: { opacity: 'hide' }
        };

        var options = $.extend(defaults, opt);

        var menu = $(options.menu);
        var speed = options.speed;
        var delay = options.delay;
        var type = options.type;
        var transIn = options.transIn;
        var transOut = options.transOut;

        var menuOver = false;
        var buttonOver = false;

        //find the top level menu image
        var topLevelMenuImage = $(this).find('a img')[0];

        //find top level anchor
        var topLevelAnchor = $(this).find('a')[0];

        var topNavItem = "";

        var topNavConfig = {
            sensitivity: 9, // number = sensitivity threshold (must be 1 or higher)    
            interval: 0, // number = milliseconds for onMouseOver polling interval    
            over: topNavOver, // function = onMouseOver callback (REQUIRED)    
            timeout: 200, // number = milliseconds delay before onMouseOut    
            out: topNavOut // function = onMouseOut callback (REQUIRED)    
        };

        var subNavConfig = {
            sensitivity: 99999, // number = sensitivity threshold (must be 1 or higher)    
            interval: 0, // number = milliseconds for onMouseOver polling interval    
            over: subNavOver, // function = onMouseOver callback (REQUIRED)
            timeout: 200, // number = milliseconds delay before onMouseOut    
            out: subNavOut // function = onMouseOut callback (REQUIRED)    
        };

        $(menu).hide();
        $(this).hoverIntent(topNavConfig);
        $(menu).hoverIntent(subNavConfig);

        function topNavOver() {
            $(".menu").hide();
            $(topLevelAnchor).parent().siblings("li").children("a.active").removeClass("active");
            if (menu.is(':animated')) { return };
            if (parseInt(menu.css("left")) < 0)
                menu.css("left", "1px");
            //alert(menu.css("left"));
            switch (type) {
                case 'slide':
                    $(menu).slideDown(speed);
                    break;
                case 'fade':
                    $(menu).fadeIn(speed);
                    break;
                case 'simple':
                    $(menu).show();
                    break;
                case 'blind':
                    $(menu).show("blind", { direction: "vertical" }, 200);
                    break;
                case 'custom':
                    $(menu).animate(transIn, speed)
            }
            buttonOver = true;
            $(topLevelAnchor).addClass("active");
        }

        function topNavOut() {
            buttonOver = false;
            setTimeout(function() {
                if (menuOver == false && buttonOver == false) {
                    switch (type) {
                        case 'slide':
                            $(menu).slideUp(speed);
                            break;
                        case 'fade':
                            $(menu).fadeOut(speed);
                            break;
                        case 'simple':
                            $(menu).hide();
                            break;
                        case 'blind':
                            $(menu).hide("blind", { direction: "vertical" }, 200);
                            break;
                        case 'custom':
                            $(menu).animate(transOut, speed)
                    }
                    $(topLevelAnchor).removeClass("active");
                }
            }, delay);

        }

        function subNavOver() {
            menuOver = true;
            $(topLevelAnchor).addClass("active");
        }

        function subNavOut() {
            menuOver = false;
            setTimeout(function() {
                if (menuOver == false && buttonOver == false) {
                    switch (type) {
                        case 'slide':
                            $(menu).slideUp(speed);
                            break;
                        case 'fade':
                            $(menu).fadeOut(speed);
                            break;
                        case 'simple':
                            $(menu).hide();
                            break;
                        case 'custom':
                            $(menu).animate(transOut, speed)
                    }
                    $(topLevelAnchor).removeClass("active");
                }
            }, delay);
        }

    }
})

(jQuery);

/*------------------------------------------AccountManage.js -------------------------------------------*/

/*---------------------------------------- ShoppingUrl.js ----------------------------------------*/

/*--------------------------------------union_websource.js -----------------------------*/

var cgushop = document.createElement('script');
cgushop.type = 'text/javascript';
cgushop.async = true;
cgushop.src = 'websource.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(cgushop, s);