function setBpoMail(){
	SkipByPost("setMail.do");
	
	/*$.ajax({
		type: "post",  
		url : "setMail.do", 
		
		success:function(data){
			$("#mailto").val(data.mailto);
			$("#mailcc").val(data.mailcc);
			$("#mailsubject").val(data.mailsubject);
			$("#mailcontent").val(data.mailcontent);
			$("#mailsignature").val(data.mailsignature);
		},
		error:function(){
			alert("sorry!");
		}
		
		
	});*/
}

function saveBpoMail(){
	var strs= new Array();
	var array = new Array();
	var str = "";
	var arr = null;
	var mailto = $("#mailto").val();
	var mailcc = $("#mailcc").val();
	var mailsubject = $("#mailsubject").val();
	var mailcontent = $("#mailcontent").val();
	var mailsignature = $("#mailsignature").val();
	var objid = $("#objid").val();
	
	
	
	if(mailto!=""){
		if(mailto.indexOf(";")==0){
			mailto +=';';
		}else if(mailto.indexOf(";")>0 && mailto.substring(mailto.length-1,mailto.length)==";" ){
			mailto = mailto.substring(0,mailto.length-1);
		}
		
		
		strs = mailto.split(";");
		

			for (var i=0;i<strs.length ;i++ ) 
			{ 
				str = strs[i]; 
			} 
			if(!checkEmail(str)){//判断发送人邮箱格式
				return;
			}
			
		
		
	}else{
		alert("请输入收件人邮箱！");
		return false;
	}
	
	
	
	if(mailcc!=""){
		
		if(mailcc.indexOf(";")==0){
			mailcc +=';';
		}else if(mailcc.indexOf(";")>0 && mailcc.substring(mailcc.length-1,mailcc.length)==";" ){
			mailcc = mailcc.substring(0,mailcc.length-1);
		}
		
		array = mailcc.split(";");
		for (var i=0;i<array.length ;i++ ) 
		{ 
			arr = array[i]; 
		} 
			if(!checkEmail(arr)){//判断发送人邮箱格式
				return;
			}
		
	}
	
	
	
	if(mailsubject.length>50){//主题必须小于50字
		alert("邮件主题必须小于50字，请重新输入！");
		return false;
	}
	
	
	
	$.ajax({
		type: "post",  
		url : "saveBpoMail.do", 
		data:{"mailto":mailto,"mailcc":mailcc,"mailsubject":mailsubject,"mailcontent":mailcontent,"mailsignature":mailsignature,"objid":objid},
		
		success:function(data){
		alert("保存成功！");
		},
		error:function(){  
			alert("保存失败!");
		}
		
		
	});
}



function checkEmail(str){
   var re = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/ ;
   if(!re.test(str)){
       alert("邮箱格式输入错误，请重新输入！");
       return false;
   }else{
	   return true;
   }
}