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';

}

//START----> ADDED for YouTube support: 1/21/2010 ELH
google.load("swfobject", "2.1");
// This function is automatically called by the player once it loads
function onYouTubePlayerReady(playerId) 
{   ytplayer = document.getElementById("ytPlayer");     }

// The "main method" of this sample. Called when someone clicks "Run".
function loadPlayer(tempVideoId) 
{
  // The video to load
  var videoID = tempVideoId;
  // Lets Flash from another domain call JavaScript
  var params = { allowScriptAccess: "always"};
  // The element id of the Flash embed
  var atts = { id: "ytPlayer" };
  // All of the magic handled by SWFObject (http://code.google.com/p/swfobject/)
  swfobject.embedSWF("http://www.youtube.com/v/" + videoID + "&enablejsapi=1&playerapiid=player1&fs=1&rel=0",
                     "videoDiv", "298", "194", "8", null, null, params, atts);
}

function SwapImageYouTube(new_image_id)
{     
    var mycontainerx = 300;
	var mycontainery = 225;

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

    myimage = dynimages[new_image_id];
	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;
	}
    
    
    if(youTubeShow == 1)
    {
        if(new_image_id != 1)
        {
            document.getElementById("imageDiv").style.display = "";
            
            if(navigator.appName == "Microsoft Internet Explorer")
            {   document.getElementById("outerVideoDiv").style.display = "none";  }
            else
            {
                document.getElementById("outerVideoDiv").style.textIndent = "-5000px";
                document.getElementById("outerVideoDiv").style.height = "0px";
                document.getElementById("outerVideoDiv").style.width = "0px";    
            }
            
            document.getElementById("current_image").src = dynimages[new_image_id].src;
        	document.getElementById("current_image").style.height = newy + "px";
        	document.getElementById("current_image").style.width = newx + "px";
            
            my_image_container.style.height = newy + "px";
            my_image_container.style.width = newx + "px"; 
        }    
        else if(new_image_id == 1)
        {
            document.getElementById("imageDiv").style.display = "none";
            document.getElementById("outerVideoDiv").style.textIndent = "";
            
            if(navigator.appName == "Microsoft Internet Explorer")
            {   document.getElementById("outerVideoDiv").style.display = "";  }
            else
            {
                document.getElementById("outerVideoDiv").style.textIndent = "";
                document.getElementById("outerVideoDiv").style.height = "194px";
                document.getElementById("outerVideoDiv").style.width = "298px";    
            }
            
            my_image_container.style.height = "194px";
            my_image_container.style.width = "300px";     
        }
    }
    else
    {
        document.getElementById("current_image").src = dynimages[new_image_id].src;
       	document.getElementById("current_image").style.height = newy + "px";
        document.getElementById("current_image").style.width = newx + "px";
            
        my_image_container.style.height = newy + "px";
        my_image_container.style.width = newx + "px";    
    }
    
	my_image_container.style.left = posx + "px";
	my_image_container.style.top = posy + "px";
}
//END----> ADDED for YouTube support: 1/21/2010 ELH

/*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;
	}
}