// JavaScript Document
var TC_Start = new Date();
var ns=(document.layers)?true:false; //火狐火NS
var ie=(document.all)?true:false;//IE
function $(){return document.getElementById?document.getElementById(arguments[0]):eval(arguments[0]);}
function addfavorite(webname,weburl)
{
   if (document.all)
   {
      window.external.addFavorite(weburl,webname);
   }
   else if (window.sidebar)
   {
      window.sidebar.addPanel(webname,weburl,"");
   }
}
function setHomepage(obj,weburl)
{
   if (ie)
   {
	  obj.style.behavior='url(#default#homepage)';
      obj.setHomePage(weburl);
   }
   else if (ns)
   {
      alert("不支持非IE浏览器！");
	  return false;
   }
}
function NotNull(Objs,Txts)
{
	var Arr_Obj=Objs.split("|");
	var Arr_Txt=Txts.split("|");
	for(var k=0;k<Arr_Obj.length;k++)
	{
		if($(Arr_Obj[k]).value=="")
		{
			alert(Arr_Txt[k]+"不能为空！");
			$(Arr_Obj[k]).focus();
			return false;
		}
	}
	return true;
}
//加入收藏：兼容火狐
function addfavorite(webname,weburl)
{
   if (document.all)
   {
      window.external.addFavorite(weburl,webname);
   }
   else if (window.sidebar)
   {
      window.sidebar.addPanel(webname,weburl,"");
   }
}
function setHomepage(obj,weburl)
{
   if (document.all)
   {
	  obj.style.behavior='url(#default#homepage)';
      obj.setHomePage(weburl);
   }
   else if (window.sidebar)
   {
      alert("不支持非IE浏览器！");
	  return false;
   }
}
function Marquee(obj,dir,scrollHW)
{
	var x;
	if(dir=="up" || dir=="down")
	{
		x=" height=\""+scrollHW+"\"";
	}
	else
	{
		x=" width=\""+scrollHW+"\"";
	}
	obj.innerHTML="<marquee direction=\""+dir+"\" scrollamount=\"2\" onmouseover=\"this.stop()\" onmouseout=\"this.start()\""+x+">"+obj.innerHTML+"</marquee>";
}
function AutoSize(obj,MaxWidth,MaxHeight)
{
	var objWidth=obj.width;
	var objHeight=obj.height;
	if((objWidth > MaxWidth) || (objHeight > MaxHeight))
	{
		var Ratio1 = (objWidth / MaxWidth);
		var Ratio2 = (objHeight / MaxHeight);
		if(Ratio1 >= Ratio2)
		{
			this.width=MaxWidth;//那么以宽度作为基准
			this.height=parseInt(objHeight / Ratio1);
		}
		else
		{
			this.width=parseInt(objWidth / Ratio2); //那么以宽度作为基准
			this.height=MaxHeight;
		}
	}
	else
	{
		this.width=objWidth;
		this.height=objHeight;
	};
	if(MaxWidth>this.width)
	{
		this.hspace=parseInt(MaxWidth-this.width)/2;
	}
	else
	{
		this.hspace=0;
	};
	if(MaxHeight>this.height)
	{
	    this.vspace=parseInt(MaxHeight-this.height)/2;
	}
	else
	{
		this.vspace=0;
	};
	obj.style.width=this.width+"px";
	obj.style.height=this.height+"px";
	obj.style.padding=this.vspace+"px";
	obj.style.paddingRight=(MaxWidth-this.width-this.hspace)+"px";
	obj.style.paddingBottom=(MaxHeight-this.height-this.vspace)+"px";
	obj.style.paddingLeft=this.hspace+"px";
}
function myTab(TabCon,TabBtn,TabNum,Length,ClassNameBefore,ClassNameAfter)//选项卡
{
var i;
for(i=1;i<=Length;i++)
{
$(TabCon+i).style.display="none";
$(TabBtn+i).className=ClassNameBefore;
}
$(TabCon+TabNum).style.display="block";
$(TabBtn+TabNum).className=ClassNameAfter;
}

function ShowOrHid(ObjId)
{
	if($(ObjId).style.display=="none")
	{
		$(ObjId).style.display="";
	}
	else
	{
		$(ObjId).style.display="none";
	}
}
function checkGuestInfo()
{
	if($("cname").value.length<2||$("cname").value.length>30)
	{
		alert("请正确填写您的姓名！");
		$("cname").focus();
		return false;
	};
	if($("password")!=null && $("password2")!=null)
	{
		if($("password").value.length==0)
		{
			alert("密码不能为空！");
			$("password").focus();
			return false;
		};
		if($("password").value.length < 5 || $("password").value.length > 20)
		{
			alert("密码长度应在5-20个字符之间！");
			$("password").focus();
			return false;
		};
		if($("password2").value!=$("password").value)
		{
			alert("确认密码与密码不一致！");
			$("password2").focus();
			return false;
		}
	};
	if($("company").value.length<3||$("company").value.length>60)
	{
		alert("请正确填写公司的名称！");
		$("company").focus();
		return false;
	};
	if($("adress").value.length<6||$("adress").value.length>60)
	{
		alert("请正确填写公司地址！");
		$("adress").focus();
		return false;
	};
	if($("mail").value.length>0)
	{
		if ($("mail").value.charAt(0)=="." || $("mail").value.charAt(0)=="@"|| $("mail").value.indexOf('@', 0) == -1 || $("mail").value.indexOf('.', 0) == -1 || $("mail").value.lastIndexOf("@")==$("mail").value.length-1 || $("mail").value.lastIndexOf(".")==$("mail").value.length-1)
		{
			alert("Email地址格式不正确！");
			$("mail").focus();
			return false;
		}
	}
	else
	{
		alert("Email不能为空！");
		$("mail").focus();
		return false;
	};
	if($("tel").value.length<3||$("tel").value.length>20)
	{
		alert("请正确输入您的联系电话，便于我们与您联系！");
		$("tel").focus();
		return false;
	};
	if($("fax").value.length<3||$("fax").value.length>20)
	{
		alert("请正确输入您的传真，便于我们与您联系！");
		$("fax").focus();
		return false;
	};
	if($("liuyan").value.length==0)
	{
		alert("请输入您的留言内容！");
		$("liuyan").focus();
		return false;
	};
	return true;
}