
	var username =''; var usermail='';
	var country =''; var province='';
	var sex ='2'; var degree='';
	var occupation =''; var animals='';
	var star =''; var blood='';
	var belief =''; var idcard='';
	var phone =''; var address='';
	var age ='';
	
	function Trim(str)
	{
		if(str.charAt(0)==' ')
		{
			str=str.slice(1);
			str=Trim(str);
		}
		return str;
	}

	function viewChart()
	{
		window.open('http://view.sznews.com/nis/vote/admin/survey/multipiechart.jsp?surveyid=801','_blank','width=600,height=800,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=yes');
	}

	function resetSurvey801()
	{
		document.frmSurvey801.reset();
	}

	function viewSurveyResult801()
	{
		window.open('http://view.sznews.com/nis/vote/temp/surveyresult/vote801_result.htm','_blank','width=600,height=800,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=yes');
	}

	function checkSubmit801()
	{
		if(document.frmSurvey801.enp_username) 
		{
			username = document.frmSurvey801.enp_username.value;
			if(username == '' ||Trim(username)==''|| username.lenght > 20)
			{
				alert('用户名不能为空或过长！');
				return false;
			}
		}
		 if(document.frmSurvey801.enp_usermail) 
		{
			usermail = document.frmSurvey801.enp_usermail.value;
			if(usermail == '' ||Trim(usermail)==''|| usermail.lenght > 50)
			{
				alert('邮件地址不能为空或过长！');
				return false;
			}
		}
	 if(document.frmSurvey801.enp_age) 
		{
			age = document.frmSurvey801.enp_age.value;
			if (!/^[0-9]\d*$/.test(age))
			{
				alert('年龄只能为正整数！');
				return false;
			}
		}
	}

	function checksurveyMaxAnswers()
	{
		if(document.all("surveyMaxAnswers"))
		{
			var surveyMaxAnswers = document.all("surveyMaxAnswers").value ;
			var counts = 0 ;
			var items = document.all("items").value ;
			items = items.substring(0,items.lastIndexOf(','));
			var itemslist = items.split(',');
			

			for(i=0;i<itemslist.length;i++)
			{
				var obj =document.all(itemslist[i]) ;
				var len = obj.length ;
				if(len == null)
				{
					if(obj.tagName=="INPUT")
					{
						if(obj.type=="radio" || obj.type=="checkbox")
						{
		
							if(obj.checked)
							{
								counts = counts + 1 ;
							}
						}
					}
					else if(obj.tagName=="TEXTAREA")
					{
						if(Trim(obj.value)!='')
						{
							counts = counts + 1 ;
						}
					}
					else if(obj.tagName=="SELECT")
					{
						if(Trim(obj.value)!='')
						{
							counts = counts + 1 ;
						}
					}
				}
				else
				{
						if(obj[0].tagName=="INPUT")
						{
							if(obj[0].type=="radio" || obj[0].type=="checkbox")
							{
								for (j = 0; j < len; j++)
								{
									if (obj[j].checked)
									{
										counts = counts + 1 ;
										break;
									}
								}
							}
						}
						else if(obj.tagName=="SELECT")
						{
							if(Trim(obj.value)!='')
							{
								counts = counts + 1 ;
							}
						}
					}
				}
			if(counts<=surveyMaxAnswers)
			{
				return true ;
			}
			else
			{
				alert("您回答的问题超出最大答题数" + surveyMaxAnswers + ",请重新填写！") ;
				return  false ;
			}
		}
		return true ;
	}

	function checkitemMaxAnswers()
	{
		if(document.all("mulitItems"))
		{
			var mulitItems = document.all("mulitItems").value ;
			mulitItems = mulitItems.substring(0,mulitItems.lastIndexOf(','));
			var mulitItemlist = mulitItems.split(',');
			for(var i=0;i<mulitItemlist.length;i++)
			{
				var counts = 0 ;
				var itemid = mulitItemlist[i].substring(0,mulitItemlist[i].lastIndexOf('_'));
				var maxanswers =  mulitItemlist[i].substring(mulitItemlist[i].lastIndexOf('_')+1);
				var obj =document.all(itemid) ;
				var len = obj.length ;
				for (var j = 0; j < len; j++)
				{
					if (obj[j].checked)
					{
						counts = counts + 1 ;
					}
				}
				if(counts<=maxanswers)
				{
					continue ;
				}
				else
				{
					alert("您填写的某个多项选择题超出最大答题数") ;
				return false ;
				}
			}
		}
		return true ;
	}
				
	function submitSurvey801()
	{
		
		alert("网上投票已结束,谢谢您的参与") ;
		window.open('http://view.sznews.com/nis/vote/temp/surveyresult/vote801_result.htm','_blank','width=600,height=800,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=yes');
	}
