//AutoTransReview_LoadReport(TransReview_DefaultReport)


function AutoTransReview_LoadReport(reportid, reportname, lowerparam, upperparam) {
document.getElementById('TransReview_ReportName').innerHTML = reportname
document.getElementById('AutoTransReview_content').innerHTML = '<br><br><br><br><br><center><b> Loading Report ... </b></center><br><br><br><br> '
	var url = "/remote/rankings.asp"
	FetchXML(url+"?id="+reportid+"&lowerparam="+lowerparam+"&upperparam="+upperparam);
}

function FetchXML(url) {
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest) {
		XMLrequest = new XMLHttpRequest();
		XMLrequest.onreadystatechange = ParseXML;
		XMLrequest.open("GET", url, true);
		XMLrequest.send(null);
	// branch for IE/Windows ActiveX version
	} else if (window.ActiveXObject) {
		try {
			XMLrequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			XMLrequest = new ActiveXObject("Microsoft.XMLHTTP");
		}
		if (XMLrequest) {
			XMLrequest.onreadystatechange = ParseXML;
			XMLrequest.open("GET", url, true);
			XMLrequest.send();
		}
	}
}


function ParseXML() {
var html = ''

	if (XMLrequest.readyState == 4) {
		// only if "OK"
	//alert(XMLrequest.status)
		if (XMLrequest.status == 200) {
			var bb = 0
			for (i=0;i<XMLrequest.responseXML.getElementsByTagName("companyname").length;i++) {
			
				if (bb==0){
					html += "<tr><td NOWRAP>&nbsp;<a href=/company/" + FormatURL(XMLrequest.responseXML.getElementsByTagName("companyname")[i].childNodes[0].nodeValue) + ">" + XMLrequest.responseXML.getElementsByTagName("companyname")[i].childNodes[0].nodeValue + "</a></td>";
					bb=1
				} else {
					html += "<tr class=\"pageboxlight\"><td NOWRAP>&nbsp;<a href=/company/" + FormatURL(XMLrequest.responseXML.getElementsByTagName("companyname")[i].childNodes[0].nodeValue) + ">" + XMLrequest.responseXML.getElementsByTagName("companyname")[i].childNodes[0].nodeValue + "</a></td>";
					bb=0
				}
				html += "<td NOWRAP align=\"center\">" + GetStarHTML(XMLrequest.responseXML.getElementsByTagName("rating")[i].childNodes[0].nodeValue) + "</td><td align=\"right\">" + XMLrequest.responseXML.getElementsByTagName("numberreviews")[i].childNodes[0].nodeValue + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>"
			}
			if(i==0) {
				html += "<tr class=\"pageboxlight\"><td NOWRAP colspan=\"3\" align=\"center\"><b>" + XMLrequest.responseXML.getElementsByTagName("notes")[0].childNodes[0].nodeValue + "</b></td></tr>";				
				html = "<table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\"><tr><td class=\"rowth\" valign=\"bottom\">Company Name</td><td class=\"rowth\" align=\"center\" valign=\"bottom\">Rating</td><td class=\"rowth\" align=\"center\" valign=\"bottom\">" + XMLrequest.responseXML.getElementsByTagName("meantitle")[0].childNodes[0].nodeValue + "</td></tr><tr><td><img src=\"/images/01.gif\" width=\"220\" height=\"1\"></td><td><img src=\"/images/01.gif\" width=\"120\" height=\"0\"></td><td><img src=\"/images/01.gif\" width=\"75\" height=\"1\"></td></tr>" + html + "</table>"			
			} else {
					if (XMLrequest.responseXML.getElementsByTagName("notes")[0].childNodes[0] !== null) {
						html += "<tr class=\"pageboxlight\"><td colspan=\"3\" align=\"center\">" + XMLrequest.responseXML.getElementsByTagName("notes")[0].childNodes[0].nodeValue + "</td></tr>"
					}
					//alert(XMLrequest.responseXML.getElementsByTagName("notes")[0].childNodes[0])
				html = "<table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\"><tr><td class=\"rowth\" valign=\"bottom\">Company Name</td><td class=\"rowth\" align=\"center\" valign=\"bottom\">Rating</td><td class=\"rowth\" align=\"center\" valign=\"bottom\">" + XMLrequest.responseXML.getElementsByTagName("meantitle")[0].childNodes[0].nodeValue + "</td></tr><tr><td><img src=\"/images/01.gif\" width=\"220\" height=\"1\"></td><td><img src=\"/images/01.gif\" width=\"120\" height=\"0\"></td><td><img src=\"/images/01.gif\" width=\"75\" height=\"1\"></td></tr>" + html + "</table>"
			}			
			document.getElementById('AutoTransReview_content').innerHTML = html
 		} else document.getElementById('AutoTransReview_content').innerHTML = "There was an error why processing this report.  Please try a different report."
	}
}





