	jQuery(document).ready(function() {
		/* randomizza i primi 5 articoli */
		
		var ftime=leggiCookie('primavolta');
		/*volte successive */
		if(ftime=='si'){
			others();
		}
		/* prima volta allora setta un immagine di base */
		else{
			creaCookie('primavolta','si','no');
			firstime();
		}
	});
	
	/* genera un numero casuale tra lowVal e HighVal*/
	function randRange(lowVal,highVal) {
	   return Math.floor(Math.random()*(highVal-lowVal+1))+lowVal;
	}
		
	//setta i cookie in acm di modifica categoria box 1
	function creaCookie(name,value,expired){
		
		if(expired == 'no'){
		
			today=new Date();
			var expires=10;
			expires = expires*100*60*60*24;
			var expires_date= new Date(today.getTime() + (expires));
			document.cookie= name+"="+value+";expires="+expires_date.toGMTString()+";path=/";
		}
		else{
			today=new Date();
			var expires=30;
			expires = expires*100*60*60*24;
			var expires_date= new Date(today.getTime() - (expires));
			document.cookie= name+"="+value+";expires="+expires_date.toGMTString()+";path=/";
		}
	}
	function firstime(){
		jQuery("#img-santino").attr("style" , "background-Image:url(/contents/instance16/images/tophead1.jpg)"); 
	}
	function others(){
		imgHeader=new Array(
			"tophead1.jpg",
			"tophead2.jpg",
			"tophead3.jpg",
			"tophead4.jpg",
			"tophead5.jpg",
			"tophead6.jpg",
			"tophead7.jpg",
			"tophead8.jpg",
			"tophead9.jpg",
			"tophead10.jpg",
			"tophead11.jpg",
			"tophead12.jpg",
			"tophead13.jpg",
			"tophead14.jpg",
			"tophead15.jpg",
			"tophead16.jpg",
			"tophead17.jpg",
			"tophead18.jpg",
			"tophead19.jpg",
			"tophead20.jpg"
		);		
	
		var numrand=randRange(1,imgHeader.length)-1;
		/* se non ho un flash ma ho solo l'immagine*/
			
		jQuery("#img-santino").attr("style" , "background-Image:url(/contents/instance16/images/"+imgHeader[numrand]+")"); 
	}
	function leggiCookie(nomeCookie)
	{
	  if (document.cookie.length > 0)
	  {
		var inizio = document.cookie.indexOf(nomeCookie + "=");
		if (inizio != -1)
		{
		  inizio = inizio + nomeCookie.length + 1;
		  var fine = document.cookie.indexOf(";",inizio);
		  if (fine == -1) fine = document.cookie.length;
		  return unescape(document.cookie.substring(inizio,fine));
		}else{
		   return "";
		}
	  }
	  return "";
	}