// starting the script on page load
$(document).ready(function(){
	$('a.zoom').lightBox();
	imagePreview();
	tooltip();
	corsi(); 
	exif();
	
    $("input").focus(function () {
         $(this).css('background','rgb(255,255,85)').css('border-color','red');
    });
	 $("input").blur(function () {
         $(this).css('background','white').css('border-color','gray');
    });
	
	$("select").focus(function () {
         $(this).css('background','rgb(255,255,85)').css('border-color','red');
    });
	$("select").blur(function () {
         $(this).css('background','white').css('border-color','gray');
    });

	$("#authfields").hide();
	
    $("span#login a").click(function () {
         $("#userstate").fadeOut("fast"); $("#authfields").fadeIn("slow"); 
         
    });	
	
    $("#hideform").click(function () {
         $("#authfields").fadeOut("fast"); $("#userstate").fadeIn("slow"); 
    });


	$("#transferbox").hover(function(){
		$(this).css('border-color', 'white');
		},function(){
		$(this).css('border-color', 'gray');
		});	


		
	$(".boxfoto:hidden").fadeIn("slow");



//	$(".boxfoto:hidden").fadeIn("slow");
		
//	updatePersonalData("nome");
//	updatePersonalData("cognome");

	
	// validation
	// validate the comment form when it is submitted
//	$("#commentForm").validate();
	
	// validate signup form on keyup and submit
/*	$("#signin").validate({
		rules: {
			name: "required",
			surname: "required",
			address: "required",
			location: "required",
			provincia: "required",
			email: {
				required: true,
				email: true
			},
			piva: "required",			
			username: {
				required: true,
				minlength: 6
			},
			password: {
				required: true,
				minlength: 6
			},
			confirm_password: {
				required: true,
				minlength: 6,
				equalTo: "#password"
			},

//			agree: "required"
		},
		messages: {
			name: "Inserire il proprio nome / Please enter your firstname",
			surname: "Inserire il proprio cognome / Please enter your lastname",
			username: {
				required: "Inserire username / Please enter a username",
				minlength: "Inserire almeno 6 caratteri / Your username must consist of at least 6 characters"
			},
			password: {
				required: "Inserire una password / Please provide a password",
				minlength: "Inserire almeno 6 caratteri / Your password must be at least 6 characters long"
			},
			confirm_password: {
				required: "Please provide a password",
				minlength: "Your password must be at least 5 characters long",
				equalTo: "Please enter the same password as above"
			},
			email: "Please enter a valid email address",
//			agree: "Please accept our policy"
		}
	});
	
	// propose username by combining first- and lastname
	$("#username").focus(function() {
		var firstname = $("#name").val();
		var lastname = $("#surname").val();
		if(firstname && lastname && !this.value) {
			this.value = firstname + "." + lastname;
		}
	});
	
	// check if confirm password is still valid after password changed
	$("#password").blur(function() {
		$("#confirm_password").valid();
	});
	*/
	
	//code to hide topic selection, disable for demo
/*	var newsletter = $("#newsletter");
	// newsletter topics are optional, hide at first
	var inital = newsletter.is(":checked");
	var topics = $("#newsletter_topics")[inital ? "removeClass" : "addClass"]("gray");
	var topicInputs = topics.find("input").attr("disabled", !inital); */
	// show when newsletter is checked
/*	newsletter.click(function() {
		topics[this.checked ? "removeClass" : "addClass"]("gray");
		topicInputs.attr("disabled", !this.checked);
	});	*/
	
});
