function doNon() {}

function wopen(url, name, w, h)
{
// Fudge factors for window decoration space.
 // In my tests these work well on all platforms & browsers.
w += 32;
h += 96;
 var win = window.open(url,
  name, 
  'width=' + w + ', height=' + h + ', ' +
  'location=no, menubar=no, ' +
  'status=no, toolbar=no, scrollbars=no, resizable=no');
 win.resizeTo(w, h);
 win.focus();
}

function showItem(item) {
	var total = nr[item];
	var a = document.getElementById("imageLink");
	while (a.firstChild) {
		a.removeChild(a.firstChild);
	}
	var img = document.createElement("img");
	img.setAttribute("id", "red_image");

	var aNavi = document.getElementById("nextLink");
	var navi = document.createElement("img");
	navi.setAttribute("id", "navi_div");

	aNavi.appendChild(navi);
	a.appendChild(img);

	if (total == 1) {
		navi.setAttribute("src", "navi_nuoli_inactive.png");
		if (item != "taulu" && item != "peili_oikea" && item != "kissa") {
			img.setAttribute("src", "tuotekuvat/"+item+"/1.jpg");
			a.setAttribute("onclick", "wopen('tuotekuvat/"+item+"/iso_1.jpg', 'popup', 500, 500); return false;");
		} else if (item == "taulu") {
			img.setAttribute("src", "tuotekuvat/"+item+"/1.png");
			a.setAttribute("onclick", "doNon()");
			//a.removeAttribute("href");
		} else {
			img.setAttribute("src", "tuotekuvat/"+item+"/1.jpg");
			a.setAttribute("onclick", "doNon()");
		}
	} else if (total > 1) {
		img.setAttribute("src", "tuotekuvat/"+item+"/1.jpg");
		a.setAttribute("onclick", "wopen('tuotekuvat/"+item+"/iso_1.jpg', 'popup', 500, 500); return false;");
//		a.setAttribute("href", "tuotekuvat/"+item+"/iso_1.jpg");
		navi.setAttribute("src", "navi_nuoli.png");
	}
	writeItemText(item);
}

function nextImg() {
	var item = document.getElementById("red_image").getAttribute("src").split(".")[0].split("/")[1];
	if (item != "taulu") {
		var number = document.getElementById("red_image").getAttribute("src").split(".")[0].split("/")[2];
		var total = nr[item];
		if (number < total) {
			var newNr = ++number;
			document.getElementById("red_image").setAttribute("src", "tuotekuvat/"+item+"/"+newNr+".jpg");
			document.getElementById("imageLink").setAttribute("onclick", "wopen('tuotekuvat/"+item+"/iso_"+newNr+".jpg', 'popup', 500, 500); return false;");
		}
		else if (number == total) {
			document.getElementById("red_image").setAttribute("src", "tuotekuvat/"+item+"/1.jpg");
			document.getElementById("imageLink").setAttribute("onclick", "wopen('tuotekuvat/"+item+"/iso_1.jpg', 'popup', 500, 500); return false;");
		}
	}
}

function writeItemText(item) {
	var textBox = document.getElementById("red_text")
	while (textBox.firstChild) { 
		textBox.removeChild(textBox.firstChild);
	}
	var h1 = document.createElement("h1");
	h1.setAttribute("class", "red");
	h1.innerHTML=otsikko[item];
	//alert(h1.innerHTML);
	textBox.appendChild(h1);
	
	var p = document.createElement("p");
	p.setAttribute("class", "red");
	p.innerHTML=text[item];
	//alert(p.innerHTML);
	textBox.appendChild(p);
	
}

var nr= new Array();
nr['ovi'] = 3;
nr['verho'] = 5;
nr['lipasto'] = 3;
nr['maja'] = 4;
nr['grilli'] = 4;
nr['kissa'] = 1;
nr['naulakko'] = 4;
nr['peili_oikea'] = 1;
nr['poyta'] = 5;
nr['taulu'] = 1;



var text= new Array();
text['ovi'] = "Other stuff we have designed:<ul><li>Naulikko coat rack for Selki Asema</li><li>Sein&auml;ruusu ryijy rug for Friends of Finnish Handicraft</li><li>Nappi sofa with Saara Renvall for Suomi Soffa</li></ul>";
text['verho'] = "A series of perforated black out curtains with city views of Paris, Tokyo, Helsinki, Berlin and Stockholm. Manufactured by Iuk Box <br/><a target='blank' href='http://www.iukbox.com'>www.iukbox.com</a>";
text['lipasto'] = "A cabinet of suitcases. Prototype, available by order.";
text['maja'] = "A modular children's bed inspired by treehouses. Prototype.";
text['grilli'] = "A portable gas grill for urban picnics. Manufactured by Selki Asema <br/><a target='blank' href='http://www.selki-asema.fi'>www.selki-asema.fi</a>";
text['kissa'] = 'Amos Aalto & Elis Aalto watching TV inside Saara Renvall\'s "Piilo" container.';
text['naulakko'] = "A coat rack inspired by antennas. The hooks rotate freely and can be arranged in any position. Available as a free standing and a wall mounted version. Manufactured by Selki Asema<br/><a target='blank' href='http://www.selki-asema.fi'>www.selki-asema.fi</a>";
text['peili_oikea'] = "Our MAJA bed will be shown as a part of the Hirameki exhibition in Tokyo, Japan from October 29th to November 7th at Living Design Center Ozone. Welcome!<br/><a target='blank' href='http://www.hiramekidesign.com'>www.hiramekidesign.com</a>";
text['poyta'] = "A table with folding legs which can be hung on the wall as a picture when not in use. Manufactured by Selki Asema <br/><a target='blank' href='http://www.selki-asema.fi'>www.selki-asema.fi</a>";
text['taulu'] = "Klaus Aalto dreams of becoming Finland's fencing champion.<br/><br/>Elina Aalto battles between being an antimaterialist and at the same time loving well designed things.";
//who is comfortable when she has no money and too much to do and accordingly becomes anxious when she has too much money and free time. She enjoys picking mushrooms and cooking on a wood heated stove.
//He is a keen recycler who battles between being an antimaterialist but at the same time loving well designed things.

var otsikko= new Array();
otsikko['ovi'] = "OTHER STUFF";
otsikko['verho'] = "BETTER VIEW";
otsikko['lipasto'] = "TAKE OUT";
otsikko['maja'] = "MAJA";
otsikko['grilli'] = "CITY BOY PICNIC GRILL";
otsikko['kissa'] = "FRIENDS";
otsikko['naulakko'] = "5.2 Mhz";
otsikko['peili_oikea'] = "NEWS - HIRAMEKI Design x Finland";
otsikko['poyta'] = "STEREO";
otsikko['taulu'] = "AALTO + AALTO";

var linkki= new Array();
linkki['ovi'] = "www.selki-asema.fi";
linkki['verho'] = 5;
linkki['lipasto'] = 3;
linkki['maja'] = 4;
linkki['grilli'] = 4;
linkki['kissa'] = 1;
linkki['naulakko'] = 4;
linkki['peili_oikea'] = 1;
linkki['poyta'] = 5;
linkki['taulu'] = 1;

