var _baseURL="/_proc/ad_display_controller_limit_number.jsp";

function AdManager(ad_location,url,slots){
	this.slots=slots;
	this.ad_loc=ad_location;
	//temp_loc=(document.location+"").substring("8");
	temp_loc=document.location.pathname;
	
	//this.url=temp_loc;
	if(url==null || url==''){
  		this.url=temp_loc;
	}else{
		this.url=url;
  	}
	this.title=document.title;
  	//alert(this.title);
	this.getAds=_getAds;
	//alert(this.url);
}


function _getAds(){
  try{	
  	var querystring=''
  	try{
    		querystring=location.search.substring(1,location.search.length);
  	}catch(error){ }
  	//alert(querystring);
	//prompt("username",_baseURL+"?slots="+this.slots+"&pageTitle="+this.title+"&url="+this.url+"&location="+this.ad_loc+"&"+querystring,"ad_loc_"+this.ad_loc);
	_loadXMLDoc(_baseURL+"?slots="+this.slots+"&pageTitle="+this.title+"&url="+this.url+"&location="+this.ad_loc+"&"+querystring,"ad_loc_"+this.ad_loc);
  }catch(loadError){  }
}


function _loadXMLDoc(url, locationDiv) 
{
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        var req = new XMLHttpRequest();
        req.onreadystatechange = function() { _processReqChange(locationDiv, req); }
        req.open("GET", url, true);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        var req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function() { _processReqChange(locationDiv, req); }
            req.open("GET", url, true);
            req.send();
        }
    }
}

function _processReqChange(locationDiv, req) 
{
    // only if req shows "complete"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
			var res=req.responseText;
			var res=res.replace(/\s/g, '');
			
			if(res!='' && res!="<!--0-->"){
			//	alert("Ad=" + res +"*");
				document.getElementById(locationDiv).innerHTML=req.responseText;	    
			}
			
        } else {
            // alert("There was a problem retrieving the XML data:\n" + req.statusText);
        }
    }
}

