var LoadingText="<table width=\"100%\" height=\"100%\"><tr><td align=\"center\" valign=\"middle\">Loading...</td></tr></table>";
var PopulatingElement=null;

function GetXmlHttpObject(){
    var xmlHttp=null;
    try {
        xmlHttp=new XMLHttpRequest();
    } catch(e) {
        try {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        } catch(e) {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}


function PopulateElement(DivID, LoadURL){
	if (PopulatingElement!=null){
		setTimeout("PopulateElement('"+DivID+"', '"+LoadURL+"')", 10);
		return false;
	}
	PopulatingElement=document.getElementById(DivID);
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		return false;
	}
	PopulatingElement.innerHTML=LoadingText;
	xmlHttp.onreadystatechange=PopulateElementResponse;
	xmlHttp.open("GET", LoadURL, true);
	xmlHttp.send(null);
	return false;
}


function PopulateElementResponse(){
	if (xmlHttp.readyState==4){
		PopulatingElement.innerHTML= xmlHttp.responseText;
		if (document.forms.length>0){
			document.forms[0].elements[0].focus();
		}
		PopulatingElement=null;
	}
}


function NewScreen(URL, W, H){
	aWindow=window.open(URL, "" ,"width="+W+",height="+H);
	return false;
}

var CurrentSortButton=1;
function SelectSortButton(BtnNum){
	document.getElementById("SortBtn1").src="images/most_recent_btn_"+(BtnNum==1?"1":"0")+".jpg";
	document.getElementById("SortBtn2").src="images/top_rated_btn_"+(BtnNum==2?"1":"0")+".jpg";
	document.getElementById("SortBtn3").src="images/most_repeeved_btn_"+(BtnNum==3?"1":"0")+".jpg";
	CurrentSortButton=BtnNum;
}