/*
   ********* BackGround Selector **********
   |					  |
   |  Autore  : Nunziante Contieri 	  |
   |  WebSite : www.globemaster.cjb.net   |
   |  E-Mail  : globemaster1@yahoo.it	  |
   |  Versione: 1.0 (18-11-2002)	  |
   |					  |
   ****************************************

   Per favore non cancellate questa introduzione!
   Lo script può essere utilizzato liberamente finchè questa introduzione rimarrà intatta! Grazie.

   L'Autore non si riterrà responsabile di alcun effetto indesiderato dovuto
   all'uso proprio e/o improprio di questo script. Non sono fornite garanzie
   di alcun genere riguardo l'utilizzo e il funzionamento di questo script.

   Un ringraziamento speciale a Nic Jansma per le funzioni Cookie.   

   ---------------------------------------------------------------------------

   Please do not delete this header!
   This script may be used freely as long as this header is intact! Thank you.

   The Author cannot be held responsible for any unwanted effects due to the    
   usage of this JavaScript or any derivative.  No warrantees for usability    
   for any specific application are given or implied. 

   Special thanks to Nic Jansma for Cookie functions.
*/


// Configura il numero di Backgrounds disponibili
// (Set the number of Available Backgrounds)
num = 20;

// Non modificare la linea seguente
// (Don't edit this line)
var sfondo = new Array()

// Configura la directory, il nome e l'estensione dei Background disponibili
// (Set directory, name and extension of Available BackGrounds) 
sfondo[2] = "http://i38.tinypic.com/ra3e37.jpg";
sfondo[3] = "http://i33.tinypic.com/wrmlhx.jpg";
sfondo[4] = "http://i38.tinypic.com/qx9sv5.jpg";
sfondo[5] = "http://i35.tinypic.com/2569wec.jpg";
sfondo[6] = "http://i37.tinypic.com/2vv5fms.jpg";
sfondo[7] = "http://i35.tinypic.com/2iqoa0.jpg";
sfondo[8] = "http://i38.tinypic.com/29pzpkk.jpg";
sfondo[9] = "http://i34.tinypic.com/2cqz91c.jpg";
sfondo[10] = "http://i34.tinypic.com/2w7hahj.jpg";
sfondo[11] = "http://i34.tinypic.com/34rwpiv.jpg";
sfondo[12] = "http://i38.tinypic.com/2d1ofg9.jpg";
sfondo[13] = "http://i38.tinypic.com/28uxop.jpg";
sfondo[14] = "http://i37.tinypic.com/34gwy6t.jpg";
sfondo[15] = "http://i34.tinypic.com/jziaa1.jpg";
sfondo[16] = "http://i36.tinypic.com/2up3j2a.jpg";
sfondo[17] = "http://i37.tinypic.com/16j319d.jpg";
sfondo[18] = "http://i37.tinypic.com/1zyheg8.jpg";
sfondo[19] = "http://i36.tinypic.com/ws9ves.jpg";
sfondo[20] = "http://i35.tinypic.com/289lqpx.jpg";
sfondo[21] = "http://i33.tinypic.com/2ekqhys.jpg";

// ATTENZIONE: Non modificare il codice seguente!
// (ATTENTION:  Don't edit below!)
function getCookieVal (offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
		endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}

function DispImg () {
	var expDays = 10;
	var exp = new Date(); 
	exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

	var next
	var Now = GetCookie('Now');
	if (Now != null){
		for (i=1 ; i<=num ; i++) {
			if (Now == "img" + i){
				next = sfondo[i];
				i = num;
			}
		}
	}
	else { next = sfondo[1]; }
	document.body.background = next;
}

function DispImg2 () {
	var expDays = 10;
	var exp = new Date(); 
	exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

	var next
	var Now = GetCookie('Now');
	var prev = document.bgs.image.value;
	if (Now != prev) {
		Now = document.bgs.image.value;
		SetCookie ('Now', Now, exp);
		for (i=1 ; i<=num ; i++) {
			if (Now == "img" + i){
				next = sfondo[i];
				i = num;
			}
		}
	
	}
	else { next = sfondo[1]; }
	document.body.background= next;
}


function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
			return getCookieVal (j);    
			i = document.cookie.indexOf(" ", i) + 1;    
			if (i == 0) break;   
		}  
	return null;
}

function SetCookie (name, value) {  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}

onload=DispImg