function setDiv(divID){
	Div_load();
	eval("member"+ divID + ".style.display='block'");
	eval("tdMenu"+ divID + ".className='sty_menu_td'");
	if(divID == "2")
	{
		start2();
	}
	if(divID == "3")
	{
		start3();
	}
	if(divID == "4")
	{
		start4();
	}
}

function Div_load()
{
	member1.style.display = 'none';	
	member2.style.display = 'none';	
	member3.style.display = 'none';	
	member4.style.display = 'none';	
	tdMenu1.className='';
	tdMenu2.className='';
	tdMenu3.className='';
	tdMenu4.className='';

}

function setReview(id)
{
	var ReviewValue,ObjTd;
	ReviewValue = eval("document.all."+id+".innerHTML;");
	if(ReviewValue.substring(0,5)=="<TEXT")
	{
		return false;
	}
	ObjTd = document.all(id);
	HtmlStr = "<textarea name='sReview' id='sReview' class='Diy_Scrollbar' style='width:98%;height:80px;overflow:auto;border:1px solid cccccc;'>"+ ReviewValue.substr(3) +"</textarea>";
	HtmlStr = HtmlStr + "<input type='submit' name='Submit' value='保存' />"
	ObjTd.innerHTML = HtmlStr;
	
}

function checkReview(){
	if(form1.sContent.value == "")
	{
		alert("评论不可为空！");
		return false;
	}
	else
	{
		return true;
	}
}

function checkComment()
{
	if((loveComments.sTitle.value == "")||(loveComments.sContent.value==""))	
	{
		alert("标题与内容为填！");
		return false;
	}
	else
	{
		return true;
	}
}
//├电子邮件验证
String.prototype.isEmail = function(){
	var tmpStr = this;
	var email = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	return email.test(tmpStr)
}
//├http地址验证
String.prototype.isUrl = function(){
	var url = /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/;
	var tmpStr = this;
	return url.test(tmpStr);
}

var vform = new Object;
//获取弹出提示的显示位置
vform.getAbsolutePos = function(el) {
	var _p = { x: 0, y: 0 };
	 do{
				_p.x += (el.offsetLeft - el.scrollLeft);
				_p.y += (el.offsetTop - el.scrollTop); 
		}
		 while(el=el.offsetParent)
     return _p;
      };
vform.rules = new Array;
vform.rules.add = function(obj,minLength,dataType,errmsg,maxLength,rule,patams)
{
    var curlen = this.length;
        this[curlen] = [obj,minLength,dataType,errmsg,maxLength,rule,patams];
        //this[curlen] = [ 0 ,    1    ,    2   ,   3  ,   4  ,  5 ,   6  ];

    return this.length;
}
vform.init= function()
{
	if(document.getElementById(this.form_id))
	{
		//获取表单
		var o = document.getElementById(this.form_id);
		//遍历规则
		for(var i = 0 ;i< this.rules.length;i++)
		{
			_r = this.rules[i]
			//如果存在元素，则添加验证程序
			if(_o = o.elements[_r[0]])
			{
				//判断是是否必填,是否有最小长度
				if(_r[1] > 0 )
				{
					_o.required = true;//必填的含义和最小长度为1是一样的
					_o.minLength = parseInt(_r[1]);
				}
				else
				{
					_o.required = false;
					_o.minLength = 0;
				}
				//判断是否有最大长度;
				if(_r[4])
				{
					_o.maxLength = parseInt(_r[4]);
				}
				//添加长度验证函数
				_o.validLength = function ()
				{
					var b =true;
					if(this.minLength)
					{
						b = (this.minLength <= this.value.length);
					}
					if(this.type == 'textarea' && this.maxLength )
					{
						b = b && (this.maxLength >= this.value.length );
					}
					return (b);
				}
				//添加验证，进行格式验证
				switch(_r[2])
				{
					case 'e-mail':
						_o.validate = function()
						{
							this.isvalid = this.validLength() && this.value.isEmail();
							return (this.isvalid);
						};
						break;
					case 'url':
						_o.validate = function()
						{
							if (this.value.substring(0,7) != 'http://')this.value = 'http://' +this.value;
							this.isvalid = this.validLength() && this.value.isUrl();
							return (this.isvalid);
						}
						break;
					case 'date':
						_o.validate = function()
						{
							var _d = Date.parse(this.value)||Date.parseDate(this.value);
							this.value =  _d.toIsoDate();
							
							this.isvalid = this.validLength() && this.value.isDateTime();
							return (this.isvalid);
							a=a>b?1:1;
						}
						break;
					case 'number':
						_o.validate = function()
						{
							this.isvalid = this.validLength() && this.value.isInteger();
							return (this.isvalid);

						}
						break;
					case 'any':
						_o.validate = function()
						{
							this.isvalid = this.validLength();
							return  this.isvalid
						}
						break;
					default :
						var regexp = /^\\\w+$/;
						if ( regexp.test(_r[2]))//表示必须和同表单下的某个字段的值一样。用于重复输入的验证
						{
							_el = _r[2].substring(1);
							if (o.elements[_el]){
								_o.equal = _el;
								_o.validate = function()
								{
									if(_o = this.form.elements[this.equal])
									{
										if ( (_o.value == this.value) && this.validLength())
										{
											return true;
										}else {
										return false;
										}
									}else{
										alert('setup error');
									}
								
								}
							}else
							{
								alert(_el + 'is not a valid form element');
								_o.validate = function(){return true;}
							}
						}
						var regexp1 = /^\\(==|!=|>=|<=|>|<)/;
						if ( regexp1.test(_r[2]) )
						{
							_s0 = _r[2];
							_s1 = RegExp.$1;
							_s2 = _s0.replace(regexp1,'');
							_operator = _s1.substring(0);//比较操作符
							var regexp2 = /^\w+$/;
							if (regexp2.test(_s2))//是一个标志符，整数 或者变量
							{
								_o.operation = _operator+_s2;
								_o.validate = function()
								{
									_b = true;
									if (this.value.length !=0)
									{
										_b = eval(this.value+this.operation+';');
									}									
									_b = _b && this.validLength();
									return _b;
								}
							}
						};
						break;
						
				}
				//添加验证提示(div标签)并初始化
				var _p = vform.getAbsolutePos(_o);
				_o.tip = new tip(_r[3],vform.err_class,_p.x+_o.offsetWidth+3,_p.y);

				_o.tip.init();
				//失去焦点时，开始验证
				_o.onblur =function(e)
				{
					if(this.minLength || this.value.length >0) 
					{ 
						if( this.validate() )
						{
							this.tip.hide();
						}else
						{
							this.tip.show();//显示错误信息
							//this.focus(); 添加这句在ie里会导致死循环 :(
							return false;
						}
					}
				}
			}
		}
	//焦点验证可能会失败,所以最后需要表单提交前的验证作为最后的补充。
		document.getElementById(this.form_id).onsubmit = function()
		{
			var valid = true;
			for(i=0;i<this.elements.length;i++)
			{
				_o = this.elements[i];
				if(_o.minLength && !_o.validate())
				{
					_o.tip.show();
					valid = false;
				}
			}
			return valid;
		}
	}
}
//弹出提示定义
function tip(text,className,x,y)
{
	var o = document.createElement("div");
	o.style.display = "none";
	o.innerHTML = text;
	//var t = document.createTextNode(text);
	document.body.appendChild(o);
	//o.appendChild(t);
	
	this.init = function(dis)
	{
		o.className = className;
		o.style.left = x+"px";
		o.style.top = y+"px";
		o.style.zindex = 100;
		if(dis)
		{
			o.style.display = "";
		}
		else
		{
			o.style.display = "none";
		}
	}
	this.show = function()
	{
		o.style.display = "";
	}
	this.hide = function()
	{
		o.style.display = "none";
	}
}


function start()
{
	vform.form_id = 'FileUpLoad1';//必须是表单的id
	vform.err_class = 'info';//出错提示的样式
	//验证规则，逐条填写
		with(vform.rules)
		{
			add('sUsername',6,'any','用户名必须至少填写6个<br /><span style="color:#f00">必填项目</span>');
			add('sIncname',5,'any','单位名称至少填写5个字符<br /><span style="color:#f00">必填项目</span>');
			add('sIncShort',2,'any','单位简称至少填写2个字符<br /><span style="color:#f00">必填项目</span>');
			//add('sEmail',1,'e-mail','请您按照 user@domain.com 的格式输入电子邮件地址。<br /><span style="color:#f00">必填项目</span>');
			add('sUrl',1,'url','请您按照 http://www.domain.com 的格式输入您的网址。<br /><span style="color:#f00">必填项目</span>');
			add('sPwd',5,'any','密码最短5位最长20位<br /><span style="color:#f00">必填项目</span>',20);
			add('sPwd2',5,"\\sPwd",'确认密码错误<br /><span style="color:#f00">必填项目</span>',20);
			//add('sLinkMan',2,'any','联系人至少填写2个字符<br /><span style="color:#f00">必填项目</span>');
			add('sLinkTime',3,'any','何时方便联系至少填写3个字符<br /><span style="color:#f00">必填项目</span>');
		}
		with(vform)
		{
			init();
		}
	
}

function start2()
{
	vform.form_id = 'FileUpLoad2';//必须是表单的id
	vform.err_class = 'info';//出错提示的样式
	//验证规则，逐条填写
		with(vform.rules)
		{
			add('sUsername',6,'any','用户名必须至少填写6个<br /><span style="color:#f00">必填项目</span>');
			add('sSectname',5,'any','科室名称至少填写5个字符<br /><span style="color:#f00">必填项目</span>');
			add('sExperttime',2,'any','核心专家至少填写2个字符<br /><span style="color:#f00">必填项目</span>');
			//add('sSpeciality',2,'any','专长至少填写2个字符<br /><span style="color:#f00">必填项目</span>');
			//add('sMail',1,'e-mail','请您按照 user@domain.com 的格式输入电子邮件地址。<br /><span style="color:#f00">必填项目</span>');
			add('sUrl',1,'url','请您按照 http://www.domain.com 的格式输入您的网址。<br /><span style="color:#f00">必填项目</span>');
			add('sPwd',5,'any','密码最短5位最长20位<br /><span style="color:#f00">必填项目</span>',20);
			add('sPwd2',5,"\\sPwd",'确认密码错误<br /><span style="color:#f00">必填项目</span>',20);
			//add('sLinkMan',2,'any','联系人至少填写2个字符<br /><span style="color:#f00">必填项目</span>');
			add('sLinkTime',3,'any','何时方便联系至少填写3个字符<br /><span style="color:#f00">必填项目</span>');
		}
		with(vform)
		{
			init();
		}
	
}

function start3()
{
	vform.form_id = 'FileUpLoad3';//必须是表单的id
	vform.err_class = 'info';//出错提示的样式
	//验证规则，逐条填写
		with(vform.rules)
		{
			add('sUsername',6,'any','用户名必须至少填写6个<br /><span style="color:#f00">必填项目</span>');
			add('sName',2,'any','姓名至少填写2个字符<br /><span style="color:#f00">必填项目</span>');
			//add('sWorktime',4,'any','门诊时间至少填写4个字符<br /><span style="color:#f00">必填项目</span>');
			//add('sSpeciality',2,'any','专长至少填写2个字符<br /><span style="color:#f00">必填项目</span>');
			//add('sMail',1,'e-mail','请您按照 user@domain.com 的格式输入电子邮件地址。<br /><span style="color:#f00">必填项目</span>');
			add('sUrl',1,'url','请您按照 http://www.domain.com 的格式输入您的网址。<br /><span style="color:#f00">必填项目</span>');
			add('sPwd',5,'any','密码最短5位最长20位<br /><span style="color:#f00">必填项目</span>',20);
			add('sPwd2',5,"\\sPwd",'确认密码错误<br /><span style="color:#f00">必填项目</span>',20);
			add('sLinkTime',3,'any','何时方便联系至少填写3个字符<br /><span style="color:#f00">必填项目</span>');
		}
		with(vform)
		{
			init();
		}
	
}

function start4()
{
	vform.form_id = 'form4';//必须是表单的id
	vform.err_class = 'info';//出错提示的样式
	//验证规则，逐条填写
		with(vform.rules)
		{
			add('sUsername',6,'any','用户名必须至少填写6个<br /><span style="color:#f00">必填项目</span>');
			add('sName',2,'any','姓名至少填写2个字符<br /><span style="color:#f00">必填项目</span>');
			//add('sMail',1,'e-mail','请您按照 user@domain.com 的格式输入电子邮件地址。<br /><span style="color:#f00">必填项目</span>');
			add('sUrl',1,'url','请您按照 http://www.domain.com 的格式输入您的网址。<br /><span style="color:#f00">必填项目</span>');
			add('sPwd',5,'any','密码最短5位最长20位<br /><span style="color:#f00">必填项目</span>',20);
			add('sPwd2',5,"\\sPwd",'确认密码错误<br /><span style="color:#f00">必填项目</span>',20);
			add('sLinkTime',3,'any','何时方便联系至少填写3个字符<br /><span style="color:#f00">必填项目</span>');
		}
		with(vform)
		{
			init();
		}
	
}

function EnterSearch()
{
	if(SiteSearch.KeyWord.value == "")
	{
		alert("关键字不可为空！");
		SiteSearch.KeyWord.focus();
	}
	else
	{
		SiteSearch.submit();
	}
}