// Falling Leaves Effect Javascript
// copyright 30th August 2005, Felgall Pty Ltd
// http://www.felgall.com/
// permission to use this Javascript on your web page is granted
// provided that all of the code in this script (including these
// comments) is used without any alteration
// you can change the number of leaves  that are displayed if you like
var num_leaves = 1;
var folder = "./include/js/img/";
var imgcnt = 8;

var aDOM = 0, ieDOM = 0, nsDOM = 0;
var stdDOM = document.getElementById;
if (stdDOM) aDOM = 1;
else {ieDOM = document.all;
if (ieDOM) aDOM = 1;
else {var nsDOM = ((navigator.appName.indexOf('Netscape') != -1) && (parseInt(navigator.appVersion) ==4));
if (nsDOM) aDOM = 1;}} 
function findDOM(objectId, wS) {if (stdDOM) return wS ? document.getElementById(objectId).style:document.getElementById(objectId);
if (ieDOM) return wS ? document.all[objectId].style: document.all[objectId];
if (nsDOM) return document.layers[objectId];} 
function findLivePageWidth() 
{return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:700;}
function ottieniMese(){
data = new Date();
ora =data.getHours();
minuti=data.getMinutes();
secondi=data.getSeconds();
giorno = data.getDay();
mese = data.getMonth();
date= data.getDate();
year= data.getYear();
if(minuti< 10)minuti="0"+minuti;
if(secondi< 10)secondi="0"+secondi;
if(year<1900)year=year+1900;
if(ora<10)ora="0"+ora;
if(giorno == 0) giorno = " Domenica ";
if(giorno == 1) giorno = " Luned\ì ";
if(giorno == 2) giorno = " Marted\ì ";
if(giorno == 3) giorno = " Mercoled\ì ";
if(giorno == 4) giorno = " Gioved\ì ";
if(giorno == 5) giorno = " Venerd\ì ";
if(giorno == 6) giorno = " Sabato ";
if(mese == 0) mese = "Gennaio ";
if(mese ==1) mese = "Febbraio ";
if(mese ==2) mese = "Marzo ";
if(mese ==3) mese = "Aprile ";
if(mese ==4) mese = "Maggio ";
if(mese ==5) mese = "Giugno ";
if(mese ==6) mese = "Luglio ";
if(mese ==7) mese = "Agosto ";
if(mese ==8) mese = "Settembre ";
if(mese ==9) mese = "Ottobre ";
if(mese ==10) mese = "Novembre ";
if(mese ==11) mese = "Dicembre";
return mese + " "+year;


}


function findLivePageHeight() {
	return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:500;
	} 
	function posX() {
		return typeof window.pageXOffset != 'undefined' ? window.pageXOffset:document.documentElement.scrollLeft? document.documentElement.scrollLeft:document.body.scrollLeft? document.body.scrollLeft:0;}
		function posY() {return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop?document.body.scrollTop:0;}
	var speed = 75;
	var mvw = [];
	var mvh = [];
	var mve = [];
	var stw = [];
	var sth = [];
	var posw = [];
	var posh = [];
	var dir = [];
	var winWidth, winHeight;
	function startleaves() {
		winWidth = findLivePageWidth()-100;winHeight = findLivePageHeight()-100;
		for (var i = 0; i < num_leaves; i++){
			mve[i] = 0;mvh[i] = 28+ Math.random()*2;
			mvw[i] = 10+ Math.random()*4;
			posw[i] = Math.random()*(winWidth-35)+12;
			posh[i] = Math.random()*winHeight; 
			stw[i] = 0.02 + Math.random()/15;
			sth[i] = 1.8 + Math.random();
			dir[i] = (Math.random()>0.5)?1:-1;document.write('<div id="leaves'+ i +'" style="position: absolute; z-index: 999'+ (i+10) +'; visibility:hidden; "><a href="#" onclick="alert(\'OFFERTA di '+ottieniMese()+': Per i clienti che ci contatteranno via e-mail sconto del 10% su preventivo\');"><img src="'+folder + 'leaf3.gif" STYLE="cursor: help"	 width="70" height="100" border="0"></a></div>');
			}setInterval("moreleaves()", speed);
			} 
			function moreleaves() {for (var i = num_leaves-1; i >= 0;i--) {if (posh[i] > winHeight-50) {posw[i] = 10+ Math.random()*(winWidth-mvw[i]-30);posh[i] = 0;dir[i]=(Math.random()<0.5)?1:-1;stw[i] = 0.03 + Math.random()/7;sth[i] = 1.3 + Math.random();} mve[i] += stw[i] *dir[i]; if (Math.abs(mve[i]) > 6) {dir[i]=-dir[i]; posh[i]+=Math.abs(mvh[i]*mve[i]);posw[i]+=mvw[i]*mve[i]; mve[i]=0;} objstyle = findDOM('leaves'+i,1); objstyle.left = (posX()+posw[i] + mvw[i]*mve[i])+'px'; objstyle.top = (posY()+posh[i] + mvh[i]*(Math.abs(Math.cos(mve[i])+mve[i])))+'px';objstyle.visibility = 'visible';}} window.onload = startleaves();
