var _baseURL="/_proc/ad_display_controller_limit_number.jsp";

function AdManager(ad_location,url,slots){
	//alert(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);
            //querystring=location.pathname;
            //alert("addisplayfunctions querystring: " + querystring);
  	}catch(error){ }
  	//alert(querystring);
	//document.write(_baseURL+"?slots="+this.slots+"&pageTitle="+this.title+"&url="+this.url+"&location="+this.ad_loc+"&"+querystring);
    //alert(_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) 
{
    //alert("locationDiv: " + locationDiv);
	//alert("url: " + url);    
    // branch for native XMLHttpRequest object
    //alert("locationDiv: " + locationDiv);
    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"
	//alert("ok");
        if (req.status == 200) {
     //  alert("locationDiv: " + locationDiv);
          var ld = document.getElementById(locationDiv);
        // alert(req.responseText);
          if (ld != null) {
			var res=req.responseText;
			var res=res.replace(/\s/g, '');
			
			if(res!='' && res!="<!--0-->"){
			//	alert("Ad=" + res +"*");
				ld.innerHTML=req.responseText;	    
			}
			
          }
        } else {
          //   alert("There was a problem retrieving the XML data:\n" + req.statusText);
        }
    }
}

