var mail_list_focused = false;

$(document).ready(function(){
	$("#email").focus(
			function(e){
				   if(!mail_list_focused){
					   $(this).val('');
					   mail_list_focused = true;
				   }
			});
});

function isValidEmail(email){
    var RegExp = /^((([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+(\.([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+)*)@((((([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.))*([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.)[\w]{2,4}|(((([0-9]){1,3}\.){3}([0-9]){1,3}))|(\[((([0-9]){1,3}\.){3}([0-9]){1,3})\])))$/
    if(RegExp.test(email)){
        return true;
    }else{
        return false;
    }
}

/*
$(document).ready(function(){
	$("#frmCreateAccount").ajaxSubmit();
});
*/
$.fn.ajaxSubmit = function(e) {
	/* Change a form's submission type to ajax */
	this.submit(function(){
		var params = {};
		$(this)
		.find("input[@checked], input[@type='text'], input[@type='hidden'], input[@type='password'], input[@type='submit'], option[@selected], textarea")
		.filter(":enabled")
		.each(function() {
			params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value;
		});
		$("body").addClass("curWait");
		$("#loadingEmail").show();
		
		$.post(this.getAttribute("action") + "?call=ajax", params, function(xml){
			$("body").removeClass("curWait");
			$("#loadingEmail").fadeOut();
			alertMsg = "";
			data = "";
			$("AjaxResponse", xml).each(function() {
				alertMsg = this.getAttribute("alertMsg");
				data = this.getAttribute("data");
			});
			if(data.length > 0) {
				$("#ajaxData").html(data);
			}
			else if(alertMsg.length > 0){
				alert(alertMsg);
			}
			else {
				alert("Beklenmeyen bir hata oluştu, lütfen daha sonra tekrar deneyiniz.");
			}
		});
		return false;
	});
	
	return this;
}

