// JavaScript Document
var server = window.location.hostname;
$(document).ready(function() {

	$("#sended").click( function() {

	var mail = $("#mail").val();
	var query = $("#query").val();
	
	$.post("http://"+server+"/subscribe.php", { email: mail, q: query},
   function(datos){
		if (datos == 'n'){
			$("#mess").remove();
			$("#okke").append('<div id="mess"><h2>Invalid E-mail!</h2><p>Please insert a valid mail!</p></div>');
		}
		else if(datos == 'y'){
		$("#messil").remove();
		$("#comm").append('<h2>Suscribed!</h2><p>You will receive periodically news and selected offers!</p>');
		}   
      });
		
	});
	
});

