function change_input_class_focus(obj)
{
	obj.removeClass("border-input");			
	obj.addClass("border-focus");
}

function change_input_class_blur(obj)
{
	obj.addClass("border-input");			
	obj.removeClass("border-focus");
}

function submit_newsletter()
{
	if($("#newsletter_privacy").is(':checked'))
	{
		jQuery.ajax({
				type: "POST",
				url: "/toccanoi/inc/newsletter_mail.asp",
				dataType: "html",
				data: "e=" + $("#newsletter").val(),
				success: function(response){
					if(response == 'OK')
					{
						$("#form_newsletter").html("<h2 class=\"TAN-nl\"><span>Iscriviti alla newsletter</span></h2><p id=\"newsletter_message\" class=\"TAN-nl-text\">Grazie! Ti terremo informato su tutte le iniziative di Tocca a Noi</p>");						
					}
					else 
					{
						alert(response);
					}
				},
				error: function(){
					alert("Impossibile inserire indirizzo email");
				}
			});
	}
	else
	{
		alert("Accettare la liberatoria");	
	}
}

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + '.' + '$2');
	}
	return x1 + x2;
}



$(window).load(function () {
	$(".border-input").focus(function () {
		change_input_class_focus($(this));
	});
	
	$(".border-input").blur(function () {
		change_input_class_blur($(this));
	});
});

