/*Funzioni Per Jquery*/
$(document).ready(
	function () {
		$("input[class^='styled']").custCheckBox();
		
		$("form.verificaForm").verificaForm({tipoVisualizzazione:2});
		
		$('#featured').orbit({
			bullets: true,
			animation: 'fade',
			bulletThumbs: true,
			animationSpeed:1200,
     		bulletThumbLocation: '../images/home/rotator/thumb/',
			advanceSpeed: 4500,
			startClockOnMouseOut: true,
			timer: true,
			afterSlideChange: function(){
				triggerID=$(".orbit-bullets li").index($(".orbit-bullets li.active"));
				quale=$(".orbit img").eq(triggerID).attr("data-thumb").replace(".jpg","");
				
				$("#descrizioneRotator .sezione img").attr("src","../images/home/rotator/sezione"+ quale +".gif");
				$("#descrizioneRotator .sottotitolo img").attr("src","../images/home/rotator/sottotitolo"+ quale +".gif");
			}
		});
		
		//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
		$("a[class*='shd']").click(function(){
			classe=$(this).attr("class");
			cliccato=$(this);
			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")){
					$(cliccato).css("background-image","url(../images/struttura/freccia_primopiano.gif)");
					if(jQuery.support.boxModel){
						if(comparsa=='1') $("#"+ idDiv).slideDown("medium");
						else if(comparsa=='2') $("#"+ idDiv).show();
					}
					else{
						$("#"+ idDiv).show();
					}
				}
				else{
					$(cliccato).css("background-image","url(../images/struttura/freccia_primopiano_close.gif)");
					if(jQuery.support.boxModel){
						if(comparsa=='1') $("#"+ idDiv).slideToggle("medium");
						else if(comparsa=='2') $("#"+ idDiv).hide();
					}
					else{
						$("#"+ idDiv).hide();
					}
				}
				return false;
			}	
		});
	}
);

function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}
