// JavaScript Document
function gtabs(xx){
	if(xx=="oTabs1"){
		document.getElementById("omTabs1").className="isSelect";
		document.getElementById("omTabs2").className="unSelect";
	}
	
	if(xx=="oTabs2"){
		document.getElementById("omTabs1").className="unSelect";
		document.getElementById("omTabs2").className="isSelect";
	}
}

function gtabsEx(xx){
	if(xx=="oTabs1"){
		document.getElementById("omTabs1").className="isSelect";
		document.getElementById("omTabs2").className="unSelect";
		document.getElementById("omTabs3").className="unSelectSp";
	}
	
	if(xx=="oTabs2"){
		document.getElementById("omTabs1").className="unSelect";
		document.getElementById("omTabs2").className="isSelect";
		document.getElementById("omTabs3").className="unSelectSp";
	}
	
	if(xx=="oTabs3"){
		document.getElementById("omTabs1").className="unSelect";
		document.getElementById("omTabs2").className="unSelect";
		document.getElementById("omTabs3").className="isSelectSp";
	}
}

function nTabs(thisObj,Num){
  if(thisObj.className == "active")return;
  var tabObj = thisObj.parentNode.id;
  var tabList = document.getElementById(tabObj).getElementsByTagName("li");
  for(i=0; i<tabList.length; i++){
		if (i == Num){
			thisObj.className = "active";
			document.getElementById(tabObj+"_Content"+i).style.display = "block";
		}else{
			tabList[i].className = "normal";
			document.getElementById(tabObj+"_Content"+i).style.display = "none";
		}
	} 
}

//检查注册时必填信息
function chkreg(){
	var frm = document.formA;
	if (frm.UserName.value == "")
	{
		alert("登录名称必须填写");
		frm.UserName.focus();
		return false;
	}
	if (frm.UserName.value.match(/^(\w*)$/)==null)
	{
		alert("登录名称包含非法字符");
		frm.UserName.focus();
		return false;
	}
	if (frm.UserName.value.length>12)
	{
		alert("登录名称的长度不能超过12个字符");
		frm.UserName.focus();
		return false;
	}
	
	//Vertify the Password.
	if (frm.Password.value == "")
	{
		alert("密码不能为空");
		frm.Password.focus();
		return false;
	}
	if (frm.Password.value.match(/^(\w*)$/)==null)
	{
		alert("密码包含非法字符");
		frm.Password.focus();
		return false;
	}
	if (frm.Password.value.length>15||frm.Password.value.length<6)
	{
		alert("密码的长度是6－15个字符");
		frm.Password.focus();
		return false;
	}
	
	//Vertify the PasswdVertify.
	if(frm.PasswdVerify.value == ""){
		alert("确认密码不能为空");
		frm.PasswdVerify.focus();
		return false;
	}
	if(frm.PasswdVerify.value!=frm.Password.value)
	{
		alert("两次密码输入不一致");
		frm.PasswdVerify.focus();
		return false;
	}
	
	//Vertify the Email Address.
	if(frm.Email.value.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)==null)
	{
		alert("电子邮箱的格式不正确");
		frm.Email.focus();
		return false;
	}
	
	//Vertify the country
	if(frm.country.value == ""){
	    alert("请输入您的省份");
	    frm.country.focus();
	    return false;
	}
	
	//Vertify the company
	if(frm.company.value == ""){
	    alert("请输入您公司的名称");
	    frm.company.focus();
	    return false;
	}
	
	//Vertify the contacter
	if(frm.contacter.value == ""){
	    alert("联系人必须填写");
	    frm.contacter.focus();
	    return false;
	}
	
	//Vertify the agent
	if(frm.agent.value == ""){
	    alert("您的供应商必须填写");
	    frm.agent.focus();
	    return false;
	}
	
	//Vertify the Code Verification.
	if(frm.numVerify.value != frm.vertNum.value){
		alert("请输入正确的验证码");
		frm.numVerify.focus();
		return false;
	}
	
	return true;
}

//检查注册用户基本信息 __$Checking the info of register. __Page: particular.asp
function chkperinf(){
	var obj = document.formB;
	if(obj.name.value.length > 20){
		alert("The length of Your Name more than 20 characters.");
		obj.name.focus();
		return false;
	}
	
	if(obj.question.value.length > 20 || obj.question.value.length < 4){
		alert("the length of Password Question between 4~20 characters.");
		obj.question.focus();
		return false;
	}
	
	if(obj.answer.value.length > 10 || obj.answer.value.length < 4){
		alert("the length of Password Answer between 4~10 characters.");
		obj.answer.focus();
		return false;
	}
	
	if(obj.tel.value.match(/^\d*$/) == null){
		alert("Telephone number must be Numbers.");
		obj.tel.focus();
		return false;
	}
	
	if(obj.fax.value.match(/^\d*$/) == null){
		alert("Fax number must be Numbers.");
		obj.fax.focus();
		return false;
	}
	return true;
}

//网站语言切换
function ChgLang(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//日历
function Clock() {
  var date = new Date();
  this.year = date.getFullYear();
	this.month = new Array("Jan.", "Feb.", "Mar.", "Apr.", "May.", "Jun.", "Jul.", "Aug.", "Sep.", "Oct.", "Nov.", "Dec.")[date.getMonth()];
  this.date = date.getDate();
	this.day = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "hursday", "Friday", "Saturday")[date.getDay()];
  this.hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
  this.minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
  this.second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();

  this.toString = function() {
		return this.month + " " + this.date + ", " + this.year + " " + this.day + " " + this.hour + ":" + this.minute + ":" + this.second;
	};
	
	this.toSimpleDate = function() {
		return this.year + "-" + this.month + "-" + this.date;
	};
	
	this.toDetailDate = function() {
		return this.year + "-" + this.month + "-" + this.date + " " + this.hour + ":" + this.minute + ":" + this.second;
	};
	
	this.display = function(ele) {
		var clock = new Clock();
		ele.innerHTML = clock.toString();
		window.setTimeout(function() {clock.display(ele);}, 1000);
	};
}

//display month. Jump Menu for ShowNewPro.asp
function SelMonth(targ,selObj,restore){ //v3.0
	var mydate = selObj.options[selObj.selectedIndex].value;
	var arytemp = mydate.split("-");
	eval(targ+".location='/ShowNewPro.asp?y="+arytemp[0]+"&m="+arytemp[1]+"'");
  if (restore) selObj.selectedIndex=0;
}

//display brand. Jump Menu for ShowNewPro.asp
function SelBrand(targ,selObj,restore){ //v3.0
	var mybrand = selObj.options[selObj.selectedIndex].value;
	eval(targ+".location='/ShowNewPro.asp?brand="+mybrand+"'");
  if (restore) selObj.selectedIndex=0;
}
