function prepare_code4image(img_src1) {
	return "<img src='"+img_src1+"' border=\"0\">";
}

function prepare_code4generichtml(img_src1) {
	return "<table>"+img_src1+"</table>";
}

function create_invisible_layer(i, name, code, start_x, start_y) {
	if (ns4up) {                      // set layers
		document.write("<layer name=\""+name+"\" left='"+start_x+"' top='"+start_y+"' visibility=\"hide\">"+code+"<\/layer>");
	} else {
		if (ie4up||ns6up) {
			document.write("<div id=\""+name+"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: hidden; TOP: "+start_y+"px; LEFT: "+start_x+"px;\">"+code+"<\/div>");
		}
	}
}
	
function swap_visibility_NS_2(img1, visibility) {  // Netscape main animation function
	if (visibility == 0) {		
		//document.layers[img1].top = Math.random()*(doc_height-200);
		//document.layers[img1].left = Math.random()*(doc_width-200);			
		document.layers[img1].visibility = 'show';
	} else
		document.layers[img1].visibility = 'hide';
	//visibility = 1 - visibility;			
	//setTimeout("swap_visibility_NS_2('"+img1+"')", 1000);	  
}

function swap_visibility_IE_NS6_2(img1, visibility) {  // IE and NS6 main animation function
	if (visibility == 0) {
		/*
		if (ie4up){			
			document.all[img1].style.pixelTop = Math.random()*(doc_height-200);
			document.all[img1].style.pixelLeft = Math.random()*(doc_width-200);
		}
		else if (ns6up){
			document.getElementById(img1).style.top=Math.random()*(doc_height-200);
			document.getElementById(img1).style.left=Math.random()*(doc_width-200);
		} 		
		*/
		document.getElementById(img1).style.visibility='visible';
	} else
		document.getElementById(img1).style.visibility='hidden';
	//visibility = 1 - visibility;
	//setTimeout("swap_visibility_IE_NS6_2('"+img1+"')", 1000);	  
}

function next_step(step) {
	if (enable == 0)
		return;
		
	if (step == 1) {
		document.getElementById('portfolio').innerHTML=prepare_code4generichtml(uno);
		setTimeout("next_step('2')", 5000);			
	}
	if (step == 2) {
		document.getElementById('portfolio').innerHTML=prepare_code4generichtml(due);
		setTimeout("next_step('3')", 5000);			
	}	
	if (step == 3) {
		document.getElementById('portfolio').innerHTML=prepare_code4generichtml(tre);
		setTimeout("next_step('4')", 5000);			
	}
	if (step == 4) {
		document.getElementById('portfolio').innerHTML=prepare_code4generichtml(quattro);
		setTimeout("next_step('5')", 5000);			
	}		
	if (step == 5) {
		document.getElementById('portfolio').innerHTML=prepare_code4generichtml(cinque);
		setTimeout("next_step('6')", 5000);			
	}		
	if (step == 6) {
		document.getElementById('portfolio').innerHTML=prepare_code4generichtml(sei);
		setTimeout("next_step('1')", 5000);			
	}		

}

// Main program
document.write("<br>");

// Stabilisce se il meccanismo dei ffumetti e' attivo (1) oppure no (0)
var enable = 1;

// sequenza delle imagini dei fumetti
var img_src1="images/folletto.gif";
var img_src2="images/fum1.gif";  
var img_src3="images/fum2.gif"; 

// Determina il tipo di browser
var ns4up = (document.layers) ? 1 : 0;  // browser sniffer
var ie4up = (document.all) ? 1 : 0;
var ns6up = (document.getElementById&&!document.all) ? 1 : 0;

// Determina le dimensioni della finestra
var  doc_width = 800, doc_height = 900;
if (ns4up||ns6up) {
	doc_width = self.innerWidth;
	doc_height = self.innerHeight;
} else if (ie4up) {
	doc_width = document.body.clientWidth;
	doc_height = document.body.clientHeight;
}

// PRIMA SCENA

//start_x = Math.random()*(doc_width-200)+100;
//start_y = Math.random()*(doc_height-400)+150;
start_x = (doc_width-800)/2+100;

//alert("x: "+start_x);
uno = '<tr><td align="center"><a target="_blank" href="http://fuoriporta.altervista.org"><img  ALT="Il portale delle gite fuoriporta per le famiglie con bambini" TITLE="Il portale delle gite fuoriporta per le famiglie con bambini" border="0" src="images/portfolio-fuoriporta.jpg"></a></td></tr><tr><td align=center nowrap><a target="_blank" class="nlink4" href="http://fuoriporta.altervista.org" >fuoriporta.altervista.org</a>';
due = '<tr><td align="center"><a target="_blank" href="http://www.amicatarta.net"><img  ALT="Il tuo sito sulle tartarughe" TITLE="Il tuo sito sulle tartarughe" border="0" src="images/portfolio-amicatarta.jpg"></a></td></tr><tr><td align=center nowrap><a target="_blank" class="nlink4" href="http://www.amicatarta.net">www.amicatarta.net</a>';
tre = '<tr><td align="center"><a target="_blank" href="http://www.mercatinodibusto.it"><img  ALT="Il sito per pubblicare gratutitamente annunci economici" TITLE="Il sito per pubblicare gratutitamente annunci economici" border="0" src="images/portfolio-mdb.jpg"></a></td></tr><tr><td align=center nowrap><a target="_blank" class="nlink4" href="http://www.mercatinodibusto.it" >www.mercatinodibusto.it</a>';
quattro = '<tr><td align="center"><a target="_blank" href="http://www.lemiedolomiti.net/lmd"><img  ALT="Un incredibile sito sulla Montagna" TITLE="Un incredibile sito sulla Montagna" border="0" src="images/portfolio-lemiedolomiti.jpg"></a></td></tr><tr><td align=center nowrap><a target="_blank" class="nlink4" href="http://www.lemiedolomiti.net/lmd" >www.lemiedolomiti.net</a>';
cinque = '<tr><td align="center"><a target="_blank" href="http://www.paoloevi.it"><img  ALT="Servizi fotografici professionali" TITLE="Servizi fotografici professionali" border="0" src="images/portfolio-paoloevi.jpg"></a></td></tr><tr><td align=center nowrap><a target="_blank" class="nlink4" href="http://www.paoloevi.it" >www.paoloevi.it</a>';
sei = '<tr><td align="center"><a target="_blank" href="http://www.aias-busto.it"><img  ALT="Il sito web dell\'AIAS di Busto Arsizio" TITLE="Il sito web dell\'AIAS di Busto Arsizio" border="0" src="images/portfolio-aias.jpg"></a></td></tr><tr><td align=center nowrap><a target="_blank" class="nlink4" href="http://www.aias-busto.it">www.aias&shy;busto.it</a></td></tr>';

next_step('1');

//uno = "<img   border=0 src='images/portfolio-aias.jpg'>";
//due = "<img   border=0 src='images/portfolio-aias.jpg'>";
//tre = "<img   border=0 src='images/portfolio-aias.jpg'>";

/*
create_invisible_layer (1, "aiasbusto", prepare_code4generichtml(uno), start_x, start_y); 
create_invisible_layer (2, "amicatarta", prepare_code4generichtml(due), start_x, start_y); 	
create_invisible_layer (3, "lemiedolomiti", prepare_code4generichtml(tre), start_x, start_y); 	

// FA PARTIRE L'ANIMAZIONE
next_step('1');
*/