
imageArray = [];
imageNum = 0;
activeImage = 0;

	imageArray.push(new Array('prodotti/Luxman_D_38u.jpg', 'Luxman D 38u'));
	
var immagini;
immagini = new Array("Luxman_D_38u.jpg");

function creaDiv() {
	padre = document.getElementById("spazio_dettaglio");
	div_uno = document.createElement("DIV");
	div_uno.setAttribute("id","img_dettaglio");
	padre.appendChild(div_uno);

	if (immagini.length > 1) {
		div_due = document.createElement("DIV");
		div_due.setAttribute("id","img_navigazione");
		padre.appendChild(div_due);
	}
}

function creaLink() {
	if (immagini.length > 1) {
		// stampo i link in basso
		nav = document.getElementById("img_navigazione");
		nav.innerHTML = "<br class='clear'/><br />Altre immagini disponibili: <strong>1</strong>. Clicca sull'immagine per visualizzarle.";
	}
}

function creaImmagine(id) {
	myImg = document.createElement("IMG");
	myImg.setAttribute("id","img_detail");
	myImg.setAttribute("src","tmb.php?img=prodotti/"+immagini[id]+"&dim=350");

	link = document.createElement("A");
	// link.setAttribute("href", "javascript:openWindow('/prodotti/"+immagini[id]+"')");
	link.setAttribute("href", "prodotti/"+immagini[id]);
	link.setAttribute("rel", "lightbox");
	link.appendChild(myImg);

	appendPoint = document.getElementById("img_dettaglio");
	appendPoint.appendChild(link);
}

function cambiaImmagine(id) {
	myImg = document.createElement("IMG");
	myImg.setAttribute("id","img_detail");
	myImg.setAttribute("src","tmb.php?img=prodotti/"+immagini[id]+"&dim=350");

	link = document.createElement("A");
	link.setAttribute("href", "javascript:openWindow('/prodotti/"+immagini[id]+"')");
	link.appendChild(myImg);

	appendPoint = document.getElementById("img_dettaglio");
	appendPoint.innerHTML = "";
	appendPoint.appendChild(link);
}

function openWindow(link, windowWidth, windowHeight) {
	var windowWidth = 800; // windowWidth + 10;
	var windowHeight = 600; // windowHeight + 10;

	var aw = (screen.availWidth - windowWidth ) / 2;
	var ah = (screen.availHeight - windowHeight) / 2;

	var winAttr = "width=" + windowWidth + ",height=" + windowHeight + ",left=" + aw + ",top=" + ah + "scrollbars=0,status=0,resizable=0";

	newWindow=window.open(link, "Anteprima", winAttr);
}

onload = function() {
	creaDiv();
	creaImmagine(0);
	creaLink();
	setTimeout('layout()',300);
	initLightbox();
}