
function NewsToteAdServerClass()
{
	this.index = -1;
	this.adServer = "/shared/Tools/AdServer.aspx";
	this.adZoneGuid = "";
	this.adZoneID = "";
	this.adZoneName = "";
	this.adGroup = "";
	this.mediaAdID = -1;
	this.isPreview = false;
	this.ignorImpression = false;
	this.siteID = "";
	this.sID = "";
	this.towns = "";
	this.regions = "";
	this.states = "";
	this.tagSetIDs = "";
	this.width = 0;
	this.height = 0;
	this.overflow = "";
	
	this.AddTown = function(town)
	{
	}
	
	this.AddRegion = function(region)
	{
	}
	
	this.AddStates =function(state)
	{
	}
	
	this.AddTagSetID =function(tagSetID)
	{
	}
	
	this.loadAd = function()
	{
		document.write("<div id='NewsToteAd"+this.index+"' style='overflow:"+this.overflow+";width:"+this.width+"px;height:"+this.height+"px;'>&nbsp;</div>");

		this.NewsToteXmlHttp=this.GetXmlHttpObject();
		if (this.NewsToteXmlHttp==null)
		  {
		  //alert ("Your browser does not support AJAX!");
		  return;
		  } 
		var url = this.adServer+"?rand"+Math.random();
		var params = "adServer="+escape(this.adServer)+"&";
		params += "adZoneID="+escape(this.adZoneID)+"&";
		params += "adZoneGuid="+escape(this.adZoneGuid)+"&";
		params += "adZoneName="+escape(this.adZoneName)+"&";
		params += "adGroup="+escape(this.adGroup)+"&";
		params += "mediaAdID="+escape(this.mediaAdID)+"&";
		params += "isPreview="+escape(this.isPreview)+"&";
		params += "ignorImpression="+escape(this.ignorImpression)+"&";
		params += "siteID="+escape(this.siteID)+"&";
		params += "towns='"+escape(this.towns)+"'&";
		params += "regions='"+escape(this.regions)+"'&";
		params += "states='"+escape(this.states)+"'&";
		params += "tagSetIDs='"+escape(this.tagSetIDs)+"'&";
		params += "sID="+escape(this.sID)+"&";
		params += "width="+escape(this.width)+"&";
		params += "height="+escape(this.height);
		
		try
		{
		    this.NewsToteXmlHttp.onreadystatechange = new Function("eval('NewsToteAdServer.ads["+this.index+"].stateChanged()')");
		    this.NewsToteXmlHttp.open("Post",url,true);
		    this.NewsToteXmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		    this.NewsToteXmlHttp.setRequestHeader("Content-length", params.length);
		    this.NewsToteXmlHttp.setRequestHeader("Connection", "close");
		    this.NewsToteXmlHttp.send(params);
		}
		catch (e)
		{
		    document.getElementById("NewsToteAd"+this.index).innerHTML = "(Mozilla) - " + e;
		}
	}

	this.GetXmlHttpObject = function()
		{
		var xmlHttp=null;
		try
		  {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp=new XMLHttpRequest();
		  }
		catch (e)
		  {
		  // Internet Explorer
		  try
			{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
		  catch (e)
			{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		  }
		return xmlHttp;
	}
	
	this.stateChanged = function(tt) 
	{
		if (this.NewsToteXmlHttp.readyState==4 && this.NewsToteXmlHttp.responseText.length > 0)
		{ 
			document.getElementById("NewsToteAd"+this.index).innerHTML = this.NewsToteXmlHttp.responseText;
		}
	}
}
	
function NewsToteAdServerManager()
{
	this.ads = new Array();
	this.randID = Math.random();
	
	this.NewAd = function()
	{
		var ad =  new NewsToteAdServerClass();
		ad.index = this.ads.length;
		this.ads[this.ads.length] = ad;
		return ad;
	}
	
	this.currentAd = function()
	{
		return this.ads[this.ads.length - 1];
	}
}



var NewsToteAdServer = new NewsToteAdServerManager();

