function categories_inf_show(img,title){     
    var categories_inf=document.getElementById("categories_inf");    
    if(categories_inf){
        if(img!="" && title!=""){
            categories_inf.innerHTML="<img src='"+img+"' width='100px'><span style='font-size:13px;color:#585858'>"+title+"</span>";
        }
    }
}
function userlogin(formname){
    var user=formname.userid;
    var pass=formname.userpassword; 
    if(user.value==''){
        alert('Please enter a login id')
        user.focus();    
        return false; 
    }  
    if(pass.value==''){
        alert('Please enter your password')
        pass.focus();    
        return false; 
    }
    return true; 
}

function checkmaincatform(){
    var maincatnameenid=document.getElementById("maincatnameenid");    
    var maincatnameb5id=document.getElementById("maincatnameb5id"); 
    var maincatnamegbid=document.getElementById("maincatnamegbid"); 
    var maincatremarkenid=document.getElementById("maincatremarkenid"); 
    var maincatremarkb5id=document.getElementById("maincatremarkb5id"); 
    var maincatremarkgbid=document.getElementById("maincatremarkgbid"); 
    var maincatfileid=document.getElementById("maincatfileid"); 
    if(maincatnameenid.value==""){
        alert("Please enter a english title of main category");
        maincatnameenid.focus();
        return false;
    }
    if(maincatnamegbid.value==""){
        alert("Please enter a chinese(Gb) title of main category");
        maincatnamegbid.focus();
        return false;
    }
    if(maincatnameb5id.value==""){
        alert("Please enter a chinese(B5) title of main category");
        maincatnameb5id.focus();
        return false;
    }
    /*if(maincatremarkenid.value==""){
        alert("Please enter a english remark of main category");
        maincatremarkenid.focus();
        return false;
    }
    if(maincatremarkgbid.value==""){
        alert("Please enter a chinese(Gb) remark of main category");
        maincatremarkgbid.focus();
        return false;
    }
    if(maincatremarkb5id.value==""){
        alert("Please enter a chinese(B5) remark of main category");
        maincatremarkb5id.focus();
        return false;
    }*/
    return true;
}

function checksubcatform(){
    if(document.getElementById("subcatselectid")){
        var subcatselectid=document.getElementById("subcatselectid"); 
    }
    var subcatnameenid=document.getElementById("subcatnameenid");   
    var subcatnamegbid=document.getElementById("subcatnamegbid");  
    var subcatnameb5id=document.getElementById("subcatnameb5id"); 
    var subcatremarkenid=document.getElementById("subcatremarkenid"); 
    var subcatremarkgbid=document.getElementById("subcatremarkgbid");
    var subcatremarkb5id=document.getElementById("subcatremarkb5id"); 
    var subcatfileid=document.getElementById("subcatfileid"); 
    
    if(document.getElementById("subcatselectid")){
        if(subcatselectid.value==""){
            alert("Please select a main category");
            subcatselectid.focus();
            return false;
        }  
    }
    if(subcatnameenid.value==""){
        alert("Please enter a english title of sub category");
        subcatnameenid.focus();
        return false;
    }else if(subcatnameenid.value.length>15){
        alert("English title is too long");
        subcatnameenid.focus();
        return false;  
    }
    if(subcatnamegbid.value==""){
        alert("Please enter a chinese(Gb) title of sub category");
        subcatnamegbid.focus();
        return false;
    }else if(subcatnamegbid.value.length>15){
        alert("chinese(Gb) title is too long");
        subcatnamegbid.focus();
        return false;  
    }
    if(subcatnameb5id.value==""){
        alert("Please enter a chinese(B5) title of sub category");
        subcatnameb5id.focus();
        return false;
    }else if(subcatnameb5id.value.length>15){
        alert("chinese(B5) title is too long");
        subcatnameb5id.focus();
        return false;  
    }
   /* if(subcatremarkenid.value==""){
        alert("Please enter a english remark of sub category");
        subcatremarkenid.focus();
        return false;
    }
    if(subcatremarkgbid.value==""){
        alert("Please enter a chinese(Gb) remark of sub category");
        subcatremarkgbid.focus();
        return false;
    }
    if(subcatremarkb5id.value==""){
        alert("Please enter a chinese(B5) remark of sub category");
        subcatremarkb5id.focus();
        return false;
    }*/
    return true;
}


function checkproductinfoform(){
    if(document.getElementById("maincatselectid")){
        var maincatselectid=document.getElementById("maincatselectid"); 
    }
    if(document.getElementById("subcatselectid")){
        var subcatselectid=document.getElementById("subcatselectid"); 
    }
    if(document.getElementById("thirdcatselectid")){
        var thirdcatselectid=document.getElementById("thirdcatselectid"); 
    }
    var productnameenid=document.getElementById("productnameenid");    
    var productnamegbid=document.getElementById("productnamegbid"); 
    var productnameb5id=document.getElementById("productnameb5id"); 
    var productremarkenid=document.getElementById("productremarkenid"); 
    var productremarkgbid=document.getElementById("productremarkgbid"); 
    var productremarkb5id=document.getElementById("productremarkb5id"); 
    var productfileid=document.getElementById("productfileid"); 
    var RetailPriceid=document.getElementById("RetailPriceid"); 
    var Costid=document.getElementById("Costid"); 
    var productcode=document.getElementById("productcodeid"); 
    
    if(document.getElementById("maincatselectid")){
        if(maincatselectid.value==""){
            alert("Please select a main category");
            maincatselectid.focus();
            return false;
        }  
    }
    if(document.getElementById("subcatselectid")){
        if(subcatselectid.value==""){
            alert("Please select a sub category");
            subcatselectid.focus();
            return false;
        }  
    }
    if(document.getElementById("thirdcatselectid")){
        if(thirdcatselectid.value==""){
            alert("Please select a third category");
            thirdcatselectid.focus();
            return false;
        }  
    }
    if(productnameenid.value==""){
        alert("Please enter a english title of product");
        productnameenid.focus();
        return false;
    }
    if(productnamegbid.value==""){
        alert("Please enter a chinese(Gb) title of product");
        productnamegbid.focus();
        return false;
    }
    if(productnameb5id.value==""){
        alert("Please enter a chinese(B5) title of product");
        productnameb5id.focus();
        return false;
    }
    if(productcode.value==""){
        alert("Please enter a Model No.");
        productcode.focus();
        return false;
    }
    if(document.getElementById("hiddentbl")){
        if(RetailPriceid.value!="" && document.getElementById("hiddentbl").style.display=='block'){
            if(isNaN(RetailPriceid.value)){
                alert("retail price must a numeric");
                RetailPriceid.focus();
                return false;    
            }
        }
        if(Costid.value!="" && document.getElementById("hiddentbl").style.display=='block'){
            if(isNaN(Costid.value)){
                alert("cost must a numeric");
                Costid.focus();
                return false;    
            }
        }
    }else{
        if(RetailPriceid.value!=""){
            if(isNaN(RetailPriceid.value)){
                alert("retail price must a numeric");
                RetailPriceid.focus();
                return false;    
            }
        }
        if(Costid.value!=""){
            if(isNaN(Costid.value)){
                alert("cost must a numeric");
                Costid.focus();
                return false;    
            }
        }  
    }
    if(productremarkenid.value==""){
        alert("Please enter a english remark of product");
        productremarkenid.focus();
        return false;
    }
    if(productremarkgbid.value==""){
        alert("Please enter a chinese(Gb) remark of product");
        productremarkgbid.focus();
        return false;
    }
    if(productremarkb5id.value==""){
        alert("Please enter a chinese(B5) remark of product");
        productremarkb5id.focus();
        return false;
    }
    return true;
}

function updateimages1(){
    var updateimagesid=document.getElementById("updateimagesid");
    var upfileid=document.getElementById("upfileid");     
    if(updateimagesid.checked==true){
        upfileid.style.display="";    
    }else{
        upfileid.style.display="none";  
    }
}

function changeLang(lang,url,to){
    window.location=url+"?changeLang="+lang+"&toppage="+to;
}

function checkthirdcatform(){
    if(document.getElementById("maincatselectid")){
        var maincatselectid=document.getElementById("maincatselectid"); 
    }
    if(document.getElementById("subcatselectid")){
        var subcatselectid=document.getElementById("subcatselectid"); 
    }   
    var thirdcatnameenid=document.getElementById("thirdcatnameenid");   
    var thirdcatnamegbid=document.getElementById("thirdcatnamegbid");  
    var thirdcatnameb5id=document.getElementById("thirdcatnameb5id"); 
    var thirdcatremarkenid=document.getElementById("thirdcatremarkenid"); 
    var thirdcatremarkgbid=document.getElementById("thirdcatremarkgbid");
    var thirdcatremarkb5id=document.getElementById("thirdcatremarkb5id"); 
    var thirdcatfileid=document.getElementById("thirdcatfileid"); 
   
    if(document.getElementById("maincatselectid")){
        if(maincatselectid.value==""){
            alert("Please select a main category");
            maincatselectid.focus();
            return false;
        }  
    }
    if(document.getElementById("subcatselectid")){
        if(subcatselectid.value==""){
            alert("Please select a sub category");
            subcatselectid.focus();
            return false;
        }  
    }
    if(thirdcatnameenid.value==""){
        alert("Please enter a english title of third category");
        thirdcatnameenid.focus();
        return false;
    }
    if(thirdcatnamegbid.value==""){
        alert("Please enter a chinese(Gb) title of third category");
        thirdcatnamegbid.focus();
        return false;
    }
    if(thirdcatnameb5id.value==""){
        alert("Please enter a chinese(B5) title of third category");
        thirdcatnameb5id.focus();
        return false;
    }
    if(thirdcatremarkenid.value==""){
        alert("Please enter a english remark of third category");
        thirdcatremarkenid.focus();
        return false;
    }
    if(thirdcatremarkgbid.value==""){
        alert("Please enter a chinese(Gb) remark of third category");
        thirdcatremarkgbid.focus();
        return false;
    }
    if(thirdcatremarkb5id.value==""){
        alert("Please enter a chinese(B5) remark of third category");
        thirdcatremarkb5id.focus();
        return false;
    }
    return true;
}

function checkAll(){  
  var accountcounter=0;
  var templogic=0;
  if(document.getElementById('accountidall').checked){
    while(document.getElementById('accountid'+accountcounter)){      
            document.getElementById('accountid'+accountcounter).checked=true;
            accountcounter++;           
       }      
  }else{
    while(document.getElementById('accountid'+accountcounter)){      
            document.getElementById('accountid'+accountcounter).checked=false; 
            accountcounter++;          
    } 
  } 
}


function changecss(cleartd){
    document.getElementById(cleartd).className="fixgb";
    var clearclass=document.getElementById("tempclassid").value;
    if(clearclass!=""){
        document.getElementById(clearclass).className="pointertd";
    }
    document.getElementById("tempclassid").value=cleartd; 
}

function changebarbg(li){
    if(document.getElementById("tempclassid").value!=""){
        var oldvalue=document.getElementById("tempclassid").value;
        document.getElementById(oldvalue).className="";
    }
    document.getElementById(li).className="tabs8onhand";
    document.getElementById("tempclassid").value=li;
}

function showmoreinput(){
    if(document.getElementById("hiddentbl").style.display=='none'){
        document.getElementById("hiddentbl").style.display='block';
    }else{
        document.getElementById("hiddentbl").style.display='none';
    }
}
  
function moveOption(e1, e2){ 
    try{ 
        for(var i = 0; i < e1.options.length; i++){ 
            if(e1.options[i].selected){ 
                var e = e1.options[i]; 
                e2.options.add(new Option(e.text, e.value)); 
                e1.remove(i); 
                i = i - 1; 
            } 
        } 
        /*document.myform.city.value=getvalue(document.myform.list2);     */
    } 
    catch(e){} 
} 
function getvalue(geto){ 
    var allvalue = ""; 
    for(var i = 0; i < geto.options.length; i++){ 
        allvalue += geto.options[i].value + ","; 
    } 
    return allvalue; 
} 
function moveAllOption(e1, e2){ 
    try{ 
        for(var i = 0;i < e1.options.length; i++){ 
        var e = e1.options[i]; 
        e2.options.add(new Option(e.text, e.value)); 
        e1.remove(i); 
        i = i - 1; 
        } 
        /*document.myform.city.value=getvalue(document.myform.list2);       */
    } 
    catch(e){} 
} 
function selectSubmit(){
    for(var i=0;i<document.getElementById('productfieldselectid').length;i++){
        document.getElementById('productfieldselectid').options[i].selected=true;
    }    
    document.forms['productfieldForm'].submit();
}
