﻿/* Common start */
var cid = 0; 
//是否为汉字
function isChinese(content) {
    var patrn = /[\u4e00-\u9fa5]+/;
    if (patrn.exec(content)) return true;
    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"); 
        }
        else {
            return false;

        }
    }
    return true;
}

//通过Id获取DOM对象
function G(id) {
    if (typeof (id) == "string") {
        return document.getElementById(id);
    }
    return id;
}

function clearHtmlTags(str) {
    return str.replace(/<[^\]]+?>/gi, "");
}

function clearWhite(str) {
    return str.replace("&nbsp;", "");
}

/* Common end */

/* cookie start */
function GetCookie(name) {

    var start = document.cookie.indexOf(name + "=");
    var len = start + name.length + 1;
    if ((!start) &&
(name != document.cookie.substring(0, name.length))) {
        return null;
    }
    if (start == -1) return null;
    var end = document.cookie.indexOf(";", len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len, end));
}

function DeleteCookie(name, path, domain) {
    if (GetCookie(name)) document.cookie = name + "=" +
((path) ? ";path=" + path : "") +
((domain) ? ";domain=" + domain : "") +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
    removeAllContent();
}

//移除
function removeAllContent() {
    var parentNode = document.getElementById("last_explorer_products");
    var chlidNodeList = parentNode.getElementsByTagName("dl");
    for (var i = 0; i < chlidNodeList.length; i++) {
        parentNode.removeChild(chlidNodeList[i]);
    }

}
/* cookie end */

/* selectall start */

function returl(v) {
    if (getUrl().indexOf("ad=NO") != -1) {
        if (getUrl().indexOf("Integral=1") != -1) {
            return getPathName() + "?ad=NO&Integral=1&countryid=" + v;
        }
        return getPathName() + "?ad=NO&countryid=" + v;
    }
    if (getUrl().indexOf("Integral=1") != -1) {
        return getPathName() + "?Integral=1&countryid=" + v;
    }
    return getPathName() + "?countryid=" + v;
}

function goCountry(id) {
    var currentUrl = getPathName();
    if (currentUrl.indexOf("?") != -1) {
        currentUrl += "&countryid=" + id;
    } else {
        currentUrl += "?countryid=" + id;
    }
    if (getUrl().indexOf("ad=NO") != -1) {
        currentUrl += "&ad=NO";
    }
    window.location.href = currentUrl;

}

function goBusinessType(businessType) {
    var currentUrl = getPathName();
    if (currentUrl.indexOf("?") != -1) {
        currentUrl += "&bt=" + businessType;
    } else {
        currentUrl += "?bt=" + businessType;
    }
    if (getUrl().indexOf("ad=NO") != -1) {
        currentUrl += "&ad=NO";
    }
    window.location.href = currentUrl;
}

function goCertificates(title) {
    var currentUrl = getPathName();
    if (currentUrl.indexOf("?") != -1) {
        currentUrl += "&cf=" + title;
    } else {
    currentUrl += "?cf=" + title;
    }
    if (getUrl().indexOf("ad=NO") != -1) {
        currentUrl += "&ad=NO";
    }
    window.location.href = currentUrl;
}


function goSynthesis() {
    var currentUrl = getPathName();

    if (currentUrl.indexOf("?") != -1) {
        currentUrl += "&showtype=synthesis";
    } else {
        currentUrl += "?showtype=synthesis";
    }

    if (getUrl().indexOf("ad=NO") != -1) {
        currentUrl += "&ad=NO";
    }
    window.location.href = currentUrl;
}

function goSuppliers() {
    var currentUrl = getPathName();
    if (getUrl().indexOf("ad=NO") != -1) {
        currentUrl += "?ad=NO";
    }
    window.location.href = currentUrl.replace(/[\?|&]?showtype=synthesis/gi, "");
}

function goMemberShip(memberShip) {
    var currentUrl = getPathName();
    if (currentUrl.indexOf("?") != -1) {
        currentUrl += "&mg=" + memberShip;
    } else {
        currentUrl += "?mg=" + memberShip;
    }
    if (getUrl().indexOf("ad=NO") != -1) {
        currentUrl += "&ad=NO";
    }
    window.location.href = currentUrl;

}

function SeniorMember() {
    var v;
    if (G("seniormember").checked) {
        v = 1;
    }
    else {
        v = 0;
    }
    if (v == 1) {
        if (getUrl().indexOf("?") != -1) {
            return getUrl().replace("&SeniorMember=0", "").replace("SeniorMember=0", "") + "&SeniorMember=1";
        }
        else {
            return getUrl() + "?SeniorMember=1";
        }
    }
    else {
        if (getUrl().indexOf("?") != -1) {
            return getUrl().replace("&SeniorMember=1", "").replace("SeniorMember=1", "") + "&SeniorMember=0";
        }
        else {
            return getUrl() + "?SeniorMember=0";
        }
    }
}

function OrderbyPoint() {
    var v;
    if (G("orderselect").checked) {
        v = 1;
    }
    else {
        v = 0;
    }

    if (v == 1) {
        if (getUrl().indexOf("?") != -1) {

            return getUrl().replace("&Integral=0", "").replace("Integral=0", "") + "&Integral=1";
        }
        else {
            return getUrl() + "?Integral=1";
        }
    }
    else {
        if (getUrl().indexOf("?") != -1) {
            return getUrl().replace("&Integral=1", "").replace("Integral=1", "") + "&Integral=0";
        }
        else {
            return getUrl() + "?Integral=0";
        }
    }
}

function OrderbyPoint(v) {
   var url = '';
   if (v == 'pointsort') {
        if (getUrl().indexOf("?") != -1) {

            url = getUrl().replace("&Integral=0", "").replace("Integral=0", "") + "&Integral=1";
        }
        else {
            url = getUrl() + "?Integral=1";
        }
    }
    else {
        if (getUrl().indexOf("?") != -1) {
            url = getUrl().replace("&Integral=1", "").replace("Integral=1", "") + "&Integral=0";
        }
        else {
            url = getUrl() + "?Integral=0";
        }
    }
    window.location = url;
}

function CheckAll(form, sel) {
    var defaultcheck = sel.checked;
    var k = 0;
    for (i = 0; i < form.elements.length; i++) {
        if (form.elements[i].name == 'SPId') {
            k++;
            form.elements[i].checked = defaultcheck;
            if (defaultcheck) {
                if (document.getElementById("dll" + k)) {
                    document.getElementById("dll" + k).style.backgroundColor = '#FFFAE3';
                }
            }
            else {
                if (document.getElementById("dll" + k)) {
                    document.getElementById("dll" + k).style.backgroundColor = '#ffffff';
                }
            }
        }
    }

    if (!defaultcheck) {
        G("subinquiry").disabled = true;
        if (isElementExists("subinquiry1"))
            G("subinquiry1").disabled = true;
    }
    else {
        G("subinquiry").disabled = false;
        if (isElementExists("subinquiry1"))
            G("subinquiry1").disabled = false;
    }
}

//定制合成
function CheckAllBySynthesis(form, sel) {
    var defaultcheck = sel.checked;
    var k = 0;
    for (i = 0; i < form.elements.length; i++) {
        if (form.elements[i].name == 'PId') {
            k++;
            form.elements[i].checked = defaultcheck;
            //选择后改变背景颜色
            if (defaultcheck) {
                document.getElementById("dls" + k).style.backgroundColor = '#FFFAE3';
                
            }
            else {
                document.getElementById("dls" + k).style.backgroundColor = '#ffffff';
            }
        }
    }

    if (k > 1) { 
        
    
    }

    if (!defaultcheck) {
        G("SynthesisInquiry").disabled = true;
        if (isElementExists("SynthesisInquiry1"))
            G("SynthesisInquiry1").disabled = true;
    }
    else {
        G("SynthesisInquiry").disabled = false;
        if (isElementExists("SynthesisInquiry1") != null)
            G("SynthesisInquiry1").disabled = false;
    }
}

function strlen() {
    G("charcount").innerHTML = G("forbuytext").value.replace(/[^\x00-\xff]/g, "**").length;
}

function checkbtn(form) {
    var flag = false;
    for (var i = 0; i < form.elements.length; i++) {
        var e = form.elements[i];
        if ((e.name == 'SPId' && e.checked == true)) {
            flag = true;
            break;
        }
    }
    
    if (!flag) {
        G("subinquiry").disabled = true;
        if (isElementExists("subinquiry1"))
            G("subinquiry1").disabled = true;
    }
    else {
        G("subinquiry").disabled = false;
        if (isElementExists("subinquiry1"))
            G("subinquiry1").disabled = false;
    }
}

// "<div id=\"contrast\" class=\"contrast\"><p>您可以选择：</p><p><a class=\"plprice\" href=\"#\"></a><span>或</span><a class=\"dbpro\" href=\"contrast.html\"></a></p></div>"
function checkbtn(form,checkvalue) {
    var flag = false;
    var checkcount = 0;
    var arrays = new Array();
    var selectedids = "";
    for (var i = 0; i < form.elements.length; i++) {
        var e = form.elements[i];
        if ((e.name == 'SPId' && e.checked == true)) {
            flag = true;
            //break;
            e.checked = true;
            selectedids += e.id.replace("SPId", "") + ",";
            checkcount++;
        }
    }
    var arrays = selectedids.split(",");
   
    if (G("contrast")) {
        closethis("contrast");
    }
    var contrasthtml = "<div id=\"contrast\" class=\"contrast\">Select suppliers and  <input name=\"imageField223\"  class=\"inquiry_button\" id=\"subinquiry1\" type=\"image\" src=\"/images/Buyer.Seller/send_inquiry_en.gif\" complete=\"complete\"/><span class=\"close\"><img onclick=\"closethis('contrast');\" src=\"/newproduct/images/close.gif\"></span></div>" 
    if (checkcount >= 2) {
        if (G("SPId" + checkvalue).checked) {
            G("dl" + checkvalue).innerHTML = contrasthtml + G("dl" + checkvalue).innerHTML;
            document.getElementById("SPId" + checkvalue).checked = true;
        }
        else {
            var PreviousX = arrays[0];
            for (i = 0; i < arrays.length - 1; i++) 
            {
                if (Math.abs(PreviousX - checkvalue) > Math.abs(arrays[i] - checkvalue) && checkvalue != arrays[i]) {
                    PreviousX = arrays[i];
                }
            }
            G("dl" + PreviousX).innerHTML = contrasthtml + G("dl" + PreviousX).innerHTML;
            document.getElementById("SPId" + PreviousX).checked = true;
        }
    }
    else {
    }
  
//    if (!flag) {
//        G("subinquiry").disabled = true;
//        if (isElementExists("subinquiry1"))
//            G("subinquiry1").disabled = true;
//    }
//    else {
//        G("subinquiry").disabled = false;
//        if (isElementExists("subinquiry1"))
//            G("subinquiry1").disabled = false;
//    }
}


function closethis(e) {
    document.getElementById(e).parentNode.removeChild(document.getElementById(e));
} 


function checkbtnBySynthesis(form) {
    var flag = false;
    for (var i = 0; i < form.elements.length; i++) {
        var e = form.elements[i];
        if ((e.name == 'PId' && e.checked == true)) {
            flag = true;
            break;
        }
    }

    if (!flag) {
        G("SynthesisInquiry").disabled = true;
        if (isElementExists("SynthesisInquiry1"))
            G("SynthesisInquiry1").disabled = true;
    }
    else {
        G("SynthesisInquiry").disabled = false;
        if (isElementExists("SynthesisInquiry1"))
            G("SynthesisInquiry1").disabled = false;
    }
}



function checkbtnBySynthesis(form,checkvalue) {
    var flag = false;
    var checkcount = 0;
    var arrays = new Array();
    var selectedids = "";
    for (var i = 0; i < form.elements.length; i++) {
        var e = form.elements[i];
        if ((e.name == 'PId' && e.checked == true)) {
            flag = true;
            //break;
            e.checked = true;
            selectedids += e.id.replace("PId", "") + ",";
            checkcount++;
        }
    }


    var arrays = selectedids.split(",");

    if (G("contrast")) {
        closethis("contrast");
    }
    var contrasthtml = "<div id=\"contrast\" class=\"contrast\">Select suppliers and  <input name=\"imageField223\"  class=\"inquiry_button\" id=\"subinquiry1\" type=\"image\" src=\"/images/Buyer.Seller/send_inquiry_en.gif\" complete=\"complete\"/><span class=\"close\"><img onclick=\"closethis('contrast');\" src=\"/newproduct/images/close.gif\"></span></div>"
    if (checkcount >= 2) {
        if (G("PId" + checkvalue).checked) {
            G("dl" + checkvalue).innerHTML = contrasthtml + G("dl" + checkvalue).innerHTML;
            document.getElementById("PId" + checkvalue).checked = true;
        }
        else {
            var PreviousX = arrays[0];
            for (i = 0; i < arrays.length - 1; i++) {
                if (Math.abs(PreviousX - checkvalue) > Math.abs(arrays[i] - checkvalue) && checkvalue != arrays[i]) {
                    PreviousX = arrays[i];
                }
            }
            G("dl" + PreviousX).innerHTML = contrasthtml + G("dl" + PreviousX).innerHTML;
            document.getElementById("PId" + PreviousX).checked = true;
        }
    }
    else {
    }

//    if (!flag) {
//        G("SynthesisInquiry").disabled = true;
//        if (isElementExists("SynthesisInquiry1"))
//            G("SynthesisInquiry1").disabled = true;
//    }
//    else {
//        G("SynthesisInquiry").disabled = false;
//        if (isElementExists("SynthesisInquiry1"))
//            G("SynthesisInquiry1").disabled = false;
//    }
}


function bInquiry(spid) {
    G(spid).checked = true;
    G("frmbuy").submit();
}

function bInquiryByGroup(pid, casno) {
    G("casno").value = casno;
    G(pid).checked = true;
    G("formgroup").submit();
}

function batchInquiry() {
    G("frmbuy").submit();
}

function batchContrast() {
    var form = G("frmbuy");
    form.action = "/Contrast.aspx";
    form.submit();
}



function check() {
    if (G("forbuytext").value.length < 20) {
        alert("Please Enter between 20 to 2,000 characters.");
        return false;
    }

}

function getUrl() {
    return window.location.href;
}

function getPathName() {
    return window.location.pathname;
}

function isElementExists(element) {
    if (G(element) != null) {
        return true;
    }
    return false;
}
/* selectall end */

/* tool start */

function createXMLHttpRequest() {
    var xmlHttp;
    try {
        xmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
    } catch (e) {
        try {
            xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
        } catch (e) {
            try {
                xmlHttp = new XMLHttpRequest();
            } catch (e) { }
        }
    }
    return xmlHttp;
}

var loadinglayer;
var loadingdiv;
function showloading(isdisplay) {
    if (isdisplay) {

        loadinglayer = document.createElement("div");
        document.body.appendChild(loadinglayer);
        loadinglayer.style.cssText = "position:absolute;z-index:999;filter:alpha(opacity=75);background:#666;opacity: 0.5;-moz-opacity: 0.5;left:0;top:0;";
        loadingdiv = document.createElement("div");
        document.body.appendChild(loadingdiv);
        loadingdiv.style.cssText = "color:#ff5500;font-weight: bold;padding-left: 190px;padding-right:20px;padding-top: 10px;padding-bottom:10px;background-image: url(/images/loading2.gif);background-repeat: no-repeat;background-position: 5px;border: #b2b1b1 solid 1px;height:58px;font-size: 10px;position: absolute; font-size:12px;z-index: 1000;";
        try {

            loadinglayer.style.display = "block";
            loadingdiv.style.display = "block";
            loadinglayer.style.width = document.documentElement.clientWidth + "px";
            loadinglayer.style.height = document.documentElement.clientHeight + "px";
            loadingdiv.style.top = document.documentElement.scrollTop + "px";
            loadingdiv.style.left = (document.documentElement.clientWidth / 2 - 100) + "px";

        }
        catch (e) { }
    } else {
        try {
            document.body.removeChild(loadinglayer);
            document.body.removeChild(loadingdiv);

        }
       catch (e) { }
    }
}

function changeimg() {
    
    var img = G("imgcountry");
    var obj = G("cbmcountry");
    img.src = "/images/country/" + obj.value.split("#")[0] + ".gif";
    if (G("cbmcountry").value != 0) {
        G("phoneCountry").value = obj.value.split("#")[2];
       
    }
}

var contexterr = "Your message must be between 10-1000 characters";
var contextchineseerr = "Please enter English characters only!";

function checkshowcontactall() {
  
    if (loginFlag == 0) {
      
        obj = G("txtemailnew");
        var patn = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
        if (G("member").style.display != "none") {
            if (!patn.test(obj.value)) {
                alert("Please enter a valid email address.");
                G("txtemailnew").focus();
                return false;
            }
        }

        if (!checkregpsw()) {
            return false;
        }
        if (!checkregpsw1()) {
            return false;
        }

        if (G("Name").value == '') {
            alert("please enter your name");
            return false;
        }

        if (G("cbmcountry").value == 0) {
            alert("please select your country");
            return false;
        }

        if (G("CompanyName").value == '') {
            alert("please enter your company name");
            return false;
        }

        if (G("phoneArea").value == '' || G("phoneArea").value == 'Area') {
            alert("please enter number,dash or space only");
            return false;
        }
        if (G("phoneNumber").value == '' || G("phoneNumber").value == 'Local Number-Ext.') {
            alert("please enter number,dash or space only");
            return false;
        }

        if (G("txtcontentnew").value.replace(/\r\n/g, "").replace(/\s/ig, "").replace("Company:Contact:Tel:MSN:Requirements:", "").length < 10) {
            alert(contexterr);
            return false;
        }
        if (!CheckIsChinese(G("txtcontentnew").value)) {
            alert("Please enter English characters only！");
            return false;
        }
       
    } else {

   
        if (G("txtpasswordnew")) {
           
                if (G("txtpasswordnew").value.length >= 6) {
                    if (G("Passworderr").style.display == "") {
                        alert("Invalid member ID or password. Please try again");
                        return false;
                    }
                    
                }
                else {
                    alert("password must be 6 - 20 characters !");
                    return false;
                }
             }
                
                if (G("txtcontentnew").value.replace(/\r\n/g, "").replace(/\s/ig, "").replace("Company:Contact:Tel:MSN:Requirements:", "").length < 10) {
                   
                    alert(contexterr);
                    return false;
                }

                if (!CheckIsChinese(G("txtcontentnew").value)) {
                    alert(contextchineseerr);
                    return false;
                }
               // G("formsendall").submit();
          }
  
        }
        
        
        
        

//0为未登陆;1:有此用户;2:已登陆
        var loginFlag = 0;
        function showBuyProduct(cas, product, userid, islogin, isdisplay) {
            if (islogin == 0) {
                loginFlag = 0;
            }
            else {
                loginFlag = 2;
            }

            var IfrRef = G('DivShim');
            if (isdisplay) {
                try {
                    if (loadinglayer != null) {
                        G("formsendall").removeChild(loadinglayer);

                    }
                    if (loadingdiv != null) {
                        G("formsendall").removeChild(loadingdiv);

                    }
                }
                catch (e) { }
                loadinglayer = document.createElement("div");
                G("formsendall").appendChild(loadinglayer);
                loadinglayer.style.cssText = "position:absolute;z-index:999;filter:alpha(opacity=50);background:#000000;opacity: 0.1;-moz-opacity: 0.1;left:0;top:0;";
                loadingdiv = document.createElement("div");
                document.getElementById("formsendall").appendChild(loadingdiv);
                loadingdiv.style.cssText = "z-index:1000; width:629px; border:12px #c8dfff solid; text-align:left; font-family:\"Tahoma\"; padding:0 0 30px 10px; POSITION: absolute;background:#FFFFFF;";

                var shtml = '<div class="lc_close" onmouseover="this.className=\'lc_close_hover\'" onmouseout="this.className=\'lc_close\'" onclick="showBuyProduct(false);" style=\"cursor:pointer;\"><a>X Close</a></div>';

                var usertitle = 'Add your Contact Detail to build trust with supplier(s)';
                if (islogin == 2) {
                    usertitle = 'Request For Quotations';
                }

                shtml += ' <table width="100%" border="0" cellspacing="5" cellpadding="0" id="contactBox"><tr><td height="58" colspan="2"  class="font1" style="padding-left:30px;"><strong>'+ usertitle +'</strong></td></tr><input type="hidden" value="' + islogin + '" id="isloginvalue" name="isloginvalue" />';

                shtml += '<tr><td align="right" style="padding-right:8px;"><span class="r4">*</span>CAS  No:</td><td><input type="text" id="txtcas" name="txtcas" value="' + cas + '" maxlength="255" class="inputStyle" /></td></tr>';
                shtml += '<tr><td align="right" style="padding-right:8px;"><span class="r4">*</span>Product Name:</td><td><input type="text" id="txttitle" name="txttitle" style="width:200px;" value="' + product + '" class="inputStyle" /></td></tr>';

                shtml += '<tr><td align="right" style="padding-right:8px;"><span class="r4">*</span>Requirements:</td><td><textarea id="txtcontentnew" name="txtcontentnew" style="width:400px; height:50px;"></textarea><div id="txtcontentErr" style="display:none;" class="C_Error">Your message must be between 10-1000 characters</div></td></tr>';

                if (islogin == 2) {

                }
                else {
                    shtml += '<tr id="member"><td align="right" style="padding-right:8px;"><span class="r4">*</span>Your email:</td><td><input type="text" id="txtemailnew" name="txtemailnew" style="width:200px;" onBlur="javascript:CheckEmailIsMemberForAllSend();" class="inputStyle" /><span id="memberexits" style="display:none;">Please enter your LookChem.com password!</span></td></tr>';
                    
                    

                    //存在要输入的密码
                    shtml += '<tr id="passwordLayer" style="display:none;"><td align="right"><span class="r4">*</span>Password:</td><td><input type="password" id="txtpasswordnew" name="txtpasswordnew" onBlur="javascript:CheckEmailandPwd();" style="width:200px;" class="inputStyle" /><a href="/forget_password.aspx" target="_blank">Forget your password?</a><div class="C_Error" id="Passworderr" style="display:none;">Invalid member ID or password. Please try again</div> </td></tr>';
                    
                    //注册密码
                    shtml += '<tr id="passwordnew" style="display:none;"><td align="right"><span class="r4">*</span>Create password:</td><td><input type="password" id="txtregpsw" name="txtregpsw" onBlur="javascript:checkregpsw();" style="width:200px;" class="inputStyle" /><div class="C_Error" id="dtxtregpsw" style="display:none;">Please enter your password with 6 - 20 characters.</div> </td></tr>';
                    shtml += '<tr id="passwordnew2" style="display:none;"><td align="right"><span class="r4">*</span>Re-enter password:</td><td><input type="password" id="txtregpsw1" name="txtregpsw1" onBlur="javascript:checkregpsw1();" style="width:200px;" class="inputStyle" /><div class="C_Error" id="detxtregpsw1" style="display:none;">Please Re-enter your password with 6 - 20 characters.</div> <div class="C_Error" id="detxtregpswsame" style="display:none;">Passwords are not the same.</div></td></tr>';
                        
                     
                    //如果用户存在的话下面这片要隐藏了。
                    shtml += '<tr id="genderLayer" style="display:none;"><td width="20%" align="right" style="padding-right:8px;"><span class="r4">*</span>Gender:</td><td width="69%"><input id="genderM" type="radio" checked="checked" value="Mr." name="gender" />Male';
                    shtml += '<input id="genderF" type="radio"  value="Ms." name="gender" />FeMale<br></td> </tr>';
                    shtml += '<tr id="realnameLayer" style="display:none;"><td align="right" style="padding-right:8px;"><span class="r4">*</span>Name:</td><td><input type="text" id="Name" name="Name" value="" maxlength="255" class="inputStyle" /></td></tr>';

                    shtml += '<tr id="positionLayer" style="display:none;"><td align="right" style="padding-right:8px;">Position:</td><td><input type="text" id="tbPosition" name="tbPosition" value="" maxlength="255" class="inputStyle" /></td></tr>';

                    shtml += '<tr id="countryLayer" style="display:none;"><td align="right" style="padding-right:8px;"><span class="r4">*</span>Country/Region:</td><td><select name="cbmcountry" id="cbmcountry" onchange="changeimg();"><option value="0">Select your country</option></select>  <img id="imgcountry" src="/images/country/1.gif"  /><div class="C_Error" id="cbmcountryerr" style="display:none;">please select your country</div></td></tr>';
                    shtml += '<tr id="companyLayer" style="display:none;"><td align="right" style="padding-right:8px;"><span class="r4">*</span>Company Name:</td><td><input type="text" id="CompanyName" name="CompanyName" value="" maxlength="255" class="inputStyle" /><div class="C_Error" id="companynameerr" style="display:none;">please enter your company name</div>  </td></tr>';


                    shtml += '<tr id="telLayer" style="display:none;"><td align="right" style="padding-right:8px;"><span class="r4">*</span>Tel:</td><td><input type="text" onchange="changeme(\'phoneCountry\',\'phoneCountry1\')" id="phoneCountry" name="phoneCountry" class="inputStyle" value="86" maxlength="8" style="width:50px;" /> <input type="text" id="phoneArea" onchange="changeme(\'phoneArea\',\'phoneArea1\')" name="phoneArea" value="Area" maxlength="8" size="9" class="inputStyle"  style="color:#919191;" onclick="clearboxphoneArea();"/> <input type="text" class="inputStyle" id="phoneNumber" name="phoneNumber" value="Local Number-Ext." maxlength="34" size="20" style="color:#919191;"  onclick="clearboxphoneNumber();"/><div id="phoneerr" style="display:none;" class="C_Error">please enter number,dash or space only</div></td></tr>';
                    shtml += '<tr id="faxLayer" style="display:none;"><td align="right" style="padding-right:8px;"> Fax:</td><td><input type="text" id="phoneCountry1" name="phoneCountry1"  value="86" onfocus="this.blur()" class="inputStyle"   maxlength="8" style="width:50px;" /> <input type="text"    id="phoneArea1" onfocus="this.blur()"  name="phoneArea1"   maxlength="8" size="9" class="inputStyle"  style="color:#919191;"  /> <input type="text" class="inputStyle" id="phoneNumber1" name="phoneNumber1"  maxlength="34" size="20"  /> </td></tr>';
                    shtml += '<tr id="skypeLayer" style="display:none;"><td align="right" style="padding-right:8px;">MSN/Skype:</td><td><input type="text" class="inputStyle" id="MSN" name="MSN" value="" maxlength="255" /></td></tr>';

                }
               
                shtml += '<tr ><td align="right" style="padding-right:8px;"><span class="r4">*</span>Valid for:</td><td> ';
                shtml += ' <input id="valid_6" type="radio" value="5" name="rblvaliddate" /> 5 Days';
                shtml +=' <input id="valid_0" type="radio" value="10" name="rblvaliddate" /> 10 Days';
                shtml += ' <input id="rblvaliddate_1" type="radio" value="20" name="rblvaliddate" /> 20 Days';
                shtml += '<input id="rblvaliddate_2" type="radio" value="30" name="rblvaliddate" /> 1 Month';
                shtml += '<input id="rblvaliddate_3" type="radio" checked="checked" value="90" name="rblvaliddate" /> 3 Month';
                shtml += '<input id="rblvaliddate_4" type="radio" value="180" name="rblvaliddate" /> 6 Month';
                shtml += '</td></tr>';

                shtml += '<tr ><td align="right" valign="top" style="padding-right:8px;line-height:16px;">Allow sellers to <br/> contact us by:</td><td style="line-height:16px; padding-bottom:8px;"><span style=" color:#ff6600;">(Must select at least one to ensure the sellers can contact you)</span> <br/>';
                shtml += ' <input type="checkbox" checked="checked" id="contacttype_1" name="contacttype" value="a"> Telephone/Fax '; 
                shtml += '<input type="checkbox" id="contacttype_2" checked="checked" name="contacttype" value="b" > Email ';
                shtml += '<input type="checkbox" id="contacttype_3" checked="checked" name="contacttype" value="c" > MSN/Skype ';
                shtml += '<input type="checkbox" id="contacttype_4" checked="checked" name="contacttype" value="d" > LookChem Member Center</td></tr>';

              
              

                shtml += '<tr><td></td><td height=50><input type="image" id="send" src="/images/Buyer.Seller/submit.gif" onclick="return checkshowcontactall();" /></td></tr></table>';
                
                loadingdiv.innerHTML = shtml;


                if (islogin == 0) {
                    addcountry();
                }

                IfrRef.style.width = 663;
                IfrRef.style.height = 300;
                IfrRef.style.top = (document.documentElement.scrollTop + 80) + "px";
                IfrRef.style.left = (document.documentElement.clientWidth / 2 - 300) + "px";
                IfrRef.style.zIndex = loadingdiv.style.zIndex - 1;
                IfrRef.style.display = "block";
                try {
                    loadinglayer.style.width = document.documentElement.clientWidth + "px";
                    loadinglayer.style.height = (document.documentElement.scrollTop + document.documentElement.clientHeight) + "px";
                    loadingdiv.style.top = (document.documentElement.scrollTop + 80) + "px";
                    loadingdiv.style.left = (document.documentElement.clientWidth / 2 - 300) + "px";

                }
                catch (e) { }
            }
            else {
                try {

                    G("formsendall").removeChild(loadinglayer);
                    G("formsendall").removeChild(loadingdiv);

                    IfrRef.style.display = "none";
                }
                catch (e) {

                    loadinglayer = null;
                    loadingdiv = null;
                    IfrRef.style.display = "none";

                }
            }
        }

        function changeme(texta, textb) {
            G(textb).value = G(texta).value;
        }
        
        function CheckEmailIsMemberForAllSend() {
            IsMemberAjax = 0;
            obj = G("txtemailnew");
            var patn = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
            if (G("member").style.display != "none") {
                if (!patn.test(obj.value)) {
                    return;
                }
            }
            var xmlhttp1 = createXMLHttpRequest();

            xmlhttp1.onreadystatechange = function() {
                if (xmlhttp1.readyState == 4) {
                    //关闭显示条

                    if (xmlhttp1.status == 200) {
                        //当加载成功时将内容显示于页面
                        if (xmlhttp1.responseText == "1") {
                            loginFlag = 1;
                            G("passwordLayer").style.display = '';
                            G("isloginvalue").value = "1";
                            G("memberexits").style.display = '';
                            //将以下字段进行隐藏
                            G("genderLayer").style.display = 'none';
                            G("realnameLayer").style.display = 'none';
                            G("passwordnew").style.display = 'none';
                            G("passwordnew2").style.display = 'none';
                            G("realnameLayer").style.display = 'none';
                            G("countryLayer").style.display = 'none';
                            G("companyLayer").style.display = 'none';
                            G("telLayer").style.display = 'none';
                            G("faxLayer").style.display = 'none';
                            G("skypeLayer").style.display = 'none';
                            G("positionLayer").style.display = "none";
                        }
                        else {
                            loginFlag = 0;
                            G("isloginvalue").value = "0";
                            G("passwordLayer").style.display = 'none';
                            G("memberexits").style.display = 'none';
                            G("genderLayer").style.display = '';
                            G("realnameLayer").style.display = '';
                            G("passwordnew").style.display = '';
                            G("faxLayer").style.display = '';
                            G("passwordnew2").style.display = '';
                            G("countryLayer").style.display = '';
                            G("companyLayer").style.display = '';
                            G("telLayer").style.display = '';
                            G("skypeLayer").style.display = '';
                            G("positionLayer").style.display = '';
                        }

                    } else {
                        //否则弹出错误信息

                    }
                }
            }
            //创建一个连接
            xmlhttp1.open("get", "/Hotproducts/ajaxIsMemberByEmail.aspx?Email=" + document.getElementById("txtemailnew").value + "&d=" + new Date());
            //发送请求
            xmlhttp1.send(null);
        }
        
 var IsClickphoneArea=false;
var IsClickphoneNumber=false;
function clearboxphoneArea(){
    if(!IsClickphoneArea){
        G("phoneArea").value="";
        G("phoneArea").style.cssText = "color:#000000;";
        IsClickphoneArea=true;
    }
}

function clearboxphoneNumber(){
    if(!IsClickphoneNumber){
        G("phoneNumber").value="";
        G("phoneNumber").style.cssText = "color:#000000;";
        IsClickphoneNumber=true;
    }
}

var country = document.getElementById("cbmcountry");
function addOption(v, t) {
    country.options.add(v, t);
}

   function addcountry()
   {
    // JScript 文件
       var country = document.getElementById("cbmcountry");
       country.options.add(new Option('United States', '10#United States#1'));
       country.options.add(new Option('United Kingdom', '9#United Kingdom#1'));
       country.options.add(new Option('China (Mainland)', '1#China (Mainland)#86'));
       country.options.add(new Option('Korea', '5#Korea#82'));
       country.options.add(new Option('Italy', '111#Italy#39'));
       country.options.add(new Option('Germany', '89#Germany#49'));
       country.options.add(new Option('Pakistan', '166#Pakistan#92'));
country.options.add(new Option('Canada','2#Canada#1'));
country.options.add(new Option('Iran (Islamic Republic of)', '107#Iran (Islamic Republic of)#98'));
country.options.add(new Option('India', '106#India#91'));
country.options.add(new Option('Afghanistan','11#Afghanistan#93'));
country.options.add(new Option('Albania','12#Albania#355'));
country.options.add(new Option('Algeria','13#Algeria#213'));
country.options.add(new Option('American Samoa','14#American Samoa#'));
country.options.add(new Option('Andorra','15#Andorra#376'));
country.options.add(new Option('Angola','16#Angola#244'));
country.options.add(new Option('Anguilla','17#Anguilla#1264'));
country.options.add(new Option('Antarctica','18#Antarctica#'));
country.options.add(new Option('Antigua and Barbuda','19#Antigua and Barbuda#1268'));
country.options.add(new Option('Argentina','20#Argentina#54'));
country.options.add(new Option('Armenia','21#Armenia#374'));
country.options.add(new Option('Aruba','22#Aruba#'));
country.options.add(new Option('Australia','23#Australia#61'));
country.options.add(new Option('Austria','24#Austria#43'));
country.options.add(new Option('Azerbaijan','25#Azerbaijan#994'));
country.options.add(new Option('Bahamas','26#Bahamas#1242'));
country.options.add(new Option('Bahrain','27#Bahrain#973'));
country.options.add(new Option('Bangladesh','28#Bangladesh#880'));
country.options.add(new Option('Barbados','29#Barbados#1246'));
country.options.add(new Option('Belarus','30#Belarus#375'));
country.options.add(new Option('Belgium','31#Belgium#32'));
country.options.add(new Option('Belize','32#Belize#501'));
country.options.add(new Option('Benin','33#Benin#229'));
country.options.add(new Option('Bermuda','34#Bermuda#1441'));
country.options.add(new Option('Bhutan','35#Bhutan#'));
country.options.add(new Option('Bolivia','36#Bolivia#591'));
country.options.add(new Option('Bosnia and Herzegowina','37#Bosnia and Herzegowina#'));
country.options.add(new Option('Botswana','38#Botswana#267'));
country.options.add(new Option('Bouvet Island','39#Bouvet Island#'));
country.options.add(new Option('Brazil','40#Brazil#55'));
country.options.add(new Option('British Indian Ocean Territory','41#British Indian Ocean Territory#'));
country.options.add(new Option('Brunei Darussalam','42#Brunei Darussalam#673'));
country.options.add(new Option('Bulgaria','43#Bulgaria#359'));
country.options.add(new Option('Burkina Faso','44#Burkina Faso#226'));
country.options.add(new Option('Burundi', '45#Burundi#257'));
country.options.add(new Option('Canada', '2#Canada#1'));
country.options.add(new Option('Cambodia','46#Cambodia#855'));
country.options.add(new Option('Cameroon','47#Cameroon#237'));
country.options.add(new Option('Cape Verde','48#Cape Verde#'));
country.options.add(new Option('Cayman Islands','49#Cayman Islands#'));
country.options.add(new Option('Central African Republic','50#Central African Republic#236'));
country.options.add(new Option('Chad','51#Chad#235'));
country.options.add(new Option('Chile', '52#Chile#56'));
country.options.add(new Option('China (Mainland)', '1#China (Mainland)#86'));
country.options.add(new Option('China(Taiwan)', '8#China(Taiwan)#886'));
country.options.add(new Option('China(Hongkong)', '3#China(Hongkong)#852'));
country.options.add(new Option('Christmas Island','53#Christmas Island#'));
country.options.add(new Option('Cocos (Keeling) Islands','54#Cocos (Keeling) Islands#'));
country.options.add(new Option('Colombia','55#Colombia#57'));
country.options.add(new Option('Comoros','56#Comoros#'));
country.options.add(new Option('Congo','57#Congo#242'));
country.options.add(new Option('Cook Islands','58#Cook Islands#682'));
country.options.add(new Option('Costa Rica','59#Costa Rica#506'));
country.options.add(new Option('Cote D&amp;quot;Ivoire','60#Cote D&amp;quot;Ivoire#'));
country.options.add(new Option('Croatia (local name: Hrvatska)','61#Croatia (local name: Hrvatska)#'));
country.options.add(new Option('Cuba','62#Cuba#53'));
country.options.add(new Option('Cyprus','63#Cyprus#357'));
country.options.add(new Option('Czech Republic','64#Czech Republic#420'));
country.options.add(new Option('Denmark','65#Denmark#45'));
country.options.add(new Option('Djibouti','66#Djibouti#253'));
country.options.add(new Option('Dominica','67#Dominica#'));
country.options.add(new Option('Dominican Republic','68#Dominican Republic#1890'));
country.options.add(new Option('East Timor','69#East Timor#'));
country.options.add(new Option('Ecuador','70#Ecuador#593'));
country.options.add(new Option('Egypt','71#Egypt#20'));
country.options.add(new Option('El Salvador','72#El Salvador#503'));
country.options.add(new Option('Equatorial Guinea','73#Equatorial Guinea#'));
country.options.add(new Option('Eritrea','74#Eritrea#'));
country.options.add(new Option('Estonia','75#Estonia#372'));
country.options.add(new Option('Ethiopia','76#Ethiopia#251'));
country.options.add(new Option('Falkland Islands (Malvinas)','77#Falkland Islands (Malvinas)#'));
country.options.add(new Option('Faroe Islands','78#Faroe Islands#'));
country.options.add(new Option('Fiji','79#Fiji#679'));
country.options.add(new Option('Finland','80#Finland#358'));
country.options.add(new Option('France','81#France#33'));
country.options.add(new Option('France Metropolitan','82#France Metropolitan#'));
country.options.add(new Option('French Guiana','83#French Guiana#594'));
country.options.add(new Option('French Polynesia','84#French Polynesia#689'));
country.options.add(new Option('French Southern Territories','85#French Southern Territories#'));
country.options.add(new Option('Gabon','86#Gabon#241'));
country.options.add(new Option('Gambia','87#Gambia#220'));
country.options.add(new Option('Georgia','88#Georgia#995'));
country.options.add(new Option('Germany', '89#Germany#49'));
country.options.add(new Option('Ghana', '90#Ghana#233'));

country.options.add(new Option('Gibraltar','91#Gibraltar#350'));
country.options.add(new Option('Greece','92#Greece#30'));
country.options.add(new Option('Greenland','93#Greenland#'));
country.options.add(new Option('Grenada', '94#Grenada#1809'));

country.options.add(new Option('Guadeloupe','95#Guadeloupe#'));
country.options.add(new Option('Guam','96#Guam#1671'));
country.options.add(new Option('Guatemala','97#Guatemala#502'));
country.options.add(new Option('Guinea','98#Guinea#224'));
country.options.add(new Option('Guinea-Bissau','99#Guinea-Bissau#'));
country.options.add(new Option('Guyana','100#Guyana#592'));
country.options.add(new Option('Haiti','101#Haiti#509'));
country.options.add(new Option('Heard and Mc Donald Islands','102#Heard and Mc Donald Islands#'));
country.options.add(new Option('Honduras','103#Honduras#504'));
country.options.add(new Option('Hungary','104#Hungary#36'));
country.options.add(new Option('Iceland','105#Iceland#354'));
country.options.add(new Option('India', '106#India#91'));
country.options.add(new Option('Indonesia', '4#Indonesia#62'));

country.options.add(new Option('Iran (Islamic Republic of)', '107#Iran (Islamic Republic of)#98'));
country.options.add(new Option('Iraq','108#Iraq#964'));
country.options.add(new Option('Ireland','109#Ireland#353'));
country.options.add(new Option('Israel', '110#Israel#972'));
country.options.add(new Option('Italy', '111#Italy#39'));

country.options.add(new Option('Jamaica','112#Jamaica#1876'));
country.options.add(new Option('Japan','113#Japan#81'));
country.options.add(new Option('Jordan','114#Jordan#962'));
country.options.add(new Option('Kazakhstan','115#Kazakhstan#327'));
country.options.add(new Option('Kenya', '116#Kenya#254'));

country.options.add(new Option('Kiribati', '117#Kiribati#'));
country.options.add(new Option('Korea', '5#Korea#82'));
country.options.add(new Option('Kuwait','118#Kuwait#965'));
country.options.add(new Option('Kyrgyzstan','119#Kyrgyzstan#331'));
country.options.add(new Option('Lao Peoples Democratic Republic','120#Lao Peoples Democratic Republic#856'));
country.options.add(new Option('Latvia','121#Latvia#371'));
country.options.add(new Option('Lebanon','122#Lebanon#961'));
country.options.add(new Option('Lesotho','123#Lesotho#266'));
country.options.add(new Option('Liberia','124#Liberia#231'));
country.options.add(new Option('Libyan Arab Jamahiriya','125#Libyan Arab Jamahiriya#218'));
country.options.add(new Option('Liechtenstein','126#Liechtenstein#423'));
country.options.add(new Option('Lithuania','127#Lithuania#370'));
country.options.add(new Option('Luxembourg','128#Luxembourg#352'));
country.options.add(new Option('Macao','129#Macao#853'));
country.options.add(new Option('Macedonia','130#Macedonia#'));
country.options.add(new Option('Madagascar','131#Madagascar#261'));
country.options.add(new Option('Malawi', '132#Malawi#265'));
country.options.add(new Option('Malaysia', '6#Malaysia#60'));
country.options.add(new Option('Maldives','133#Maldives#960'));
country.options.add(new Option('Mali', '134#Mali#223'));
country.options.add(new Option('Malta','135#Malta#356'));
country.options.add(new Option('Marshall Islands','136#Marshall Islands#'));
country.options.add(new Option('Martinique','137#Martinique#'));
country.options.add(new Option('Mauritania','138#Mauritania#'));
country.options.add(new Option('Mauritius','139#Mauritius#230'));
country.options.add(new Option('Mayotte','140#Mayotte#'));
country.options.add(new Option('Mexico','141#Mexico#52'));
country.options.add(new Option('Micronesia','142#Micronesia#'));
country.options.add(new Option('Moldova','143#Moldova#373'));
country.options.add(new Option('Monaco','144#Monaco#377'));
country.options.add(new Option('Mongolia','145#Mongolia#976'));
country.options.add(new Option('Montserrat','146#Montserrat#1664'));
country.options.add(new Option('Morocco','147#Morocco#212'));
country.options.add(new Option('Mozambique','148#Mozambique#258'));
country.options.add(new Option('Myanmar','149#Myanmar#95'));
country.options.add(new Option('Namibia','150#Namibia#264'));
country.options.add(new Option('Nauru','151#Nauru#674'));
country.options.add(new Option('Nepal','152#Nepal#977'));
country.options.add(new Option('Netherlands','153#Netherlands#31'));
country.options.add(new Option('Netherlands Antilles','154#Netherlands Antilles#'));
country.options.add(new Option('New Caledonia','155#New Caledonia#'));
country.options.add(new Option('New Zealand','156#New Zealand#64'));
country.options.add(new Option('Nicaragua','157#Nicaragua#505'));
country.options.add(new Option('Niger','158#Niger#227'));
country.options.add(new Option('Nigeria','159#Nigeria#234'));
country.options.add(new Option('Niue','160#Niue#'));
country.options.add(new Option('Norfolk Island','161#Norfolk Island#'));
country.options.add(new Option('North Korea','162#North Korea#850'));
country.options.add(new Option('Northern Mariana Islands','163#Northern Mariana Islands#'));
country.options.add(new Option('Norway','164#Norway#47'));
country.options.add(new Option('Oman','165#Oman#968'));
country.options.add(new Option('Pakistan', '166#Pakistan#92'));
country.options.add(new Option('Palau','167#Palau#'));
country.options.add(new Option('Panama','168#Panama#507'));
country.options.add(new Option('Papua New Guinea', '169#Papua New Guinea#675'));

country.options.add(new Option('Paraguay','170#Paraguay#595'));
country.options.add(new Option('Peru','171#Peru#51'));
country.options.add(new Option('Philippines','172#Philippines#63'));
country.options.add(new Option('Pitcairn','173#Pitcairn#'));
country.options.add(new Option('Poland','174#Poland#48'));
country.options.add(new Option('Portugal','175#Portugal#351'));
country.options.add(new Option('Puerto Rico','176#Puerto Rico#1787'));
country.options.add(new Option('Qatar','177#Qatar#974'));
country.options.add(new Option('Reunion','178#Reunion#'));
country.options.add(new Option('Romania','179#Romania#40'));
country.options.add(new Option('Russian Federation','180#Russian Federation#7'));
country.options.add(new Option('Rwanda', '181#Rwanda#'));

country.options.add(new Option('Saint Kitts and Nevis','182#Saint Kitts and Nevis#'));
country.options.add(new Option('Saint Lucia','183#Saint Lucia#1758'));
country.options.add(new Option('Saint Vincent and the Grenadines','184#Saint Vincent and the Grenadines#1784'));
country.options.add(new Option('Samoa','185#Samoa#'));
country.options.add(new Option('San Marino','186#San Marino#378'));
country.options.add(new Option('Sao Tome and Principe','187#Sao Tome and Principe#239'));
country.options.add(new Option('Saudi Arabia','188#Saudi Arabia#966'));
country.options.add(new Option('Senegal', '189#Senegal#221'));
country.options.add(new Option('Serbia', '240#Serbia#381'));
country.options.add(new Option('Seychelles','190#Seychelles#248'));
country.options.add(new Option('Sierra Leone', '191#Sierra Leone#232'));
country.options.add(new Option('Singapore', '7#Singapore#65'));
country.options.add(new Option('Slovakia (Slovak Republic)','192#Slovakia (Slovak Republic)#421'));
country.options.add(new Option('Slovenia','193#Slovenia#386'));
country.options.add(new Option('Solomon Islands','194#Solomon Islands#677'));
country.options.add(new Option('Somalia','195#Somalia#252'));
country.options.add(new Option('South Africa','196#South Africa#27'));
country.options.add(new Option('Spain','197#Spain#34'));
country.options.add(new Option('Sri Lanka','198#Sri Lanka#94'));
country.options.add(new Option('St. Helena','199#St. Helena#'));
country.options.add(new Option('St. Pierre and Miquelon','200#St. Pierre and Miquelon#'));
country.options.add(new Option('Sudan','201#Sudan#249'));
country.options.add(new Option('Suriname','202#Suriname#597'));
country.options.add(new Option('Svalbard and Jan Mayen Islands','203#Svalbard and Jan Mayen Islands#'));
country.options.add(new Option('Swaziland','204#Swaziland#268'));
country.options.add(new Option('Sweden','205#Sweden#46'));
country.options.add(new Option('Switzerland','206#Switzerland#41'));
country.options.add(new Option('Syrian Arab Republic','207#Syrian Arab Republic#963'));
country.options.add(new Option('Tajikistan','208#Tajikistan#992'));
country.options.add(new Option('Tanzania','209#Tanzania#255'));
country.options.add(new Option('Thailand','210#Thailand#66'));
country.options.add(new Option('Togo','211#Togo#228'));
country.options.add(new Option('Tokelau','212#Tokelau#'));
country.options.add(new Option('Tonga','213#Tonga#676'));
country.options.add(new Option('Trinidad and Tobago','214#Trinidad and Tobago#1809'));
country.options.add(new Option('Tunisia','215#Tunisia#216'));
country.options.add(new Option('Turkey','216#Turkey#90'));
country.options.add(new Option('Turkmenistan','217#Turkmenistan#993'));
country.options.add(new Option('Turks and Caicos Islands','218#Turks and Caicos Islands#'));
country.options.add(new Option('Tuvalu','219#Tuvalu#'));
country.options.add(new Option('Uganda','220#Uganda#256'));
country.options.add(new Option('Ukraine', '221#Ukraine#380'));

country.options.add(new Option('United Arab Emirates', '222#United Arab Emirates#971'));
country.options.add(new Option('United Kingdom', '9#United Kingdom#'));
country.options.add(new Option('United States', '10#United States#1'));
country.options.add(new Option('United States Minor Outlying Islands','223#United States Minor Outlying Islands#'));
country.options.add(new Option('Uruguay','224#Uruguay#598'));
country.options.add(new Option('Uzbekistan','225#Uzbekistan#233'));
country.options.add(new Option('Vanuatu','226#Vanuatu#'));
country.options.add(new Option('Vatican City State (Holy See)','227#Vatican City State (Holy See)#'));
country.options.add(new Option('Venezuela','228#Venezuela#58'));
country.options.add(new Option('Vietnam','229#Vietnam#84'));
country.options.add(new Option('Virgin Islands (British)','230#Virgin Islands (British)#'));
country.options.add(new Option('Virgin Islands (U.S.)','231#Virgin Islands (U.S.)#'));
country.options.add(new Option('Wallis And Futuna Islands','232#Wallis And Futuna Islands#'));
country.options.add(new Option('Western Sahara','233#Western Sahara#'));
country.options.add(new Option('Yemen','234#Yemen#967'));
country.options.add(new Option('Yugoslavia','235#Yugoslavia#381'));
country.options.add(new Option('Congo, The Democratic Republic Of The','236#Congo, The Democratic Republic Of The#243'));
country.options.add(new Option('Zambia','237#Zambia#260'));
country.options.add(new Option('Zimbabwe','238#Zimbabwe#263'));
country.options.add(new Option('Other Country','239#Other Country#'));

   }
   /* tool end */
   /*showmember start*/

   function showmember() {
       //创建浏览器兼容的XMLHttpRequest对象
       var xmlhttp1 = createXMLHttpRequest();

       //定义XMLHttpRequest对象的事件处理程序
       xmlhttp1.onreadystatechange = function() {
           if (xmlhttp1.readyState == 4) {
               //关闭显示条
               if (xmlhttp1.status == 200) {
                   //当加载成功时将内容显示于页面
                   if (xmlhttp1.responseText == 0) {
                       G("member").style.display = "";
                   }
                   else {
                       IsMemberAjax = 2;
                       G("member").style.display = "none";
                       G("password").style.display = "none";
                       //G("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;
       }
   }

   var seniorMember = 0;
   function setSeniorMember() {
       if (seniorMember == 0) {
           seniorMember = 1;
       }
       else {
           seniorMember = 0;
       }
   }

   var memberGroupId = 0;
   var businessType = "";

   function setMemberGroupId(mg) {
       cid = 0;
       businessType = "";
       memberGroupId = mg;
       certificates = "";
   }


   function setBusinessType(bt) {
       cid = 0;
       memberGroupId = 0;
       businessType = bt;
       certificates = "";
   }

   var certificates = "";
    
   function setCertificates(title) {
       cid = 0;
       certificates = title;
       memberGroupId = 0;
       businessType = "";
   }

   function setCountryId(id) {
       memberGroupId = 0;
       businessType = "";
       cid = id;
       certificates = "";
   }

   function showsupplierp(cas, productname, groupname, page) {
       if (isElementExists("s1")) {
           cid = G("s1").value;
       }
       //创建浏览器兼容的XMLHttpRequest对象
       var xmlhttp1 = createXMLHttpRequest();
       //定义XMLHttpRequest对象的事件处理程序
       xmlhttp1.onreadystatechange = function() {
           if (xmlhttp1.readyState == 4) {
               //关闭显示条
               if (xmlhttp1.status == 200) {
                   //当加载成功时将内容显示于页面
                   G("supplierhtml").innerHTML = xmlhttp1.responseText;
               } else {
                   //否则弹出错误信息
               }
           }
       }
       //创建一个连接
       xmlhttp1.open("get", "/Hotproducts/ajaxsupplier_new.aspx?cas=" + cas + "&CountryId=" + cid + "&Integral=" + sort + "&p=" + page + "&mg=" + memberGroupId + "&bt=" + businessType + "&seniorMember=" + seniorMember + "&productname=" + productname + "&groupname=" + groupname);
       //发送请求
       xmlhttp1.send(null);
   }

   function showsupplier(cas, productname, groupname) {
       //s1是国家的select id
       if (G("s1") != null) {
           cid = G("s1").value;
       }
       //创建浏览器兼容的XMLHttpRequest对象
       var xmlhttp1 = createXMLHttpRequest();
       //定义XMLHttpRequest对象的事件处理程序
       xmlhttp1.onreadystatechange = function() {
           G("supplierhtml").innerHTML = "<div style=\"text-align: center;\">Loading...</div>";
           if (xmlhttp1.readyState == 4) {
               //关闭显示条

               if (xmlhttp1.status == 200) {
                   //当加载成功时将内容显示于页面
                   G("supplierhtml").innerHTML = xmlhttp1.responseText;

               } else {
                   //否则弹出错误信息

               }
           }
       }
       //创建一个连接
       xmlhttp1.open("get", "/Hotproducts/ajaxsupplier_new.aspx?cas=" + cas + "&CountryId=" + cid + "&Integral=" + sort + "&mg=" + memberGroupId + "&bt=" + businessType + "&productname=" + escape(productname) + "&SeniorMember=" + seniorMember + "&groupname=" + groupname + "&cf=" + certificates);
       //发送请求
       xmlhttp1.send(null);

   }

   function showsupplierbySynthesisp(cas, productname, groupname, page) {
       //s1是国家的select id
       if (isElementExists("s1")) {
           cid = G("s1").value;
       }
       //创建浏览器兼容的XMLHttpRequest对象
       var xmlhttp1 = createXMLHttpRequest();
     
       //定义XMLHttpRequest对象的事件处理程序
       xmlhttp1.onreadystatechange = function() {
           G("supplierhtml").innerHTML = "<div style=\"text-align: center;\">Loading...</div>";
           if (xmlhttp1.readyState == 4) {
               //关闭显示条

               if (xmlhttp1.status == 200) {
                   //当加载成功时将内容显示于页面
                   G("supplierhtml").innerHTML = xmlhttp1.responseText;

               } else {
                   //否则弹出错误信息

               }
           }
       }
       //创建一个连接
       xmlhttp1.open("get", "/Hotproducts/ajaxsupplier_new.aspx?cas=" + cas + "&CountryId=" + cid + "&Integral=" + sort + "&mg=" + memberGroupId + "&bt=" + businessType + "&productname=" + escape(productname) + "&SeniorMember=" + seniorMember + "&showtype=synthesis&groupname=" + groupname + "&p=" + page);
       //发送请求
       xmlhttp1.send(null);

   }

   function showsupplierbySynthesis(cas, productname, groupname) {
       //s1是国家的select id
       if (G("s1") != null) {
           cid = G("s1").value;
       }
       //创建浏览器兼容的XMLHttpRequest对象
       var xmlhttp1 = createXMLHttpRequest();
       //定义XMLHttpRequest对象的事件处理程序
       xmlhttp1.onreadystatechange = function() {
           G("supplierhtml").innerHTML = "<div style=\"text-align: center;\">Loading...</div>";
           if (xmlhttp1.readyState == 4) {
               //关闭显示条

               if (xmlhttp1.status == 200) {
                   //当加载成功时将内容显示于页面
                   G("supplierhtml").innerHTML = xmlhttp1.responseText;

               } else {
                   //否则弹出错误信息

               }
           }
       }
       //创建一个连接
       xmlhttp1.open("get", "/Hotproducts/ajaxsupplier_new.aspx?cas=" + cas + "&CountryId=" + cid + "&Integral=" + sort + "&mg=" + memberGroupId + "&bt=" + businessType + "&productname=" + escape(productname) + "&SeniorMember=" + seniorMember + "&showtype=synthesis&groupname=" + groupname + "&cf=" + certificates);
       //发送请求
       xmlhttp1.send(null);

   }

   function dosubmitp() {

       obj = G("txtemail");
       var patn = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
       if (G("member").style.display != "none") {
           if (!patn.test(obj.value)) {
               alert("Please enter a valid email address.");
               G("txtemail").focus();
               return;
           }
           if (G("txtemail").value != "") {
               CheckEmailIsMember();
              
               if (document.getElementById("memberexits").style.display == "") {
                   if (document.getElementById("Passworderr2").style.display == "") {
                       alert("Invalid member ID or password. Please try again");
                       return;
                   }
               }
           }
       }
       if (G("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(G("txtcontent").value)) {
           alert("Please enter English characters only！");
           return;
       }
       if (G("isloginvalue").value == 0) {
           showcontact(true);
       }
       else if (G("isloginvalue").value == 2) {
           G("formsend").submit();
       }
       else {
           if (G("txtpassword").value.length >= 6) {
               G("formsend").submit();
           }
           else {
               alert("password must be 6 - 20 characters !");
           }
       }


   }

   var IsMemberAjax = 0;



   function showsendc(cas, product, userid, islogin) {
       document.writeln("<form id=\"formsend\"  action=\"/HotProducts/send.aspx?type=cas\" method=\"post\">");

       document.writeln("<dl><dt>CAS  No:</dt><dd><input type=\"hidden\" value=\"" + islogin + "\" id=\"isloginvalue\" name=\"isloginvalue\" /><input id=\"txtcas\" name=\"txtcas\" type=\"text\" value=\"" + cas + "\" class=\"width210\" /></dd></dl>");
       document.writeln("<dl><dt><span>*</span> Product Name:</dt><dd><input name=\"txttitle\" id=\"txttitle\" type=\"text\" value=\"Name:" + product + "\" class=\"width320\" /></dd></dl>");
       document.writeln("<dl id=\"member\"><dt><span>*</span> Your email:</dt><dd><input id=\"txtemail\" name=\"txtemail\" type=\"text\" class=\"width210\" onBlur=\"javascript:CheckEmailIsMember();\" /></dd><span id=\"memberexits\" style=\"display:none;float:left; margin-left:150px;*margin-left:-8px; \">Please enter your LookChem.com password!</span></dl>");

       document.writeln("<dl id=\"password\" style=\"display:none;\"><dt><span>*</span> Password:</dt><dd><input id=\"txtpassword\" type=\"password\" class=\"width210\" name=\"txtpassword\" onBlur=\"javascript:CheckEmailandPwd2();\" /></dd><span style=\"float:left; margin-left:150px;*margin-left:-8px;\"><a href=\"/forget_password.aspx\" target=\"_blank\">Forget your password?</a></span><span id=\"Passworderr2\"  style=\"display:none;\">*</span></dl>");


       document.writeln("<dl><dt><span>*</span> Requirements:</dt><dd><textarea name=\"txtcontent\" id=\"txtcontent\"></textarea></dd></dl>");
       document.writeln("<dl><dt>&nbsp;</dt><dd><input id=\"btn2\" type=\"button\" class=\"btnstyle2\" onclick=\"dosubmitp();\" /></dd></dl>");
       if (userid == 0) {

           G("member").style.display = "";
           if (GetCookie('BuyEmail') != '' && GetCookie('BuyEmail') != null) {
               G("txtemail").value = GetCookie('BuyEmail');
               CheckEmailIsMember();
           }
       }
       else {
           IsMemberAjax = 2;
           G("member").style.display = "none";
           G("password").style.display = "none";
           G("txtcontent").value = "";
       }
       document.writeln("</form>");
   }

   function CheckEmailIsMember() {
       IsMemberAjax = 0;
       obj = G("txtemail");
       var patn = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
       if (G("member").style.display != "none") {
           if (!patn.test(obj.value)) {

               return;
           }
       }
       var xmlhttp1 = createXMLHttpRequest();

       xmlhttp1.onreadystatechange = function() {
           if (xmlhttp1.readyState == 4) {
               //关闭显示条

               if (xmlhttp1.status == 200) {
                   //当加载成功时将内容显示于页面
                   if (xmlhttp1.responseText == "1") {
                       G("password").style.display = '';
                       G("isloginvalue").value = "1";
                       G("memberexits").style.display = '';
                   }
                   else {
                       G("isloginvalue").value = "0";
                       G("password").style.display = 'none';
                       G("memberexits").style.display = 'none';
                   }

               } else {
                   //否则弹出错误信息

               }
           }
       }
       //创建一个连接
       xmlhttp1.open("get", "/Hotproducts/ajaxIsMemberByEmail.aspx?Email=" + document.getElementById("txtemail").value + "&d=" + new Date());
       //发送请求
       xmlhttp1.send(null);
   }


//底部用
   function CheckEmailandPwd2() {
       IsMemberAjax = 0;
       var email = G("txtemail").value;
       var pwd = G("txtpassword").value;

       var xmlhttp1 = createXMLHttpRequest();

       xmlhttp1.onreadystatechange = function() {
           if (xmlhttp1.readyState == 4) {
               //关闭显示条

               if (xmlhttp1.status == 200) {
                   //当加载成功时将内容显示于页面

                   if (xmlhttp1.responseText == "1") {
                       G("Passworderr2").style.display = "none";
                       return true;
                   }
                   else {
                       G("Passworderr2").style.display = "";
                       return false;

                   }

               } else {
                   //否则弹出错误信息

               }
           }
       }
       //创建一个连接
       xmlhttp1.open("get", "/server/Member.aspx?type=2&Email=" + email + "&pwd=" + pwd + "&d=" + new Date());
       //发送请求
       xmlhttp1.send(null);
   }


//弹窗用
   function  CheckEmailandPwd() {
       IsMemberAjax = 0;

       var email = G("txtemailnew").value;
       var pwd = G("txtpasswordnew").value;
      
       var xmlhttp1 = createXMLHttpRequest();

       xmlhttp1.onreadystatechange = function() {
           if (xmlhttp1.readyState == 4) {
               //关闭显示条

               if (xmlhttp1.status == 200) {
                   //当加载成功时将内容显示于页面

                   if (xmlhttp1.responseText == "1") {
                       G("Passworderr").style.display = "none";
                       return true;
                   }
                   else {
                       G("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 checkregpsw() {
       var patn = /^.{6,20}$/;
       if (!patn.test(G("txtregpsw").value)) {
           G("dtxtregpsw").style.display = "";
           return false;
       }
       else {
           G("dtxtregpsw").style.display = "none";
           return true;
       }
   }

   function checkregpsw1( ) {
       var patn = /^.{6,20}$/;
       if (!patn.test(G("txtregpsw1").value)) {
           G("detxtregpsw1").style.display = "";
           //  obj.txtregpsw1.focus();
           //  err = false;
           return false;
       }
       else {
           G("detxtregpsw1").style.display = "none";
           //return true;
       }
       if (G("txtregpsw").value != '' && G("txtregpsw").value != G("txtregpsw1").value) {
           G("detxtregpswsame").style.display = "";
           //  obj.txtregpsw.focus();
           // err = false;
           return false;
       }
       else {
           G("detxtregpswsame").style.display = "none";
           return true;
       }
   }
   

   function changespan() {
       var mli = G("_more_li");
       var mdd = G("_more_dd");
       var mtext = G("_more");
       if (mtext.innerHTML == "More...") {
           mtext.innerHTML = "Less...";
           mli.className = "less";
           G("_more_dd").className = "";
       }
       else {
           mtext.innerHTML = "More...";
           mli.className = "more";
           mdd.className = "click";
       }
   }

   /*showmember end*/

 var isFirefox=navigator.userAgent.indexOf("Firefox");
   function GetIMsell_product(siteurl, sellerid, productid) {
       var iWidth = 729;
       var iHeight = 560;
       var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
       var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
     //  if (isFirefox > 0) {
           var winim = window.open('http://im.lookchem.com/service/link1.asp?ver=1&siteurl=' + siteurl + '&portId=1&status=1&itemId=' + productid + '&comId=' + sellerid + '', '_blank', 'height=' + iHeight + ',width=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
       //}
      // else {
       //    var winim = window.showModelessDialog('http://im.lookchem.com/service/link1.asp?ver=1&siteurl=' + siteurl + '&portId=1&status=1&itemId=' + productid + '&comId=' + sellerid + '', window, 'dialogWidth:729px;dialogHeight:560px;edge:sunken;scroll:no;Minimize=yes;Maximize=no');
      // }
   }


   function GetIMsell(siteurl, sellerid) {
       var iWidth = 729;
       var iHeight = 560;
       var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
       var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
      // if (isFirefox > 0) {
           var winim = window.open('http://im.lookchem.com/service/link1.asp?ver=1&siteurl=' + siteurl + '&portId=1&status=1&itemId=1&comId=' + sellerid + '', '_blank', 'height=' + iHeight + ',width=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
       //}
      // else {

        //   var winim = window.showModelessDialog('http://im.lookchem.com/service/link1.asp?ver=1&siteurl=' + siteurl + '&portId=1&status=1&itemId=1&comId=' + sellerid + '', window, 'dialogWidth:729px;dialogHeight:560px;edge:sunken;scroll:no;Minimize=yes;Maximize=no' );
      // }
       }





       var __is_ff = (navigator.userAgent.indexOf("Firefox") != -1); //Firefox


       function castitle_show(ts) {
           var td = document.getElementById(ts);

           var div = document.getElementById("title_show");

           title_value = td.title;
           if (title_value.length > 0) {
               var words_per_line = 50;  //每行字数
               var title = split_str(td.title, words_per_line); //按每行50个字显示标题内容。
               div.innerHTML = title;

               div.style.display = '';
               td.title = ''; 	//去掉原有title显示。

               var m;
               if (__is_ff) {
                   m = getMouseLocation();
               }
               else {
                   m = getMouseXY();
               }
               with (div.style) {
                   top = (m.Y + 20) + "px";
                   left = (m.X) + "px";
               }
           }
       }

       function castitle_back(ts) {
           var td = document.getElementById(ts);
           var div = document.getElementById("title_show");
           td.title = title_value;
           div.style.display = "none";
       }

       function title_back(td) {
           var div = document.getElementById("title_show");
           td.title = title_value;
           div.style.display = "none";
       }


       function getMouseXY(e) {
           var posx = 0, posy = 0;
           if (e == null) e = window.event;
           if (e.pageX || e.pageY) {
               posx = e.pageX; posy = e.pageY;
           }
           else if (e.clientX || e.clientY) {
               if (document.documentElement.scrollTop) {
                   posx = e.clientX + document.documentElement.scrollLeft;
                   posy = e.clientY + document.documentElement.scrollTop;
               }
               else {
                   posx = e.clientX + document.body.scrollLeft;
                   posy = e.clientY + document.body.scrollTop;
               }
           }
           return {
               X: posx,
               Y: posy
           }
       }


    


       var xPos;
       var yPos;
       function setbackgroundColor(obj, index, type) {

           if (type == 'set') {
               obj.style.backgroundColor = '#FFFAE3';
           }
           else if (type == 'out') {
               if (document.getElementById(index)) {
                   if (document.getElementById(index).checked == false) {
                       obj.style.backgroundColor = '#ffffff';
                   }
               }
               else {
                   obj.style.backgroundColor = '#ffffff';
               }
           }
       }

       function getMouseLocation() {
           return { X: xPos, Y: yPos };
       }

       function mouseMove(ev) {
           ev = ev || window.event;
           var mousePos = mouseCoords(ev);
           //alert(ev.pageX);
           xPos = mousePos.x;
           yPos = mousePos.y;
       }

       function mouseCoords(ev) {
           if (ev.pageX || ev.pageY) {
               return { x: ev.pageX, y: ev.pageY };
           }
           return {
               x: ev.clientX + document.body.scrollLeft - document.body.clientLeft,
               y: ev.clientY + document.body.scrollTop - document.body.clientTop
           };
       }

       document.onmousemove = mouseMove;


       function killErrors() {
           return true;
       } 
       //JS容错
         window.onerror = killErrors;

