/**
 * @author Gea
 */

$.metadata.setType("attr", "validate");
var options = { 
    beforeSubmit:  showRequest,  		// pre-submit callback 
    success:       showResponse,  		// post-submit callback 
	url: 'ims.php',
	type: 'post',
	clearForm: true,
	resetForm: true		
};	
	
$(document).ready(function() {

	$("ul#frm li").bind("mouseenter", function(e){
		$(this).addClass('currentRow');
	});
	$("ul#frm li").bind("mouseleave", function(e){
		$(this).removeClass('currentRow');
	});

	$("input[name='opzione']").change( function()
		{
			var selected = $("input[name='opzione']:checked").val();
			if (selected=='web'){
				$('#rffx').hide();
				$('#rfpw').show();
			} else if (selected=='feed' || selected == 'dati'){
				$('#rffx').show();
				$('#rfpw').hide();
			} else {
				$('#rffx').hide();
				$('#rfpw').hide();
			}
		}
	);
	
	$("#frmContacts").validate({
		rules: {
			name: "required",
			lname: "required",
			mail: {
				required: true,
				email: true
			}
		},
		messages: {
			name:  "Inserire il nome",
			lname: "Inserire il cognome",
			email: "Indirizzo email non valido"//,
		},
		submitHandler: function(form){
			$("#act").attr("value", "RequestInclusion"); 	
			jQuery(form).ajaxSubmit(options);
		}

	});
 });
 
function showRequest(formData, jqForm, options) { 
} 
 
function showResponse(responseText, statusText)  { 
	alert(responseText);
} 
