function closeLR(){
	setTimeout("getId('BN_LAYER').style.display='none'", 30000);
}

function rotateBN(field, first){
	if( first == null )
		var first = 1;
	
	var item;
	for( i=0; i<field.length; ++i ){
		 item = field[i];

		 if( !item )
			 continue;
			 
		 var tt = null;
		 for( j=0; j<item.length; ++j ){
			 if( getId(item[j]).style.display=="" ){
			     getId(item[j]).style.display="none";
			 	 if( tt == null )
				 	 tt = j;
			 }
		 }
		 if( !item[tt+1] || first )
		 	 getId(item[0]).style.display="";
		 else
		 	 getId(item[tt+1]).style.display="";
	}	
	
	setTimeout(function(){
  		rotateBN(field, 0);
	}, 15000);
}

function getId(id){
	var element = document.getElementById(id+"");	
	return element;
}

// get cookie
function getCookie(NameOfCookie){
	if (document.cookie.length > 0) { 
		begin = document.cookie.indexOf(NameOfCookie+"="); 
	if (begin != -1){ 
		begin += NameOfCookie.length+1; 
		end = document.cookie.indexOf(";", begin);
		if (end == -1) end = document.cookie.length;
		return unescape(document.cookie.substring(begin, end)); } 
	}
	return null; 
}

// set cookie
function setCookie(NameOfCookie, value, expirehours){
	var ExpDate = new Date ();
	ExpDate.setTime(ExpDate.getTime() + (expirehours * 3600 * 1000));
	document.cookie = NameOfCookie + "=" + escape(value) + ((expirehours == null) ? ";" : "; expires=" + ExpDate.toGMTString());
}

function setFontSize(size) {
	var body = document.getElementsByTagName('body')[0];
	var percentuale = "100%";
	
	if( size == 2 ) percentuale = "125%";
	if( size == 3 ) percentuale = "150%";
	if( size == 4 ) percentuale = "175%";
	if( size == 5 ) percentuale = "200%";
	
	body.style.fontSize = percentuale;
	
	setCookie('fontSize', size, 1);
}

function returnSelection(radioButton) {
	var selection=null;
	for(var i=0; i<radioButton.length; i++) {
		 if(radioButton[i].checked) {
		   selection=radioButton[i].value;
		   return selection;
		 }
	}
	return selection; 
} 

// preload images
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

// switch images
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features){
  window.open(theURL,winName,features);
}

// openWindow('urlPage', 'namePopup', 'width', 'height', 'yes/no', 'yes/no');
function openWindow(mypage,myname,w,h,resizable,scrollbars){ 
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; 
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0; 
	settings = 'scrollbars='+scrollbars+',resizable='+resizable+',height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition;
	win = window.open(mypage,myname,settings);
}

/* clock script */ 
function stampDate(){
	var months = new Array(12);
	months[0]  = "gennaio";
	months[1]  = "febbraio";
	months[2]  = "marzo";
	months[3]  = "aprile";
	months[4]  = "maggio";
	months[5]  = "giugno";
	months[6]  = "luglio";
	months[7]  = "agosto";
	months[8]  = "settembre";
	months[9]  = "ottobre";
	months[10] = "novembre";
	months[11] = "dicembre";
	
	var days = new Array(6);
	days[0]  = "Domenica";
	days[1]  = "Lunedì";
	days[2]  = "Martedì";
	days[3]  = "Mercoledì";
	days[4]  = "Giovedì";
	days[5]  = "Venerdì";
	days[6]  = "Sabato";

	var data 	= new Date();
	var lday      = days[data.getDay()];
	var lmonth    = months[data.getMonth()];
	var date 	= data.getDate();
	var year	= data.getFullYear();
	
	var date_div = document.getElementById('date');
	date_div.innerHTML = lday + " " + date + " " + lmonth + " " + year;
}
function stampClock(){
	var clock_time = new Date();
	var clock_hours = clock_time.getHours();
	var clock_minutes = clock_time.getMinutes();
	var clock_seconds = clock_time.getSeconds();
	
	if (clock_hours < 10){
		clock_hours = "0" + clock_hours;
	}
	if (clock_minutes < 10){
		clock_minutes = "0" + clock_minutes;
	}
	if (clock_seconds < 10){
		clock_seconds = "0" + clock_seconds;
	}
	
	var clock_div = document.getElementById('clock');
	clock_div.innerHTML = clock_hours + ":" + clock_minutes + ":" + clock_seconds;
	
	setTimeout("stampClock()", 1000);
}
/* clock script */ 

/* function correct date */
function areCharsInList(s,list) {
	var i,c;
	for (i=0;i<s.length; i++) {
		c = s.charAt(i);
	if (list.indexOf(c) == -1)
		return false;
	}
return true;
}

function isDate(str){
	if(str.length!=10){
		return false;
	}
	if(str.charAt(2)!='/' || str.charAt(5)!='/'){
		return false;
	}
	if( !areCharsInList(str.substring(0,2)+str.substring(3,5)+str.substring(6,10), '1234567890') ){
		return false;
	}
	if(str.substring(3,5)>12){
		return false;
	}
	if(str.substring(0,2)>31){
		return false;
	}
return true;
}
/* function correct date */
