var jQ = jQuery.noConflict();

function nothing() {
	return true;
}

jQ(document).ready(function(){
	
	var error = false;
	var emailuniquefail = false;
	
		
	/*jQ('input[name=email]').blur(function () {
		jQ.ajax({
	 		 type: "GET",
	  		 url: "http://www.marketingszoftverek.hu/api/check-email-uniqueness-json.php",
	  		 data: "mssys_formid=wp7l3HEQ4D4xzaAic7dVuiMFeb77&email=" + jQ(this).val(),
	  		 cache: false,
	  		 dataType: "jsonp",
	  		 jsonp: 'jsonp_callback',
	  		 async: false,
	  		 success: function(msg){
			     if (msg.response == '1') {
			     	alert('Ezzel az e-mail címmel már feliratkozott korábban!');		     	
			     	emailuniquefail = true;
			     } else {		     	
			     	emailuniquefail = false;
			     }
	   		}
		});
	});*/
	
	// validate form in header
	jQ("#mssysform7199_1 input[type=button]").click(function(){
		
		var thisId = "#mssysform7199_1";
		var ajaxVar = 0;
		error = false;
		
		jQ.ajax({
	 		type: "GET",
	  		url: "http://www.marketingszoftverek.hu/api/check-email-uniqueness-json.php",
	  		data: "mssys_formid=wp7l3HEQ4D4xzaAic7dVuiMFeb77&email=" + jQ(thisId+' input[name=email]').val(),
	  		cache: false,
	  		dataType: "jsonp",
	  		jsonp: 'jsonp_callback',
	  		async: false,
	  		success: function(msg){
			 	if (msg.response == '1') {
			     		alert('Ezzel az e-mail címmel már feliratkozott korábban!');		     	
			     		emailuniquefail = true;
			     		error = true;
			     		ajaxVar = 1;
			     	} else {		     	
			     		emailuniquefail = false;
			     		ajaxVar = 1;
			     		if (!checkMail(jQ(thisId+' input[name=email]').val())) {
						alert('Hibás e-mail cím');
						error = true;
					}		
							
					if (jQ(thisId+" input[name=mssys_firstname]").val() == '') {
						alert('Kérjük, adja meg a keresztnevét!')
						error = true;
					}
							
					if (error) {
						return false;
					} else {
						// submit form
						jQ(thisId).submit();
					}
			 	}
			}
	   	});
					
	});
	
	// validate form on front page (post 9)
	jQ("#mssysform7199_2 input[type=button]").click(function(){
		
		var thisId = "#mssysform7199_2";
		var ajaxVar = 0;
		error = false;
		
		jQ.ajax({
	 		type: "GET",
	  		url: "http://www.marketingszoftverek.hu/api/check-email-uniqueness-json.php",
	  		data: "mssys_formid=wp7l3HEQ4D4xzaAic7dVuiMFeb77&email=" + jQ(thisId+' input[name=email]').val(),
	  		cache: false,
	  		dataType: "jsonp",
	  		jsonp: 'jsonp_callback',
	  		async: false,
	  		success: function(msg){
			 	if (msg.response == '1') {
			     		alert('Ezzel az e-mail címmel már feliratkozott korábban!');		     	
			     		emailuniquefail = true;
			     		error = true;
			     		ajaxVar = 1;
			     	} else {		     	
			     		emailuniquefail = false;
			     		ajaxVar = 1;
			     		if (!checkMail(jQ(thisId+' input[name=email]').val())) {
						alert('Hibás e-mail cím');
						error = true;
					}		
							
					if (jQ(thisId+" input[name=mssys_firstname]").val() == '') {
						alert('Kérjük, adja meg a keresztnevét!')
						error = true;
					}
							
					if (error) {
						return false;
					} else {
						// submit form
						jQ(thisId).submit();
					}
			 	}
			}
	   	});
					
	});
	
	// validate form on "/barath-andras" (post 11)
	jQ("#mssysform7199_3 input[type=button]").click(function(){
		
		var thisId = "#mssysform7199_3";
		var ajaxVar = 0;
		error = false;
		
		jQ.ajax({
	 		type: "GET",
	  		url: "http://www.marketingszoftverek.hu/api/check-email-uniqueness-json.php",
	  		data: "mssys_formid=wp7l3HEQ4D4xzaAic7dVuiMFeb77&email=" + jQ(thisId+' input[name=email]').val(),
	  		cache: false,
	  		dataType: "jsonp",
	  		jsonp: 'jsonp_callback',
	  		async: false,
	  		success: function(msg){
			 	if (msg.response == '1') {
			     		alert('Ezzel az e-mail címmel már feliratkozott korábban!');		     	
			     		emailuniquefail = true;
			     		error = true;
			     		ajaxVar = 1;
			     	} else {		     	
			     		emailuniquefail = false;
			     		ajaxVar = 1;
			     		if (!checkMail(jQ(thisId+' input[name=email]').val())) {
						alert('Hibás e-mail cím');
						error = true;
					}		
							
					if (jQ(thisId+" input[name=mssys_firstname]").val() == '') {
						alert('Kérjük, adja meg a keresztnevét!')
						error = true;
					}
							
					if (error) {
						return false;
					} else {
						// submit form
						jQ(thisId).submit();
					}
			 	}
			}
	   	});
					
	});
	

	// validate form on "/blog/..." (imi form)
	jQ("#mssysform7199_4 input[type=button]").click(function(){
		
		var thisId = "#mssysform7199_4";
		var ajaxVar = 0;
		error = false;
		
		jQ.ajax({
	 		type: "GET",
	  		url: "http://www.marketingszoftverek.hu/api/check-email-uniqueness-json.php",
	  		data: "mssys_formid=wp7l3HEQ4D4xzaAic7dVuiMFeb77&email=" + jQ(thisId+' input[name=email]').val(),
	  		cache: false,
	  		dataType: "jsonp",
	  		jsonp: 'jsonp_callback',
	  		async: false,
	  		success: function(msg){
			 	if (msg.response == '1') {
			     		alert('Ezzel az e-mail címmel már feliratkozott korábban!');		     	
			     		emailuniquefail = true;
			     		error = true;
			     		ajaxVar = 1;
			     	} else {
			     		emailuniquefail = false;
			     		ajaxVar = 1;
			     		if (!checkMail(jQ(thisId+' input[name=email]').val())) {
						alert('Hibás e-mail cím');
						error = true;
					}
							
					if (jQ(thisId+" input[name=mssys_firstname]").val() == '') {
						alert('Kérjük, adja meg a keresztnevét!')
						error = true;
					}
							
					if (error) {
						return false;
					} else {
						// submit form
						jQ(thisId).submit();
					}
			 	}
			}
	   	});
					
	});
});


	
