function getCookie(d){var b="",c="",a="";b=document.cookie;var c=b.indexOf(d+"=");if(c==-1){return""}c+=d.length+1;var a=b.indexOf(";",c);if(a==-1){return unescape(b.substring(c))}return unescape(b.substring(c,a))}function delCookie(b){var a=new Date();a.setTime(a.getTime()-24*60*60*1000);domain=".tradehong.com";path="/";document.cookie=b+"=;expires="+a.toUTCString()+";domain="+domain+";path="+path;}function checkLogout(){delCookie("CHECK_STR_B");delCookie("ACTIVED_B");delCookie("USERNAME_B");var a=document.getElementById("userstatus");a.innerHTML="Welcome! <a rel='nofollow' class='red' target='_top' href='http://www.tradehong.com/user/login.html' title='Sign in'>Sign in</a>&nbsp;or&nbsp;<a rel='nofollow' class='red' target='_top' href='http://www.tradehong.com/user/login.html' title='New guest'> New guest</a>"}function checkUserState(){var a=getCookie("USERNAME_B");var b=document.getElementById("userstatus");if(a.length>0){b.innerHTML="Hello, <a href='http://www.tradehong.com/buyer/'>" + a +"</a>!    <a class='b_ red' title='Log Out' href='javascript:void(0)' onclick='checkLogout();'>Log Out</a> "}else{b.innerHTML="Welcome! <a rel='nofollow' class='red' target='_top' href='http://www.tradehong.com/user/login.html' title='Sign in'>Sign in</a>&nbsp;or&nbsp;<a rel='nofollow' class='red' target='_top' href='http://www.tradehong.com/user/login.html' title='New guest'> New guest</a>"}}function getCartCount(){var a=getCookie("productoption");if(a!=null&&a!=""){var b=a.replace(/%40/g,"@");var c=/\d+@{2,3}\d+/gi;var d=b.match(c);if(d!=null&&d!=""){document.getElementById("cartstatus").innerHTML=d.length}}}function add_question(a){emailObj=document.getElementById("email");contentObj=document.getElementById("content");infoBoard=document.getElementById("checkInfo");emailBoard=document.getElementById("checkEmail");contentBoard=document.getElementById("checkContent");if(contentObj.value==""){contentBoard.innerHTML="<font color=red>Please enter message!</font>";contentObj.focus();return false}else{contentBoard.innerHTML=""}if(emailObj.value!=""){var b=/^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;if(!b.test(emailObj.value)){emailBoard.innerHTML="<font color=red>Invalid email address!</font>";emailObj.focus();return false}else{emailBoard.innerHTML=""}}myurl="/suggestion/add_action.php?email="+emailObj.value+"&content="+contentObj.value;retCode=openUrl(myurl);switch(retCode){case"-1":infoBoard.innerHTML="Message is null!";break;case"-2":infoBoard.innerHTML="Sorry,system error,Please try again later.";break;case"0":infoBoard.innerHTML="Sorry,system error,Please try again later.";break;case"1":infoBoard.innerHTML="Your message has been successfully sent!";break;default:}document.getElementById("talkWithUs").style.display="none";document.getElementById("talkWithUs_tj").style.display="";return}function openUrl(a){var c;if(window.XMLHttpRequest){c=new XMLHttpRequest();if(c.overrideMimeType){c.overrideMimeType("text/xml")}}else{if(window.ActiveXObject){try{c=new ActiveXObject("Msxml2.XMLHTTP")}catch(b){c=new ActiveXObject("Microsoft.XMLHTTP")}}}c.open("Get",a,false);c.setRequestHeader("Content-Type","text/xml");c.send(null);retInfo=c.responseText;if(c.status=="200"){return retInfo}else{return"-2"}}function StrCode(a){if(encodeURIComponent){return encodeURIComponent(a)}if(escape){return escape(a)}}function commAddCart(b,d,a){var c;c=window.location.href;window.location.href="/cart_getcookie.php?productid="+b+"&productNum="+d+"&refurl="+c+"&optionid="+a;return false}function addFavor(b,a){if(document.all){window.external.AddFavorite(a,b)}else{if(window.sidebar){window.sidebar.addPanel(b,a,"")}}}function playdiv(a){document.getElementById(a).style.display=""}function displaydiv(a){document.getElementById(a).style.display="none"}function createXmlHttp(){if(window.XMLHttpRequest){xmlHttp=new XMLHttpRequest()}else{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")}}function displaysugg(){document.getElementById("suggest").style.display="none"}function goSuggest(b){if(b.keyCode==40){changeItem("up")}else{if(b.keyCode==38){changeItem("down")}else{createXmlHttp();var a=document.getElementById("kw").value;xmlHttp.onreadystatechange=suggestResult;xmlHttp.open("get","/searchresult/suggest.php?kw="+a,true);xmlHttp.send(null)}}}function suggestResult(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){var a=xmlHttp.responseText;document.getElementById("suggest").style.display="";document.getElementById("suggest").innerHTML=a;document.getElementById("coverframe").style._height=document.getElementById("suggest").style._height}}}function updatekw(b,a){b.style.backgroundColor="#2A78B9"}function setkw(a){document.getElementById("kw").value=a;document.getElementById("suggest").style.display="none";document.getElementById("kw").focus()}function colorwhilte(a){a.style.backgroundColor="#FFFFFF"}function displaysea(){document.getElementById("suggest").style.display="none"}function changeItem(b){if(menuFocusIndex==null){menuFocusIndex=-1}var a=menuFocusIndex;if(a==-1){a=10}if(b=="up"){if(menuFocusIndex==-1||menuFocusIndex==10){menuFocusIndex=0}else{menuFocusIndex++}}else{if(menuFocusIndex==0||menuFocusIndex==-1){menuFocusIndex=10}else{menuFocusIndex--}}onselectli(menuFocusIndex,a)}function onselectli(c,b){var a="menu"+c;if(document.getElementById(a)){document.getElementById(a).style.backgroundColor="#2A78B9";document.getElementById("kw").value=document.getElementById(a).innerHTML}if(document.getElementById("menu"+b)){document.getElementById("menu"+b).style.backgroundColor="#FFFFFF"}}function updateProdNum(e,f){var g="productoption";var d=getCookie(g);var b="";if(d!=null&&d.length>0){var h=d.indexOf("@"+e+"@");if(h>=0){var c=new RegExp("@@"+e+"@\\d+","ig");var i=d.match(c);var a="@@"+e+"@"+f;b=d.replace(c,a);setCookie(g,b.toString(),"","/",".tradehong.com","")}}}function addProd(g,f,h){var k="productoption";var e=getCookie(k);var c="";if(e==null||e.length<=0){c=g+"@@@"+f+"@"+h}else{var l=e.indexOf("@"+f+"@");if(l>=0){var d=new RegExp("@@"+f+"@\\d+","ig");var n=e.match(d);var l=n.toString();var i=l.substr(l.lastIndexOf("@")+1);i=parseInt(i)+parseInt(h);var a="@@"+f+"@"+i;c=e.replace(d,a)}else{var b=new RegExp("(^|@{4})"+g+"(@{1,3}\\d+)*","ig");var m=e.match(b);if(m){var j=m.toString();j+="@@"+f+"@"+h;c=e.replace(b,j)}else{c=e+"@@@@"+g+"@@@"+f+"@"+h}}}setCookie(k,c.toString(),"","/",".tradehong.com","")}function removeProd(e){var g="productoption";var d=getCookie(g);if(d!=null&&d.length>0){var b=new RegExp("(^\\d+|@{4})\\d+(@{1,3}\\d+)*@{2,3}"+e+"(@{1,3}\\d+)+","ig");var i=d.match(b);var f=i.toString();var h=/\d+@@\d+@\d+/ig;var j=f.match(h);if(j){var c=new RegExp("@@"+e+"@\\d+","ig");var a=d.replace(c,"")}else{var a=d.replace(f,"");if(a.indexOf("@@@@")===0){a=a.substr(4)}}if(a.length>0){setCookie(g,a,"","/",".tradehong.com","")}else{delCookie(g)}}}function setCookie(c,e,a,h,d,g){var b=new Date();b.setTime(b.getTime());if(a){a=a*1000*60*60*24}var f=new Date(b.getTime()+(a));document.cookie=c+"="+escape(e)+((a)?";expires="+f.toGMTString():"")+((h)?";path="+h:"")+((d)?";domain="+d:"")+((g)?";secure":"")}function accAdd(f,d){var c,b,a;try{c=f.toString().split(".")[1].length}catch(g){c=0}try{b=d.toString().split(".")[1].length}catch(g){b=0}a=Math.pow(10,Math.max(c,b));return(Math.ceil(f*a+d*a))/a}function accMinus(f,d){var c,b,a;try{c=f.toString().split(".")[1].length}catch(g){c=0}try{b=d.toString().split(".")[1].length}catch(g){b=0}a=Math.pow(10,Math.max(c,b));return(Math.ceil(f*a-d*a))/a}function getCartList(){var a=getCookie("productoption");if(a!=null&&a!=""){createXmlHttp();xmlHttp.onreadystatechange=getCartListResponse;xmlHttp.open("post","/cart_information.php?action=getList",true);xmlHttp.send(null)}else{document.getElementById("noprod").style.display="";document.getElementById("withprod").style.display="none"}}function getCartListResponse(){if(xmlHttp.readyState==4&&xmlHttp.status==200){var cate1=xmlHttp.responseText;var a=eval("("+cate1+")");if(a.error>0){document.getElementById("noprod").style.display="";document.getElementById("withprod").style.display="none"}else{document.getElementById("noprod").style.display="none";document.getElementById("withprod").style.display="";document.getElementById("cartinfo").innerHTML=a.content;document.getElementById("prod_num").innerHTML=a.total_num;document.getElementById("prod_price").innerHTML="$"+a.total_price;document.getElementById("hidden_prod_num").value=a.total_num;document.getElementById("hidden_prod_price").value=a.total_price}}else{document.getElementById("noprod").style.display="";document.getElementById("withprod").style.display="none"}}function delProductDisplay(e){if(document.getElementById("pop_hidden_price_"+e)){if(document.getElementById("hidden_prod_num").value>0){document.getElementById("hidden_prod_num").value-=document.getElementById("pop_hidden_num_"+e).value;document.getElementById("prod_num").innerHTML=document.getElementById("hidden_prod_num").value}if(document.getElementById("hidden_prod_num").value>0){document.getElementById("hidden_prod_price").value=accMinus(document.getElementById("hidden_prod_price").value,document.getElementById("pop_hidden_price_"+e).value);document.getElementById("prod_price").innerHTML="$"+document.getElementById("hidden_prod_price").value}else{document.getElementById("hidden_prod_price").value=0;document.getElementById("prod_price").innerHTML="$0";document.getElementById("noprod").style.display="";document.getElementById("withprod").style.display="none"}var a=document.getElementById("li_"+e);var d=a.parentNode;d.removeChild(a)}}function delProduct(a){delProductDisplay(a);if(document.getElementById("hidden_price_"+a)){removeCartDisplay(a)}removeProd(a);getCartCount()}function cartCheckout(a){if(typeof(pageTracker)!="undefined"){pageTracker._trackPageview("/uradd/"+a+"_checkout")}var b=new Date();b.setTime(b.getTime()+24*60*60*10);document.cookie="BNOW="+escape("0")+";expires="+b.toGMTString()+";path=/;domain=.tradehong.com";window.location="http://pay.tradehong.com/checkout.php";return false};
