	var aRequestedSelects = Array();
	function fetchSelect(obj, xml, redirect){
		obj.style.display = '';
		if(aRequestedSelects[xml] != true){
			option = document.createElement('div')
			option.appendChild(document.createTextNode('Loading...'))
			option.className = 'myOption'
			obj.appendChild(option)
			
			httpRequest = prepareHTTPRequest()
			httpRequest.onreadystatechange = function() { 
				if (httpRequest.readyState == 4){
					if (httpRequest.status == 200){
						try{
							obj.removeChild(option);
						
							aGames = httpRequest.responseXML.getElementsByTagName('g')
							for(var i = 0;i < aGames.length;i++){
								option = document.createElement('div')
								option.setAttribute('id', 	getChildElementText(aGames[i], 'i'))
								option.onclick = function(){
									window.location = redirect+this.id
								}
								option.onmouseover = function(){
									this.style.backgroundColor = "#0A246A";
									this.style.color = "#FFFFFF";
								}
								option.onmouseout = function(){
									this.style.backgroundColor = "";
									this.style.color = "#000000";
								}
								option.className = 'myOption'
								option.appendChild(document.createTextNode(getChildElementText(aGames[i], 'n')))
								obj.appendChild(option)
							}
						}catch(e){alert('Error:' + e)}
					}
				}
			}
			httpRequest.open('GET', xml, true);
			httpRequest.send(null);
			aRequestedSelects[xml] = true
		}
	}
	function prepareHTTPRequest(){
		var HttpRequest;
		if (window.XMLHttpRequest) { // Mozilla, Safari, ...
			HttpRequest = new XMLHttpRequest();
			if (HttpRequest.overrideMimeType) {
				HttpRequest.overrideMimeType('text/xml');
				// See note below about this line
			}
		} 
		else if (window.ActiveXObject) { // IE
			// assume IE6 or older
			var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
											"MSXML2.XMLHTTP.5.0",
											"MSXML2.XMLHTTP.4.0",
											"MSXML2.XMLHTTP.3.0",
											"MSXML2.XMLHTTP",
											"Microsoft.XMLHTTP");
			// try every prog id until one works
			for (var i=0; i<XmlHttpVersions.length && !HttpRequest; i++){
			  try{ 
				// try to create XMLHttpRequest object
				HttpRequest = new ActiveXObject(XmlHttpVersions[i]);
			  }catch (e){} // ignore potential error
			}
		}

		if (!HttpRequest){
			alert('Cannot create an XMLHTTP instance');
			return false;
		}
		return HttpRequest;
	}
	function getChildElementText(parentNode, childTagName){
        try {
			var childTag = parentNode.getElementsByTagName(childTagName);
			var out = document.createTextNode(childTag[0].firstChild.nodeValue).data;
			return out == "undefined" ? false : out;
		}catch(e){
			return false;
		}
	}
	function getClickedElement(e){
		 if(!e)e = window.event;
		 return e.target ? e.target : e.srcElement;
	}	
	function hideObjects(e){
		hideMySelect(getClickedElement(e))
	}
	function hideMySelect(elemClicked){
		if(elemClicked.id != 'mySelectWrapper' && elemClicked.id != 'mySelectImg' && elemClicked.id != 'mySelectResults')
			document.getElementById('mySelectResults').style.display = 'none'
	}
	document.onclick = hideObjects
