/*
 * this file is used to declare all the globals javascript vars 
 * of the application
 * */
// var Url = 'http://localhost/danikautomate.ro/';
 var Url = 'http://danikautomate.ro/';
 var Loader = '<div id="Loader" style="color: #000"><img src="'+Url+'loader.gif" alt="" style="border: none" />&nbsp;Se incarca...</div>';//the image that will be loaded
 //email validation function
 function validEmail(supposeEmailAddress) 
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(supposeEmailAddress)){
		return (true)
	}
	return (false)
}

Event.observe(window, 'load', function(){
	$('BtnSubscribeNewsletter').onclick = function()
	{
		$('errorPlacer').update('');
		if (!validEmail($F('TxtSubscribeNewsletter').strip()))
		{
			$('errorPlacer').update('Va rugam sa introduceti o adresa de e-mail valida');
			return;
		}
		$('errorPlacer').update(Loader)
		new Ajax.Request('storeEmailAddress.php', {
			parameters: 'emailAddress='+encodeURI($F('TxtSubscribeNewsletter').strip()),
			onSuccess: function(t)
			{
				$('errorPlacer').update(t.responseText);
			},
			onFailure: function()
			{
				alert('error - ')
			}
		})
	}
});
