var tc;
function s2up(id){
 var o=document.getElementById(id);//hscroll(o);
 window.setInterval(function(){window.clearTimeout(tc);o.firstChild.style.marginLeft='0px';scrollup(o,20,0);},6000);
}
function scrollup(o,d,c){
 if(d==c){
  var t=o.firstChild.cloneNode(true);
  o.removeChild(o.firstChild);o.appendChild(t);
  t.style.marginTop=o.firstChild.style.marginTop='0px';
  hscroll(o);
 }
 else{
  ch=false;var s=3,c=c+s,l=(c>=d?c-d:0);
  o.firstChild.style.marginTop=-c+l+'px';
  window.setTimeout(function(){scrollup(o,d,c-l)},50);
 }
}

function hscroll(o){
 var w1=o.firstChild.offsetWidth,w2=o.offsetWidth;
 if(w1<=w2)return;
 tc=window.setTimeout(function(){hs(o,w1-w2,0,w1-w2)},3500);
}

function hs(o,d,c,p){
 c++;var t=(c>0?-c:c);o.firstChild.style.marginLeft=t+'px';
 if(c==d){if(d==0){tc=window.setTimeout(function(){hs(o,p,0,p)},2500);}else tc=window.setTimeout(function(){hs(o,0,-p,p)},3500);}
 else tc=window.setTimeout(function(){hs(o,d,c,p)},5);
}

function setTab(name,cursel,n){
for(i=1;i<=n;i++){
  var menu=document.getElementById(name+i);
  var con=document.getElementById("n"+name+i);
  menu.className=i==cursel?"on":"";
  con.style.display=i==cursel?"block":"none";
}
}

function checksearchform(obj)
{if($("keyword").value=="")
	{//alert('Please input keyword!');
	 $("keyword").focus();
	 return false
		}
if($("searchtype").selectedIndex==0)
	{$("searchtype").focus();
	return false;
	}
	switch($("searchtype").value)
	{case "1":
		//obj.action="/product.asp"
		var strkeywordjs=($("keyword").value);
		if (strkeywordjs.toLowerCase()=="led light" || strkeywordjs.toLowerCase()=="led lights")
		{
		location.href="http://en.cnledw.com/LED-Lights.htm"
		break;
		}
		if (strkeywordjs.toLowerCase()=="led daylight" || strkeywordjs.toLowerCase()=="led daylights")
		{
		location.href="http://en.cnledw.com/LED-Daylights.htm"
		break;
		}
		if (strkeywordjs.toLowerCase()=="led lamp" || strkeywordjs.toLowerCase()=="led lamps")
		{
		location.href="http://en.cnledw.com/LED-Lamps.htm"
		break;
		}
		location.href="http://en.cnledw.com/ps"+encodeURIComponent($("keyword").value.replace('_',''))+".htm"
		break;


		//switch($("keyword").value)
		//{ case "led light":
		  //case "led lights":
			 // location.href="http://en.cnledw.com/LED-Lights.htm"
			  //break;
		  //case "led daylight":
		  //case "led daylights":
			  //location.href="http://en.cnledw.com/LED-Daylights.htm"
			 // break;
		 // case "led lamp":
		  //case "led lamps":
			//  location.href="http://en.cnledw.com/LED-Lamps.htm"
			 // break;
		 // default:
			//  location.href="http://en.cnledw.com/ps"+encodeURIComponent($("keyword").value.replace('_',''))+".htm"
			//  break;
		 // } 
	 case "2":
	 	//obj.action="/buying.asp"
	 	location.href="http://en.cnledw.com/bs"+encodeURIComponent($("keyword").value.replace('_',''))+".htm"
	 	break;
	 case "6":
	 	//obj.action="/trade.asp"
	 	location.href="http://en.cnledw.com/ts"+encodeURIComponent($("keyword").value.replace('_',''))+".htm"
	 	break;
	 case "7":
	 location.href="http://en.cnledw.com/ns"+encodeURIComponent($("keyword").value.replace('_',''))+".htm"
	 	//obj.action="/news.asp"
	 	break;
	 case "8":
	 location.href="http://en.cnledw.com/co"+encodeURIComponent($("keyword").value.replace('_',''))+".htm"
	 	break;
	 case "10":
	  location.href="http://en.cnledw.com/ss"+encodeURIComponent($("keyword").value.replace('_',''))+".htm"
	 	//obj.action="/suppliers.asp"
	 	break;	 	
	 default:
	 	break;
		}
return false;
	}
	
function $(id)
{return document.getElementById(id)
	}
	
function areaextra(id)
{init("sc","country","/xml/scountry.asp?SortID="); 
 if(id.toString().length==6)
 	{
  getSorts('/xml/scountry.asp?SortID=0',39);
 	setTimeout("getSorts('/xml/scountry.asp?SortID=39',"+id+")",1000)
 	return
 	}
 if(id==39)
 {getSorts('/xml/scountry.asp?SortID=0',39);
 setTimeout("getSorts('/xml/scountry.asp?SortID=39',0)",1000)
	return
 }
 getSorts('/xml/scountry.asp?SortID=0',39);
}
	
function checklogin(obj)
{if(obj.username.value=="")
	{alert('Please input your memberid!');
		obj.username.focus()
		return}
 if(obj.pass.value=="")
 {alert('Please input type password!');
 	obj.pass.focus();
 	return;}
	obj.submit();	
	}
function checkfind(obj)
{if(obj.username.value=="")
	{alert("Please input your id!")
 obj.username.focus();
 return false;
	}
if(!/^[\w-.]+@([\w-]+(\.)?)+$/ig.test(obj.email.value))
	{alert("Please input your email!");
 obj.email.focus();
 return false;
	}	
	return true;
	}
	
	
function catalogextra(cat)
{init("cc","catid","/xml/catalog.asp?SortID="); 
 var c=cat.split("-")
 if(c.length<1){c="0-0".split("-")}
 if(c[0]>0)
 {getSorts('/xml/catalog.asp?SortID=0',c[0])
 	setTimeout("getSorts('/xml/catalog.asp?SortID="+c[0]+"',"+c[1]+")",1000)}
 else
 	getSorts('/xml/catalog.asp?SortID=0',c[1])
}

function doSelAll(obj,s)
{	var id=document.getElementsByName("id");
	for(var i=0; i<id.length; i++){
		id[i].checked=(s.checked) ? true : false;
	}
	obj.checkall.checked=s.checked;
	}
function uncheck(obj,s)
	{if(s.checked==false)
		obj.checkall.checked=s.checked;
	}
	
	function checkuser(a,b)
{
	var xmlhttp = new XMLHttpRequest();
	xmlhttp.open("GET", "checkusername.asp?"+a+"="+b,false);
	xmlhttp.send(null);
	return xmlhttp.responseText;
}

function existuser(obj)
{	var f;
	if (!/^[a-zA-Z0-9\-]{6,20}$/.test(obj.username.value))
		{$("exituser").innerHTML="<font color=red>6-20 characters (A-Z, a-z, 0-9, hyphen ( '-' ), no spaces)</font>";
		f=1;}
	else
		f=0;
	if(f==0)
		{if(checkuser('searchid',obj.username.value)==1)
			$("exituser").innerHTML="<font color=red>Exists the same id,please change another!</font>";
		else
			$("exituser").innerHTML="<font color=green>√</font>";
			}
		}
	function checkregform(obj)
	{	if (!/^[a-zA-Z0-9\-]{6,20}$/.test(obj.username.value))
		{
			alert("ID should be 6-20 characters (A-Z, a-z, 0-9, hyphen ( '-' ), no spaces)");
			obj.username.focus();
			return false;
		}
		if(checkuser('searchid',obj.username.value)==1)
		{alert("Exists the same id,please change another!")
		 obj.username.focus();
			return false;}
		if (obj.pwd1.value.length==0)
		{
			alert('Please input password!');
			obj.pwd1.focus();
			return false;
		}
		if (obj.pwd2.value=="")
		{
			alert('Please input confirm password!');
			obj.pwd2.focus();
			return false;
		}
		if (obj.pwd1.value!=obj.pwd2.value)
		{
			alert('Confirm password not same as the password!')
			obj.pwd2.focus();
			return false;
		}
		if (obj.cmpname.value=="")
		{
			alert('Please input company name!');
			obj.cmpname.focus();
			return false;
		}
		if (obj.cname.value=="")
		{
			alert('Please input You Name.!');
			obj.cname.focus();
			return false;
		}

		if (obj.cphone0.value=="")
		{
			alert('Please input Phone No.!');
			obj.cphone0.focus();
			return false;
		}
		if (obj.cphone1.value=="")
		{
			alert('Please input Phone No.!');
			obj.cphone1.focus();
			return false;
		}
		if (obj.cphone2.value=="")
		{
			alert('Please input Phone No.!');
			obj.cphone2.focus();
			return false;
		}

		//$("content").value=window.frames["Editor"].frames["HtmlEditor"].document.getElementsByTagName("BODY")[0].innerHTML;
		if(!/^[\w-.]+@([\w-]+(\.)?)+$/ig.test(obj.email.value))
		{
			alert('Please input your email!');
			obj.email.focus();
			return false;
		}
		//if(!/^[\w-.]+@([\w-]+(\.)?)+$/ig.test(obj.msn.value)&&obj.msn.value!="")
		//{
			//alert('Please input your msn!');
			//obj.msn.focus();
			//return false;
		//}		
		if(obj.CheckCode.value=="")
		{alert("Please input Verification Code!")
		obj.CheckCode.focus();
		return false;}
		obj.onsubmit.disable=true;	
		return true;
	}	


