function SwapImage(new_image_id) {

	var mycontainerx = 300;
	var mycontainery = 225;

	myimage = dynimages[new_image_id];

	var my_image_container = document.getElementById('image_container_inner');

	myimagex = dynimages[new_image_id].width;
	myimagey = dynimages[new_image_id].height;

	if(myimagex<myimagey) {
		newx = parseInt(mycontainery*(myimage.width/myimage.height));
		newy = mycontainery;
		posx = (mycontainerx-newx)/2;
		posy = 0;
	} else {
		newx = mycontainerx;
		newy = parseInt(mycontainerx*(myimage.height/myimage.width));
		posx = 0;
		posy = 0;
	}
	document.current_image.src = dynimages[new_image_id].src;
	document.current_image.style.height = newy+'px';
	document.current_image.style.width = newx+'px';
	my_image_container.style.left = posx+'px';
	my_image_container.style.top = posy+'px';
	my_image_container.style.height = newy+'px';
	my_image_container.style.width = newx+'px';

}

function SwapImageBig(new_image_id) {

	var mycontainerx = 600;
	var mycontainery = 450;

	myimage = dynimages[new_image_id];

	var my_image_container = document.getElementById('image_container_inner_big');

	myimagex = dynimages[new_image_id].width;
	myimagey = dynimages[new_image_id].height;

	if(myimagex<myimagey) {
		newx = parseInt(mycontainery*(myimage.width/myimage.height));
		newy = mycontainery;
		posx = (mycontainerx-newx)/2;
		posy = 0;
	} else {
		newx = mycontainerx;
		newy = parseInt(mycontainerx*(myimage.height/myimage.width));
		posx = 0;
		posy = 0;
	}
	document.current_image_big.src = dynimages[new_image_id].src;
	document.current_image_big.style.height = newy+'px';
	document.current_image_big.style.width = newx+'px';
	my_image_container.style.left = posx+'px';
	my_image_container.style.top = posy+'px';
	my_image_container.style.height = newy+'px';
	my_image_container.style.width = newx+'px';;

}

/*function addLoadEvent(func) {
	var oldonload = window.onload;

	if (typeof window.onload != "function") {
		window.onload = func;
	} else {
		window.onload = function () {
			oldonload();
			func();
		}
	}
}
addLoadEvent( function () { self.focus(); });
*/

var xmlhttp = null;
var target_url = "";

function retrieveUrl(url) {
	target_url = url;
	try{xmlhttp = new XMLHttpRequest();}
	catch(trymicrosoft){
		try{xmlhttp = new ActiveXObject("Msxm12.XMLHTTP");}
		catch(othermicrosoft){
			try{xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
			catch(fail){xmlhttp = null;}
		}
	}
	if(xmlhttp == null){alert("Error creating XMLHttpRequest!");}
	if(xmlhttp) {
		try{
			xmlhttp.open('GET', url, true);
			xmlhttp.onreadystatechange = lstURLresponse; //on state change load the response?>
		    xmlhttp.send(null);
	    } catch(err){
			//alert(err);
		}
	}
}

function lstURLresponse() {
	if (xmlhttp.readyState == 4 && xmlhttp.responseXML) {
		var xmlDocument = xmlhttp.responseXML;
    	var xml_message = xmlDocument.getElementsByTagName('results').item(0).firstChild.data;
    	document.getElementById('saved-favorites-holder').innerHTML = xml_message;
	}
}
