﻿// JScript 文件
function $(obj){
    return document.getElementById(obj);
}

function CheckLogin(){
    if($("Login1_txtUserID").value==""){
        $("Login_UserID").className="red";
        $("Login1_txtUserID").focus();
        return false;
    }
    
    if($("Login1_txtPassword").value==""){
        $("Login_Password").className="red";
        $("Login1_txtPassword").focus();
        return false;
    }
    
    $("Login1_ImageButton1").onCheck();
}

function __doPostSelect(sname,obj)
{
	var objcheck=document.getElementsByName(sname);
	for(var i=0;i<objcheck.length;i++)
	{
		objcheck[i].checked = obj.checked;
	}
}

function CheckLoginObj(obj,sobj){
    $(sobj).className= $(obj).value==""?"red":"";
}

function ChanagePageSize(str,obj){
    var psize = obj.value;
    var url = str+(psize!=20?"?"+psize:"")
    window.location.href = url;    
}

function ChanageSearchPageSize(str,obj){
    var psize = obj.value;
    var url = str.replace("$pagesize$",psize);
    window.location.href = url;    
}

function ChangePage(str){
    var url = "";
    
}


function UnShow(obj){
    $(obj).style.display="none";
}

function MainSearch(){
    var key = $("searchkeywords").value.replace("\/","fangxiegang").replace("\\","zhengxiegang");
    
    if(checken(key)==false){
        alert("Sorry,the information you filled in is not in English. Please input the information in English instead.");
        return false;
    }
    
    if(key==""){
        alert("Please enter keywords.");
        return false;
    }
    var opt = $("searchoptions").value;
    var a=new Array('http://www.tradett.com/searchsellleads.html?page=1&pagesize=20&key=', '/searchbuyleads.html?page=1&pagesize=20&key=', '/searchproducts.html?page=1&pagesize=20&key=', '/searchcompanies.html?page=1&pagesize=20&key=');
    window.location.href= a[opt-1] + escape(key);
    return false;
}

function dMainSearch(){
    var key = $("dsearchkeywords").value.replace("\/","fangxiegang").replace("\\","zhengxiegang");
    
    if(checken(key)==false){
        alert("Sorry,the information you filled in is not in English. Please input the information in English instead.");
        return false;
    }
    
    if(key==""){
        alert("Please enter keywords.");
        return false;
    }
    var opt = $("dsearchoptions").value;
    var a=new Array('http://www.tradett.com/searchsellleads.html?page=1&pagesize=20&key=', '/searchbuyleads.html?page=1&pagesize=20&key=', '/searchproducts.html?page=1&pagesize=20&key=', '/searchcompanies.html?page=1&pagesize=20&key=');
    window.location.href= a[opt-1] + escape(key);
    return false;
}

function MyTT(){
    window.location.href="http://www.tradett.com/members/redirect.html";
}

function DoCurrentPage(str){
    var reg = /[0-9]$/;
    var n = $("CurrentPageNumber").value;
    
    if(reg.test(n)==false){
        alert("Please enter numeric.");
        return false;    }
    
    var url = str.replace("$page$",n);
    window.location.href=url;
}

function singleInquiryNow(uid,c){
    var url = "/message/contact.html?" + uid + ":" + c;
    window.location.href=url;
}

function Register(){
    var url= "register.html";
    window.location.href= "http://www.tradett.com/" + url;
}


function FMainSearch(){
    var key = $("searchkeywords").value.replace("\/","fangxiegang").replace("\\","zhengxiegang");
    
    if(checken(str)==false){
        alert("Sorry,the information you filled in is not in English. Please input the information in English instead.");
        return false;
    }
    
    if(key==""){
        alert("Please enter keywords.");
        return false;
    }
    var url = "http://www.tradett.com/searchproducts.html?page=1&pagesize=20&key=" + escape(key);
    newWin=window.open(url,"theNewWindow",",,location=yes,menubar=yes,resizable=yes,screenX=,screenY=,status=yes,toolbar=yes,scrollbars=yes");

    return false;
}

function FsingleInquiryNow(uid,c){
    var url = "http://www.tradett.com/message/contact.html?" + uid + ":" + c;
    newWin=window.open(url,"theNewWindow",",,location=yes,menubar=yes,resizable=yes,screenX=,screenY=,status=yes,toolbar=yes,scrollbars=yes");
}



function checken(str){
        for(i=0;i<str.length;i++){
            if(str.charCodeAt(i)>256){
                return false;
            }
        }
        return true;    
    }

function checkens(str){
    var a = str.split(',');
    for(var i=0;i<a.length;i++){
        if(checken($(a[i]).value)==false){
            return false;
        }
    }
    return true;
}


function SearchTradeShow(){
    var _industry = $("Showright1_txtIndustry").value;
    var _year = $("Showright1_txtyearmonth").value;

    var _month= _year!=""?_year.split('|')[1]:"";
    _year = _year!=""?_year.split('|')[0]:"";
    var _lc = $("Showright1_txtlocation").value;
    var key = $("Showright1_tskeywords").value;
    
    var url = "http://www.tradett.com/tradeshow/search.html\?str=" + _industry + "\&year=" + (_year==""?"0":_year) + "\&month=" + (_month==""?"0":_month) + "\&lc=" + _lc + "\&page=1\&key=" + escape(key) ;
    window.location.href= "/" + url;

}

function SendInquirys(){
    var objcheck =document.getElementsByName("Plistbox");
    var p = "",pid="";
    var s = "",sid="";
	for(var i = 0;i<objcheck.length;i++)
	{
	    p += objcheck[i].checked==true?"p"+objcheck[i].value + "," : "";
	}
	
    var objcheck =document.getElementsByName("Slistbox");
	for(var i=0;i<objcheck.length;i++)
	{
	    s += objcheck[i].checked == true?"s"+objcheck[i].value + "," : "";
	}
	
	var ids = p+s;
	if(ids == ""){
	    alert('No item(s) selected');
	}
	else{
        var url = "http://www.tradett.com/message/contact.html?" + ids + ":" + 5;
        window.location.href = url;
	}
}
