//A Link
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//make window height 100%
/*function  load(){
	if( document.body.scrollHeight <=  document.body.clientHeight ){
		document.all.cmc.style.height  =  document.body.clientHeight  -  133;
	}else{
		document.all.cmc.style.height  =  document.body.scrollHeight  -  133;
	}
}
window.onresize  =  function(){
		if( document.body.scrollHeight <=  document.body.clientHeight ){
		document.all.cmc.style.height  =  document.body.clientHeight  - 133;
	}else{
		document.all.cmc.style.height  =  document.body.scrollHeight  -  133;
	}
}*/
//general variables,regular expressions and functions
var blankreg=RegExp("^[ ]*$");
//
function menus_init() { 
     if (document.all&&document.getElementById) { 
          menuList = document.getElementsByTagName("UL"); 
          if (menuList.length > 0) 
          { 
               for (x=0; x<menuList.length; x++) 
               { 
                    menuRoot = menuList[x]; 
                    for (i=0; i<menuRoot.childNodes.length; i++) { 
                         menuNode = menuRoot.childNodes[i]; 
                         if (menuNode.nodeName=="LI") { 
                              if (menuNode.className == "dropdown") 
                              { 
                                   menuNode.onmouseover=function() { 
                                        this.className+=" over"; 
                                   } 
                                   menuNode.onmouseout=function() { 
                                        this.className=this.className.replace(" over", ""); 
                                   } 
                              } 
                         } 
                    } 
               } 
          } 
     } 
} 
addEvent(window, "load", menus_init); 

function addEvent(obj, evType, fn){ 
  if (obj.addEventListener){ 
    obj.addEventListener(evType, fn, true); 
    return true; 
  } else if (obj.attachEvent){ 
     var r = obj.attachEvent("on"+evType, fn); 
    return r; 
  } else { 
     return false; 
  } 
}

//homepage login validation
function home_login(){
	if(document.forms[0].username.value.match(blankreg)!=null){
document.getElementById('warnmsg').innerHTML='Please enter your login ID';document.forms[0].username.style.background='#FFC6C6';
document.forms[0].username.focus();return false;}else{document.getElementById('warnmsg').innerHTML='';document.forms[0].username.style.background='none';}
if(document.forms[0].pswd.value.match(blankreg)!=null){
document.getElementById('warnmsg').innerHTML='Please enter your password';document.forms[0].pswd.style.background='#FFC6C6';
document.forms[0].pswd.focus();return false;}else{document.getElementById('warnmsg').innerHTML='';document.forms[0].pswd.style.background='none';}
document.forms[0].submit();
}
//select a city for an order
function city_selector(){
var acity=document.forms[0].cityselector.selectedIndex;
switch(acity){
case 1:
var goto="ord-sh.php";
break;
case 2:
var goto="ord-zj.php";
break;
case 3:
var goto="ord-js.php";
break;
default:
var goto="index.php";
break;
}
window.location.href=goto;
}
//show and hide main meu
function showmenu(x)
{
	document.getElementById('mainmenulink'+x).style.background='url(/imgs/mom.gif)';
	//if(x!=1 && x!=0){ document.getElementById('submenu'+x).style.display="block"; }
	if(x!=0){ document.getElementById('submenu'+x).style.display="block"; }
}
function hidemenu(x,n)
{
	//if(x!=1 && x!=0){ document.getElementById('submenu'+x).style.display="none"; }
	if(x!=0){ document.getElementById('submenu'+x).style.display="none"; }
	if(x!=n)
	{ 
		document.getElementById('mainmenulink'+x).style.background='url(/imgs/menu-off.gif)'; 
	}else
	{
		document.getElementById('mainmenulink'+x).style.background='url(/imgs/menu-on.gif)';
	}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function demoover(demoid){
	document.getElementById(demoid).style.background='url(../imgs/demoback-o.gif)';
	document.getElementById(demoid).style.color='ffffff';
}
function demoout(demoid){
	document.getElementById(demoid).style.background='url(../imgs/demoback.gif)';
	document.getElementById(demoid).style.color='787878';
}

function checkmsg(){
	var warnmsgarr=new Array();
	warnmsgarr[0]="请确保您的邮箱信息完整";
	warnmsgarr[1]="留言字数请控制在1000字以内";
	warnmsgarr[2]="请留下您公司的全称";
for(i=0;i<3;i++){
//		if(document.forms[0].elements[i].value.match("^[ ]*$")!=null || 1)  || (document.forms[0].elements[0].value.indexOf("@")==-1)
		if(document.forms[1].elements[0].value.indexOf("@")==-1||document.forms[1].elements[i].value=='')
		{
			document.getElementById('warnmsg').innerHTML=warnmsgarr[i];
			document.forms[1].elements[i].style.background='#FFC6C6';
			document.forms[1].elements[i].focus();
			return false;
		}else{
			document.getElementById('warnmsg').innerHTML='';
			document.forms[1].elements[i].style.background='none';
		}
	}
}
//make demo index menu height 100%
function  dmload(){
	if( document.body.scrollHeight <=  document.body.clientHeight ){
		document.all.dm.style.height  =  document.body.clientHeight  -  100;
	}else{
		document.all.dm.style.height  =  document.body.scrollHeight  -  100;
	}
	document.all.cm.style.height = document.all.dm.style.height;
}
/*window.onresize  =  function(){
		if( document.body.scrollHeight <=  document.body.clientHeight ){
		document.all.dm.style.height  =  document.body.clientHeight  -  100;
	}else{
		document.all.dm.style.height  =  document.body.scrollHeight  -  100;
	}
	document.all.cm.style.height = document.all.dm.style.height;
}*/



//Contrl Demo Page Menu
function dmo(demoid,bf){
	if(bf==0){
		document.getElementById(demoid).style.background='url(../imgs/de-mi-o.gif)';
		document.getElementById(demoid).style.color='ffffff';
	}
}
function dmu(demoid,bf){
	if(bf==0){
		document.getElementById(demoid).style.background='url(../imgs/de-mi.gif)';
		document.getElementById(demoid).style.color='000000';
	}
}
//Contrl HomePage Loginbox
function chloginbox(chf){
	if(chf=='u'){
		document.all.mlp.style.display = 'none';
		document.all.mlu.style.display = 'block';
	}else{
		document.all.mlu.style.display = 'none';
		document.all.mlp.style.display = 'block';
	}
		
}

function chltrainbox()
{
	var warnmsgarr=new Array();
	warnmsgarr[0]="请选择您要购买的产品型号";
	warnmsgarr[1]="请输入您的电子邮箱地址";
	warnmsgarr[2]="请输入您的留言";
	warnmsgarr[3]="请输入您公司的全称";
	warnmsgarr[4]="请输入联系人姓名";
	warnmsgarr[5]="请输入联系电话";

	for(i=1;i<6;i++){
			if(document.forms[0].elements[i].value.match("^[ ]*$")!=null){
				document.getElementById('warnmsg').innerHTML=warnmsgarr[i];
				document.forms[0].elements[i].style.background='#FFC6C6';
				document.forms[0].elements[i].focus();
				return false;
			}else
			{
				document.getElementById('warnmsg').innerHTML='';
				document.forms[0].elements[i].style.background='none';
			}
	}

}

//Home Page button
function submitok(formid){   
  document.getElementById(formid).submit();   
}  

function npmover(itemid)
{
	document.getElementById(itemid).style.background='ff0000';
}
function npmout(itemid)
{
	document.getElementById(itemid).style.background='';
}
//home page tabs
function changeTab(n){
    //tab个数
    var len=4;
    for(i=1;i<=len;i++){
	    document.getElementById("tab_"+i).style.display=(i==n)?"block":"none";
	    document.getElementById("tab_head_"+i).className=(i==n)?"isactive":"none";
    }
}

var timeout; 
function delayChangeTab(m,n){
    timeout = setTimeout("changeTab("+m+")",n);
}

function cancelChangeTab(){
    clearTimeout(timeout);
}
function menu_selector()
{
	for(i=0;i<7;i++)
	{
		document.getElementById('mainmenulink'+i).style.background='url(/imgs/menu-off.gif)';	
	}
}


function chkuserexp()
{
	var blankreg=RegExp("^[ ]*$");
	var warnmsgarr=new Array();
	warnmsgarr[0]="输入公司名称";
	warnmsgarr[1]="输入联系人姓名";
	warnmsgarr[2]="输入联人职位";
	warnmsgarr[3]="输入联系电话";
	warnmsgarr[4]="输入联系人邮件";


	for(i=0;i<document.forms['order'].elements.length;i++)
	{
		if(document.forms['order'].elements[i].value.match(blankreg)!=null)
		{
			document.getElementById('warnmsg').innerHTML=warnmsgarr[i];
			document.forms['order'].elements[i].style.background='#FFC6C6';
			document.forms['order'].elements[i].focus();
			return false;
		}else
		{
			document.getElementById('warnmsg').innerHTML='';
			document.forms['order'].elements[i].style.background='none';
		}
	}
}

function chkorderexp()
{
	var blankreg=RegExp("^[ ]*$");
	var warnmsgarr=new Array();
	warnmsgarr[1]="输入公司名称";
	warnmsgarr[2]="输入公司网站";
	warnmsgarr[3]="输入具体地址";
	warnmsgarr[4]="输入邮政编码";
	warnmsgarr[5]="输入联系人邮件";
	warnmsgarr[6]="输入电子邮件";
	warnmsgarr[7]="输入联系人";

	for(i=1;i<document.forms['order'].elements.length;i++)
	{
		if(document.forms['order'].elements[i].value.match(blankreg)!=null)
		{
			document.getElementById('warnmsg').innerHTML=warnmsgarr[i];
			document.forms['order'].elements[i].style.background='#FFC6C6';
			document.forms['order'].elements[i].focus();
			return false;
		}else
		{
			document.getElementById('warnmsg').innerHTML='';
			document.forms['order'].elements[i].style.background='none';
		}
	}
}
