// JavaScript Document
var xmlHttp = createXHRObject();

function createXHRObject(){
	var xmlHttp;
	try {
		xmlHttp = new XMLHttpRequest();
	}
	catch (e) {
		var xmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP");
		for(var i=0;i<xmlHttpVersions.length && !xmlHttp;i++){
			try {
				xmlHttp = new ActiveXObject(xmlHttpVersions[i]);	
			}
			catch (e){}
		}
	}
	if(!xmlHttp)
		alert("Error creating the XMLHttpRequest Object.");
	else return xmlHttp;
}

function sendRequest(id){
	if(xmlHttp){
		req = "wp-content/themes/soluglass/selectimage.php?id=1"+ id;
		try {
			xmlHttp.open("GET",req,true);
			xmlHttp.onreadystatechange = handleRequestStateChange;
			xmlHttp.send(null);
		}
		catch (e){
			alert("Can't connect to server:\n"+e.toString());	
		}
	}
	else {
		alert("xmlHttp object not created.");
	}
}

function getRequest(){
	loadingtext.innerHTML = "<b id='loadingtext'>Chargement image...</b>";
	if(xmlHttp.readyState==4 && xmlHttp.status==200){
		response = xmlHttp.responseText;
		//imagearea.innerHTML = response;
		alert(response);
	}
}
