﻿//------------------------------登陆-----------------------------------//
function userLogin() {
    if (confirm("您尚未登陆，是否登陆？")) {
        OpenDiv2(ContentPanel1, '250px', '180px');
    }
}
//-----------------------------控制登陆层------------------------------------//
//克隆对象方式
var isdisplay;
var fg;
function OpenDiv2(o, divWight, divHegth, top) {
    o.style.display = 'block'
    if (isdisplay) return;
    var iw = divWight.indexOf('%');
    var ih = divHegth.indexOf('%');
    if (iw > 0) {
        divWight = (document.documentElement.clientWidth / 100 * parseInt(divWight)) - 5;
    }
    if (ih > 0) {
        divHegth = (document.documentElement.clientHeight / 100 * parseInt(divHegth)) - 5;
    }
    fg = document.getElementById("divfg");
    if (fg == null || fg == undefined) {
        fg = GetDiv();
    }
    fg.style.display = "block";
    fg.style.height = document.documentElement.scrollHeight;
    var obj = o;
    var conentdiv = obj.document.getElementById(o.id + 'ContentDIV');
    conentdiv.style.height = (parseInt(divHegth) - 50) + "px";
    obj.style.position = "absolute";
    obj.style.background = "#FFFFFF";
    obj.style.display = "none";
    obj.style.top = "50%";
    if (top != null) {
        obj.style.top = top;
    }
    obj.style.left = "50%";
    obj.style.width = divWight;
    obj.style.height = divHegth;
    var w = parseInt(divWight);
    obj.style.marginLeft = '-' + (w / 2) + "px";
    obj.style.marginTop = '-' + (parseInt(divHegth) / 2) + "px";
    obj.style.textAlign = "center";
    obj.style.zIndex = "9999";
    var titlieTable = obj.document.getElementById(o.id + 'tooltip');
    if (titlieTable != null && titlieTable != undefined) {
        titlieTable.style.display = 'none';
    }
    var TrContent = obj.document.getElementById(o.id + 'Content'); //将内容显示
    if (TrContent != null && TrContent != undefined) {
        TrContent.style.display = 'block';
    }
    obj.onmousemove = "return;";
    obj.onmousemout = "return;";
    var Contenttitle = obj.document.getElementById(o.id + 'title');
    Contenttitle.style.cursor = "hand";
    isdisplay = true;
    Contenttitle.onclick = function() {
        isdisplay = false;
        $("#" + obj.id).hide(1000);
        setTimeout(function() {
            fg.style.display = "none";
        }, 1000);
    }
    $("#" + obj.id).show("slow");
}
//------------------------------登陆成功后-----------------------------------//
function loginUpLoad() {
    $('#' + ContentPanel1.id).hide(1000);
    setTimeout(function() {
        fg.style.display = 'none';
        javascript: __doPostBack('LinkButton3', '');
    }, 1000);
}
//----------------------------登陆按钮事件[用户登陆]-------------------------------------//
function butLogin() {
    var dtn = document.getElementById("txbDTN");
    var pwd = document.getElementById("txbPwd");
    if (dtn.value == '') {
        alert("请输入DTN号");
        return false;
    }
    if (pwd.value == '') {
        alert("请输入密码");
        return false;
    }
    $.ajax({
        type: 'GET',
        url: 'IndexPage.ashx',
        datatype: 'text',
        data: 'RequestType=UserLogin&Dtn=' + dtn.value + "&Pwd=" + pwd.value,
        cache: false,
        beforeSend: function() { },
        success: function(msg) {
            if (msg != '') {
                alert(msg);
                return false;
            }
            $(ContentPanel1).hide(1000);
            setTimeout(function() {
                fg.style.display = 'none';
                javascript: __doPostBack('LinkButton3', '');
            }, 1000);
        },
        error: function() {
            alert("操作出现异常,请再次尝试!");
        }
    });
}
//-------------------------------商品类型滚动----------------------------------//
var regionLeft = 0;
var productTypeLeft = 0;
function marquees(conId, orient) {
    if (conId == 'region') {
        regionLeft = orient == "left" ? regionLeft -= 200 : regionLeft += 200;
        regionLeft = regionLeft < 0 ? 0 : regionLeft;
        $("#" + conId).animate({ scrollLeft: regionLeft }, 300);
    }
    else {
        productTypeLeft = orient == "left" ? productTypeLeft -= 200 : productTypeLeft += 200;
        productTypeLeft = productTypeLeft < 0 ? 0 : productTypeLeft;
        $("#" + conId).animate({ scrollLeft: productTypeLeft }, 300);
    }

}
//-------------------------------收藏成功后提示----------------------------------//
function reault(r) {
    if (r) {
        alert("收藏成功！");
    } else {
        alert("收藏失败！");
    }
}
//-------------------------------商家、商品、广告排行绑定事件----------------------------------//
$(function() {
    //商家排行转换
    $("#Ranking0 li").mouseover(function() {
        $("#Ranking0 li").removeClass("selectTag");
        $("#Ranking0>#storeDiv>div").removeClass("selectTag");
        $("#Ranking0>#storeDiv>div[id='Div" + this.lang + "']").addClass("selectTag");
        this.className = "selectTag";
    });
    //商品排行转换
    $("#Ranking1 li").mouseover(function() {
        $("#Ranking1 li").removeClass("selectTag");
        $("#Ranking1>#productDiv>div").removeClass("selectTag");
        $("#Ranking1>#productDiv>div[id='productDiv" + this.lang + "']").addClass("selectTag");
        this.className = "selectTag";
    });
    //广告转换
    $("#advertise>ul[id='tags2']>li").mouseover(function() {
        $("#advertise>ul[id='tags2']>li").removeClass("selectTag");
        $("#advertise>#tagContents>div").removeClass("selectTag");
        $("#advertise>#tagContents>div[id='tagContent" + this.lang + "']").addClass("selectTag");
        this.className = "selectTag";
    });
    //商家、商品排行转换
    $("#Ranking>ul[id='storeAndProduct']>li").mouseover(function() {
        $("#Ranking>ul[id='storeAndProduct']>li").removeClass("selectTag");
        $("#Ranking>div[id^='Ranking']").css("display", "none");
        $("#Ranking>div[id='Ranking" + this.lang + "']").css("display", "block");
        this.className = "selectTag";
    });
    //保存商家排行点击率
    $("#storeDiv a").click(function() {
        PageMethods.SaveClick(this.lang, 0);
        if (this.href.lenght <= 0) return false;
    });
    $("#right>a").attr("target", "top");
    //单击顶部登陆连接标签
    $("#login").click(function() {
        ContentPanel1.style.display = "block";
        OpenDiv2(ContentPanel1, '250px', '180px');
        document.cookie
    });
    var cookie = getCookie('DisplayState');
    if (cookie == 1) {
        $(WebList).css("display", "none");
    }
})
//-------------------------------打开或关闭网站指南----------------------------------//
function openWebList(obj) {
    if (obj == 0) {
        $(WebList).css("display", "block");
//        $(WebList).show(500);
    } else {
    $(WebList).css("display", "none");
//        $(WebList).hide(500);
    }
    var expires = new Date();
    expires.setTime(expires.getTime() + 60 * 1000);
    document.cookie = 'DisplayState=' + obj + ';expires=' + expires.toGMTString();
}
//-------------------------------获取Cookie----------------------------------//
function getCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    var j = 0;
    while (i < clen) {
        j = i + alen;
        if (document.cookie.substring(i, j) == arg) {
            return getCookieVal(j);
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i === 0) {
            break;
        }
    }
    return '';
}
function getCookieVal(offset) {
    var endstr = document.cookie.indexOf(";", offset);
    if (endstr == -1) {
        endstr = document.cookie.length;
    }
    return document.cookie.substring(offset, endstr);
}