function TextDropList(oImg){
    var oSpan=oImg.parentNode;
    var strcouValue="";
    if(arguments.length>1&&arguments[1]){
        var ochildInput=$(arguments[1]).getElementsByTagName("input");
        if(ochildInput.length<=1||!ochildInput[0].value){
            alert("country is null,request failure");
            return false;
        }
        strcouValue=ochildInput[0].value;
    }
    var oImgs=oSpan.getElementsByTagName("img");
    if(oImgs.length>=2){
        oImg.style.display="none";
        oImgs[1].style.display="inline";
    }
    _textDropList(strcouValue,oSpan);
}
function TextDropListAsync(result,context){
    var oUls=context.getElementsByTagName("ul");
    for(var i=0;i<oUls.length;i++)
        context.removeChild(oUls[i]);
        
    var oUl=document.createElement("ul");
    oUl.innerHTML=result;
    context.appendChild(oUl);
    if(IEXPLORER)
        oUl.style.height=oUl.offsetHeight>200?"200px":"auto";
    
    var oImgs=context.getElementsByTagName("img");
    if(oImgs.length>0){
        oImgs[0].style.display="inline";
        for(var i=1;i<oImgs.length;i++)
            oImgs[i].style.display="none";
    }
//    var oSpan=context.getElementsByTagName("span");
    var oInput=context.getElementsByTagName("input");
    var oLis=oUl.getElementsByTagName("li");
    
    for(var i=0;i<oLis.length;i++){
        var tempInput=oLis[i].getElementsByTagName("input")
        if(!tempInput||tempInput.length){
            tempInput[0].onclick=function(){EventUtil.getEvent().stopPropagation();};
            tempInput[0].onblur=function(){
                if(oInput.length<2||tempInput.length<1)return false;
                oInput[0].value=tempInput[0].value;
                oInput[1].value=tempInput[0].value;
            };
        }
        if(oLis[i].title=="other")
            continue;
        oLis[i].onmouseover=function(){
            EventUtil.getEvent().stopPropagation();
            this.style.backgroundColor="#f5f5f5";
        }
        oLis[i].onmouseout=function(){
            EventUtil.getEvent().stopPropagation();
            this.style.backgroundColor="transparent";
        }
        oLis[i].onclick=function(){
            EventUtil.getEvent().stopPropagation();
//            if(oSpan.length>0)
//                oSpan[0].innerHTML=this.getAttribute("title");
            if(oInput.length>1){
                oInput[0].value=this.getAttribute("title");
                oInput[1].value=this.innerHTML;
            }
            oUl.style.display="none";
        }
    }
    var objevent=window;
    if(IEXPLORER)
        objevent=document.body;
    var clearevent=function(){
        oUl.style.display="none";
        EventUtil.removeEventHandler(objevent,"click",clearevent);
    }
    EventUtil.addEventHandle(objevent,"click",clearevent);
}
function GlobalLogin(){  
    var sb=new StringBuilder();
    sb.append("<div class=\"divgloballogin\">")
    sb.append("<span>Please enter your email and password</span>");
    sb.append("<label>Email: <input id=\"inplEmail\" type=\"text\" class=\"tbxCss\" style=\"margin-left:27px\"/></label>")
    sb.append("<label>Password: <input id=\"inplPassword\" type=\"password\" class=\"tbxCss\"/></label>")
    sb.appendFormat("<div><a href=\"{0}getpassword.aspx\">Forgot your password</a></div>",SITEURL);
    sb.appendFormat("<div><input id=\"inpLoginBtn\" type=\"button\" value=\"Login\" class=\"btnCss\" /><img id=\"imglWait\" src=\"{0}images/re/be-wait.jpg\"/></div>",LIBRARYURL)
    sb.append("</div>");
    
    var oLayer=LayerShield();
    var oRegion=LayerTable("User Login",sb.toString());
    oRegion.style.width="275px";
    oRegion.style.left="50%";
    oRegion.style.marginLeft="-137px";
    oRegion.style.top=document.documentElement.scrollTop+160+"px";
    
    var obtn=$("inpLoginBtn");
    obtn.focus();
    
    obtn.onclick=function(){
        var email=$("inplEmail").value;
        var password=$("inplPassword").value;
        if(!email){alert("email is not null.");return false;}
        if(!password){alert("password is not null.");return false;}
        if(!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(email))
        {alert("email format is wrong.");return false;}
        
        EventUtil.getEvent().target.style.display="none";
        $("imglWait").style.display="inline";
        _globalLogin(String.format("{0},{1}",email,password),oRegion);
    };
    document.body.onkeypress=function(){
        var e=EventUtil.getEvent();
        if(e.charCode==13)obtn.click();
    }
}
function GlobalLoginAsync(result,context){
    var obtn=$("inpLoginBtn");
    var oimg=$("imglWait");
    if(result){
        if(result=="-1")
        {
            alert("email or password is wrong.");
            obtn.style.display="inline";
            oimg.style.display="none";
        }
        else location.href=SITEURL+result;
    }
    else 
    {
        alert("system error.");
        obtn.style.display="inline";
        oimg.style.display="none";
    }
}

function JoinUsEmail(){
    var otbx=$("inpJoinUsEmail");
    if(!otbx||!otbx.value){alert("please input your email address.");otbx.focus(); return false;}
    if(!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(otbx.value))
    {alert("email format is wrong.");otbx.focus();return false;}
    
    $("inpJoinUsBtn").style.display="none";
    $("imgJoinUsWait").style.display="inline";
    _joinUsEmail(otbx.value,"inpJoinUsEmail,inpJoinUsBtn,imgJoinUsWait");
}
function JoinUsEmailAsync(result,context){
    var arry=context.split(',');
    $(arry[1]).style.display="inline";
    $(arry[2]).style.display="none";
    switch(result){
        case "1":{alert("your email has join us.");$(arry[0]).value=""; break;}
        case "2":{alert("your email is exist.");break;}
        case "-1":
        default:{alert("system error.");break;}
    }
}
function JoinUsEmailEnter(){
    var e=EventUtil.getEvent();
    if(e.charCode==13)
    {
        $("inpJoinUsBtn").click();
        return false;
    }
}

//update on 2010/6/21
function JoinUsEmail2(){
    var otbx=$("inpJoinUsEmail2");
    if(!otbx||!otbx.value){alert("please input your email address.");otbx.focus(); return false;}
    if(!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(otbx.value))
    {alert("email format is wrong.");otbx.focus();return false;}
    
    $("inpJoinUsBtn2").style.display="none";
    $("imgJoinUsWait2").style.display="inline";
    _joinUsEmail(otbx.value,"inpJoinUsEmail2,inpJoinUsBtn2,imgJoinUsWait2");
}
function JoinUsEmailAsync2(result,context){
    $("inpJoinUsBtn2").style.display="inline";
    $("imgJoinUsWait2").style.display="none";
    switch(result){
        case "1":{alert("your email has join us.");context.value=""; break;}
        case "2":{alert("your email is exist.");break;}
        case "-1":
        default:{alert("system error.");break;}
    }
}
function JoinUsEmailEnter2(){
    var e=EventUtil.getEvent();
    if(e.charCode==13)
    {
        $("inpJoinUsBtn2").click();
        return false;
    }
}

//update on 2010/6/21 end



function showmore(mun)
{
var mydescription =  document.getElementById("product_more_description"+mun);
var readmore = document.getElementById("readmore"+mun);
if(mydescription.style.display == "none")
{
mydescription.style.display="block";
readmore.innerHTML="hide";
}
else
{
mydescription.style.display="none";
readmore.innerHTML="read more";
}
}