var dc_count = 1;
var http_request = new Array();
var handled = new Array();
var dc;
var id;
var pr;
var idd;
var ip;

function makeRequest(url, i) 
	{
 	  	if (window.XMLHttpRequest) 
			{ // Mozilla, Safari, etc.
		        http_request[i] = new XMLHttpRequest();
        		if (http_request[i].overrideMimeType) 
					{
			            http_request[i].overrideMimeType('text/xml');
			        }
			} 
		else if (window.ActiveXObject) 
			{ // IE
				try 
					{
						http_request[i] = new ActiveXObject("Msxml2.XMLHTTP");
					} 
				catch (e) 
					{
						try 
							{
								http_request[i] = new ActiveXObject("Microsoft.XMLHTTP");
							} 
						catch (e) 
							{
							}
					}
			}
 	   	if (!http_request[i]) 
	   		{
        		return false;
		    }
	    http_request[i].onreadystatechange = handleResponse;
    	http_request[i].open('GET', url, true);
	    http_request[i].send(null);
    	return true;
	}

function handleResponse() 
	{
		
    	var nr = -1;
	    for (var i = 0; i < dc_count; ++i) 
			{				
		        if ((handled[i] != true) && http_request[i] && (http_request[i].readyState == 4) && (http_request[i].status == 200)) 
					{
			            nr = i;
			            break;
			        }
		    }
	    if (nr != -1) 
			{
		        var xmldoc = http_request[nr].responseXML;
		        
						var dg = xmldoc.getElementsByTagName('dig').item(0);
						if (dg != null)
							{				
								id = dg.getElementsByTagName('id').item(0).firstChild.data;
								dc = dg.getElementsByTagName('dc').item(0).firstChild.data;
		                		pr = dg.getElementsByTagName('pr').item(0).firstChild.data;
							}								
						else						
							{
//								dc = dc + " DOWN";
	//							pr ="-";
							}
							             
		        
		        handled[nr] = true;				
		        updatePR();
		    } 
		else 
			{
		        //alert('There was a problem with the request.');
		    }
	}

function updatePR() 
	{
    //alert('id: '+id+'\nDC: '+dc+'\nPR: '+tb+'\nLivePR: '+live+'\Bigdaddy: '+bd);
    // DC
	    var dc_content = "<a ";    	
	    dc_content += "href='http://"+dc+"'>"+dc+"</a>";	   
	    // ToolBar
	    var tb_content = "";
	    if (pr != "N/A") 
			{
		        tb_content += pr;
			} 
		else 
			{
		        tb_content += "N/A&nbsp;";
		    }
		idd = parseInt(id) + 1;			
		Element.setOpacity('dc'+id, 0.0);
		Element.setOpacity('pr'+id, 0.0);
		Element.setOpacity('id'+id, 0.0);
		document.getElementById('dc'+id).innerHTML = dc_content;
	    document.getElementById('pr'+id).innerHTML = tb_content;
	    document.getElementById('id'+id).innerHTML = idd;
		Effect.Appear('dc'+id, { duration: 2 });
	    Effect.Appear('pr'+id, { duration: 2 });
	    Effect.Appear('id'+id, { duration: 2 });

	}

function dig(url, dc) 
	{
    		
		dc_count = dc.length;		
	    for (var i = 0; i < dc_count; i++) 
			{						     
				ip = dc[i];
				makeRequest('dig.php?d='+url+'&ip='+dc[i]+'&n='+i, i);
		    }
	}
