var xmlhttp = false;                          
function getXmlHttp(){

if (typeof XMLHttpRequest != 'undefined'){
try
{
//   netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
//   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
   xmlhttp = new XMLHttpRequest();
		if (xmlhttp.overrideMimeType) {
			xmlhttp.overrideMimeType('text/xml');
		}
   // instantiate it
}
catch (err)
{
   //alert("Error initializing XMLHttpRequest.\n" + err);
   // show error
}
}
else
{
// else assume this is IE and
var msobj = new Array("Msxml2.XMLHTTP.6.0",
"Msxml2.XMLHTTP.4.0",
"Msxml2.XMLHTTP.3.0",
"Msxml2.XMLHTTP",
"Microsoft.XMLHTTP");
var x, len = msobj.length;
for(x = 0; x < len; ++ x)
{
   // try each MS ActiveX object in turn
   try
   {
      xmlhttp = new ActiveXObject(msobj[x]);
      break;
   }
   catch (err)
   {
      //alert("Error initializing XMLHttpRequest : IE : \n" + err.message);
      // show error
   }
   ;
}
}

    return xmlhttp;
}

function getHostsResultHandler() {
    if (xmlhttp.readyState == 4) {
        if(xmlhttp.status == 200) {	
            var responseData = xmlhttp.responseText;
	    eval("cbData="+responseData);
			 
             var hostsHtmlData = '<select class="inputbox" style="width:120px;" name="s2" id="s2" onChange="redirectToCurrentHost()" onfocus="window.dropdown_menu_hack(this)">';
             hostsHtmlData+= '<OPTION value="">Select Web Host</OPTION>';
             var i;
             for (i=0;i<cbData.hostsList.length;i++) {
                hostsHtmlData+="<OPTION value='" + cbData.hostsList[i][1] + "'>" + cbData.hostsList[i][0] + "</OPTION>"; 
             }
             hostsHtmlData+= '<OPTION value="0000">All Web Hosts</OPTION></SELECT>';
             hostsHtmlData+= '<INPUT type="image" src="http://www.hostdiscussion.com/images_hd/misc/images_hd/button_findhost.gif" name="Button1" value="Go" class="inlineimg />';
             hostsHtmlData+= '<INPUT type="image" src="http://www.hostdiscussion.com/images_hd/misc/images_hd/button_findhost.gif" name="Button1" value="Go" class="inlineimg" onclick="redirectToHostsList()"/>';
             document.getElementById("searchByHost").innerHTML = hostsHtmlData;
             


             var hostTypesHtmlData = '<select class="inputbox" style="width:120px;" name="s3" id="s3" onChange="redirectToCurrentHostType()" onfocus="window.dropdown_menu_hack(this)">';

             hostTypesHtmlData += '<OPTION value="">Select Hosting Type</OPTION>';
             for (i=0;i<cbData.hostTypesList.length;i++) {
                hostTypesHtmlData+="<OPTION value='" + cbData.hostTypesList[i][1] + "'>" + cbData.hostTypesList[i][0] + "</OPTION>"; 
             }
             hostTypesHtmlData+='<OPTION value="0000">All Hosting Types</OPTION></SELECT>';   
             hostTypesHtmlData+='<input type="image" src="http://www.hostdiscussion.com/images_hd/misc/images_hd/button_findhost.gif" class="inlineimg" value="Search" onclick="redirectToHostsList()"/>';
             document.getElementById("searchByType").innerHTML = hostTypesHtmlData;
        }
    }
}

function redirectToHostsList() {
    window.location="http://www.findmyhost.com/reportcards.aspx";
}

function redirectToCurrentHost() {
    window.location="http://www.findmyhost.com/reviews/"+document.f2.s2.options[document.f2.s2.selectedIndex].value+".aspx";
}

function redirectToCurrentHostType() {
    window.location="http://www.findmyhost.com/webhost_powersearch.aspx?type="+document.f3.s3.options[document.f3.s3.selectedIndex].value;
}

function getHostsList() {
var path = '/handler.ashx?method=getHosts&+?r='+Math.random();
    var hostReq = getXmlHttp();
    hostReq.open('GET', 'http://www.hostdiscussion.com/hostlist_service.php?yws_path=' + encodeURIComponent(path), true);
    hostReq.onreadystatechange = getHostsResultHandler;
    hostReq.send(null);
}
