	function checkValue(){
		theForm = document.getElementById('forwardform');
		if(!CheckMail(theForm.target_email.value)){
			alert('請輸入正確的朋友email');	
			return false;
		}	
		
		if(theForm.my_name.value.length < 2){
			alert('請輸入您正確的姓名');	
			return false;
		}
		
		if(!CheckMail(theForm.my_email.value)){
			alert('請輸入您正確的email');	
			return false;
		}
		
		if(theForm.mcode.value==""){
        	alert("驗證碼不可空白，請輸入驗證碼");	
			return false;
        }
		
		
		//theForm.submit();
		//獲取接受返回資訊層
		var msg = document.getElementById("errorMessage");
		//獲取表單物件和使用者資訊值
		var f = document.forwardform;
		var chid = f.chid.value;
		var title = f.title.value;
		var url = f.url.value;
		var from = f.from.value;
		var target_email = f.target_email.value;
		var my_name = f.my_name.value;
		var my_email = f.my_email.value;
		var comment = f.comment.value;
		var mcode = f.mcode.value;
		//需要POST的值，把每個變數都透過&來聯接
		var postStr = "chid="+ chid +"&title="+ title +"&url="+ url +"&from="+ from +"&target_email="+ target_email +"&my_name="+ my_name +"&my_email="+ my_email +"&comment="+ comment +"&mcode="+ mcode;
		
		$.ajax({
		url: '/dobby/mailer', 
		type: 'post', 
		data: postStr,
		success: function(d, s) {
			switch(d) {
				case 'y':
					alert('已成功寄出郵件！');		
					window.close();
					break;
				case 'n':
					alert('驗證碼錯誤！');	
					break;
				default:
					alert(d);				
			}
		}
	});

		
	}
	
function CheckMail(email) {
	//var rege = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9])+$/;
	var rege = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   
	if (email.length == 0 || rege.exec(email) == null) {
		return false;
	}else{
		return true;
	}
}

function articleForward(c,t,p,u,event) {  

	var top = ( event.screenY + 60);
	var left = ( screen.width - 509 ) / 2;
	var height = 400; //568;
	var tools = "toolbar=no,location=no,height="+ height +",width=509,top="+top+",left="+left ;	
	window.open("/dobby/mailer?chid="+c+"&title="+encodeURI(t)+"&pos="+p+"&u="+u,"forward", tools );        
}

function reloadAntiRobot() 	{
	var nocache = new Date();
	$('#antiRobot').attr('src','/AntiRobot/getImage?'+ nocache.getTime() );
}

