
function loading()
{
	//We change submit image to sending gif
	document.getElementById("imgbutton").src = "img/sending.gif";
	document.getElementById("linksubmit").blur();
	//We block the imputs
	document.getElementById("cinema").disabled = true;
	document.getElementById("name").disabled = true;
	document.getElementById("email").disabled = true;
}

function sendData()
{ 
	var cinema = document.getElementById("cinema").options[document.getElementById("cinema").selectedIndex].value;
	var name = document.getElementById("name").value;
	var email = document.getElementById("email").value;
	
	//Check if they're empty
	if(name.length == 0 || email.length == 0)
	{
		showErrors("error","Fields error");
	}
	else
	{
		if(!validateEmail(email))
		{
			showErrors("error","Mail error");
		}
		else
		{
			loading();
			var aleatorio=Math.random();
			var sendRequest = new Request({
		     method: 'get',
		     url: 'sendData.php?name=' + name + '&cinema=' + cinema + '&email=' + email + '&nocache=' + aleatorio,
		     onRequest: function() 
		     { 
		  		//alert('Empezando esta solicitud Ajax send info!');
		     },
		     onSuccess: function(responseText)
		     { 
				 showErrors("error",responseText);
				 
		     },
		     onFailure: function()
		     {
		    	 alert('Error!');
				 loadingOff();
		     },
			 onComplete: function()
			 {

			 }
		  }).send();
		//Fin prueba
			
		}
	}
	
}

