function modalBoxKeyPressed(oEvent, oInput)
{
	var iKeyCode = oEvent.keyCode;
	
	if(iKeyCode == 13)
	{
		switch(oInput.id)
		{
			case 'inputEmailLog':
			case 'inputPasswordLog':
				subscribe_alert_email("log");
				
				break;
			case 'inputEmailSub':
			case 'inputPasswordSub':
			case 'inputPasswordCheckSub':
				subscribe_alert_email("sub");
				break;
		}
	}
}
function subscribe_alert_email(subOrLog)
{
 
	 // ajax execute subscription here and if it is ok
	
	 $('msgBox').setAttribute("class","loading");
	
	 if($('inputEmailSub') && subOrLog == "sub")
	 {
		sendMethod = "post";
		emailValue = $('inputEmailSub').value;
		passwordValue = $('inputPasswordSub').value;
		passwordValueCheck = $('inputPasswordCheckSub').value;
		newUserValue = true;
		
	 }
	 else if($('inputEmailLog') && subOrLog == "log")
	 {
		sendMethod = "post";
		emailValue = $('inputEmailLog').value;
		passwordValue = $('inputPasswordLog').value;
		passwordValueCheck = "";
		newUserValue = false;
		
	 }
	 else
	 {
		sendMethod = "get";
		emailValue = "";
		passwordValue = "";
		passwordValueCheck = "";
		newUserValue = "";
		
	 }
	 
	 new Ajax.Request(
			   
			   '/myathome/save-search/'
			   ,
			   {
			    method: sendMethod,
			    parameters:{ email: emailValue, password: passwordValue, passwordCheck: passwordValueCheck, newUser: newUserValue},
			    onSuccess: function (transport, json) 
				 {
				     $('msgBox').setAttribute("class","");
				     if(json)
				     {
				    	 $('titleBox').innerHTML = json.title;
				     }
				     $('msgBox').innerHTML = transport.responseText;     
			 }
			   } 
	 );
			 	 
 
}
function lost_email()
{
	$('msgBox').setAttribute("class","loading");
	if($('inputEmailLog'))
	{
		emailValue = $('inputEmailLog').value;
	}
	else
	{
		emailValue = "";
	}
	new Ajax.Request(
			   
			   '/myathome/lost/'
			   ,
			   {
			    method: "post",
			    parameters:{ email: emailValue },
			    onSuccess: function (transport, json) 
				 {
				     $('msgBox').setAttribute("class","");
				     $('titleBox').innerHTML = json.title;
				     $('msgBox').innerHTML = transport.responseText;     
			 }
			   } 
	 );
}
