function rimuovi(s) {
	var l = document.getElementsByTagName('LI');
	var replaceStr = "";
	var re = s;
	for(i=0; i<l.length; i++) {
		l[i].className = l[i].className.replace(re , replaceStr);
	}
}

// Returns an XmlHttpRequestObject, or boolean 'false' on failure
function getXHRObject () {
	var obj = false;
	try {obj = new ActiveXObject("Msxml2.XMLHTTP");}
	catch (e) {
		try {obj = new ActiveXObject("Microsoft.XMLHTTP");}
		catch (e) {
			try {obj = new XMLHttpRequest();}
			catch (e) {return false;}
		}
	} return obj;
}

function sendRequest (id) {
	// Create the XmlHttpRequest object
	var xhr = getXHRObject();
	// Make sure the object was created successfully
	if (xhr){
		var sito = document.getElementById('sito').value;
		var file = sito + "virtual.php?sez="+id;
		// Open an asynchronous connection to the server, requesting page "test.php" with "get" method
		xhr.open("get", file, true);
		// Response is received by browser from server
		xhr.onreadystatechange = function () {
			if (xhr.readyState == 1) {}
			if (xhr.readyState == 4) {
				// Make sure server returned status code 200 (200 = OK, 404 = Page not Found, ...)
				if (xhr.status == 200) {
					// Simply alert what the server returned to us for now
					document.getElementById('widthbox').innerHTML = xhr.responseText;
					tit[0] = id;
					switch (id) {
						case "albero":
							vedi(0);
						break;
						case "anubi":
							vedi(5)
						break;
						case "murena":
							vedi(10);
						break;
						case "ripple":
							vedi(15);
						break;
						case "yacht":
							vedi(20);
						break;
						case "morgan":
							vedi(25);
						break;
					}
				}
			}
		};
		// Send the request
		xhr.send(null);
	}
}

function vedi(thisid) {
	thiswidth = imggallery[thisid][1];
	thisheight = imggallery[thisid][2];
	thispos = imggallery[thisid][8];
	getstarted(Number(thiswidth), Number(thisheight), 'imgloader', Number(thispos), Number(thispos), current_imgid);
}

function ff() {
	checkbutton(addposition('minus'));
	movethumbs('plus');
}

function rw() {
	checkbutton(addposition('plus'));
	movethumbs('minus');
}

window.onload = function() {
	var u = document.getElementsByTagName('UL');
	var m = document.getElementsByTagName('LI');
	var l = document.getElementsByTagName('A');
	var s = "sel "
	var c = new Array();
	
	for (var i=0; i<l.length; i++) {
		if (l[i].className == "ext") {
			l[i].target = "_blank";
		}
		if (l[i].href == document.baseURI) {
			l[i].href = "javascript:void(null);"
		}
	}	

	for(var i=0; i<u.length; i++) {
		switch (u[i].id) {
		case "vs":
			for(var i=0; i<m.length; i++) {
				m[i].onclick = function() {
					rimuovi(s);
					sendRequest(this.title)
					this.className = s + this.className;
				}
			}
		break;
		}
	}
	sendRequest("morgan")
	loadfirstimage();
}
