﻿// JScript 文件
var act;
var cat;
var xmlHttp;
function createXMLHttpRequest()
{
    if(window.ActiveXObject)
    {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if(window.XMLHttpRequest)
    {
        xmlHttp = new XMLHttpRequest();
    }
}


function getHello2()
{
    document.getElementById("piao_03_id").style.display = 'block';
    createXMLHttpRequest();
    var url= "Ajax/Ajax_Say.ashx";//
    if(url!="")
    {
    xmlHttp.open("GET",url,true);
    xmlHttp.onreadystatechange=Result_say2;
    xmlHttp.send(null);
    }
}
function Result_say2()
{
    if(xmlHttp.readyState==4)
    {
        if(xmlHttp.status==200)//Distric
        {
            var Text=xmlHttp.responseText;
            document.getElementById("PiaoFuWu1_Say").innerHTML = Text;
            LoadX();
        }
    }
}
function outHello2()
{
    document.getElementById("piao_03_id").style.display = 'none';
    document.getElementById("PiaoFuWu1_Say").innerHTML = "";
    LoadX();
}

function PiaoFuMessage()
{
    createXMLHttpRequest();
    var url= "Ajax/Ajax_PiaoFuMessage.ashx";//
    if(url!="")
    {
    xmlHttp.open("POST",url,true);
    xmlHttp.onreadystatechange=Result_PiaoFuMessage;
    xmlHttp.send(null);
    }
}
function fapiao11()
{
   
    
    createXMLHttpRequest();
    if(document.getElementById("fapiao").checked== true)
    {
        var url= "Ajax/Ajax_fapiao.ashx?fapiao=1";//
        document.getElementById("invoiceDiv").style.display = 'block';
    }
    else
    {
        var url= "Ajax/Ajax_fapiao.ashx?fapiao=2";//
        document.getElementById("invoiceDiv").style.display = 'none';
    }
    if(url!="")
    {
    xmlHttp.open("POST",url,true);
    xmlHttp.onreadystatechange=Result_fapiao;
    xmlHttp.send(null);
    }
}
function Result_fapiao()
{
    if(xmlHttp.readyState==4)
    {
        if(xmlHttp.status==200)//Distric
        {
        }
    }
}

function Result_PiaoFuMessage()
{
    if(xmlHttp.readyState==4)
    {
            if(xmlHttp.status==200)//Distric
            {
                var xmlHttpRequestText=xmlHttp.responseText;
                if("Exception Shopping Procduct Count More 9"==xmlHttpRequestText)
                {
                    alert("If you buy the some item more than 10, please call the customer service center at 1-(877)-933-5525");
                    return;
                }
//                var tt = xmlHttpRequestText.split("&&");
//                var UserName = tt[0];
//                if(UserName != "_")
//                {
//                    var kk = document.getElementById("PiaoFuWu1_UserName");
//                    kk.innerHTML = UserName;
//                }
//                var yifuMessage = tt[1];
//                var message = yifuMessage.substring(0,yifuMessage.indexOf("|",0));
//                var message_1 =yifuMessage.substring(yifuMessage.indexOf("|",0)+1,yifuMessage.length);
//                var mycartTable = document.getElementById("PiaoFuWu1_MyCart");

//                mycartTable.innerHTML = message; //PiaoFuWu1_number
//                var mycartTable_1 = document.getElementById("PiaoFuWu1_number");
//                if(!isNaN(message_1))
//                {
//                    mycartTable_1.innerHTML = "共" + message_1 + "件产品";
//                }
//                else
//                {
//                    alert(message_1);
//                }
//                getHello2();
//                LoadX();
            }
    }
}
function login()
{
    createXMLHttpRequest();
    if(document.getElementById("fangda_bian")!=null)
    {
        close_div_3();
    }
    var zhanghao = document.getElementById("Login_Zhuce1_dm_dl").value;
    var pass = document.getElementById("Login_Zhuce1_dm_mm").value;
    var url= "Ajax/Ajax_Login2.ashx?p1="+zhanghao+"&p2="+pass+"";
    if(url!="")
    {
    xmlHttp.open("GET",url,true);
    xmlHttp.onreadystatechange=Result_Login;
    xmlHttp.send(null);
    }
}
function Result_Login()
{
    if(xmlHttp.readyState==4)
    {
        if(xmlHttp.status==200)//Distric
        {
            var Text=xmlHttp.responseText;
            if(Text == "true")
            {
                PiaoFuMessage();
                close_Alldiv();
                location.replace('paying2.aspx'); 
            }
            else
            {
                var tmp=Text.split("|");
                if(tmp[0]!="false")
                {
                    
                    $("#Login_Zhuce1_dm_mm").val("");
                    $("#Login_Zhuce1_dm_dl").select();
                    alert("Unknown error");
                    return;
                }
                else
                {
                    $("#Login_Zhuce1_dm_mm").val("");
                    $("#Login_Zhuce1_dm_dl").select();
                    alert("Account number is incorrect, please re-enter.");
                    return;
                }
            }
        }
    }
}

function beforeRegister()
{
    var lbclientid="Login_Zhuce1_lbMagazine";
    var txtclientid="Login_Zhuce1_txtMagazineID";
    
    var magazineid=$("#"+txtclientid).val();
    if(magazineid==""||magazineid==null)
    {
        govipcard();
    }
    else
    {
         $.ajax({
        type:"GET",
        cache:false,
        async: false,
        url:"Ajax/CheckMaganzineNumber.ashx?MagazineID="+magazineid,
        success:function(msg){rtnbeforeRegister(msg);},
        error:function(){alert("occur error")}
        });
    }
}

function rtnbeforeRegister(msg)
{
    if(msg=="1")
    {
        govipcard();
    }
    else
    {
        alert("Picture number is incorrect, cannot be entered.")
    }
}

function govipcard()
{
    var lbtigvipcardid="Login_Zhuce1_Msg_vipcard";
    var txtvipcardid="Login_Zhuce1_txtVipCard";
    var vipcard=$("#"+txtvipcardid).val();
    vipcard=$.trim(vipcard);
    if(vipcard.length>0)
    {
        $.ajax({
            type:"GET",
            cache:false,
            async:false,
            url:"Ajax/checkvipcard.ashx?vipcardid="+vipcard,
            success:function(msg){rtnbeforeRegister1(msg);},
            error:function(){alert("occur error");}
        });
    }
    else
    {
        register();
    }   
}

function rtnbeforeRegister1(msg)
{
    if(msg=="1")
    {
        register();
    }
    else
    {
        alert("VIP card number is incorrect, cannot be entered")
    }
}

function register()
{
    createXMLHttpRequest();
    validateAnymore();
    var zhanghao = document.getElementById("Login_Zhuce1_zc_01").value;
    var pass = document.getElementById("Login_Zhuce1_zc_03").value;
    //var shouji = document.getElementById("Login_Zhuce1_zc_04").value;
    //var email = document.getElementById("Login_Zhuce1_zc_05").value;
    //var name = document.getElementById("Login_Zhuce1_zc_06").value;
    //var yanzhengma = document.getElementById("Login_Zhuce1_yanzhengma").value;
    var yanzhengma ="";
    //var hid_Username = document.getElementById("Login_Zhuce1_hid_Username").value;
    //var hid_mobileTel = document.getElementById("Login_Zhuce1_txtVipCard").value;
    //var hid_email = document.getElementById("Login_Zhuce1_hid_email").value;
    //var hid_Pass = document.getElementById("Login_Zhuce1_hid_Pass").value;
    //var hid_name = document.getElementById("Login_Zhuce1_hid_name").value;
    //var proname=$("#Login_Zhuce1_txtMagazineID").val()
    //var url= "Ajax/Ajax_Register2.ashx?p1="+zhanghao+"&p2="+pass+"&p3="+shouji+"&p4="+email+"&p5="+escape(name)+"&p6="+yanzhengma+"&p7="+hid_Username+"&p8="+hid_mobileTel+"&p9="+hid_email+"&p10="+hid_Pass+"&p11="+hid_name;
    var url= "Ajax/Ajax_Register2.ashx?p1="+zhanghao+"&p2="+pass+"&p6="+yanzhengma;

    if(url!="")
    {
    xmlHttp.open("GET",url,true);
    xmlHttp.onreadystatechange=Result_Login;
    xmlHttp.send(null);
    }
}
function Result_Register()
{
    if(xmlHttp.readyState==4)
    {
        if(xmlHttp.status==200)//Distric
        {
            var Text=xmlHttp.responseText;
            if(Text == "true")
            {
                PiaoFuMessage();
                close_Alldiv();
                location.replace('paying2.aspx');
            }
            else
            {
                alert("Registration is failed, the information you enter is incorrect. ");
            }
        }
    }
}
/*
关闭层
*/
function close_div_1(p1)
{
    if(document.getElementById("fangda_bian")!=null)
    {
        open_div_3();
    }
    var bgObj=document.getElementById("bgDiv");
    var obj  = document.getElementById(p1);
    bgObj.style.display  = "none";
    obj.style.display  = "none";
    var alldivTags=document.getElementById("yincang");
    if(alldivTags != null)
    {
            alldivTags.style.display='block';
    }
    try{
    document.getElementById("chima").style.visibility="visible";
    document.getElementById("ddl_proCount").style.visibility="visible";
    if(isKuZi)
    {
      document.getElementById("kuchang").style.visibility="visible";
    }
    }catch(Exception){}
    
}
function close_Alldiv()
{
    if(document.getElementById("fangda_bian")!=null)
    {
        open_div_3();
    }
    var bgObj = document.getElementById("bgDiv");
    var obj1  = document.getElementById("pop1");
    var obj2  = document.getElementById("pop2");
    var obj3  = document.getElementById("pop3");
    if(bgObj)
    {
    bgObj.style.display  = "none";
    }
    if(obj1)
    {
    obj1.style.display  = "none";
    }
    if(obj2)
    {
    obj2.style.display  = "none";
    }
    if(obj3)
    {
    obj3.style.display  = "none";
    }
    var alldivTags=document.getElementById("yincang");
    if(alldivTags != null)
    {
            alldivTags.style.display='block';
    }
}
function close_Alldiv2()
{
    var bgObj = document.getElementById("bgDiv");
    var obj1  = document.getElementById("pop1");
    var obj2  = document.getElementById("pop2");
    var obj3  = document.getElementById("pop3");
    bgObj.style.display  = "none";
    obj1.style.display  = "none";
    obj2.style.display  = "none";
    obj3.style.display  = "none";
    
    var alldivTags=document.getElementById("yincang");
    if(alldivTags != null)
    {
            alldivTags.style.display='block';
    }
    
}
/*
渐变效果
*/
function over(s,wMax,hMax)
{
    var obj=document.getElementById(s);
    var h = parseInt(obj.offsetHeight);
    var w = parseInt(obj.offsetWidth);
    if (h < hMax && w < wMax)
    {
        obj.style.height = (h + 2)+"px";
        obj.style.width = (w + 2)+"px";
        clearTimeout(act);
        act = setTimeout("over('"+s+"',"+wMax+","+hMax+")", 10);
    }
}
function out(s)
{
    var obj=document.getElementById(s);
    var h = parseInt(obj.offsetHeight);
    var w = parseInt(obj.offsetWidth);
    if (h > 0 && w > 0)
    {
        obj.style.height = (h - 2)+"px";
        obj.style.width = (w - 2)+"px";
        clearTimeout(cat);
        cat = setTimeout("out('"+s+"')", 10);
    }
    else
    {
        document.getElementById("pop1").style.display = "none";
    }
}
/*
窗体参数
*/
function getPosition() 
{
    var top    = document.documentElement.scrollTop;
    var left   = document.documentElement.scrollLeft;
    var height = document.documentElement.clientHeight;
    var width  = document.documentElement.clientWidth;
    return {top:top,left:left,height:height,width:width};
}
function sizeChange()
{
    var bgObj=document.getElementById("bgDiv");
    bgObj.style.width = document.body.offsetWidth;
    bgObj.style.height = document.body.offsetHeight;
    var pop = document.getElementById("pop1");
    pop.style.top  = (document.body.clientHeight -pop.clientHeight)/2  + "px";
    pop.style.left = (document.body.clientWidth -pop.clientWidth)/2 + "px";
    var pop2 = document.getElementById("pop2");
    pop2.style.top  = (document.body.clientHeight -pop2.clientHeight)/2  + "px";
    pop2.style.left = (document.body.clientWidth -pop2.clientWidth)/2 + "px";
    var pop3 = document.getElementById("pop3");
    pop3.style.top  = (document.body.clientHeight -pop3.clientHeight)/2  + "px";
    pop3.style.left = (document.body.clientWidth -pop3.clientWidth)/2 + "px";
}
/*
打开层
*/
function show_Pop(p1)
{
    /*
    把窗体其他控件锁死
    */
    var msgw,msgh,bordercolor;
    msgw=400;//提示窗口的宽度
    msgh=100;//提示窗口的高度
    titleheight=25 //提示窗口标题高度
    bordercolor="#336699";//提示窗口的边框颜色
    titlecolor="#99CCFF";//提示窗口的标题颜色

    var sWidth,sHeight;
    sWidth=document.body.offsetWidth;
    sHeight=document.body.offsetHeight;
    var bgObj=document.getElementById("bgDiv");
    bgObj.style.position="absolute";
    bgObj.style.display  = "block";
    bgObj.style.top="0";
    bgObj.style.background="#777";
    bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
    bgObj.style.opacity="0.6";
    bgObj.style.left="0";
    bgObj.style.width=sWidth + "px";
    bgObj.style.height=sHeight + "px";
    bgObj.style.zIndex = "10000";
			
    /*
    弹出框的宽度
    */
    var width  = 500;
    var height = document.getElementById(p1).style.height;  //弹出框的高度
    //var width  = 300;  //弹出框的宽度
    //var height = 300;  //弹出框的高度
    var obj    = document.getElementById(p1);
    obj.style.display  = "block";
    obj.style.position = "absolute";
    obj.style.zIndex   = "10001";
    //滑动弹出效果
    over('pop',width,height);
    //obj.style.width    = width + "px";
    //obj.style.height   = height + "px";
    var Position = getPosition();
    leftadd = (Position.width-width)/2+100;
    topadd  = (Position.height-height)/2-100;
    obj.style.top  = (document.body.clientHeight -obj.clientHeight)/2  + "px";
    obj.style.left = (document.body.clientWidth -obj.clientWidth)/2 + "px";
    window.onscroll = function ()
                {
                    var Position   = getPosition();
                    obj.style.top  = (document.body.clientHeight -obj.clientHeight)/2  + "px";
                    obj.style.left = (document.body.clientWidth -obj.clientWidth)/2 + "px";
                };
}
/*
打开注册层
*/
function show_Pop2(p1)
{
    /*
    把窗体其他控件锁死
    */
    close_Alldiv();
    var msgw,msgh,bordercolor;
    msgw=400;//提示窗口的宽度
    msgh=100;//提示窗口的高度
    titleheight=25 //提示窗口标题高度
    bordercolor="#336699";//提示窗口的边框颜色
    titlecolor="#99CCFF";//提示窗口的标题颜色

    var sWidth,sHeight;
    sWidth=document.body.offsetWidth;
    sHeight=document.body.offsetHeight;
    var bgObj=document.getElementById("bgDiv");
    bgObj.style.position="absolute";
    bgObj.style.display  = "block";
    bgObj.style.top="0";
    bgObj.style.background="#777";
    bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";//alpha(opacity=0)，//progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75
    bgObj.style.opacity="0.6";
    bgObj.style.left="0";
    bgObj.style.width=document.body.offsetWidth + "px";
    bgObj.style.height=document.body.offsetHeight + "px";
    bgObj.style.zIndex = "10000";
    
    var alldivTags=document.getElementById("yincang");
    if(alldivTags != null)
    {
            alldivTags.style.display='none';
    }
    if(document.getElementById("fangda_bian")!=null)
    {
        close_div_3();
    }
			
    /*
    弹出框的宽度
    */
    var width  = 500;
    var height = document.getElementById(p1).style.height;  //弹出框的高度
    var obj = document.getElementById(p1);
    obj.style.display  = "block";
    obj.style.position = "absolute";
    obj.style.zIndex   = "10001";
    //滑动弹出效果
    LoadX();
    var Position = getPosition();
    leftadd = (Position.width-width)/2+100;
    topadd  = (Position.height-height)/2-100;
    obj.style.top  = (document.body.clientHeight -obj.clientHeight)/2  + "px";
    obj.style.left = (document.body.clientWidth -obj.clientWidth)/2 + "px";
    window.onscroll = function ()
                    {
                        //obj.style.top  = (document.body.clientHeight -obj.clientHeight)/2  + "px";
                        obj.style.left = (document.body.clientWidth -obj.clientWidth)/2 + "px";
                    };
    window.onresize = function()
                    {
                        obj.style.top  = (document.body.clientHeight -obj.clientHeight)/2  + "px";
                        obj.style.left = (document.body.clientWidth -obj.clientWidth)/2 + "px";
                    };
}
function LoadX()
{
    var a_1= document.getElementById("skyEmartMallMenu");
    var obj1=document.getElementById("blemallb1");
    if(obj1==null)
    {
        var html= document.getElementById("skyEmartMallMenu");
        var suspendcodeb1="<DIV id=\"blemallb1\" style='Z-INDEX: 100;right: 1px;POSITION:absolute;top:63px;font-size:12px;'><table  border=0 cellspacing=0 cellpadding=0 id=ad_left name=ad_left ><tr><td height=20 align=center bgcolor=#FFFFFF></td></tr><tr><td><a href='#'> "+html.innerHTML +"</a></td></tr></table></div>";
        document.write(suspendcodeb1);
        var obj1=document.getElementById("blemallb1");
    }
    obj1.innerHTML=a_1.innerHTML;
    var a_2="<DIV id=\"blemallb1\" style='Z-INDEX: 100;right: 1px;POSITION:absolute;top:150px;font-size:12px;'><table  border=0 cellspacing=0 cellpadding=0 id=ad_left name=ad_left ><tr><td height=20 align=center bgcolor=#FFFFFF></td></tr><tr><td><a href='#'> "+a_1.innerHTML +"</a></td></tr></table></div>";
    
}