/*Funzioni Per Jquery*/
$(document).ready(
	function () {
		apriLingue('');
		
		$(".hide").hide();
	
		$(".chiediConferma").click(function(){
			return chiediConferma(this);
		});
	
		//Mostro o nascondi i div al click su un link con class shd. Parametri: Tipo di link, Tipo di comparsa del div, Id del div
		//shd01biblio
		$("div[class*='shd']").click(function(){
			classe=$(this).attr("class");
			myregexp = new RegExp(/(shd[^ ]*)/);
			mymatch = myregexp.exec(classe);
			if(mymatch!=null){
				valore=mymatch[1].replace("shd","");
				tipologia=valore.substring(0,1);comparsa=valore.substring(1,2);idDiv=valore.substring(2);
				
				if($("#"+ idDiv).is(":hidden")){
					$(".shd"+ valore +" img").attr("src","../images/install/arrow_up.gif");
					if(jQuery.support.boxModel){
						if(comparsa=='1') $("#"+ idDiv).slideDown("slow");
						else if(comparsa=='2') $("#"+ idDiv).show();
					}
					else{
						$("#"+ idDiv).show();
					}
				}
				else{
					$(".shd"+ valore +" img").attr("src","../images/install/arrow_down.gif");
					if(jQuery.support.boxModel){
						if(comparsa=='1') $("#"+ idDiv).slideToggle("slow");
						else if(comparsa=='2') $("#"+ idDiv).hide();
					}
					else{
						$("#"+ idDiv).hide();
					}
				}
				return false;
			}	
		});
	}
);

function chiediConferma(anchor){
	if (confirm("Sei sicuro? L'operazione non potra' essere annullata")){
		anchor.href += '&conferma=1';
		return true;
	}
	return false;
}

function apriLingue(idElemento){
	$(idElemento +".linguaSel span").click(function(){
		if($(idElemento +".elencoLingue").is(":hidden"))
			$(idElemento +".elencoLingue").slideDown("fast");
		else
			$(idElemento +".elencoLingue").slideToggle("fast");
	});
}

function fading(){
	posCurr++;
	if(posCurr>=arrSfondi.length)
		posCurr=0;
		
	perc = $("#testata").css("background-image");
	perc = perc.substr(0,perc.lastIndexOf("/")+1);
	
	currImg=arrSfondi[posCurr];
	$("<div class=\"tmpDiv\">&nbsp;</div>").css("background-image",perc + currImg +"\")").appendTo("#testata").fadeIn("slow",function(){
		$("#testata").css("background-image",perc + currImg +"\")");
		$(".tmpDiv").remove();
	});
	
	setTimeout(function() {fading();}, 5000);
}
