$(function() {

	// effetto di rollover su bottone
	$("#promozione, input[type=submit]").hover(
      function () {
        $(this).css({'background-color' : '#ffb76f', 'color:' : '#535353'});
      }, 
      function () {
        $(this).css({'background-color' : '#ffce9e', 'color:' : '#414141'});
      }		
	);

	// effetto acqua su pulsanti
	$(".category").hover(
      function () {
        $(this).css({'background-color' : '#ffb76f', 'color:' : '#535353'});
      	$(this).animate({paddingLeft:"15px"}, 100);
      	$(this).animate({paddingRight:"15px"}, 100);
      }, 
      function () {
        $(this).css({'background-color' : '#ffce9e', 'color:' : '#414141'});
      	$(this).animate({paddingLeft:"0"}, 100);
      	$(this).animate({paddingRight:"0"}, 100);
      }		
	);

	// Validazione del formulario di invio messaggio
	$("input[name=sendSpareMsg], input[name=sendRequest]").click(function(){
		var fname	= $("input[name=fname]").val();
		var lname	= $("input[name=lname]").val();
		var email	= $("input[name=email]").val();
		var msg 	= $("textarea[name=message]").val();
	
		var error = false;
		var at = email.indexOf("@");
		var dot = email.indexOf(".");
		
		if(fname == ""){
			error = true;
			$("input[name=fname]").css({ 'border' : '1px solid #ffb164' });
		}else{
			$("input[name=fname]").css({ 'border' : '1px solid #e0ddd4' });
		}
		
		if(lname == ""){
			error = true;
			$("input[name=lname]").css({ 'border' : '1px solid #ffb164' });
		}else{
			$("input[name=lname]").css({ 'border' : '1px solid #e0ddd4' });
		}
		
		if((email == "") || (at == -1) || (dot == -1) ){
			error = true;
			$("input[name=email]").css({ 'border' : '1px solid #ffb164' });
		}else{
			$("input[name=email]").css({ 'border' : '1px solid #e0ddd4' });
		}
		
		if(msg == ""){
			error = true;
			$("textarea[name=message]").css({ 'border' : '1px solid #ffb164' });
		}else{
			$("textarea[name=message]").css({ 'border' : '1px solid #e0ddd4' });
		}
		
		if( !error ){
			$( this ).parents('form').submit();
		}
		
		return false;
	});

	$('.reqInfo').click(function(){
		$('#request').fadeIn(500);
		$('html, body').animate({scrollTop:0}, 'slow');  
		return false;
	});
	
	$('.close').click(function(){
		$('#request').fadeOut(500);
		return false;
	});

});