$("document").ready(function(){
		
		$(".voce").click(function(){
			var idP = $(this).attr("rel");
			var parent = $(this).parent("div").attr("rel");
			document.location.href="?act="+parent+"&c="+idP;
		});
		
		$('.lightBoxThumb').lightBox();
});

function gestFontSize(action)
{
	var min=8;
	var max=18;
	
	var div = $(".contentTestoArticolo");
	
	if($(".contentTestoArticolo").css("fontSize")) {
			 var s = $(".contentTestoArticolo").css("fontSize"); 
			 var s = parseInt(s.replace("px",""));
			} else { var s = 12;}
			
	if(action=="aumenta") {
			 if(s<max) s += 1;
		} else if(action=="diminuisci") {
			if(s>min) s -= 1; }
		
	$(".contentTestoArticolo").css("fontSize",s+"px");   
	
}

function soloNumeri(e,tipo) {
	
  	var c = e.keyCode ? e.keyCode : e.charCode
	if(tipo=="money") {
		if ( ((c >= 48) && (c <= 57)) || (c == 8) || (c==9) || (c==46) || (c==44) || (c==37) || (c==39)) { return true;} else {return false;}	
	}
	else if(tipo=="telephon"){
		if ( ((c >= 48) && (c <= 57)) || (c == 8) || (c==9) || (c==45) || (c==43) || (c==47) || (c==37) || (c==39)) { return true;} else {return false;}
	}
	else { 
		if ( ((c >= 48) && (c <= 57)) || (c == 8) || (c==9) || (c==37) || (c==39)) { return true;} else {return false;}
	}
}

function paginePerCategoria(value,tipo){
	if(value!="")
	$.post("ajax.request.php",{azione:"paginePerCategoria", valore:value, tipo:tipo},function(data){$("#contentCat").html(data);});
}

function cambiaCategoria(valore, idPagina) {
	$.post("ajax.request.php",{azione:"pagineAllaCategoria", valore:valore, idPagina:idPagina});
}

function goToPage(pagina){
	document.location.href=pagina;
}

function cancella(foto){
	if(confirm("Sicuro di voler cancellare questa foto?")) {
	var id = $(foto).attr("id");
	$.post("ajax.request.php",{azione:"cancellaFoto", valore:id},function(data){$("#riga_"+id).fadeOut();});
	}
}

function inizializzaSlide() {

	$("#slider").easySlider({
		auto: false, 
		continuous: true,
		numeric: true

	});
	
}

function controllaRicerca() {
	
	var testo = $("#ricercato").val();
	if(testo.length>3) { document.getElementById("ricercaForm").submit();} else {alert("Inserire un testo superiore a 3 caratteri!");} 
	
}

function cambiaAttivo(oggetto) {
	var valore = $(oggetto).attr("rel");
	var idP = $(oggetto).val();
	$.post("ajax.request.php",{azione:"statoPagina", valore:valore, idP:idP}, function(data) {$(oggetto).attr("rel",(valore)?0:1)});
}

function mostraGalleria(IDCat) {
	$.post("ajax.request.php",{azione:"mostraGalleria", IDCat:IDCat}, function(data) {$("#contentGalleria").html(data);});
}

function cancellaImmagine(IDImg) {
	if(confirm("Sicuro di voler cancellare questa immagine?")) {
		$.post("ajax.request.php",{azione:"cancellaImmagine", valore:IDImg},function(data){$("#imgLayer_"+IDImg).fadeOut();});
		}
}
