		function sendmail_submit(obj){
			temp=document.sendmail.from.value;
			if(document.sendmail.Subject.value.length==0)
				{
					alert("主题不能为空！");
					document.sendmail.Subject.focus();
					return false;
				}
			if ((temp.indexOf("@")==-1) || (temp.indexOf("@")!=temp.lastIndexOf("@")) || temp.indexOf("@")==temp.length-1)
				{
					alert("您的Email地址不正确，请到个人资料里修改！");
					//document.sendmail.from.focus();
					return false;
				}
			var count;
   			count=document.sendmail.sendmail.length;
   			if (count==0)
   				{
   					alert("您没有选择给谁发信！");
   					return false;   			
   				}
			if(document.sendmail.Content.value.length==0)
				{
					alert("Email正文不能为空！");
					document.sendmail.Content.focus();
					return false;
				}
			for (i=0;i<count;i++)
				{
					document.sendmail.sendmail[i].selected=true;
				}

				document.sendmail.submit.disabled=true

				//initAd();
		}

		function selectall(){
			var sendcount,allcount;
			var optmail;
			sendcount=document.sendmail.sendmail.length;
			for(i=0;i<sendcount;i++)
				{
					document.sendmail.sendmail.remove(0);
				}
			allcount=document.sendmail.allmail.length;		
			for(i=0;i<allcount;i++)
				{
	   				optmail=document.createElement("option");
					optmail.text=document.sendmail.allmail[i].text;
					optmail.value=document.sendmail.allmail[i].value;
					document.sendmail.sendmail.add(optmail);
				}
			for(i=0;i<allcount;i++){
				if(document.sendmail.allmail[i].selected==true){
				document.sendmail.allmail[i].selected=false;
				}
			}
		}

		function addmail(){
			var allcount,sendcount,flag1,flag2;
			var optmail;
			allcount=document.sendmail.allmail.length;
			sendcount=document.sendmail.sendmail.length;
   			flag1=0;
   			flag2=0;
			for(i=0;i<allcount;i++){
				if(document.sendmail.allmail[i].selected==true){
					document.sendmail.allmail[i].selected=false;
					for(j=0;j<sendcount;j++){
						if(document.sendmail.allmail[i].value==document.sendmail.sendmail[j].value)
							{
								alert("您选择的Email已经存在了！");
								flag1=1;
							}
					}
				if(flag1==0)
					{
						flag2=1;
						optmail=document.createElement("option");
						optmail.text=document.sendmail.allmail[i].text;
						optmail.value=document.sendmail.allmail[i].value;
						document.sendmail.sendmail.add(optmail);
					}
				}
				if(flag1==1)break;
			}
			if(flag2==0){
				if (flag1==0)
					{
						alert("请选择要添加的Email！")
					}
			}	
		}

		function delmail(){
			var sendcount,flag,delcount;
			var optmail;
			flag=0;
			delcount=0;
			sendcount=document.sendmail.sendmail.length;
			for(i=0;i<sendcount;i++){
				if(document.sendmail.sendmail[i].selected==true){
					flag=1;
					for(j=i;j>0;j--)
						{
							document.sendmail.sendmail[j].value=document.sendmail.sendmail[j-1].value;
							document.sendmail.sendmail[j].text=document.sendmail.sendmail[j-1].text;
						}
					delcount=delcount+1;				
				}			
			}
			if (flag==0)
				{
					alert("请选择要删除的Email！");
				}
			for(i=0;i<delcount;i++)
				{
					document.sendmail.sendmail.remove(0);
				}
			for(i=0;i<document.sendmail.sendmail.length;i++)
				{
					document.sendmail.sendmail[i].selected=false;
				}
		}

		function delall(){
			var sendcount;
			var optmail;
			sendcount=document.sendmail.sendmail.length;
			if (sendcount==0)
				{
					alert("没有可以删除的Email！");
				}
			for(i=0;i<sendcount;i++)
				{
					document.sendmail.sendmail.remove(0);
				}
		}
