var url = document.URL;
var ThisPage='';
var min = 4;
var max = 231;

function italiano(){
	var file_name = document.location.href;
    	var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
	var nomefile=file_name.substring(file_name.lastIndexOf("/")+1, end);
	if(nomefile==""){nomefile='index'}
	else{
		nomefile=nomefile.substring(0,nomefile.lastIndexOf("."));
		estensione=nomefile.substring(nomefile.length-2,nomefile.length);
		if(estensione=="EN" || estensione=="ES" || estensione=="FR" ){
			nomefile=nomefile.substring(0,nomefile.length-2);
		}
	}
	nomefile=nomefile+".html";
	location.href=nomefile;
}

function inglese(){
	var file_name = document.location.href;
    	var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
	var nomefile=file_name.substring(file_name.lastIndexOf("/")+1, end);
	if(nomefile==""){nomefile='index'}
	else{
		nomefile=nomefile.substring(0,nomefile.lastIndexOf("."));
		estensione=nomefile.substring(nomefile.length-2,nomefile.length);
		if(estensione=="EN" || estensione=="ES" || estensione=="FR" ){
			nomefile=nomefile.substring(0,nomefile.length-2);
		}
	}
	nomefile=nomefile+"EN.html";
	location.href=nomefile;
}

function francese(){
	var file_name = document.location.href;
    	var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
	var nomefile=file_name.substring(file_name.lastIndexOf("/")+1, end);
	if(nomefile==""){nomefile='index'}
	else{
		nomefile=nomefile.substring(0,nomefile.lastIndexOf("."));
			estensione=nomefile.substring(nomefile.length-2,nomefile.length);
		if(estensione=="EN" || estensione=="ES" || estensione=="FR" ){
			nomefile=nomefile.substring(0,nomefile.length-2);
		}
	}
	nomefile=nomefile+"FR.html";
	location.href=nomefile;
}

function spagnolo(){
	var file_name = document.location.href;
    	var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
	var nomefile=file_name.substring(file_name.lastIndexOf("/")+1, end);
	if(nomefile==""){nomefile='index'}
	else{
		nomefile=nomefile.substring(0,nomefile.lastIndexOf("."));
			estensione=nomefile.substring(nomefile.length-2,nomefile.length);
		if(estensione=="EN" || estensione=="ES" || estensione=="FR" ){
			nomefile=nomefile.substring(0,nomefile.length-2);
		}
	}
	nomefile=nomefile+"ES.html";
	location.href=nomefile;
}

function caricaImmagine(){
	if(navigator.userAgent.indexOf('MSIE')<0){
		parametri();
		document.immagineCentrale.src="Schede2009\/"+ThisPage+".jpg";
	}else{ 
		parametri();
		immagineCentrale.src="Schede2009\/"+ThisPage+".jpg";
	}
	document.getElementById('destra').style.visibility = "Visible";
	document.getElementById('sinistra').style.visibility = "Visible";
	document.getElementById('home').style.visibility = "Visible";
}
function modificaParametro(lato){
	if (lato=='destra' && ThisPage<max){ThisPage++;
	}	
	if (lato=='sinistra' && ThisPage>min){	ThisPage--;
	}
}
function cambia(lato,immagine){
	if(ThisPage>=min-1 && ThisPage<max+1){
		modificaParametro(lato);
		immagine.src="Schede2009\/"+ThisPage+".jpg";
	}
	if((ThisPage>min) && (ThisPage<max) ){
		window.setTimeout("document.getElementById('sinistra').style.visibility = 'visible'",100);
		window.setTimeout("document.getElementById('destra').style.visibility   = 'visible'",100);
		window.setTimeout("document.getElementById('home').style.visibility   = 'visible'",100);
	}else{
		if((ThisPage<=min) ){
			document.getElementById(lato).style.visibility = "hidden";
		}else{
			document.getElementById(lato).style.visibility   = "hidden";
		}
	}
}
function visualizzaFreccia(event) {

	document.getElementById('destra').style.left       = 960+'px';
	document.getElementById('sinistra').style.left     = 10+'px';
	document.getElementById('home').style.left	   = 41+'px';
	document.getElementById('destra').style.position   = "Absolute";
	document.getElementById('sinistra').style.position = "Absolute";
	document.getElementById('home').style.position 	   = "Absolute";
	document.getElementById('destra').style.top        = document.documentElement.scrollTop
	document.getElementById('sinistra').style.top      = document.documentElement.scrollTop
	document.getElementById('home').style.top          = document.documentElement.scrollTop
}
function nascondi(lato){
	//document.getElementById(lato).style.visibility="hidden";
}
function parametri(){
	var param = [], coppiaValori;
	var arrayCoppie = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
	for(var i = 0; i < arrayCoppie.length; i++)
	{
		coppiaValori = arrayCoppie[i].split('=');
		//alert('coppiaValori = '+coppiaValori);
		param.push(coppiaValori[0]);
		param[coppiaValori[0]] = coppiaValori[1];
	} 
	ThisPage=param['id'];
}

function crea_tabellaEN(){
	prodotti1= new Array("Turtle","Antares","Ufo","Sky","Thunder","Moon","Sun","Land","Bellatrix","Rain","Ciop","Ciops","Cip","Cips","Space","Vega","Sirio","Fog","Fogs","Aledan","Aledans","Storm","Alien","Teti","Pegaso","Lux","Light");
	prodotti2 = new Array("Rigel mini","Rigel maxi","Carlux","Walklux","Steplux","Waylux","Star","Urano","Saturno","Plutone","Nettuno","Drop","Cloud","Rainbow","Eclipse","Globolux","Globolight","Globolens","Cometa","Iadi","Art","Ellisse","Luna","Venere");
	numerazione1= new Array(5,8,11,14,16,18,20,22,27,30,33,36,39,45,51,61,67,73,79,85,91,97,105,112,118,125,129);
	numerazione2= new Array(132,138,145,150,155,158,162,165,169,173,177,181,187,192,198,203,205,206,207,208,219,224,226,228);
	genera_tabellaEN(prodotti1,numerazione1,'tab1',0);
	genera_tabellaEN(prodotti2,numerazione2,'tab2',prodotti1.length);
}

 function genera_tabellaEN(prodotti,numerazione,tab,incremento){
	var tabella=document.createElement("TABLE");
	var corpo=document.createElement("TBODY");
	tabella.setAttribute('width','70%');
	tabella.setAttribute('id','tabella3');
	for(var i=1;i<=prodotti.length;i++)
        {
			riga=document.createElement("TR");
			colonna=document.createElement("TD");
			colonna.setAttribute('id','etichetta');
			colonna.innerHTML="<a href=\"PaginaEN.html?id="+numerazione[i-1]+"\">"+prodotti[i-1]+"<\/a>";
			riga.appendChild(colonna);
			colonna=document.createElement("TD");
			colonna.setAttribute('id','immagine');
			colonna.innerHTML="<a href=\"PaginaEN.html?id="+numerazione[i-1]+"\">"+"<img src=\"icone2009/"+(i+incremento)+".jpg\" \/>"+"<\/a>";
			riga.appendChild(colonna);
			corpo.appendChild(riga);
         }
	 tabella.appendChild(corpo);
	 document.getElementById(tab).appendChild(tabella);
  }

 function crea_tabella(lang){
	prodotti1= new Array("Turtle","Antares","Ufo","Sky","Thunder","Moon","Sun","Land","Bellatrix","Rain","Ciop","Ciops","Cip","Cips","Space","Vega","Sirio","Fog","Fogs","Aledan","Aledans","Storm","Alien","Teti","Pegaso","Lux","Light");
	prodotti2 = new Array("Rigel mini","Rigel maxi","Carlux","Walklux","Steplux","Waylux","Star","Urano","Saturno","Plutone","Nettuno","Drop","Cloud","Rainbow","Eclipse","Globolux","Globolight","Globolens","Cometa","Iadi","Art","Ellisse","Luna","Venere");
	numerazione1= new Array(5,8,11,14,16,18,20,22,27,30,33,36,39,45,51,61,67,73,79,85,91,97,105,112,118,125,129);
	numerazione2= new Array(132,138,145,150,155,158,162,165,169,173,177,181,187,192,198,203,205,206,207,208,219,224,226,228);
	genera_tabella(prodotti1,numerazione1,'tab1',0,lang);
	genera_tabella(prodotti2,numerazione2,'tab2',prodotti1.length,lang);
	
 }
 
 function genera_tabella(prodotti,numerazione,tab,incremento,lang){
	if(lang=="IT"){lang='';}
	var tabella=document.createElement("TABLE");
	var corpo=document.createElement("TBODY");
	tabella.setAttribute('width','70%');
	tabella.setAttribute('id','tabella3');
	for(var i=1;i<=prodotti.length;i++)
        {
			riga=document.createElement("TR");
			colonna=document.createElement("TD");
			colonna.setAttribute('id','etichetta');
			colonna.innerHTML="<a href=\"Pagina"+lang+".html?id="+numerazione[i-1]+"\">"+prodotti[i-1]+"<\/a>";
			riga.appendChild(colonna);
			colonna=document.createElement("TD");
			colonna.setAttribute('id','immagine');
			colonna.innerHTML="<a href=\"Pagina"+lang+".html?id="+numerazione[i-1]+"\">"+"<img src=\"icone2009/"+(i+incremento)+".jpg\" \/>"+"<\/a>";
			riga.appendChild(colonna);
			corpo.appendChild(riga);
         }
	 tabella.appendChild(corpo);
	 document.getElementById(tab).appendChild(tabella);
  }
