﻿function resetByNavigator(n)
{
    if(navigator.B+navigator.V=='IE6'&&$(n))
    {
        $(n).style.position='absolute';
        $(n).style.top = document.documentElement.scrollTop+'px';
        $(n).style.zIndex = 100;
        window.onscroll = function()
        {
            $(n).style.top = document.documentElement.scrollTop+'px';
        }
    }
}

function ClassContact(){
this.truename = '';
this.mobile = '';
this.telephone = '';
this.postalcode='';
this.buildname='';
this.companyname='';
this.address='';
};

ClassContact.prototype._ContactView = '<div id="" style="border:#66a537 1px solid; width:608px; position:fixed !important; position:absolute; left:expression((document.body.clientWidth-608)/2+offsetParent.scrollLeft); z-index:101; top:expression((document.documentElement.clientHeight-offsetHeight)/2+offsetParent.scrollTop); background-color:#fff">'
                                    + '<p style="text-align:left; padding-left:23px; color:#007236; font-weight:400; line-height:32px; height:32px;background:url(images/cart_gb.gif) #e7f6dc no-repeat 6px 3px;">请输入并确认您的收货信息！</p>'
                                    + '<p style="position:absolute; float:right; right:0px; top:0px; z-index:100; padding:4px 4px 8px 4px;"><a class="close" href="#" onclick="Contact.Hidden();return false;">关闭</a></p>'
                                    + '<ul style="margin:0px; margin-top:-20px; padding:0px; color:#5a5a5a; list-style-type:none; vertical-align:top">'
                                    + '<li style="padding-top:5px">'
                                    + '<span>姓名：</span>'
                                    + '<span><input id="txtXm" class="inputtext" type="text" size="12"/></span>'
                                    + '&nbsp;<span>手机：</span>'
                                    + '<span><input id="txtSj" class="inputtext" type="text" size="12"/></span>'
                                    + '&nbsp;<span>电话：</span>'
                                    + '<span><input id="txtDh" class="inputtext" type="text" size="12"/></span>'
                                    + '&nbsp;<span>邮编：</span>'
                                    + '<span><input id="txtYb" class="inputtext" type="text" size="12"/></span>'
                                    + '</li>'
                                    + '<li style="padding-top:5px">'
                                    + '<span>所在写字楼：</span>'
                                    + '<span><input id="txtXzl" class="inputtext" type="text" size="32"/></span>'
                                    + '&nbsp;&nbsp;<span>公司名称：</span>'
                                    + '<span><input id="txtGsmc" class="inputtext" type="text" size="33"/></span>'
                                    + '</li>'
                                    + '<li style="padding-top:5px">'
                                    + '<span>详细地址：</span>'
                                    + '<span><input id="txtDz" class="inputtext" type="text" size="87"/></span>'
                                    + '</li>'
                                    + '</ul>'
                                    + '<div style="text-align:center; margin-top:5px; margin-bottom:5px">'
                                    + '<a class="button" href="#" onclick="Contact.Save();return false;">确认并提交</a>'
                                    + '<a class="button offwhite" href="" onclick="Contact.Hidden();Cart.Show();return false;">返  回</a>'
                                    + '</div>'
                                    + '</div>';

ClassContact.prototype.Show = function()
{
    var obj=$('divContact');
    if(!obj)
        obj = $C('div');
    obj.id = 'divContact';
    obj.innerHTML = this._ContactView;
    document.body.appendChild(obj);
    obj.style.display= '';
}

ClassContact.prototype.Hidden = function()
{
    if($('divContact'))
	    $('divContact').style.display='none';
}

ClassContact.prototype.Save = function()
{
    var data = 'action=createorder';
    data +='&proIdList='+escape(getCookie(Cart.CCN));
    if($('txtXm').value.length==0)
    {
        alert('请输入姓名');$('txtXm').focus();return false;    
    }
    data +='&xm='+$('txtXm').value;
    data +='&sj='+$('txtSj').value;
    data +='&dh='+$('txtDh').value;
    data +='&yb='+$('txtYb').value;
    
    data +='&xzl='+$('txtXzl').value;
    if($('txtXzl').value.length==0)
    {
        alert('请输入所在写字楼');$('txtXzl').focus();return false;    
    }
    
    data +='&gsmc='+$('txtGsmc').value;
    if($('txtGsmc').value.length==0)
    {
        alert('请输入公司名称');$('txtGsmc').focus();return false;    
    }
    
    if($('txtDz').value.length==0)
    {
        alert('请输入详细地址');$('txtDz').focus();return false;    
    }
    data += '&dz=' + $('txtDz').value;
    data += '&ly=' + $('txtLy').value;

    XMLHttp.sendReq('post', 'ajax.aspx', data, 
    function(objXml){
        var result = objXml.responseText;
        if(result.indexOf('订单生成成功')>=0)
        {
            alert('订单生成成功');
            document.location.href='cart.aspx?gId='+ escape(result.split(',')[1]);
        }
        else
        {
            alert(result);
        }
    }
    );
}
var Contact = new ClassContact();
                                                

function ClassMember(){this.action='';};

ClassMember.prototype._LoginView = '<div id="divMemberContent" style="border:#66a537 1px solid; width:608px; margin:0px auto 0px auto; background-color:#fff">'
                              + '<p style="text-align:left; margin:0px; padding:0px 0px 0px 23px; color:#007236; font-weight:400; line-height:32px; height:32px;background:url(images/cart_gb.gif) #e7f6dc no-repeat 6px 3px;"><span style="float:left">您还未登录，请先进行登录！</span><a class="close" style="float:right; margin:8px 5px" href="#" onclick="Member.Hidden();return false;">关闭</a></p>'
                              
                              + '<ul id="ulMember" style="margin:0px; padding:0px; color:#5a5a5a; list-style-type:none; vertical-align:top; text-align:center">'
                              + '<li style="height:inherit; line-height:inherit; ">'
                              + '昵称：<input id="txtWinNickName" class="inputtext" type="text" size="18"/>'
                              + '&nbsp;&nbsp;&nbsp;密码：<input id="txtWinPassword" class="inputtext" type="password" size="18"/>'
                              + '<input type="button" style="font-weight:bold;vertical-align:middle;width:130px;height:35px;cursor:pointer;color:#fff;border:none;letter-spacing:1em;background:url(/images/lgoin_form_submit_2.gif) #f6f6f6 no-repeat 0px 0px" name="Submit" value="登 录" onclick="Member.Login()"/>'
                              + '</li>'
                              + '<li>&nbsp;</li>'
                              + '<li style="height:inherit; line-height:inherit; ">'
                              + '我还没有注册... <img src="/images/register_submit002.gif" style="cursor:pointer;vertical-align:middle;" border="0" align="absmiddle" onclick="Member.ShowReg()">'
                              + '</li>'
                              + '<li>&nbsp;</li>'
                              + '</ul>'
                              + '</div>'; 
                                                          
ClassMember.prototype._RegView = '<div id="divRegContent" style="border:#66a537 1px solid; width:608px; margin:0px auto 0px auto; background-color:#fff">'
                              + '<p style="text-align:left; margin:0px; padding:0px 0px 0px 23px; color:#007236; font-weight:400; line-height:32px; height:32px;background:url(images/cart_gb.gif) #e7f6dc no-repeat 6px 3px;"><span style="float:left">您还没有帐号，花几秒钟注册一个吧！</span><a class="close" style="float:right; margin:8px 5px" href="#" onclick="Member.HiddenReg();return false;">关闭</a></p>'

                              
                              + '<ul id="ulReg" style="margin:0px; padding:0px; color:#5a5a5a; list-style-type:none; text-align:center">'
                              + '<li style="padding-top:5px">'
                              + '<span style="width:200px;text-align:right">给自己取个昵称：</span><span style="width:300px;text-align:left"><input id="txtRegNickName" class="inputtext" type="text" size="20"/>(用于登录)</span>'
                              + '</li>'
                              + '<li style="padding-top:5px">'
                              + '<span style="width:200px;text-align:right">E-Mail 帐号：</span><span style="width:300px;text-align:left"><input id="txtRegEmail" class="inputtext" type="text" size="20"/>(用于寻回密码)</span>'
                              + '</li>'
                              + '<li style="padding-top:5px">'
                              + '<span style="width:200px;text-align:right">设定密码：</span><span style="width:300px;text-align:left"><input id="txtRegPassword" class="inputtext" type="password" size="22"/>(最少4位，最多20位)</span>'
                              + '</li>'
                              + '<li style="padding-top:5px">'
                              + '<span style="width:200px;text-align:right">再次输入密码：</span><span style="width:300px;text-align:left"><input id="txtRegCheckPass" class="inputtext" type="password" size="22"/>(同上密码，请再输入一次)</span>'
                              + '</li>'
                              + '<li style="text-align:center; margin-top:10px;">'
                              + '<img src="/images/register_submit002.gif" style="cursor:pointer"; border="0" align="absmiddle" onclick="Member.Reg()">'
                              + '</li>'
                              + '</ul>'
                              + '</div>'; 
                              
ClassMember.prototype._PatchInfoView = '<div id="divPatchInfoContent" style="border:#66a537 1px solid; width:608px; margin:0px auto 0px auto; background-color:#fff">'
                              + '<p style="text-align:left; margin:0px; padding:0px 0px 0px 23px; color:#007236; font-weight:400; line-height:32px; height:32px;background:url(images/cart_gb.gif) #e7f6dc no-repeat 6px 3px;"><span style="float:left">请补充完以下信息，以便会员之间能更好的交流心得！</span><a class="close" style="float:right; margin:8px 5px" href="#" onclick="Member.HiddenPatchInfo();return false;">关闭</a></p>'
                              + '<ul id="ulPatchInfo" style="margin:0px; padding:0px; color:#5a5a5a; list-style-type:none;">'
                              + '<li>'
                              + '<span style="width:150px;text-align:right">性别：</span><span style="width:300px;text-align:left"><input type="radio" value="女" name="rdosex" id="rdosex1"> 女 <input type="radio" value="男" name="rdosex" id="rdosex2">男</span>'
                              + '</li>'
                              + '<li>'
                              + '<span style="width:150px;text-align:right">生日：</span><span style="width:350px;text-align:left">'
                              + '<select class="font3" id="selbirthy1" name="selbirthy1"><option value="19">19</option></select>'
                              + '<select class="font3" id="selbirthy2" name="selbirthy2">'
							  + '<option value="" selected>----</option><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option>'
							  + '</select>'
							  + '<select class="font3" id="selbirthy3" name="selbirthy3">'
							  + '<option value="" selected>----</option><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option>'
							  + '</select> 年'
							  + '<select class="font3" id="selbirthm" name="selbirthm">'
						      + '<option value="" selected>----</option>'
						      + '<option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option>'
                              + '</select> 月'
							  + '<select class="font3" id="selbirthd" name="selbirthd">'
							  + '<option value="" selected>----</option>'
							  + '<option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option>'
							  + '<option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option>'
							  + '<option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option><option value="31">31</option>'
							  + '</select> 日 '
                              + '</span>'
                              + '</li>'
                              + '<li>'
                              + '<span style="width:150px;text-align:right">年龄设置：</span>'
                              + '<span><input id="cbxAge" type="checkbox" value="1">在网站中不要公开我的年龄</span>'
                              + '</li>'  
                              + '<li>'
                              + '<span style="width:150px;text-align:right">肤质：</span><span style="width:300px;text-align:left">'
						      + '<select id="selSkin" name="selSkin">'
					          + '<option value="" selected>--请选择--</option>'
					          + '<option value="1">普通性肌肤</option><option value="2">干性肌肤</option><option value="3">油性肌肤</option><option value="4">混合性肌肤</option><option value="5">敏感性肌肤</option><option value="6">先天过敏性肌肤</option>'
				              + '</select></span>'
                              + '</li>'
                              + '<li>'
                              + '<span style="width:150px;text-align:right">职业：</span><span style="width:300px;text-align:left">'
                              + '<select name="selJob" class="font3" id="selJob">'
						      + '<option value="" selected>--请选择--</option>'
						      + '<option value="1">农林渔牧业</option><option value="2">制造业</option><option value="3">咨询网络相关业</option><option value="4">广告业</option><option value="5">金融保险业</option><option value="6">运输通信业</option><option value="7">建筑不动产业</option><option value="8">商业</option><option value="9">服务业</option><option value="10">自由业</option><option value="11">军警公务人员</option><option value="12">学生</option><option value="13">待业中</option><option value="14">其他</option>'
					          + '</select>'
                              + '</span>'
                              + '</li>'
                              + '<li style="text-align:center">'
                              + '<img src="/images/sub_save.gif" style="cursor:pointer"; border="0" align="absmiddle" onclick="Member.SavePatchInfo()">'
                              + '</li>'
                              + '</ul>'
                              + '</div>';


ClassMember.prototype._ExpView = '<div id="divExpContent" style="border:#66a537 1px solid; width:608px; margin:0px auto 0px auto; background-color:#fff">'
                              + '<p style="text-align:left; margin:0px; padding:0px 0px 0px 23px; color:#007236; font-weight:400; line-height:32px; height:32px;background:url(images/cart_gb.gif) #e7f6dc no-repeat 6px 3px;"><span style="float:left">请补充完以下信息，以便会员之间能更好的交流心得！</span><a class="close" style="float:right; margin:8px 5px" href="#" onclick="Member.HiddenExp();return false;">关闭</a></p>'
                              + '<ul id="ulPatchInfo" style="margin:0px; padding:0px; color:#5a5a5a; list-style-type:none;">'
                              + '<li>'
                              + '<span style="width:150px;text-align:right">评价指数：</span><span style="width:350px;text-align:left">'
                              + '<select class="font3" id="selEvaluate" name="selEvaluate"><option value="0">请选择评价指数</option><option value=7>7颗星　真的超棒！超赞的，超强推荐！</option><option value=6>6颗星　相当不错！会想推荐给別人！</option><option value=5>5颗星　还不错，有好感…会再买来用！</option><option value=4>4颗星　普通啦！如果能再…的话就更好了！</option><option value=3>3颗星　嗯…勉强接受，不过下次购买会再考虑一下下！</option><option value=2>2颗星　不合我意…不会再买来用！</option><option value=1>1颗星　完全给它不行，有问题！</option></select>'
                              + '</span>'
                              + '</li>'
                              + '<li style="margin-bottom:0px;">'
                              + '<span style="width:150px;text-align:right">效果：</span><span style="width:300px;text-align:left;">请选择使用此产品的效果</span>'
                              + '</li>'
                              + '<li style="margin-top:0px;">'
                              + '<span style="width:150px;text-align:right">&nbsp;</span><span id="spnSituation" style="width:300px;text-align:left;">	<ul><li><input type="checkbox" id="cbxSituation1" name="cbxSituation" value="1"><label for="cbxSituation1">保湿</label></li><li><input type="checkbox" id="cbxSituation2" name="cbxSituation" value="2"><label for="cbxSituation2">防晒</label></li><li><input type="checkbox" id="cbxSituation3" name="cbxSituation" value="3"><label for="cbxSituation3">美白</label></li><li><input type="checkbox" id="cbxSituation4" name="cbxSituation" value="4"><label for="cbxSituation4">消除细纹</label></li><li><input type="checkbox" id="cbxSituation5" name="cbxSituation" value="5"><label for="cbxSituation5">遮瑕．修饰</label></li><li><input type="checkbox" id="cbxSituation6" name="cbxSituation" value="6"><label for="cbxSituation6">活化肌肤</label></li><li><input type="checkbox" id="cbxSituation7" name="cbxSituation" value="7"><label for="cbxSituation7">透明．有光泽</label></li><li><input type="checkbox" id="cbxSituation8" name="cbxSituation" value="8"><label for="cbxSituation8">不油腻</label></li><li><input type="checkbox" id="cbxSituation9" name="cbxSituation" value="9"><label for="cbxSituation9">不会过敏</label></li><li><input type="checkbox" id="cbxSituation10" name="cbxSituation" value="10"><label for="cbxSituation10">低刺激性</label></li><li><input type="checkbox" id="cbxSituation11" name="cbxSituation" value="11"><label for="cbxSituation11">清洁</label></li><li><input type="checkbox" id="cbxSituation12" name="cbxSituation" value="12"><label for="cbxSituation12">持久．不晕染</label></li></ul></span>'
                              + '</li>'
                              + '<li style="margin-bottom:0px;">'
                              + '<span style="width:150px;text-align:right">分享使用心得：</span>'
                              + '<span style="width:400px;text-align:left">将您使用产品的前因后果，及使用后的优缺点清楚表达出来是最好的哦！</span>'
                              + '</li>'
                              + '<li style="margin-top:0px;">'
                              + '<span style="width:150px;text-align:right">&nbsp;</span>'
                              + '<span><textarea id="txtExpComment" name="txtExpComment" rows=8 cols=40 class="textbox"></textarea></span>'
                              + '</li>'
                              
                              + '<li style="text-align:center">'
                              + '<img src="/images/emit_submit.gif" style="cursor:pointer"; border="0" align="absmiddle" onclick="Member.SaveExp()">'
                              + '</li>'
                              + '</ul>'
                              + '</div>';

ClassMember.prototype.Exp = function(id) {

    var data = 'action=checkexp&f=win&nickName=';
    //document.location.href =  '/ajax.aspx?'+data;
    XMLHttp.sendReq('post', '/ajax.aspx', data,
    function(objXml) {
        var result = objXml.responseText;
        if (result == 'Ok') {
            Member.ShowExp();
        }
        else
            if (result.indexOf('NeedPatch') >= 0) {
            Member.ShowPatchInfo(result);
        }
        else
            if (result == 'NeedLogin') {
            Member.action = 'Exp';
            Member.Show();
        }
    }
    );
} 
                              
ClassMember.prototype.Login = function()
{
    nickName = document.getElementById('txtWinNickName').value;
	password = document.getElementById('txtWinPassword').value;

	if(nickName.length==0)
	{
		alert('请输入昵称');
		return false;
	}else
	if(password.length==0)
	{
		alert('请输入密码');
		return false;
	}

    var data ='action=memberlogin&f=win&nickName='+escape(nickName)+'&password='+escape(password);
    XMLHttp.sendReq('post', '/ajax.aspx', data, 
    function(objXml){
        var result = objXml.responseText;
        if(result=='登录成功')
        {
            href = document.location.href.toLowerCase();
            if(href.indexOf('cart.aspx')>0)
            {
                alert('登录成功');
                Member.Hidden();
                getCon();
            }
            else
            if(Member.action=='AddFavorite')
            {
                alert('登录成功');
                Member.Hidden();
            }
            else
                if (Member.action == 'Exp') {
                alert('登录成功');
                Member.Exp();
            }
            else
                document.location.href='/my/cart.aspx';
            //Member.Hidden();
            //Cart.Show();
        }
        else
        {
            alert(result);
        }
    }
    );
}

ClassMember.prototype.Reg = function()
{
    nickName = $('txtRegNickName').value;
    email = $('txtRegEmail').value;
	password = $('txtRegPassword').value;
	checkpass = $('txtRegCheckPass').value;

	if(nickName.length==0)
	{
		alert('请输入昵称');
		return false;
	}
	if(nickName.length==1)
	{
	    alert('昵称必须大于一个字符');
	    return false;
	}
	if(email.length==0)
	{
	    alert('请输入E-Mail');
	    return false;
	}
	if(!checkEmail(email))
	{
	    alert('E-Mail输入不正确');
	    return false;
	}
	
    if(password.length==0)
	{
		alert('请输入密码');
		return false;
	}
	
	if(password.length<4||password.length>20)
	{
		alert('密码最少4位，最多20位');
		return false;
	}

	if(checkpass!=password)
	{
		alert('确认密码与设定密码不一致');
		return false;
	}

    var data ='action=addwinmember&f=win&nickName='+escape(nickName)+'&password='+escape(password)+'&email='+escape(email);
    //document.location.href='ajax.aspx?'+data;
    XMLHttp.sendReq('post', '/ajax.aspx', data, 
    function(objXml){
        var result = objXml.responseText;
        if(result.indexOf('注册成功')>=0)
        {
            alert('注册成功');
            Member.HiddenReg();
            if (typeof getCon != 'undefined' && getCon != null)
                getCon();
            if (Member.action == 'Exp')
                Member.Exp();
            //Contact.Show();
        }
        else
        {
            alert(result);
        }
    }
    );
}

ClassMember.prototype.Show = function()
{
    var obj=$('divMember');
    if(!obj)
    {
        obj = $C('div');
        obj.id = 'divMember';
        obj.style.position = 'fixed';
        obj.style.left ='0px';
        obj.style.top = '0px';
        obj.style.width = '100%';
        obj.style.zIndex = 10;
        document.body.appendChild(obj);
    }
    obj.innerHTML = '<table width="100%"><tr><td id="tbCart" height="'+document.documentElement.clientHeight+'">'+this._LoginView+'</td></tr></table>';
    obj.style.display = 'block';
    window.onresize = function(){if($('tbCart')) $('tbCart').height=document.documentElement.clientHeight;}
    resetByNavigator(obj.id);

}

ClassMember.prototype.ShowReg = function()
{
    this.Hidden();
    var obj=$('divMemberReg');
    if(!obj)
    {
        obj = $C('div');
        obj.id = 'divMemberReg';
        obj.style.position = 'fixed';
        obj.style.left ='0px';
        obj.style.top = '0px';
        obj.style.width = '100%';
        obj.style.zIndex = 10;
        document.body.appendChild(obj);
    }
    obj.innerHTML = '<table width="100%"><tr><td id="tbCart" height="'+document.documentElement.clientHeight+'">'+this._RegView+'</td></tr></table>';
    obj.style.display = 'block';
    window.onresize = function(){if($('tbCart')) $('tbCart').height=document.documentElement.clientHeight;}
    resetByNavigator(obj.id);
}

ClassMember.prototype.ShowPatchInfo = function(re)
{
    this.Hidden();
    var obj=$('divMemberPatchInfo');
    if(!obj)
    {
        obj = $C('div');
        obj.id = 'divMemberPatchInfo';
        obj.style.position = 'fixed';
        obj.style.left ='0px';
        obj.style.top = '0px';
        obj.style.width = '100%';
        obj.style.zIndex = 10;
        document.body.appendChild(obj);
    }
    var view = this._PatchInfoView;
    obj.innerHTML = '<table width="100%"><tr><td id="tbCart" height="'+document.documentElement.clientHeight+'">'+ view +'</td></tr></table>';
    obj.style.display = 'block';
    window.onresize = function(){if($('tbCart')) $('tbCart').height=document.documentElement.clientHeight;}
    resetByNavigator(obj.id);
    var ar = re.split(',');
    if(ar.length>=5)
    {
        if(ar[1]=='女')
            $('rdosex1').checked = true;
        if(ar[1]=='男')
            $('rdosex2').checked = true;
        if(ar[2].length>0)
        {
            var br = ar[2].split('-');
            $('selbirthy2').options[0].selected = true;
            $('selbirthy2').options[br[0].substr(2,1)*1+1].selected = true;
            $('selbirthy3').options[br[0].substr(3,1)*1+1].selected = true;
            $('selbirthm').options[br[1]].selected = true;
            $('selbirthd').options[br[2]].selected = true;
            if(ar[3].length>0)
            $('selSkin').options[ar[3]].selected = true;
            if(ar[4].length>0)
            $('selJob').options[ar[4]].selected = true;
        }
    }
}

ClassMember.prototype.ShowExp = function() {
    this.Hidden();
    var obj = $('divMemberExp');
    if (!obj) {
        obj = $C('div');
        obj.id = 'divMemberExp';
        obj.style.position = 'fixed';
        obj.style.left = '0px';
        obj.style.top = '0px';
        obj.style.width = '100%';
        obj.style.zIndex = 10;
        document.body.appendChild(obj);
    }
    var view = this._ExpView;
    obj.innerHTML = '<table width="100%"><tr><td id="tbCart" height="' + document.documentElement.clientHeight + '">' + view + '</td></tr></table>';
    obj.style.display = 'block';
    window.onresize = function() { if ($('tbCart')) $('tbCart').height = document.documentElement.clientHeight; }
    resetByNavigator(obj.id);
}


ClassMember.prototype.SavePatchInfo = function() {
    var sex = '';
    if ($('rdosex1').checked)
        sex = $('rdosex1').value;
    if ($('rdosex2').checked)
        sex = $('rdosex2').value;

    y1 = $('selbirthy1').value;
    y2 = $('selbirthy2').value;
    y3 = $('selbirthy3').value;
    m = $('selbirthm').value;
    d = $('selbirthd').value;
    br = y1 + '' + y2 + '' + y3 + '-' + m + '-' + d;
    var open = 0;
    if ($('cbxAge').checked)
        open = 1;
    skin = $('selSkin').value;
    job = $('selJob').value;

    if (sex.length == 0) {
        alert('请选择您的性别');
        return false;
    }

    if (y2.length == 0 || y3.length == 0 || m.length == 0 || d.length == 0) {
        alert('请选择您的生日');
        return false;
    }
    if (skin.length == 0) {
        alert('请选择肤质');
        return false;
    }

    if (job.length == 0) {
        alert('请选择职业');
        return false;
    }

    var data = 'action=SavePatchInfo&f=win&sex=' + escape(sex) + '&br=' + escape(br) + '&open=' + escape(open) + '&skin=' + escape(skin) + '&job=' + escape(job);
    //document.location.href='ajax.aspx?'+data;
    XMLHttp.sendReq('post', '/ajax.aspx', data,
    function(objXml) {
        var result = objXml.responseText;
        if (result.indexOf('成功') >= 0) {
            alert('保存成功');
            Member.HiddenPatchInfo();
            Member.Exp();
        }
        else {
            alert(result);
        }
    }
    );
}

ClassMember.prototype.SaveExp = function() {

    var proId = $('hdnProId').value;

    if (proId == 0) {
        alert('出错了，请尝试刷新一下页面');
        return false;
    }

    var evaluate = $('selEvaluate').value;
    if (evaluate == 0) {
        alert('请选择评价指数');
        return false;
    }

    var situation = '';
    for (var i = 1; i <= 12; i++) {
        obj = $('cbxSituation' + i);
        if (obj.checked) {
            situation += ',' + obj.value;
        }
    }
    if (situation.length == 0) {
        alert('请选择产品效果');
        return false;
    }

    var expComment = $('txtExpComment').value;
    if (expComment.trim().length == 0) {
        alert('请输入您的使用心得');
        return false;
    }

    var data = 'action=SaveExp&f=win&evaluate=' + escape(evaluate) + '&situation=' + escape(situation) + '&expComment=' + escape(expComment) + '&proId=' + escape(proId);
    //document.location.href='ajax.aspx?'+data;
    XMLHttp.sendReq('post', '/ajax.aspx', data,
    function(objXml) {
        var result = objXml.responseText;
        if (result.indexOf('成功') >= 0||result) {
            alert('使用心得发表成功，谢谢您的分享！刷新一下页面就能看到了哦^_^');
            Member.HiddenExp();
        }
        else {
            alert(result);
        }
    }
    );
}


ClassMember.prototype.Hidden = function()
{
    	if($('divMember'))
	$('divMember').style.display='none';
}

ClassMember.prototype.HiddenReg = function()
{
    	if($('divMemberReg'))
	$('divMemberReg').style.display='none';
}

ClassMember.prototype.HiddenPatchInfo = function()
{
    	if($('divMemberPatchInfo'))
	$('divMemberPatchInfo').style.display='none';
}

ClassMember.prototype.HiddenExp = function() {
    if ($('divMemberExp'))
        $('divMemberExp').style.display = 'none';
}

var Member = new ClassMember();

function ClassCart(){};
ClassCart.prototype.CCN = '@@CartCookieName';
ClassCart.prototype._CartView = '<div id="divCartContent" style="border:#66a537 1px solid; width:608px; margin:0px auto 0px auto; background-color:#fff">'
                              + '<p style="text-align:left; margin:0px; padding:0px 0px 0px 23px; color:#007236; font-weight:400; line-height:32px; height:32px;background:url(images/cart_gb.gif) #e7f6dc no-repeat 6px 3px;"><span style="float:left">商品已成功添加到购物车！</span><a class="close" style="float:right; margin:8px 5px" href="#" onclick="Cart.Hidden();return false;">关闭</a></p>'
                              + '<ul id="ulCart" style="margin:0px; padding:0px; color:#5a5a5a; list-style-type:none; vertical-align:top">'
                              + '<li>'
                              + '<span class="mc">商品名称</span>'
                              + '<span class="dj">单价</span>'
                              + '<span class="sl">数量</span>'
                              + '<span class="hj">本商品合计</span>'
                              + '<span class="cz">操作</span>'
                              + '</li>'
                              + '<li>'
                              + '正在加载商品数据...'
                              + '</li>'

                              + '</ul>'
                              + '<div style="text-align:center; clear:both; margin-top:5px; margin-bottom:5px">'
                              + '<a class="button" href="" onclick="Cart.Contact();return false;">生成订单联系客服</a>'
                              + '<a class="button offwhite" href="" onclick="Cart.Hidden();return false;">继续购物</a>'
                              + '</div>'
                              + '</div>';    
ClassCart.prototype.SetCookie = function(str)
{
    setCookie(this.CCN, str, '', '/', '');
}        
ClassCart.prototype.GetCookie = function()
{
    return getCookie(this.CCN);
}
              
ClassCart.prototype.Add = function(proId, num)
{
    var str = '';
    var ary = getCookie(this.CCN).split(',');
    for(var i=0; i<ary.length; i++)
    {
        var temp = ary[i].split('|');
        if(temp.length!=2) continue;
        if(temp[0]==proId)
        {   
            num += temp[1]*1;
            continue;
        }
        str += temp[0]+'|'+temp[1]+',';
    }
    this.SetCookie(','+proId+'|'+num+','+str);
}

ClassCart.prototype.AddFavorite = function(proId)
{
    var data ='action=addfavorite&proId='+escape(proId);
    //document.location.href='ajax.aspx?'+data;
    XMLHttp.sendReq('post', '/ajax.aspx', data, 
    function(objXml){
        var result = objXml.responseText;
        if(result.indexOf('收藏成功')>=0)
        {
            alert('商品收藏成功');
        }
        else
        if(result.indexOf('登录超时')>=0)
        {
            Member.action = 'AddFavorite';
            Member.Show();
        }
        else
        {
            alert(result);
        }
    }
    );
}

ClassCart.prototype.DelFavorite = function(proList)
{
    var data ='action=delfavorite&proList='+escape(proList);
    //document.location.href='ajax.aspx?'+data;
    XMLHttp.sendReq('post', '/ajax.aspx', data, 
    function(objXml){
        var result = objXml.responseText;
        if(result.indexOf('收藏删除成功')>=0)
        {
            //alert('收藏删除成功');
            document.location.reload();
        }
        else
        if(result.indexOf('登录超时')>=0)
        {
            Member.action = 'AddFavorite';
            Member.Show();
        }
        else
        {
            alert(result);
        }
    }
    );
}


ClassCart.prototype.Set = function(proId, num)
{
    var str = '';
    var ary = getCookie(this.CCN).split(',');
    for(var i=0; i<ary.length; i++)
    {
        var temp = ary[i].split('|');
        if(temp.length!=2) continue;
        if(temp[0]==proId)
        {   
            continue;
        }
        str += temp[0]+'|'+temp[1]+',';
    }
    this.SetCookie(','+proId+'|'+num+','+str);
}

ClassCart.prototype.Show = function()
{
    var obj=$('divCart');
    if(!obj)
    {
        obj = $C('div');
        obj.id = 'divCart';
        obj.style.position = 'fixed';
        obj.style.left ='0px';
        obj.style.top = '0px';
        obj.style.width = '100%';
        obj.style.zIndex = 10;
        document.body.appendChild(obj);
    }
    obj.innerHTML = '<table width="100%"><tr><td id="tbCart" height="'+document.documentElement.clientHeight+'">'+this._CartView+'</td></tr></table>';
    obj.style.display = 'block';
    window.onresize = function()
    {
        if($('tbCart')) $('tbCart').height=document.documentElement.clientHeight;
    }

    resetByNavigator(obj.id);
    
    var proIdList = '';
    ary = getCookie(this.CCN).split(',');
    for(var i=0; i<ary.length; i++)
    {
        temp = ary[i].split('|');
        if(temp.length==2)
        {
            if(proIdList.length>0) proIdList+=',';
            proIdList += temp[0];
        }
    }
    var url = 'ajax.aspx?action=showcart&proIdList='+escape(this.ProIdList())+"&"+Math.random();
    //document.location.href = url;
    ENetwork.DownloadScript(url,function(){
        if(typeof CartItem!='undefined'&&CartItem!=null)
        {
            ulobj = $('ulCart');
            deleteLi(ulobj, 1);
            var totalNum = 0;
            var totalPrice = 0;
            for(var i=0; i<CartItem.length; i++)
            {
                var li = document.createElement("li");
                li.id = 'proId'+CartItem[i].ProId;
                name = CartItem[i].ProName;
                if(name.length>24) name = name.substring(0,24);
                num = Cart.GetNum(CartItem[i].ProId);
                price = (CartItem[i].ProPrice*1).toFixed(2);
                html = '<span class="mc">'+name+'</span>';
                html += '<span id="dj" class="dj">'+price+'</span>';
                html += '<span id="sl" class="sl"><input type="hidden" id="proId" value="'+CartItem[i].ProId+'"><input id="proNum" class="inputtext" type="text" value="'+num+'" style="width:20px; height:16px; text-align:right"/></span>';
                html += '<span id="hj" class="hj">'+multi(price,num).toFixed(2)+'</span>';
                html += '<span class="cz"><a href="#" onclick="Cart.Del(this); return false;">删除</a></span>';
                li.innerHTML = html;
                ulobj.appendChild(li);
                
                objProNum = getChildNodeById(li, 'proNum');
                objProNum.style.imeMode="disabled";
                objProNum.onkeydown = function(evt)
                {
                    var evt=evt?evt:event;
                    if((evt.keyCode<48||evt.keyCode>57)&&evt.keyCode!=8&&evt.keyCode!=9)
                        return false;
                }
                objProNum.onkeyup = function(evt)
                {
                    var evt=evt?evt:event;
                    var dj = getChildNodeById(this.parentNode.parentNode, 'dj').innerHTML;
                    var num = this.value;
                    if(num=='') num=0;
                    getChildNodeById(this.parentNode.parentNode, 'hj').innerHTML=multi(dj,num);
                    Cart.Refresh();
                }

                totalNum = add(totalNum,num);
                totalPrice = add(totalPrice,multi(price,num)).toFixed(2);
            }
            
            if(CartItem.length>0)
            {
                var li = document.createElement("li");
                html = '<span class="mc">总计</span>';
                html += '<span class="dj">&nbsp;</span>';
                html += '<span id="sl" class="sl">'+totalNum+'</span>';
                html += '<span id="hj" class="hj">'+totalPrice+'</span>';
                html += '<span class="cz"><a href="#" onclick="Cart.DelAll(); return false;">全部删除</a></span>';
                li.innerHTML = html;
                ulobj.appendChild(li);
            }
        }
    });
    
    
}

ClassCart.prototype.Hidden = function()
{
	if($('divCart'))
	$('divCart').style.display='none';
}

ClassCart.prototype.Del = function(obj)
{
    var li = obj.parentNode.parentNode;
    var proId = getChildNodeById(li, 'proId').value;
    var str = '';
    var ary = getCookie(this.CCN).split(',');
    for(var i=0; i<ary.length; i++)
    {
        var temp = ary[i].split('|');
        if(temp.length==2)
        {
            if(temp[0]==proId)
                continue;
            str += temp[0]+'|'+temp[1]+',';
        }
    }
    if(str.length>0)
        str = ',' + str; 
    this.SetCookie(str);
    $('ulCart').removeChild(li);
    this.Refresh();
}

ClassCart.prototype.DelAll = function()
{
    ulobj = $('ulCart');
    var l = ulobj.childNodes.length;
    for(var i=1; i<ulobj.childNodes.length-1; i++)
    {
        ulobj.removeChild(ulobj.childNodes[1]);
    }
    this.SetCookie('');
    this.Refresh();
}

ClassCart.prototype.Refresh = function()
{
    ulobj = $('ulCart');
    var str = '';
    var totalNum = 0;
    var totalPrice = 0;
    if(ulobj)
    {
        for(var i=1; i<ulobj.childNodes.length-1; i++)
	    {
	        var proId = getChildNodeById(ulobj.childNodes[i], 'proId').value;
		    var dj = getChildNodeById(ulobj.childNodes[i], 'dj').innerHTML;
            var num = getChildNodeById(ulobj.childNodes[i], 'proNum').value;
            if(num=='') num=0;
            totalNum = add(totalNum,num);
            totalPrice = add(totalPrice+multi(dj,num));
            str += proId+'|'+num+',';
	    }
	    getChildNodeById(ulobj.childNodes[ulobj.childNodes.length-1], 'sl').innerHTML = totalNum;
	    getChildNodeById(ulobj.childNodes[ulobj.childNodes.length-1], 'hj').innerHTML = totalPrice;
	    this.SetCookie(','+str);
	}
}

ClassCart.prototype.Contact = function()
{
    document.location.href='/my/cart.aspx';
    /*
    var url = 'ajax.aspx?action=checklogin&'+Math.random();
    ENetwork.DownloadScript(url,function(){
        if (typeof IsLogin == 'undefined' || IsLogin == null||IsLogin==0)
        {
            Cart.Hidden();
            Member.Show();
        }
        else
        {
            document.location.href='/my/cart.aspx';
            //Cart.Hidden();
            //Contact.Show();
        }
    }
    );
    */
}

ClassCart.prototype.GetNum = function(proId)
{
    var ary = getCookie(this.CCN).split(',');
    for(var i=0; i<ary.length; i++)
    {
        var temp = ary[i].split('|');
        if(temp.length!=2) continue;
        if(temp[0]==proId)
        {   
            return temp[1];
        }
    }
    return 0;
}

ClassCart.prototype.ProIdList = function()
{
    var proIdList = '';
    ary = getCookie(this.CCN).split(',');
    for(var i=0; i<ary.length; i++)
    {
        temp = ary[i].split('|');
	    
	    if(temp.length==2)
	    {
		    if(proIdList.length>0) proIdList+=',';
		    proIdList += temp[0];
	    }
    }
    return proIdList;
}

ClassCart.prototype.ItemCount = function()
{
    var count = 0;
    ary = getCookie(this.CCN).split(',');
    for(var i=0; i<ary.length; i++)
    {
	    temp = ary[i].split('|');
	    if(temp.length==2)
	    {
		    count++;
	    }
    }
    return count;
}

ClassCart.prototype.SetMyNum = function()
{
    var data ='action=getmynum';
    //document.location.href='ajax.aspx?'+data;
    XMLHttp.sendReq('post', '/ajax.aspx', data, 
    function(objXml){
        var result = objXml.responseText;
        if(result.indexOf('收藏成功')>=0)
        {
            alert('商品收藏成功');
        }
        else
        if(result.indexOf('登录超时')>=0)
        {
            Member.action = 'AddFavorite';
            Member.Show();
        }
        else
        {
            alert(result);
        }
    }
    );
}

var Cart = new ClassCart();

function insertLi(ulobj, index)
{
   var root = document.createElement("li");
   ulobj.appendChild(root);
   return root;
}

function deleteLi(ulobj, index)
{
	for(var i=0; i<ulobj.childNodes.length; i++)
	{
		if(i==index)
			ulobj.removeChild(ulobj.childNodes[i]);
	}
}

function GlobalConfig()
{
    this.LinkAuthority='http://';
};
GlobalConfig.prototype.PointTrans = function(p)
{
    return (p/2).toFixed(0);
}

var GC = new GlobalConfig();
