var _country= new Array();
_country[0]=new Array("Afghanistan","AF","93");
_country[1]=new Array("Albania","AL","355");
_country[2]=new Array("Algeria","DZ","213");
_country[3]=new Array("American Samoa","AS","684");
_country[4]=new Array("Andorra","AD","376");
_country[5]=new Array("Angola","AO","244");
_country[6]=new Array("Anguilla","AV","1264");
_country[7]=new Array("Antigua and Barbuda","AG","1268");
_country[8]=new Array("Argentina","AR","54");
_country[9]=new Array("Armenia","AM","374");
_country[10]=new Array("Ascension","AC","247");
_country[11]=new Array("Australia","AU","61");
_country[12]=new Array("Austria","AT","43");
_country[13]=new Array("Azerbaijan","AZ","994");
_country[14]=new Array("Bahamas","BF","1242");
_country[15]=new Array("Bahrain","BH","973");
_country[16]=new Array("Bangladesh","BD","880");
_country[17]=new Array("Barbados","BB","1246");
_country[18]=new Array("Belarus","BY","375");
_country[19]=new Array("Belgium","BE","32");
_country[20]=new Array("Belize","BZ","501");
_country[21]=new Array("Benin","BJ","229");
_country[22]=new Array("Bermuda Is.","BM","1441");
_country[23]=new Array("Bolivia","BO","591");
_country[24]=new Array("Botswana","BW","267");
_country[25]=new Array("Brazil","BR","55");
_country[26]=new Array("Brunei","BN","673");
_country[27]=new Array("Bulgaria","BG","359");
_country[28]=new Array("Burkina-faso","BF","226");
_country[29]=new Array("Burma","MM","95");
_country[30]=new Array("Burundi","BI","257");
_country[31]=new Array("Cameroon","CM","237");
_country[32]=new Array("Canada","CA","1");
_country[33]=new Array("Cayman Is.","KY","1345");
_country[34]=new Array("Central African Republic","CF","236");
_country[35]=new Array("Chad","TD","235");
_country[36]=new Array("Chile","CL","56");
_country[37]=new Array("China","CN","86");
_country[38]=new Array("Colombia","CO","57");
_country[39]=new Array("Congo","CG","242");
_country[40]=new Array("Cook Is.","CK","682");
_country[41]=new Array("Costa Rica","CR","506");
_country[42]=new Array("Cuba","CU","53");
_country[43]=new Array("Cyprus","CY","357");
_country[44]=new Array("Czech Republic","CZ","420");
_country[45]=new Array("Denmark","DK","45");
_country[46]=new Array("Djibouti","DJ","253");
_country[47]=new Array("Dominica Rep","DO","1890");
_country[48]=new Array("Ecuador","EC","593");
_country[49]=new Array("Egypt","EG","20");
_country[50]=new Array("EI Salvador","SV","503");
_country[51]=new Array("Estonia","EE","372");
_country[52]=new Array("Ethiopia","ET","251");
_country[53]=new Array("Fiji","FJ","679");
_country[54]=new Array("Finland","FI","358");
_country[55]=new Array("Foeroyar,The Faroe Islands","FO","298");
_country[56]=new Array("France","FR","33");
_country[57]=new Array("French Guiana","GF","594");
_country[58]=new Array("French Polynesia","PF","689");
_country[59]=new Array("Gabon","GA","241");
_country[60]=new Array("Gambia","GM","220");
_country[61]=new Array("Georgia","GE","995");
_country[62]=new Array("Germany","DE","49");
_country[63]=new Array("Ghana","GH","233");
_country[64]=new Array("Gibraltar","GI","350");
_country[65]=new Array("Greece","GR","30");
_country[66]=new Array("Grenada","GD","1809");
_country[67]=new Array("Guam","GU","1671");
_country[68]=new Array("Guatemala","GT","502");
_country[69]=new Array("Guinea","GN","224");
_country[70]=new Array("Guyana","GY","592");
_country[71]=new Array("Haiti","HT","509");
_country[72]=new Array("Honduras","HN","504");
_country[73]=new Array("Hong kong","HK","852");
_country[74]=new Array("Hungary","HU","36");
_country[75]=new Array("Iceland","IS","354");
_country[76]=new Array("India","IN","91");
_country[77]=new Array("Indonesia","ID","62");
_country[78]=new Array("Iran","IR","98");
_country[79]=new Array("Iraq","IQ","964");
_country[80]=new Array("Ireland","IE","353");
_country[81]=new Array("Israel","IL","972");
_country[82]=new Array("Italy","IT","39");
_country[83]=new Array("Ivory Coast","CI","225");
_country[84]=new Array("Jamaica","JM","1876");
_country[85]=new Array("Japan","JP","81");
_country[86]=new Array("Jordan","JO","962");
_country[87]=new Array("Kampuchea (Cambodia )","KH","855");
_country[88]=new Array("Kazakstan","KZ","327");
_country[89]=new Array("Kenya","KE","254");
_country[90]=new Array("Korea","KR","82");
_country[91]=new Array("Kuwait","KW","965");
_country[92]=new Array("Kyrgyzstan","KG","331");
_country[93]=new Array("Laos","LA","856");
_country[94]=new Array("Latvia","LV","371");
_country[95]=new Array("Lebanon","LB","961");
_country[96]=new Array("Lesotho","LS","266");
_country[97]=new Array("Liberia","LR","231");
_country[98]=new Array("Libya","LY","218");
_country[99]=new Array("Liechtenstein","LI","423");
_country[100]=new Array("Lithuania","LT","370");
_country[101]=new Array("Luxembourg","LU","352");
_country[102]=new Array("Macao","MO","853");
_country[103]=new Array("Macedonia","MK","389");
_country[104]=new Array("Madagascar","MG","261");
_country[105]=new Array("Malawi","MW","265");
_country[106]=new Array("Malaysia","MY","60");
_country[107]=new Array("Maldives","MV","960");
_country[108]=new Array("Mali","ML","223");
_country[109]=new Array("Malta","MT","356");
_country[110]=new Array("Martinique","MQ","596");
_country[111]=new Array("Mauritius","MU","230");
_country[112]=new Array("Mexico","MX","52");
_country[113]=new Array("Moldova Republic of","MD","373");
_country[114]=new Array("Monaco","MC","377");
_country[115]=new Array("Mongolia","MN","976");
_country[116]=new Array("Montserrat Is","MS","1664");
_country[117]=new Array("Morocco","MA","212");
_country[118]=new Array("Mozambique","MZ","258");
_country[119]=new Array("Namibia","NA","264");
_country[120]=new Array("Nauru","NR","674");
_country[121]=new Array("Nepal","NP","977");
_country[122]=new Array("Netherlands","NL","31");
_country[123]=new Array("Netherlands Antilles","AN","599");
_country[124]=new Array("New Zealand","NZ","64");
_country[125]=new Array("Nicaragua","NI","505");
_country[126]=new Array("Niger","NE","227");
_country[127]=new Array("Nigeria","NG","234");
_country[128]=new Array("North Korea","KP","850");
_country[129]=new Array("Northern Mariana Islands","MP","1670");
_country[130]=new Array("Norway","NO","47");
_country[131]=new Array("Oman","OM","968");
_country[132]=new Array("Pakistan","PK","92");
_country[133]=new Array("Panama","PA","507");
_country[134]=new Array("Papua New Cuinea","PG","675");
_country[135]=new Array("Paraguay","PY","595 ?");
_country[136]=new Array("Peru","PE","51");
_country[137]=new Array("Philippines","PH","63");
_country[138]=new Array("Poland","PL","48");
_country[139]=new Array("Portugal","PT","351");
_country[140]=new Array("Puerto Rico","PR","1787");
_country[141]=new Array("Qatar","QA","974");
_country[142]=new Array("Reunion","RE","262");
_country[143]=new Array("Romania","RO","40");
_country[144]=new Array("Russia","RU","7");
_country[145]=new Array("Saint Lueia","LC","1758");
_country[146]=new Array("Saint Vincent","VC","1784");
_country[147]=new Array("Samoa Western","WS","685");
_country[148]=new Array("San Marino","SM","378");
_country[149]=new Array("Sao Tome and Principe","ST","239");
_country[150]=new Array("Saudi Arabia","SA","966");
_country[151]=new Array("Senegal","SN","221");
_country[152]=new Array("Seychelles","SC","248");
_country[153]=new Array("Sierra Leone","SL","232");
_country[154]=new Array("Singapore","SG","65");
_country[155]=new Array("Slovakia","SK","421");
_country[156]=new Array("Slovenia","SI","386");
_country[157]=new Array("Solomon Is","SB","677");
_country[158]=new Array("Somali","SO","252");
_country[159]=new Array("South Africa","ZA","27");
_country[160]=new Array("Spain","ES","34");
_country[161]=new Array("Sri Lanka","LK","94");
_country[162]=new Array("St.Lucia","LC","1758");
_country[163]=new Array("St.Vincent","VC","1784");
_country[164]=new Array("Sudan","SD","249");
_country[165]=new Array("Suriname","SR","597");
_country[166]=new Array("Swaziland","SZ","268");
_country[167]=new Array("Sweden","SE","46");
_country[168]=new Array("Switzerland","CH","41");
_country[169]=new Array("Syria","SY","963");
_country[170]=new Array("Taiwan","TW","886");
_country[171]=new Array("Tajikstan","TJ","992");
_country[172]=new Array("Tanzania","TZ","255");
_country[173]=new Array("Thailand","TH","66");
_country[174]=new Array("Togo","TG","228");
_country[175]=new Array("Tonga","TO","676");
_country[176]=new Array("Trinidad and Tobago","TT","1809");
_country[177]=new Array("Tunisia","TN","216");
_country[178]=new Array("Turkey","TR","90");
_country[179]=new Array("Turkmenistan","TM","993");
_country[180]=new Array("Uganda","UG","256");
_country[181]=new Array("Ukraine","UA","380");
_country[182]=new Array("United Arab Emirates","AE","971");
_country[183]=new Array("United Kingdom","UK","44");
_country[184]=new Array("United States","US","1");
_country[185]=new Array("Uruguay","UY","598");
_country[186]=new Array("Uzbekistan","UZ","233");
_country[187]=new Array("Venezuela","VE","58");
_country[188]=new Array("Vietnam","VN","84");
_country[189]=new Array("Yemen","YE","967");
_country[190]=new Array("Yugoslavia","YU","381");
_country[191]=new Array("Zaire","ZR","243");
_country[192]=new Array("Zambia","ZM","260");
_country[193]=new Array("Zimbabwe","ZW","263");

/**
* form  表单id
*scountry 选中的值
*
**/
function countryinit(form,scountry){
  	for(var i=0;i<194;i++){
		var opt = document.createElement("option");   
		document.getElementById(form).country.appendChild(opt); 
		opt.text=_country[i][0];   
  		opt.value=_country[i][0]; 
  		opt.img=_country[i][1];	
		opt.code=_country[i][2];
		if(opt.value.toLowerCase()==scountry.toLowerCase()) opt.selected=true;
	}
	//document.getElementById(form).country.value=scountry;
}


function _sid_(id){
var f=document.SearchForm;
var host=""
var key=f.keyword.value.Trim();
var sw=false;
if(",Search Products,Search Selling Leads,Search Suppliers,Search Buyers,Search Buying Leads,".indexOf(","+key+",")!=-1||key=="")sw=true;
if(sw){
		f.keyword.style.color="#999999";
	}else{
		f.keyword.style.color="";
}
if(id=="product"){
	if(sw)f.keyword.value="Search Products";
	document.SearchForm.gourl.value=host+'/product/search.jsp?'
}else if(id=="sell"){
	if(sw)f.keyword.value="Search Selling Leads";
	document.SearchForm.gourl.value=host+'/trade/search.jsp?tradetype=sell&'
}else if(id=="buy"){
	if(sw)f.keyword.value="Search Buying Leads";
	document.SearchForm.gourl.value=host+'/trade/search.jsp?tradetype=buy&'
}else if(id=="company"){
	if(sw)f.keyword.value="Search Suppliers";
	document.SearchForm.gourl.value=host+'/suppliers/search.jsp?'
}else{
	if(sw)f.keyword.value="Search Products";
	id="product";
	document.SearchForm.gourl.value=host+'/product/search.jsp?'
}
	radioinit("way",id); 
}
function dosearch(){
	var f=document.SearchForm;
	var key=f.keyword.value.Trim();
	var sw=false;
	if(",Search Products,Search Selling Leads,Search Suppliers,Search Buyers,Search Buying Leads,".indexOf(","+key+",")!=-1||key=="")sw=true;
	if(sw){
		alert("Please type the word or words you wish to search for in the Search box. ");
		f.keyword.focus();
		return ;
	}else{
		var country=f.country.value;
		var gourl=f.gourl.value;
		var keyword=escape(f.keyword.value.Trim());
		gourl+="keyword="+keyword;
		if(country!="") gourl+="&country="+escape(country);
		var url="/ajax.do?actiontype=searchkey&key="+keyword+"&url="+escape(window.location.href);
		$.get(url);
		window.location=gourl;
	}
 }


function ckkeys(key,tag){
	var f=document.SearchForm;
	var sw=false;
	if(",Search Products,Search Selling Leads,Search Suppliers,Search Buyers,Search Buying Leads,".indexOf(","+key+",")!=-1||key=="")sw=true;
	if(tag==1){
		if(sw){
			f.keyword.style.color="";
			f.keyword.value="";
		}
	}else if(tag==2){
		if(key==""){
			var id="";
			var o = document.getElementsByName("way")  ;
			if(o==null) return;
			for(var i=0 ; i<o.length ; i++){
				if(o[i].checked == true){
					 id=o[i].value;
				}
			}
			_sid_(id);
		}
	}
}

//-------------首页菜单导航选中js-------------------------------------------------------------------------------------
var menuTimer =null;
function showmenu(obj1,obj2,state,location){ 
    var btn=document.getElementById(obj1);
    var obj=document.getElementById(obj2);
    var h=btn.offsetHeight;
    var w=btn.offsetWidth;
    var x=btn.offsetLeft;
    var y=btn.offsetTop;
    
    obj.onmouseover =function(){
        showmenu(obj1,obj2,'show',location);
    }
    obj.onmouseout =function(){
        showmenu(obj1,obj2,'hide',location);
    }
    
    while(btn=btn.offsetParent){y+=btn.offsetTop;x+=btn.offsetLeft;}
    
    var hh=obj.offsetHeight;
    var ww=obj.offsetWidth;
    var xx=obj.offsetLeft;//style.left;
    var yy=obj.offsetTop;//style.top;
    var obj2state=state.toLowerCase();
    var obj2location=location.toLowerCase();
    
    var showx,showy;

    if(obj2location=="left" || obj2location=="l" || obj2location=="top" || obj2location=="t" || obj2location=="u" || obj2location=="b" || obj2location=="r" || obj2location=="up" || obj2location=="right" || obj2location=="bottom"){
        if(obj2location=="left" || obj2location=="l"){showx=x-ww;showy=y;}
        if(obj2location=="top" || obj2location=="t" || obj2location=="u"){showx=x;showy=y-hh;}
        if(obj2location=="right" || obj2location=="r"){showx=x+w;showy=y;}
        if(obj2location=="bottom" || obj2location=="b"){showx=x;showy=y+h;}
    }else{ 
        showx=xx;showy=yy;
    }
    obj.style.left=showx+"px";
    obj.style.top=showy+"px";
    if(state =="hide"){
        menuTimer =setTimeout("hiddenmenu('"+ obj2 +"')", 0);
    }else{
        clearTimeout(menuTimer);
        obj.style.visibility ="visible";
    }
}
function hiddenmenu(psObjId){
    document.getElementById(psObjId).style.visibility ="hidden";
} 


