var url_domain = "http://www.edzesonline.hu";

function sendContent() {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.sendcontent.email.value)) {
		new Ajax.Request('/ajax/send_article_process.php', 
		{   
			method: 'post',
			parameters: $('sendcontent').serialize(true)   ,
	    	onSuccess: function(transport){       
	    		var response = transport.responseText || "no response text";
	    		valid.deactivate();
	    	},     
	    	onFailure: function(){ alert('Hiba a levélküldés közben') } 		
		}); 
	} else {
		alert("Érvénytelen a címzett e-mail cím formátuma! Javítsd ki légy szíves!")
		return (false)
	}
}

function copyEvent() {
	var ndyear = $F("newdate").substring(0,4);
	var ndmonth = $F("newdate").substring(5,7);	    		
	var location_url = url_domain + "/index.php?page_id=42&action=search&search_year=" + ndyear + "&search_month=" + ndmonth;
	new Ajax.Request('/ajax/copy_event_process.php', 
	{   
		method: 'post',
		parameters: $('copyevent').serialize(true),
    	onSuccess: function(transport){       
    		var response = transport.responseText || "no response text";
			var respjson = response.evalJSON();
			if (respjson.error_code == 0) {
	    		valid.deactivate();
	    		window.location = location_url;
			} else if (respjson.error_code == 1) {
	    		alert("Érvénytelen dátum formátum");
			} else if (respjson.error_code == 2) {
	    		alert("Adatbázis hiba");
	    	}
    	},     
    	onFailure: function(){ alert('Hiba az eseménymásolás közben') } 		
	}); 
}
