var $e=function(i){return document.getElementById(i);}
var $v=function(i){if($e(i)) return $e(i).value;else return null;}
var $r=function(n){
    while(n){
        if(n.nodeType==1&&n.tagName) return n;
        else n=n.nextSibling;
    } 
    return null;
}
var ES={
    Site:"http://www.7190.cc/",
    IsStatic:false,
    Handle:"Member/myConfig.ashx?",
    data:{
        Aid:null,
        Acode:null,
        Refer:null,
        Module:null,
        PageIndex:null,
        proName:null
    },
    init:function(){
        var h=location.href.toLowerCase();
        this.IsStatic=h.substring(h.lastIndexOf('.'))!=".aspx";
        if(this.IsStatic){
            var base=document.getElementsByTagName("base")[0];
            if(base) ES.Handle=base.href+ES.Handle;
            else{
                var hp=location.pathname.toLowerCase()
                ES.Handle='/eshop/'+ES.Handle;
            }
        }
        var val=$e('aval');
        if(val)
        {
            var vals=val.value.split(',');
            this.data.Aid=vals[0];
            this.data.Acode=vals[1];
            this.data.Module=vals[2];
            this.data.PageIndex=vals[3];
            this.data.Refer=vals[4];
        }
        ES.Dialog.init();   //初始化对话框
        setTimeout(function(){ES.TagTip.init();},88);   //初始化标签
    }
    
};
window.onload=function(){ES.init();}

ES.You={
    data:[{id:"title",name:"标题",value:"",type:'input'},
        {id:"number",name:"数量",value:"",type:'input'},
        {id:"context",name:"其他说明",value:"",style:"width:315px; height: 45px",type:'textarea'},
        {id:"company",name:"单位名称",value:"",type:'input'},
        {id:"addr",name:"单位地址",value:"",type:'input'},
        {id:"name",name:"姓名/称谓",value:"",type:'input'},
        {id:"phone",name:"电话",value:"",type:'input'},
        {id:"email",name:"邮箱",value:"",type:'input'}],
    words:'我想咨询贵公司在展销店上发布的销售产品[$1]',
    words_order: '我要订购贵公司在展销店上发布的销售产品[$1]',
    words_quote: '我要报价,对贵公司在展销店上发布的销售产品[$1]',
    alert_value:'',
    filldata:function(mod){
        var dm={};
        for(var i=0;i<this.data.length;i++)
        {
            var v=$e(mod.toLowerCase()+"_"+this.data[i].id);
            if(v){this.data[i].value=v.value;}
            dm[this.data[i].id]=this.data[i].value;
        }
        return dm;
    }
}
ES.Time={
    Zero:function(d){
        if(parseInt(d)<10)
        return '0'+d;
        else return d;
    }
};
ES.E=function(e){   
    e=window.event||e;   
    return e.srcElement||e.target;
}
ES.Login={
    is:false,
    data:{
        uid:null,
        aid:null,
        name:null,
        email:null,
        phone:null,
        company:null,
        addr:null
    },
    check:function(Refer,Module){
        if(Refer){
            ES.data.Refer=Refer;
        }
        if(Module){
            ES.data.Module=Module;
        }
        $.ajax({type:"POST",async:false,data:"",url:ES.Handle+'cmd=islogin&fmt=json',cache:false,dataType:"json",success:function(j){
            if(j.Count>0){$.extend(ES.Login.data,j.Data[0]);ES.Login.is=true;}
            else ES.Login.is=false;
        }});
    },
    redirect:function(){
        var os=new oStringBuffer();
        os.append('<div style="font-size:12px;text-align:center;padding:5px;color:#000;">5秒后将打开登陆界面<hr>');
        os.append('如果不能打开，请点击这里<a href="/subsystem/login.aspx" target="_blank">打开</a><p />');
        os.append('如果还没注册，请点击这里<a href="/subsystem/login.aspx" target="_blank">注册</a><p />');
        os.append('<a href="javascipt:ES.Dialog.close(); >点击关闭</a></div>');
        ES.Dialog.show('此功能需要注册用户登陆[<span id="closetimeout">15</span>秒后半闭]',os.toString(),{width:408,height:120});
        
        var closeTimeout=function(){
            var c=$e('closetimeout');
            if(c){
                var n=parseInt(c.innerHTML)-1;
                c.innerHTML=n;
                if(n>0){setTimeout(closeTimeout,1000);}
                else{ES.Dialog.close();}
            }
        }
        setTimeout("window.open('/subsystem/login.aspx')",5000);
        setTimeout(closeTimeout,0);
    },
    Open_login:function(){
        var os=new oStringBuffer();
        os.append('<div style="font-size:12px;text-align:center;padding:5px;color:#000;">帐&nbsp;&nbsp;号：<input type="text" id="usr" class="input_login"/><br/>');
        os.append('密&nbsp;&nbsp;码：<input type="password" id="pwd" class="input_login"/><br/>');
        //os.append('验证码：<input type="text" id="yzm" class="input_login"/><br/>');
        //os.append('<img id="imgVerify" style="margin: 0 0 -6px 0px;" width="128px" height="28px" src="/SubSystem/LoginVfCode.aspx?'+ Math.random()+'"/>');
        //os.append('<a style="font-size: 12px; margin-left: 3px;" href="javascript:void(0)" onclick="RefVCode()">看不清,换一张</a><br/>');
        os.append('<input type="button" style="margin-top:7px;"  class="Allbtn" value="登录" onclick="ES.Login.Inter_Login()"/></div>');
        ES.Dialog.show('用户登录',os.toString(),{width:308,height:180});
        //RefVCode();
    },
    Inter_Login:function(){
       var usr = $("#usr")[0].value;
       var pwd = $("#pwd")[0].value;
       //var yzm = $("#yzm")[0].value;
       if(usr == "")
       {
         alert("请填帐号!");
         return false;
       }
       if(pwd == "")
       {
         alert("请填密码!");
         return false;
       }
       //if(yzm == "")
       ///{
      //  alert("请填验证码!");
      //   return false;
      // }
       $.ajax({type:"POST",data:$.extend({usr:usr,pwd:pwd},ES.data),url:ES.Handle+'cmd=Get_login&fmt=html',cache:true,dataType:"html",success:this.loginsuc});
    },
    loginsuc:function(h){
       if(h == "1"){
         alert("登录成功!");
         ES.Dialog.close();
         //location.reload();
       }
       else if(h == "3")
       {
         alert("验证码填写失败，请重填!");
         //RefVCode();
       }
       else
       {
         alert(h);
         //RefVCode();
       }
    }
}
ES.Reply = {
    data: {},
    button: null,
    page: 1,
    submit: function(e) {
        this.button = ES.E(e);
        this.data.Uid = $v('reply_uid');
        this.data.UserName = $v('reply_username');
        this.data.Password = $v('reply_password');
        this.data.Content = $v('reply_content');
        this.data.Anonymous = $e('reply_anonymous').checked;
        var title = $e('title').innerHTML;
        if (this.data.Content == "") {
            alert('请输入回复内容'); return false;
        }
        else {
            if (this.data.Content.length > 1000) {
                alert('输入太多的字符'); return false;
            }
        }
        if (!this.data.Anonymous) {
            if (!this.data.Uid) {
                if (this.data.UserName == "") {
                    alert('请输入用户名'); return false;
                }
                if (this.data.Password == "") {
                    alert('请输入密码'); return false;
                }
            }
        }
        this.button.disabled = true;
        this.button.value = "回复提交";
        $.ajax({ type: "POST", data: $.extend({ title: title }, this.data, ES.data), url: ES.Handle + 'cmd=replysubmit&fmt=json', cache: false, dataType: "json", success: this.suc });
    },
    SystemSubmit: function(e) {
        this.button = ES.E(e);
        this.data.Uid = $v('reply_uid');
        this.data.UserName = $v('reply_username');
        this.data.Password = $v('reply_password');
        this.data.Content = $v('reply_content') + "<div style='text-align:right;width:100%;'>" + $e('ReplyValue').value + "</div>";
        this.data.Anonymous = $e('reply_anonymous').checked;
        var title = $e('title').innerHTML;
        if (this.data.Content == "") {
            alert('请输入回复内容'); return false;
        }
        else {
            if (this.data.Content.length > 1000) {
                alert('输入太多的字符'); return false;
            }
        }
        if (!this.data.Anonymous) {
            if (!this.data.Uid) {
                if (this.data.UserName == "") {
                    alert('请输入用户名'); return false;
                }
                if (this.data.Password == "") {
                    alert('请输入密码'); return false;
                }
            }
        }
        this.button.disabled = true;
        this.button.value = "回复提交";
        $.ajax({ type: "POST", data: $.extend({ title: title }, this.data, ES.data), url: ES.Handle + 'cmd=replysubmit&fmt=json', cache: false, dataType: "json", success: this.suc });
    },
    pageto: function(i) {
        if (this.page == i) { return; }
        else {
            $e('replyloading').style.display = 'block';
            $.ajax({ type: "POST", data: $.extend({ ReplyPageIndex: i }, ES.data), url: ES.Handle + 'cmd=getreplys&fmt=html', cache: true, dataType: "html", success: this.pagesuc });
            this.page = i;
        }
    },
    pagesuc: function(h) {
        if (h != "") {
            var r = $('#reply').children().eq(0);
            var vhtml = $('<div>').append(r.children().eq(0).clone()).html();
            r.empty();
            r.append(vhtml + h);
        }
    },
    suc: function(j) {
        if (j.Count > 0) {
            var d = new Date();
            var dt = d.getFullYear() + "-" + ES.Time.Zero(d.getMonth() + 1) + "-" + ES.Time.Zero(d.getDate()) + " " + ES.Time.Zero(d.getHours()) + ":" + ES.Time.Zero(d.getMinutes());
            var rj = $('#reply').children().eq(0);
            rj.children().eq(rj.children().length - 1).before("<li><div class=\"userinfo\"><span class=\"floatR\">发表时间：<span class=\"fontGr\">" + dt + "</span></span><span>发表人：<span class=\"fontGr\">" +
                                  "<a href=\"javascript:;\">" + j.Data[0] + "</a></span></span></div><div class=\"repCon\">" + ES.Reply.data.Content + "</div></li>");
            var nr = rj.children().eq(rj.children().length - 2);
            nr.css({ opacity: 0, display: 'block' });
            nr.animate({ opacity: 1 }, 'slow');
            var rc = $e('reply_count');
            rc.innerHTML = parseInt(rc.innerHTML) + 1;
            ES.Reply.button.value = "发表留言";
        }
        else {
            alert("回复失败:" + j.Err);
        }
        $e('reply_content').value = "";
        ES.Reply.button.disabled = false;
    }
}
ES.Order={
    data:{},
    button:null,
    submit:function(e){
        this.button=ES.E(e);
        this.button.disabled = true;
        this.button.value = '发送中';
        ES.Dialog.loading.style.display='block';
        this.data=ES.You.filldata('order');
        var infohtml=this.data['title']+'<br>'+'我需要的数量是:'+this.data['number'];
        this.data['context']=infohtml+"<br>补充信息:"+this.data['context'];
        if(ES.data.proName == "" || ES.data.proName == null)
        {
           ES.data.proName = $e('title').innerHTML; 
        }     
        $.ajax({type:"POST",data:$.extend({},this.data,ES.data),url:ES.Handle+'cmd=ordersubmit&fmt=html',cache:false,dataType:"html",success:this.suc});
    },
    suc:function(j){
        if(parseInt(j)>0) {
            ES.Order.button.value="发表成功";
            setTimeout(function(){ES.Dialog.close();},1000);
        }
        else{
            ES.Order.button.value="发表失败,请重试";
        }
        ES.Dialog.loading.style.display='none';
        ES.Order.button.disabled = false;
        ES.Order.button.onclick=function(){ES.Dialog.close();};
    },
    init:function(Refer,Module,ProName){
        ES.Login.check(Refer,Module);
        if(ES.Login.is)
        {
            ES.data.proName = ProName;
            var os=new oStringBuffer();
            var ss='<div><label><span>$1：</span><$2 class="text-input" id="$3" style="$5" value="$4" $6</label></div>';
            os.append('<div><fieldset>');
            os.append('<div class="spb" style="overflow:auto;position:relative;">');
            var pro=ProName?ProName:($e('title')?$e('title').innerHTML:'');
            var y=ES.You.data;
            for(var i=0;i<y.length;i++){
                var val=ES.Login.data[y[i].id];
                if(y[i].id=='title'){
                    val=ES.You.words_order.format(pro);
                }
                os.append(ss.format(y[i].name,
                                    y[i].type,
                                    "order_"+y[i].id,
                                    val,
                                    y[i].style?y[i].style:'',
                                    y[i].type=='textarea'?'></textarea>':'/>'));
            }
            os.append('</div>');
            os.append('</fieldset></div>');
            ES.Dialog.show('发送定单',os.toString(),{width:408,height:520},'ES.Order.submit();');
        }
        else
        {
            //ES.Login.redirect();
            alert("您尚未登录,请先登录!");
            ES.Login.Open_login();
        }
    }
}
ES.Inquiry_view={
    data:{},
    title:'',
    page:1,
    init:function (Refer,Module,ReplyPage,ProName){
         var login_Judge = false;
         if(ES.Login.is)
         {
             login_Judge = true;
         }
         var os=new oStringBuffer();
         var pro=ProName?ProName:($e('title')?$e('title').innerHTML:'');
         if(pro.length >17){
            pro = pro.substring(0,17)+"...";
         } 
         os.append('<div id="Inquiry_view"></div>');
         Refer = ES.data.Refer;
         ReplyPage = "1";
         var con = "";
         if(ES.data.Module == "service" || ES.data.Module == "product"){
            con = "询价";
         }
         else{
            con = "报价";
         }
         ES.Dialog.show('"'+pro+'"的' + con + '信息',os.toString(),{width:408,height:520},'ES.Dialog.close()');
         $.ajax({type:"POST",data:$.extend({},this.data,ES.data),url:ES.Handle+'cmd=queto_view&fmt=html',cache:false,dataType:"html",success:this.suc});
    },
    suc:function(h){
         if(h!=""){
         $('#Inquiry_view')[0].innerHTML = h;
        }
    },
    pageto:function(i){
        if(this.page==i){return;}
        else{
            //alert(i);
            //$e('replyloading').style.display='block';
            $.ajax({type:"POST",data:$.extend({ReplyPageIndex:i},ES.data),url:ES.Handle+'cmd=get_page_view&fmt=html',cache:true,dataType:"html",success:this.suc});
            this.page=i;
        }
    },
    open_login:function(){
    //alert("s");
        //ES.Dialog.close();
        ES.Login.Open_login();
    }
}
ES.Inquiry={
    data:{},
    info:[{id:"i1",value:"单价",type:'checkbox'},
        {id:"i2",value:"产品规格/型号",type:'checkbox'},
        {id:"i3",value:"原产地",type:'checkbox'},
        {id:"i4",value:"能否提供样品",type:'checkbox'},
        {id:"i5",value:"最小订货量",type:'checkbox'},
        {id:"i6",value:"交货期",type:'checkbox'},
        {id:"i7",value:"供货能力",type:'checkbox'},
        {id:"i8",value:"包装方式",type:'checkbox'},
        {id:"i9",value:"质量/安全认证",type:'checkbox'}],
    title:'我还想咨询的有：',
    button:null,
    submit:function(e){
        var company = $e("inquiry_company");
        var companyadd = $e("inquiry_addr");
        var name = $e("inquiry_name");
        var phone = $e("inquiry_phone");
        var email = $e("inquiry_email");
        if(company.value == "")
        {
          alert("请输入单位名称!");
          return false;
        }
        if(companyadd.value == "")
        {
          alert("请输入单位地址!");
          return false;
        }
        if(name.value == "")
        {
          alert("请输入姓名!");
          return false;
        }
        if(phone.value == "" && email.value == "")
        {
          alert("请输入电话或者邮箱");
          return false;
        }
        this.button=ES.E(e);
        this.button.disabled = true;
        this.button.value = '发送中';
        ES.Dialog.loading.style.display='block';
        this.data=ES.You.filldata('inquiry');
        var infos=document.getElementsByName('inquiry_info');
        var infohtml=this.data['title']+'<br>'+'我需要的数量是:'+this.data['number'];
        infohtml+='<br>'+this.title+":";
        for(var i=0;i<infos.length;i++){
            if(infos[i].checked){
            infohtml+=infos[i].value+",";
            }
        }
        var price=$e('inquiry_price');
        if(price){
            infohtml+='<br>我期望的价格:'+price.value;
        }
        this.data['context']=infohtml+"<br>补充信息:"+this.data['context'];
        if(ES.data.proName == "" || ES.data.proName == null)
        {
           ES.data.proName = $e('title').innerHTML; 
        } 
        $.ajax({type:"POST",data:$.extend({},this.data,ES.data),url:ES.Handle+'cmd=inquirysubmit&fmt=html',cache:false,dataType:"html",success:this.suc});
    },
    suc:function(j){
        if(parseInt(j)>0) {
            ES.Inquiry.button.value="发表成功";
            ES.Dialog.close();
            alert("我们已获悉您的询价，并会尽快与您取得联系，谢谢！");
            //setTimeout(function(){ES.Dialog.close();},1000);
        }
        else{
            ES.Inquiry.button.value="发表失败,请重试";
        }
        ES.Dialog.loading.style.display='none';
        ES.Inquiry.button.disabled = false;
        ES.Inquiry.button.onclick=function(){ES.Dialog.close();};
    },
    init:function(Refer,Module,ProName){
        //ES.Login.check(Refer,Module);
        //if(ES.Login.is)
        //{
            var title=this.title;
            var info=this.info;
            ES.data.proName = ProName;
            var os=new oStringBuffer();
            var ss='<div><label><table  border="0" cellspacing="0" cellpadding="0"><tr><td width="70px"><span>$1：</span></td><td><$2 class="text-input" id="$3" style="$5" value="$4" $6</td></tr></table></label></div>';
            var is='<label><input type="$1" id="$2" name="$3" value="$4" />$5</label>'
            os.append('<div style=\"\"></div><div><fieldset>');
            os.append('<div class="spb" style="overflow:auto;position:relative;">');
            var pro=ProName?ProName:($e('title')?$e('title').innerHTML:'');
            var y=ES.You.data;
            for(var i=0;i<y.length;i++){
                var val=ES.Login.data[y[i].id];
                if(y[i].id=='title'){
                    val=ES.You.words.format(pro);
                }
                
                os.append(ss.format(y[i].name,
                                    y[i].type,
                                    "inquiry_"+y[i].id,
                                    val,
                                    y[i].style?y[i].style:'',
                                    y[i].type=='textarea'?'></textarea>':'/>'));
                if(y[i].id == "number"){
                     os.append(ss.format('期望价格', 'input',"inquiry_price",'','','/>'));
                     os.append('<div>'+title+'<br>');
                     for(var j=0;j<info.length;j++)
                     {
                         os.append(is.format(info[j].type,'inquiry_'+info[j].id,'inquiry_info',info[j].value,info[j].value));
                     }
                     os.append('</div>');
                }
                if(y[i].id == "context"){
                     if(ES.Login.is)
                     {
                       os.append('<div style=\"\"></div>');
                     }
                     else{
                       os.append('<div style=\"\">尊敬的访客，您好！请尽量完整地填写联系信息，便于我们及时准确地联系到您。此信息对互联网游客不予公开！</div>');
                     }
                }
            }
            os.append('</div>');
            os.append('</fieldset></div>');
            ES.Dialog.show('发送询价',os.toString(),{width:508,height:540},'ES.Inquiry.submit()');
        //}
        //else
        //{
        //    ES.Login.redirect();
        //}
    }
}
ES.Quote={
    data:{},
    button:null,
    submit:function(e){
        var company = $e("quote_company");
        var companyadd = $e("quote_addr");
        var name = $e("quote_name");
        var phone = $e("quote_phone");
        var email = $e("quote_email");
        if(company.value == "")
        {
          alert("请输入单位名称!");
          return false;
        }
        if(companyadd.value == "")
        {
          alert("请输入单位地址!");
          return false;
        }
        if(name.value == "")
        {
          alert("请输入姓名!");
          return false;
        }
        if(phone.value == "" && email.value == "")
        {
          alert("请输入电话或者邮箱");
          return false;
        }
        this.button=ES.E(e);
        this.button.disabled = true;
        this.button.value = '发送中';
        ES.Dialog.loading.style.display='block';
        this.data=ES.You.filldata('quote'); 
        var infohtml=this.data['title']+'<br>'+'我需要的数量是:'+this.data['number'];
        this.data['context']=infohtml+"<br>补充信息:"+this.data['context'];
        var reltitle=$e('title').innerHTML;     
        $.ajax({type:"POST",data:$.extend({reltitle:reltitle},this.data,ES.data),url:ES.Handle+'cmd=quotesubmit&fmt=html',cache:false,dataType:"html",success:this.suc});
    },
    suc:function(j){
        if(parseInt(j)>0) {
            ES.Quote.button.value="发表成功";
            setTimeout(function(){ES.Dialog.close();},1000);
        }
        else{
            ES.Quote.button.value="发表失败,请重试";
        }
        ES.Dialog.loading.style.display='none';
        ES.Quote.button.disabled = false;
        ES.Quote.button.onclick=function(){ES.Dialog.close();};
    },
    init:function(Refer,Module,ProName){
        //ES.Login.check(Refer,Module);
        //if(ES.Login.is)
        //{
            var os=new oStringBuffer();
            var ss='<div><label><table  border="0" cellspacing="0" cellpadding="0"><tr><td width="70px"><span>$1：</span></td><td><$2 class="text-input" id="$3" style="$5" value="$4" $6</td></tr></table></label></div>';
            if(ES.Login.is)
            {
            os.append('<div style=\"\"></div><div><fieldset>');
            }
            else{
            os.append('<div style=\"padding:5px;\">尊敬的访客，您好！请尽量完整地填写联系信息，便于我们及时准确地联系到您。此信息对互联网游客不予公开！</div><div><fieldset>');
            }
            os.append('<div class="spb" style="overflow:auto;position:relative;">')
            var pro=ProName?ProName:($e('title')?$e('title').innerHTML:'');
            var y=ES.You.data;
            for(var i=0;i<y.length;i++){
                var val=ES.Login.data[y[i].id];
                if(y[i].id=='title'){
                    val=ES.You.words_quote.format(pro);
                }
                os.append(ss.format(y[i].name,
                                    y[i].type,
                                    "quote_"+y[i].id,
                                    val,
                                    y[i].style?y[i].style:'',
                                    y[i].type=='textarea'?'></textarea>':'/>'));
            }
            os.append('</div>');
            os.append('</fieldset></div>');
            ES.Dialog.show('发送报价',os.toString(),{width:508,height:430},'ES.Quote.submit()');
       // }
        //else
        //{
        //    ES.Login.redirect();
        //}
    }
}
ES.Dialog={
    id:'dialog',
    mask:'mask_layout',
    dom:null,
    head:null,
    title:null,
    content:null,
    loading:null,
    init:function(){
        if(!this.dom)
        {
            insertHtml("beforeend",document.body,
             '<div class="layer_global" id="'+this.id+'" style="z-index:9000;display:none;position:absolute;">'+
                '<div class="layer_global_main" id="dialog_main">'+
                    '<div class="layer_global_title" id="dialog_head">'+
                        '<h3><img class="none" alt="icon" src="/eshop/in/img/b.gif" /><span id="dialog_title">title</span></h3>'+
                        '<button id="dialog_button" onclick="ES.Dialog.close();" title="close">╳</button></div>'+
                    '<div class="layer_global_cont" id="dialog_content" style="min-height:300px;"></div>'+
                '</div></div>'+
            '<div id="mask_layout" class="mask_layout" style="z-index: 5000; display:none;"></div>');
        }
        this.dom=$e(this.id);
        var m=$r(this.dom.childNodes[0]);
        this.head=$r(m.childNodes[0]);
        this.title=$r(this.head.childNodes[0]).lastChild;
        this.content=$r(this.head.nextSibling);
    },
	maskLayout:function(h){
	    var s=$('#'+this.mask);
	    s.css('height',document.documentElement.offsetHeight);
        if(h&&h!='none'){s.css({opacity:0,display:'block'});s.animate({opacity:0.2},'normal');}
        else{s.animate({opacity:'hide'},'normal');};
    },
    contentHTML:function(content,height,es,ec){
        var h='<div class="layer_global_cont mode_new_add" style="height:'+height+'px">$1</div>';
        if(es||ec){
            h+='<div class="global_tip_button"><div id="dialogloading" style="display:none;" class="replyloading"></div><button type=button onclick="$2" class="spr bt_tip" id="btn_pl_submit">确认</button>'+
            '<button type=button onclick="$3" class="spr bt_tip" id="btn_pl_back">取消</button></div>';
        }
        return h.format(content,es?es:'javascript:;',ec?ec:'ES.Dialog.close()');
    },
    show:function(title,content,option,submit){
        this.dom.style.display="block";
        for(var o in option){
            this.dom.style[o]=parseInt(option[o])+'px';
        }
        var bw=document.documentElement.offsetWidth;
        var bh=document.documentElement.offsetHeight;
        var sw=document.documentElement.scrollLeft;
        var sh=document.documentElement.scrollTop;
        var dw=this.dom.offsetWidth;
        var dh=this.dom.offsetHeight;
        
        this.dom.style.left=((bw-dw)/2+sw)+'px';
        this.dom.style.top=((bh-dh)/2+sh)+'px';
        this.title.innerHTML=title;
        this.content.innerHTML=this.contentHTML(content,this.dom.offsetHeight-64,submit);
        this.loading=$e('dialogloading');
        this.maskLayout(1);
    },
    close:function(){
        this.dom.style.display='none';
        this.title.innerHTML="";
        this.content.innerHTML="";
        this.maskLayout();
    }
}
ES.TagTip = {
    id: 'tagtip',
    color: "#c60a00",
    container: null,
    dom: null,
    title: null,
    content: null,
    data: null,
    clear: null,
    list: '<li><a target="$4" title="$1" href="$2">$3</a></li>',
    init: function() {
        ES.Login.check();
        this.container = $e('describe');
        if (this.container) {
            if (!this.dom) { insertHtml("beforeend", document.body, this.tipFrame()); }
            this.dom = $e(this.id);
            var m = $r(this.dom.childNodes[0]);
            var h = $r(m.childNodes[0]);
            this.title = $r(h.childNodes[0]).lastChild;
            this.content = $r(h.nextSibling);
            $.ajax({ type: "post",
                data: "", //$.extend({'context':decodeURIComponent(this.container.innerHTML)},ES.data), //传参数
                url: ES.Handle + 'cmd=tagtip&fmt=json',
                cache: false, dataType: "json",
                success: this.suc
            });
        }
    },
    show: function(o) {
        var s = o.innerHTML;
        var os = new oStringBuffer();
        os.append('<div class="listA"><ul>');
        var d = null;
        for (var i = 0; i < this.data.length; i++) {
            if (s == this.data[i].keyword) {
                d = this.data[i].links; break;
            }
        }
        for (var i = 0; i < d.length; i++) {
            if (d[i].href.toLowerCase().indexOf('http://') < 0 && d[i].href != '#')
                d[i].href = 'http://' + d[i].href;
            os.append(this.list.format(d[i].title, d[i].href, d[i].anchor, (d[i].href != '#' ? '_blank' : '')));

        }
        os.append('</ul></div>');
        this.title.innerHTML = s;
        this.content.innerHTML = os.toString();
    },
    close: function(a) {
        clearTimeout(ES.TagTip.clear);
        if (a) {
            ES.TagTip.dom.style.display = 'none';
        }
        else {
            this.clear = setTimeout(function() {
                var s = $(ES.TagTip.dom);
                s.animate({ opacity: 'hide' }, 'fast');
            }, 288);
        }
    },
    tipFrame: function() {
        var ev = 'onmouseover="ES.TagTip.tipover(this,event);" onmouseout="ES.TagTip.tipout(this,event);"';
        var os = new oStringBuffer();
        os.append('<div class="layer_global" ' + ev + ' id="' + this.id + '" style="z-index:4999;display:none;width:180px;height:77px;position:absolute;">');
        os.append('<div class="layer_global_main" id="dialog_main">');
        os.append('<div class="layer_global_title" style="height:17px" id="dialog_head">');
        os.append('<h3 style="font-size:12px;margin-top:0px;line-height:17px;height:17px;"><span id="dialog_title"></span></h3>');
        os.append('<button id="dialog_button" style="margin:0px;" onclick="ES.TagTip.close(true);" title="close">╳</button></div>');
        os.append('<div class="layer_global_cont" id="dialog_content" style="min-height:60px;"></div></div></div>');
        return os.toString();
    },
    parseTag: function(tags, tags_count, tags_url) {
        var str = this.container.innerHTML;
        for (var i = 0; i < tags.length; i++) {
            str = str.replace(/(^|>)([^<]+)(?=<|$)/ig, function($1, $2, $3) {
                if (tags[i]) {
                    while ($3.indexOf(tags[i]) != -1) {
                        $3 = $3.replace(tags[i], '<h_' + i + '>');
                    }
                }
                return $2 + $3;
            });
        }
        for (var i = 0; i < tags.length; i++) {
            var re = new RegExp('<h_' + i + '>', "ig");
            str = str.replace(re, function($1, $2) {
                var ev = 'onmouseover="ES.TagTip.over(this,event)" onmouseout="ES.TagTip.out(this,event)"';
                var ev_url = tags_url[i];
                if (tags_count[i] == 1) {
                    return '<a href="http://' + ev_url + '" target="_blank">' + tags[i] + '</a>';
                }
                else {
                    return '<font ' + ev + ' class="tagtip">' + tags[i] + '</font>';
                }
            });
        }
        this.container.innerHTML = str;
    },
    suc: function(j) {
        if (j.Count > 0) {
            ES.TagTip.data = j.Data;
            var ks = [];
            var ks_count = [];
            var ks_url = [];
            for (var i = 0; i < j.Data.length; i++) {
                ks[i] = j.Data[i].keyword;
                var jj = j.Data[i].links.length;
                ks_count[i] = jj;
                if (jj == 1) {
                    ks_url[i] = j.Data[i].links[0].href;
                }
                else {
                    ks_url[i] = "0";
                }
            }
            ES.TagTip.parseTag(ks, ks_count, ks_url);
        }
    },
    tipover: function(o, e) {
        clearTimeout(this.clear);
        var s = $(this.dom);
        s.css({ display: 'block' });
        s.animate({ opacity: 1 }, 'normal');
    },
    tipout: function(o, e) {
        this.close();
    },
    over: function(o, e) {
        var xy = this.getMouseXY(e);
        this.setXY(ES.TagTip.dom, xy.x, xy.y);
        this.show(o);
        var s = $(this.dom);
        s.css({ opacity: 0, display: 'block' }); s.animate({ opacity: 1 }, 'normal');
        o.onmouserover = null;
    },
    out: function(o, e) {
        this.close();
        o.onmouserover = function(o, e) { ES.TagTip.over(o, e); };
    },
    getMouseXY: function(e) {
        e = window.event || e;
        var _x = e.pageX || (e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft));
        var _y = e.pageY || (e.clientY + (document.documentElement.scrollTop || document.body.scrollTop));
        return { x: _x, y: _y };
    },
    getXY: function(el) {
        var _t = 0; var _l = 0;
        if (document.documentElement.getBoundingClientRect) {
            var box = el.getBoundingClientRect();
            var oDoc = el.ownerDocument;
            _t = box.top - 2 + this.getScrollTop(oDoc);
            _l = box.left - 2 + this.getScrollLeft(oDoc);
        } else {
            while (el.offsetParent) {
                _t += el.offsetTop;
                _l += el.offsetLeft;
                el = el.offsetParent;
            }
        }
        return { left: _l, top: _t };
    },
    setXY: function(el, x, y) {
        var _ml = parseInt(el.style.marginLeft) || 0;
        var _mt = parseInt(el.style.marginTop) || 0;
        el.style.left = parseInt(x) - _ml + "px";
        el.style.top = parseInt(y) - _mt + "px";
    },
    getScrollLeft: function(doc) {
        doc = doc || document;
        return Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft);
    },
    getScrollTop: function(doc) {
        doc = doc || document;
        return Math.max(doc.documentElement.scrollTop, doc.body.scrollTop);
    }
}
function ValidateCode(imgId)
{
    var img = document.getElementById(imgId);
    img.src = "/SubSystem/LoginVfCode.aspx?"  + Math.random();
}
function RefVCode()
{
    ValidateCode('imgVerify');
}
ES.Collection={
    show:function(e){
       var xy=this.getMouseXY(e);
       $("#Collection")[0].style.display = "";
       $("#Collection")[0].style.top = xy.y+"px";
       $("#Collection")[0].style.left = xy.x+"px";
    },
    close:function(){
       $("#Collection")[0].style.display = "none";
    },
    getMouseXY:function(e){
        e=window.event||e;
		var _x=e.pageX||(e.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));
		var _y=e.pageY||(e.clientY+(document.documentElement.scrollTop||document.body.scrollTop));
		return {x:_x,y:_y};
    },
    h:function(o, l){
      if (document.all)
      {
         window.external.addFavorite(o, l);
      }
      else if (window.sidebar)
      {
         window.sidebar.addPanel(o, l, "");
      }
    },
    submit_c:function(name,website,pic,aid,gsname){
        ES.Login.check('0','c');
        if(ES.Login.is)
        {
           $.ajax({type:"POST",data:$.extend({name:encodeURIComponent(name),website:encodeURIComponent(website),pic:pic,aid:aid,gsname:encodeURIComponent(gsname)},ES.data),url:ES.Handle+'cmd=collection_submit&fmt=html',cache:true,dataType:"html",success:this.succss});
        }
        else
        {
            //ES.Login.redirect();
            alert("您尚未登录,请先登录!");
            ES.Login.Open_login();
        }
    },
    succss:function(h){
       if(h == "3"){
       alert("此网站已收藏!");
       }
       else if(h == "1"){
       alert("收藏成功!");
       }
       else{
       alert("收藏失败!");
       }
    }
}
