// JavaScript Document

	
//$(document).ready(function(){
//	$.ajaxSetup ({
//		cache: false
//	});
//	var ajax_load = '<img src="http://www.torrevillamtb.com/images/ajax-loader.gif" alt="" class="ajaxImg" "  />';	
//    $('#nav2 a, .green a').click(function(){	
//	   	var page = $(this).attr('href');	
//		$('.testoIN')
//			.html(ajax_load)
//			.load(page+' .testoIN')
//			.slideDown();		
//		return false;
//	});
//
//});

//		bordi arrotondati per Internet esplorer
/*addEvent(window, 'load', initCorners);
function initCorners() {
var setting = {
tl: { radius: 6 },
tr: { radius: 6 },
bl: { radius: 6 },
br: { radius: 6 },
antiAlias: true
}
curvyCorners(setting, ".rounded");
};
//		annullamento bordi arrotondati
addEvent(window, 'load', initCorners);
function initCorners() {
var setting = {
tl: { radius: 0 },
tr: { radius: 0 },
bl: { radius: 0 },
br: { radius: 0 },
antiAlias: true
}
curvyCorners(setting, ".NOrounded");
};
*/
/*		funzione per emulare la pseudo classe :hover in internet esplorer	*/
sfHover = function() {
			var sfEls = document.getElementById("nav").getElementsByTagName("LI");
			for (var i=0; i<sfEls.length; i++) {
				sfEls[i].onmouseover=function() {
					this.className+=" sfhover";
				}
				sfEls[i].onmouseout=function() {
					this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
				}
			}
		}
		if (window.attachEvent) window.attachEvent("onload", sfHover);
		
/*		Funzione per cambiare lo sfondo	 	*/
/*var i =Math.floor( Math.random() * 3 +1)*/
//var min=2
//var max=3
function changeDivImage(min,max)
{
	var now= new Date();
	var day= now.getMonth();
do
	{
	var i=Math.floor( Math.random() * max +1); //genera un numero casuale non superiore alla variabile:max
	if (day<9 && i>40)
	{
		i=i-10;
		};
	}
	while(i<min) // controlla che il numero non sia inferiore alla Var: min
	if(document.all)
	{ 
	document.all.contenitore.style.backgroundImage = "url(http://www.torrevillamtb.com/images/foto/BG-"+ i + ".jpg)";
	}
   else {
   document.getElementById("contenitore").style.backgroundImage = "url(http://www.torrevillamtb.com/images/foto/BG-" + i + ".jpg)"; //assegna al elemento con nome "estata" l'immagine di sfondo
   }
//	i++; // aumenta il valore di uno ad ogni passaggio
	if (i>max) // controlla e resetta il valore al minimo in caso che il contatore non superi il livello: max
		{i=min}
	setTimeout("changeDivImage("+min+","+max+")",20000);	
	
};

/* 	funzione per cambiare lo sfondo dell'elemento HTML:
	paramtri:
		divid= elemento a cui cambiare lo sfondo
		filename= file dello sfondo
	*/
function switchBg(divid) {
	
	var divTgt = document.getElementById(divid);
	divTgt.style.backgroundImage = "url(http://www.torrevillamtb.com/images/bg_red80.png";
	
};
function changeBgImage (image, id) {
	var element = document.getElementById(id);
	element.style.backgroundImage = "url("+image+")";
};

/*		funzione per cambiare lo sfondo nella sezione Community		*/

function changeDivImageBlog(min,max)
{
	var now= new Date();
	var day= now.getMonth();

do
	{
	var i=Math.floor( Math.random() * max +1); //genera un numero casuale non superiore alla variabile:max
	
	if (day<9 && i>40)
	{
		i=i-10;
		};

	}
	while(i<min) // controlla che il numero non sia inferiore alla Var: min
	if(document.all)
	{ 
	document.all.page.style.backgroundImage = "url(http://www.torrevillamtb.com/images/foto/BG-"+ i + ".jpg)";
	}
   else {
   document.getElementById("page").style.backgroundImage = "url(http://www.torrevillamtb.com/images/foto/BG-"+ i + ".jpg)"; //assegna al elemento con nome "estata" l'immagine di sfondo
   };
//	i++; // aumenta il valore di uno ad ogni passaggio
	if (i>max) // controlla e resetta il valore al minimo in caso che il contatore non superi il livello: max
		{i=min}
	setTimeout("changeDivImage("+min+","+max+")",20000);	
	
};


//-->
