/* Menu Orizzontale */

function show_insegnanti (value) 
{
	if(value=="12")
	{
		$("#insegnanti, #scuola").show();
		$("#scuola > input").addClass('required');
	}
	else
	{
		$("#insegnanti, #scuola").hide();
		$("#scuola > input").removeClass('required');
	}
}

clickMenu = function(menu) {
	var getEls = document.getElementById(menu).getElementsByTagName("LI");
	var getAgn = getEls;

	for (var i=0; i<getEls.length; i++) {
			getEls[i].onclick=function() {
				for (var x=0; x<getAgn.length; x++) {
				getAgn[x].className=getAgn[x].className.replace("unclick", "");
				getAgn[x].className=getAgn[x].className.replace("click", "unclick");
				}
			if ((this.className.indexOf('unclick'))!=-1) {
				this.className=this.className.replace("unclick", "");;
				}
				else {
				this.className+=" click";
				}
			}
			getEls[i].onmouseover=function() {
				this.className+=" hover";
			}
			getEls[i].onmouseout=function() {
				this.className=this.className.replace("hover", "");
			}
		}
	}

$(document).ready
(	
	function()
	{
		$("#insegnanti, #scuola").hide();
		
//------show hide
//		if($(".hidden").length!="")
//		{
//			$(".hidden").hide();
//			/*$(".show b").html("Show");*/
//			$(".show b").html("");
//			
//			$(".show").click(function() {
//			if (this.className.indexOf('clicked') != -1 ) {
//					$(".hidden").hide();
//					$(this).removeClass('clicked')
//					/*$(this).children("b").html("Show");*/
//					$(this).children("b").html("");
//					}
//					else {
//					$(".hidden").hide();
//					$(".show").removeClass('clicked');
//					/*$(".show").children("b").html("Show");*/
//					$(".show").children("b").html("");
//					current = $(this).children("b").attr("class");
//					$("#"+current).show();
//					$(this).addClass('clicked')
//					/*$(this).children("b").html("Nascndi");*/
//					$(this).children("b").html("");
//					}
//			});
//		}
//		
//------show hide con amimazione
		if($(".hidden2").length!="")
		{
			$(".hidden2").hide();
			$(".show2").html("Continua qui...");
			
			$(".show2").click(function() {
			if (this.className.indexOf('clicked') != -1 ) {
				//aggiunto per avere una anteprima del messaggio
				$(".anteprima").show();
				//fine
				$(this).prev().slideUp(500);
				$(this).removeClass('clicked')
				$(this).html("Continua qui...");
				}
				else {
				//aggiunto per avere una anteprima del messaggio
				$(".anteprima").hide();
				//fine
				$(this).addClass('clicked')
				$(this).prev().slideDown(500);
				$(this).html("...Nascondi");
				}
			});
		}
		
//------tableSorter
		if($("#myTable").length!="")
		{
			$("#myTable").tablesorter();
		}
		
//------LightBox
	
			//$('a[@rel*=lightbox]').lightBox(); // Select all links that contains lightbox in the attribute rel
			// This, or...
			//$('#gallery a').lightBox(); // Select all links in object with gallery ID
			// This, or...
			$('a.lightbox').lightBox(); // Select all links with lightbox class
			$('a.lightbox1').lightBox(); // Select all links with lightbox class
			$('a.lightbox2').lightBox(); // Select all links with lightbox class
			$('a.lightbox3').lightBox(); // Select all links with lightbox class
			$('a.lightbox4').lightBox(); // Select all links with lightbox class
			// This, or...
			//$('a').lightBox(); // Select all links in the page
			// ... The possibility are many. Use your creative or choose one in the examples above
		
//------Validazione di un form		
		if($("#posta").length!="")
		{
			$("#posta").validate();
		}
		
		if($("#friend").length!="")
		{
			$("#friend").validate();
		}
		
		if($("#abbonati").length!="")
		{
			$("#abbonati").validate({
				rules: {
					password: {
						required: true,
						minlength: 8
					},
					password2: {
						required: true,
						minlength: 8,
						equalTo: "#password"
					},
					email: {
						required: true,
						email: true
					},
					username: "required"
				},
				messages: {
					password: {
						//required: "Please provide a password",
						required: "Questo campo è richiesto",						
						//minlength: "Your password must be at least 5 characters long"
						minlength: "La password deve essere di almeno 8 caratteri"

					},
					password2: {
						//required: "Please provide a password",
						required: "Questo campo è richiesto",
						//minlength: "Your password must be at least 5 characters long",
						minlength: "La password deve essere di almeno 8 caratteri",
						//equalTo: "Please enter the same password as above"
						equalTo: "Le password non corrispondono"
					},
					username: "Manca il consenso"
				}
			});
		}

		if($("#testo").length!="")
		{
			$('#testo').wysiwyg();		
		}
	}	
);


function onKeyNumeric(e) 
{
	// Accetto solo numeri e backspace <-
	if ( ((e.keyCode >= 48) && (e.keyCode <= 57)) || (e.keyCode == 8) || (e.keyCode == 9) || ((e.keyCode >= 96) && (e.keyCode <= 105)) ) {
		return true;
	} else {
		return false;
	}
}

