    
    
    var handled = new Array();
    var startNum;
    var domain;
    var origPR;
    var count;
    var theURLs = 1;
    var pr;
    var nofollow;
    var anchor;
    var VER = 0; //0=FIREFOX, ETC  1=IE
    var idd;
    var anIP;
    var http_request = new Array();
    var doPR = false;;
    var doNoFollow = false;
    var doAnchor = false;
    
    var indexHighURL = 0;
    
   
    function handleBacklinkResponse() 
    	{
    		
        	var nr = -1;
    	    for (var i = 0; i < indexHighURL; ++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('smart').item(0);
    						
    						if (dg != null)
    							{				
    								//count = dg.getElementsByTagName('number').item(0).firstChild.data;
                    count = nr;
                    domain   = dg.getElementsByTagName('domain').item(0).firstChild.data;
                    pr       = dg.getElementsByTagName('pagerank').item(0).firstChild.data;                    
                    if (doAnchor)   anchor   = dg.getElementsByTagName('anchor').item(0).firstChild.data;
                    if (doNoFollow) nofollow = dg.getElementsByTagName('nofollow').item(0).firstChild.data;
                    if (nofollow == "Yes") nofollow = "<font color=red><b>Yes</b></font>";
                    else nofollow = "No";
    		            
    							}								
    						else						
    							{ 
    //								domain = domain + " DOWN";
    	//							pr ="-";
    							}
    							             
    		        
    		        handled[nr] = true;				
    		        updateBacklinkPR();
    		    } 
    		else 
    			{
    		        //alert('There was a problem with the request.');
    		    }
    	}
    	
    	function makeRequestForBacklinks(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 = handleBacklinkResponse;
        	http_request[i].open('GET', url, true);
    	    http_request[i].send(null);
        	return true;
    	}
    
    
    function updateBacklinkPR() 
    	{
        //alert('count: '+count+'\nDC: '+domain+'\nPR: '+tb+'\nLivePR: '+live+'\Bigdaddy: '+bd);
        // DC
          var allContent;
          var attnStyle;
          var cutDom;
        
          var maxSize = 70;
          if (VER == 1) maxSize = 50;
          
          if (domain.length > maxSize) {
             cutDom = domain.substring(0,maxSize) + "...";
          }
          else {
             cutDom = domain;
          }
    	    var dc_content = "&nbsp;<a ref=nofollow target=_blank ";    	
    	    dc_content += "href='"+domain+"'>"+cutDom+"</a>";	   
    	    // ToolBar
    	    var tb_content = "";
    	    
    	    if (doPR){
        	    if (pr != "N/A") 
        			{    			
        			      tb_content += "<center>"+pr+"</center>";
        		        
                    if (pr > origPR){
        		           if (VER == 1) attnStyle = " background-color: #ccff99; background-repeat: repeat;";
        		           else attnStyle = " style='background-color: #ccff99; background-repeat: repeat;'";
        		           //attnStyle = "";
        		        }
        		        else{
                       attnStyle = "";
                    }
        			} 
        		else 
        			{
        		        tb_content += "0";
        		  }
    		  }
    		  var nofollow_content=" ";
    		  if (doNoFollow){
    		      if (VER == 1) nofollow_content += "<div class=backLinks style='float:left; width:100px; "+attnStyle+"'><center>"+nofollow+"</center></div>";    		                                        
    		      else nofollow_content += "<td  class=backLinks"+attnStyle+"><center>"+nofollow+"</center></td>";
    		  }
    		  var anchor_content=" ";
    		  if (doAnchor){
    		      if (VER == 1) anchor_content += "<div class=backLinks style='float:left; width:145px; "+attnStyle+"'><center><small>"+anchor+"</small></center></div>";
    		      else anchor_content +=   "<td  class=backLinks"+attnStyle+"><center><small>"+anchor+"</small></center></td>";
    		  }
    		  
    		    //alert('count: '+count);
    		idd = parseInt(count) + 1;		
        tmp = 	'domain'+count;
        //tmpURL = 'resURL'+count;
        // tmpPR = 'resPR'+count;
          tmpNum = 'blNum'+count;
          
          var num_content = idd+startNum-1;
          
        if (VER == 1) allContent = "<div style='float:left; width:60px; "+attnStyle+"'><center>"+num_content+"</center></div><div class=backLinks style='float:left;  width:525px; "+attnStyle+"'>"+dc_content+"</div><div class=backLinks style='float:left; width:50px; "+attnStyle+"'>"+tb_content+"</div>"+nofollow_content+anchor_content;
        else          allContent = "<TD"+attnStyle+"><center>"+num_content+"</center></td><TD class=backLinks"+attnStyle+">"+dc_content+"</td><td  class=backLinks"+attnStyle+">"+tb_content+"</td>"+nofollow_content+anchor_content;
        
    		//Element.setOpacity(tmpURL, 0.0);
    		//Element.setOpacity(tmpPR, 0.0);
    		Element.setOpacity(tmpNum, 0.0);
    	//	document.getElementById(tmpURL).innerHTML = dc_content;
    	 //   document.getElementById(tmpPR).innerHTML = tb_content;
    	    document.getElementById(tmpNum).innerHTML = allContent;
    		//Effect.Appear(tmpURL, { duration: 2 });
    	  //  Effect.Appear(tmpPR, { duration: 2 });
    	    Effect.Appear(tmpNum, { duration: 2 });
    
    	}
    
    function getPRforBacklinks(urls,starting, sentPR, sentDoPR, sentDoNoFollow, sentDoAnchor, sentOrigSite) 
    	{
    	  doPR = sentDoPR;
    	  doNoFollow = sentDoNoFollow;
    	  doAnchor = sentDoAnchor;

    	  
    	  origPR = sentPR;
        startNum = starting;
    		theURLs = urls.length;
        indexHighURL = urls.length;
        
    	    for (var i = 0; i < theURLs; i++) 
    			{						     
    				aURL = urls[i];
    				makeRequestForBacklinks('prNoFollowEngine.php?domain='+aURL+'&num=0&noFollow='+doNoFollow+'&anchor='+doAnchor+'&origSite='+sentOrigSite, i);
    		  }
    	}
    	function getPRforBacklinks_SelectOnly(urls, locs, starting, sentPR, sentDoPR, sentDoNoFollow, sentDoAnchor, sentOrigSite) 
    	{
    	  doPR = sentDoPR;
    	  doNoFollow = sentDoNoFollow;
    	  doAnchor = sentDoAnchor;

    	  
    	  origPR = sentPR;
        startNum = starting;
    		theURLs = urls.length;
        indexHighURL = locs[locs.length-1]+1; 	
        	
    	    for (var i = 0; i < theURLs; i++) 
    			{						     
    				aURL = urls[i];
    				aLoc = locs[i];
    				makeRequestForBacklinks('prNoFollowEngine.php?domain='+aURL+'&num=0&noFollow='+doNoFollow+'&anchor='+doAnchor+'&origSite='+sentOrigSite, aLoc);
    		  }
    	}

