var img2;

String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}


function getImage(){

xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
//alert("get1");	
	var url="getKey.jsp";
	xmlHttp.onreadystatechange=imgResponse;  
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function imgResponse(){
	if (xmlHttp.readyState==4)// ajax return value on the process status. 4 is success.
		{ 
		img=xmlHttp.responseText;
var s = new String(img);

img=s.trim();
//alert("img:"+img);
		setTimeout('function2();', 100);
		}
	}
	
function function2(){


	document.getElementById("scrambledImage2").src= "getRandomImage.jsp?key="+img;
}
	
function getImage2(){
//alert("get2");	

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="getKey.jsp";
	xmlHttp.onreadystatechange=imgResponse2;  
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function imgResponse2(){
	if (xmlHttp.readyState==4)// ajax return value on the process status. 4 is success.
		{ 
		img2=xmlHttp.responseText;

var s = new String(img2)

img2=s.trim();
//alert("img2:"+img2);
		setTimeout('function22();', 100);
		}

}
	
function function22(){

	document.getElementById("scrambledImage").src= "getRandomImage.jsp?key="+img2;
} 	
