﻿ //showmember();
 var cid=0; 
 function closethis(id)
{
  var obj = document.getElementById(id);
  obj.style.display="none";
}
function checkc()
{
if(document.getElementById("cbmcountry").value=="0")

{
document.getElementById("dcountry").style.display="";
return false;
}
}



function CheckIsChinese(content) { 
var str=content; 

var s; 
var ts; 
var tscode; 
for (i=0;i<str.length;i++) { 
ts=str.substring(i); 
tscode=str.charCodeAt(i); 
if ((tscode<19968)) {//alert("you must input chinese"); 
//return false;i
} 

else {
return false;

}

} 
return true; 
}

    function showmember(){
       
             
                //创建浏览器兼容的XMLHttpRequest对象
                var xmlhttp1;
                try{
                    xmlhttp1= new ActiveXObject('Msxml2.XMLHTTP');
                }catch(e){
                    try{
                        xmlhttp1= new ActiveXObject('Microsoft.XMLHTTP');
                    }catch(e){
                        try{
                            xmlhttp1= new XMLHttpRequest();
                        }catch(e){}
                    }
                }
                //定义XMLHttpRequest对象的事件处理程序
                xmlhttp1.onreadystatechange=function(){
                    if(xmlhttp1.readyState==4){
                        //关闭显示条
                       
                        if(xmlhttp1.status==200){
                            //当加载成功时将内容显示于页面
                            if(xmlhttp1.responseText==0)
                            {
   
                             document.getElementById("member").style.display="";
                                //document.getElementById("password").style.display="";
                           
                            }
                            else
                            {
                              IsMemberAjax=2;
                              document.getElementById("member").style.display="none";
                               document.getElementById("password").style.display="none";
                              document.getElementById("txtcontent").value="";
                          
                            }
                        }else{
                            //否则弹出错误信息
                             
                        }
                    }
                }
                //创建一个连接
                xmlhttp1.open("get","/Hotproducts/ajaxmember.aspx?d="+new Date());
                //发送请求
                xmlhttp1.send(null);

            }
            


                            var sort=0;
                  function cgsort()
                  {
                  if(sort==0)
                  {
                   sort=1;
                  }
                  else
                  {
                  sort=0;
                  }
                  }
            
                   function showsupplierp(cas,page){
                   if(document.getElementById("s1")!=null)
                   {
                     cid=  document.getElementById("s1").value;
                     }
                  
                //创建浏览器兼容的XMLHttpRequest对象
                var xmlhttp1;
                try{
                    xmlhttp1= new ActiveXObject('Msxml2.XMLHTTP');
                }catch(e){
                    try{
                        xmlhttp1= new ActiveXObject('Microsoft.XMLHTTP');
                    }catch(e){
                        try{
                            xmlhttp1= new XMLHttpRequest();
                        }catch(e){}
                    }
                }
                //定义XMLHttpRequest对象的事件处理程序
                xmlhttp1.onreadystatechange=function(){
                    if(xmlhttp1.readyState==4){
                        //关闭显示条
                       
                        if(xmlhttp1.status==200){
                            //当加载成功时将内容显示于页面
                             document.getElementById("supplierhtml").innerHTML=xmlhttp1.responseText;

                        }else{
                            //否则弹出错误信息
                             
                        }
                    }
                }
                //创建一个连接
                xmlhttp1.open("get","/Hotproducts/ajaxsupplier.aspx?cas="+cas+"&CountryId="+cid+"&Integral="+sort+"&p="+page);
                //发送请求
                xmlhttp1.send(null);

            }
        
               function showsupplier(cas){
                     if(document.getElementById("s1")!=null)
                   {
                 cid= document.getElementById("s1").value;
                 }
                //创建浏览器兼容的XMLHttpRequest对象
                var xmlhttp1;
                try{
                    xmlhttp1= new ActiveXObject('Msxml2.XMLHTTP');
                }catch(e){
                    try{
                        xmlhttp1= new ActiveXObject('Microsoft.XMLHTTP');
                    }catch(e){
                        try{
                            xmlhttp1= new XMLHttpRequest();
                        }catch(e){}
                    }
                }
                //定义XMLHttpRequest对象的事件处理程序
                xmlhttp1.onreadystatechange=function(){
                document.getElementById("supplierhtml").innerHTML="<div style=\"text-align: center;\">Loading...</div>";
                    if(xmlhttp1.readyState==4){
                        //关闭显示条
                       
                        if(xmlhttp1.status==200){
                            //当加载成功时将内容显示于页面
                             document.getElementById("supplierhtml").innerHTML=xmlhttp1.responseText;

                        }else{
                            //否则弹出错误信息
                             
                        }
                    }
                }
                //创建一个连接
                xmlhttp1.open("get","/Hotproducts/ajaxsupplier.aspx?cas="+cas+"&CountryId="+cid+"&Integral="+sort);
                //发送请求
                xmlhttp1.send(null);

            }


            function dosubmitp() {

                obj = document.getElementById("txtemail");
                var patn = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
                if (document.getElementById("member").style.display != "none") {
                    if (!patn.test(obj.value)) {
                        alert("Please enter a valid email address.");
                        document.getElementById("txtemail").focus();
                        return;
                    }
                    if (document.getElementById("txtemail").value != "") {
                        CheckEmailIsMember();
                        if (document.getElementById("memberexits").style.display == "") {
                            if (document.getElementById("Passworderr").style.display == "") {
                                alert("Invalid member ID or password. Please try again");
                                return;
                            }
                        }
                    }
                }
                if (document.getElementById("txtcontent").value.replace(/\r\n/g, "").replace(/\s/ig, "").replace("Company:Contact:Tel:MSN:Requirements:", "").length < 10) {
                    alert("Your message must be between 10-1000 characters");
                    return;
                }
                if (!CheckIsChinese(document.getElementById("txtcontent").value)) {
                    alert("Please enter English characters only！");
                    return;
                }
                if (document.getElementById("isloginvalue").value == 0) {
                    showcontact(true);
                }
                else if (document.getElementById("isloginvalue").value == 2) {
                    document.getElementById("formsend").submit();
                }
                else {
                    if (document.getElementById("txtpassword").value.length >= 6) {
                        document.getElementById("formsend").submit();
                    }
                    else {
                        alert("password must be 6 - 20 characters !");
                    }
                }


            }
 
                 function isdel()
            {
            var ok=confirm("确定删除吗?");
            if(!ok)return false
            else return true
            
            }
            function GetCookie(name)
{
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
        if(arr=document.cookie.match(reg)) return unescape(arr[2]);
        else return null;
}

var IsMemberAjax=0;


function showsendp(cas, product, userid, islogin) {

    document.writeln("<a name=\"Inquire\"></a>");
    document.writeln("<form id=\"formsend\" action=\"/HotProducts/send.aspx?type=productname\" method=\"post\">");
    document.writeln("<table width=\"100%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"margin-bottom: 10px;\">");
    document.writeln("<tr><td align=\"right\"><span class=\"location_font2\">CAS:</span></td>");
    document.writeln("<td align=\"left\"> <input type=\"hidden\" value=\"" + islogin + "\" id=\"isloginvalue\" name=\"isloginvalue\" /><input name=\"txtcas\" type=\"text\" value=\"" + cas + "\" maxlength=\"20\" id=\"txtcas\" /></td>");
    document.writeln("</tr><tr><td  align=\"right\"><span class=\"location_font\">Purchase Request:</span></td>");
    document.writeln("<td  align=\"left\"><input name=\"txttitle\" type=\"text\" value=\"Name:" + product + "\" maxlength=\"255\" id=\"txttitle\"  style=\"width:300px;\" />                               </td></tr>");
    document.writeln("<tr id=\"member\"><td align=\"right\"><span class=\"location_font\">Your email: </span></td><td align=\"left\">");
    document.writeln("<input name=\"txtemail\" type=\"text\" maxlength=\"100\" id=\"txtemail\" tabindex=\"1\"  style=\"width:251px;\" onBlur=\"javascript:CheckEmailIsMember();\"/><div id=\"memberexits\" style=\"display:none;\">Please enter your LookChem.com password!</div>");
    document.writeln("</td></tr><tr id=\"password\" style=\"display:none;\"><td align=\"right\"><span class=\"location_font\">Password: </span></td><td align=\"left\">");
    document.writeln("<input name=\"txtpassword\" type=\"password\" maxlength=\"100\" id=\"txtpassword\" tabindex=\"1\" onBlur=\"javascript:CheckEmailandPwd();\"  style=\"width:251px;\" /> <a href=\"/forget_password.aspx\" target=\"_blank\">Forget your password?</a> <div id=\"Passworderr\" class=\"C_Error\" style=\"display:none;\">Invalid member ID or password. Please try again</div>");
    document.writeln("</td></tr><tr><td align=\"right\" valign=\"top\"><span class=\"location_font\">Requirements:</span></td>");
    document.writeln("<td align=\"left\"><textarea name=\"txtcontent\" rows=\"2\" cols=\"20\" id=\"txtcontent\"  style=\"height:100px;width:450px;\">");
    document.writeln("</textarea><div class=\"lnquiry_Error1\" id=\"dcontent\" style=\"display: none;\">Please enter your message\'s description.</div></td></tr>");
    document.writeln("<tr><td colspan=\"2\" align=\"center\" style=\"height: 45px\">");
    document.writeln("<img src=\"/images/Buyer.Seller/Send.gif\" style=\"padding-top:5px\" onclick=\"dosubmitp()\" title=\"Send RFQ for " + product + "\" style=\"border-width:0px; cursor:pointer;\" />");
    document.writeln("<br /><span class=\"font_5\" style=\"text-align:left;\">Please tick the suppliers below to send inquiries. Or complete and post your buying offer of CAS No " + cas + " above with <br />your contact details. So that our qualified suppliers will send you quotations soonest. </span><br><span id=\"issupplier\"></span></td></tr>");
    document.writeln("</table></form>");
    if (userid == 0) {

        document.getElementById("member").style.display = "";
        if (GetCookie('BuyEmail') != '' && GetCookie('BuyEmail') != null) {
            document.getElementById("txtemail").value = GetCookie('BuyEmail');
            CheckEmailIsMember();
        }

    }
    else {
        IsMemberAjax = 2;
        document.getElementById("member").style.display = "none";
        document.getElementById("password").style.display = "none";
        document.getElementById("txtcontent").value = "";

    }

}


function CheckEmailandPwd() {
    IsMemberAjax = 0;

    var email = document.getElementById("txtemail").value;
    var pwd = document.getElementById("txtpassword").value;

    var xmlhttp1;
    try {
        xmlhttp1 = new ActiveXObject('Msxml2.XMLHTTP');
    } catch (e) {
        try {
            xmlhttp1 = new ActiveXObject('Microsoft.XMLHTTP');
        } catch (e) {
            try {
                xmlhttp1 = new XMLHttpRequest();
            } catch (e) { }
        }
    }

    xmlhttp1.onreadystatechange = function() {
        if (xmlhttp1.readyState == 4) {
            //关闭显示条

            if (xmlhttp1.status == 200) {
                //当加载成功时将内容显示于页面

                if (xmlhttp1.responseText == "1") {
                    document.getElementById("Passworderr").style.display = "none";
                    return true;
                }
                else {
                    document.getElementById("Passworderr").style.display = "";
                    return false;

                }

            } else {
                //否则弹出错误信息

            }
        }
    }
    //创建一个连接
    xmlhttp1.open("get", "/server/Member.aspx?type=2&Email=" + email + "&pwd=" + pwd + "&d=" + new Date());
    //发送请求
    xmlhttp1.send(null);
}




function showsendc(cas, product, userid, islogin) {

    document.writeln("<a name=\"Inquire\"></a>");
    document.writeln("<form id=\"formsend\" action=\"/HotProducts/send.aspx?type=cas\" method=\"post\">");
    document.writeln("<table width=\"100%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"margin-bottom: 10px;\">");
    document.writeln("<tr><td align=\"right\"><span class=\"location_font2\">CAS:</span></td>");
    document.writeln("<td align=\"left\"> <input type=\"hidden\" value=\"" + islogin + "\" id=\"isloginvalue\" name=\"isloginvalue\" /><input name=\"txtcas\" type=\"text\" value=\"" + cas + "\" maxlength=\"20\" id=\"txtcas\" /></td>");
    document.writeln("</tr><tr><td  align=\"right\"><span class=\"location_font\">Purchase Request:</span></td>");
    document.writeln("<td  align=\"left\"><input name=\"txttitle\" type=\"text\" value=\"Name:" + product + "\" maxlength=\"255\" id=\"txttitle\"  style=\"width:300px;\" />                               </td></tr>");
    document.writeln("<tr id=\"member\"><td align=\"right\"><span class=\"location_font\">Your email: </span></td><td align=\"left\">");
    document.writeln("<input name=\"txtemail\" type=\"text\" maxlength=\"100\" id=\"txtemail\" tabindex=\"1\"  style=\"width:251px;\" onBlur=\"javascript:CheckEmailIsMember();\"/><div id=\"memberexits\" style=\"display:none;\">Please enter your LookChem.com password!</div>");
    document.writeln("</td></tr><tr id=\"password\" style=\"display:none;\"><td align=\"right\"><span class=\"location_font\">Password: </span></td><td align=\"left\">");
    document.writeln("<input name=\"txtpassword\" type=\"password\" maxlength=\"100\" id=\"txtpassword\" tabindex=\"1\"  style=\"width:251px;\" /> <a href=\"/forget_password.aspx\" target=\"_blank\">Forget your password?</a> ");
    document.writeln("</td></tr><tr><td align=\"right\" valign=\"top\"><span class=\"location_font\">Requirements:</span></td>");
    document.writeln("<td align=\"left\"><textarea name=\"txtcontent\" rows=\"2\" cols=\"20\" id=\"txtcontent\"  style=\"height:100px;width:450px;\">");
    document.writeln("</textarea><div class=\"lnquiry_Error1\" id=\"dcontent\" style=\"display: none;\">Please enter your message\'s description.</div></td></tr>");
    document.writeln("<tr><td colspan=\"2\" align=\"center\" style=\"height: 45px\">");
    document.writeln("<img src=\"/images/Buyer.Seller/Send.gif\" onclick=\"dosubmitp()\" title=\"Send RFQ for " + product + "\" style=\"border-width:0px; cursor:pointer;\" />");
    document.writeln("<br /><span class=\"font_2\" style=\"text-align:left;\">Please tick the suppliers below to send inquiries. Or complete and post your buying offer of CAS No " + cas + " above with <br />your contact details. So that our qualified suppliers will send you quotations soonest. </span><br><span id=\"issupplier\"></span></td></tr>");
    document.writeln("</table></form>");
    if (userid == 0) {

        document.getElementById("member").style.display = "";
        if (GetCookie('BuyEmail') != '' && GetCookie('BuyEmail') != null) {
            document.getElementById("txtemail").value = GetCookie('BuyEmail');
            CheckEmailIsMember();
        }

    }
    else {
        IsMemberAjax = 2;
        document.getElementById("member").style.display = "none";
        document.getElementById("password").style.display = "none";
        document.getElementById("txtcontent").value = "";

    }

}

            function CheckEmailIsMember()
            {
                IsMemberAjax = 0;
            obj=document.getElementById("txtemail");
              var patn = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
              if (document.getElementById("member").style.display != "none") {
                  if (!patn.test(obj.value)) {

                      return;
                  }
              }
          var xmlhttp1;
                try{
                    xmlhttp1= new ActiveXObject('Msxml2.XMLHTTP');
                }catch(e){
                    try{
                        xmlhttp1= new ActiveXObject('Microsoft.XMLHTTP');
                    }catch(e){
                        try{
                            xmlhttp1= new XMLHttpRequest();
                        }catch(e){}
                    }
                }

                xmlhttp1.onreadystatechange = function() {
                    if (xmlhttp1.readyState == 4) {
                        //关闭显示条

                        if (xmlhttp1.status == 200) {
                            //当加载成功时将内容显示于页面
                            if (xmlhttp1.responseText == "1") {
                                document.getElementById("password").style.display = '';
                                document.getElementById("isloginvalue").value = "1";
                                document.getElementById("memberexits").style.display = '';
                                //document.getElementById("member1").style.display='none';
                            }
                            else {
                                document.getElementById("isloginvalue").value = "0";
                                document.getElementById("password").style.display = 'none';
                                document.getElementById("memberexits").style.display = 'none';
                                // document.getElementById("member1").style.display='';
                            }

                        } else {
                            //否则弹出错误信息

                        }
                    }
                }
                //创建一个连接
                xmlhttp1.open("get","/Hotproducts/ajaxIsMemberByEmail.aspx?Email="+document.getElementById("txtemail").value+"&d="+new Date());
                //发送请求
                xmlhttp1.send(null);
            }
