var TargettedCampaignBanner = {
	initialize : function(container) {
		
		this.container = container;
		this.ajaxUpdateHandler = this.ajaxUpdate.bind(this);
		
		var cookies = new CookieManager();
		this.partnerId = cookies.getValueIgnoreCase('s_campaign');
		/*
		//Override partner id and show repeat banner if the users first visit was X days ago.
		
		//Never expires.  Lets us know they've been here before.
		this.repeatVisit = cookies.getValueIgnoreCase('repeatVisit');
		
		//Expires with session.  Prevents showing repeat visitor banner on initial visit of site.
		this.firstVisit = cookies.getValueIgnoreCase('firstVisit');
		
		//Expires in X amount of days.
		this.showRepeatBanner = cookies.getValueIgnoreCase('showRepeatBanner');
		
		//Check if they've been here before, and make sure this isn't their first visit.
		if (this.repeatVisit == "Y" && this.firstVisit != 'Y') {
			//Check to see if their first visit was less than X days ago. 
			if (this.showRepeatBanner == 'Y') {
				this.partnerId = 'RepeatVisitor';
			}
		} else {
			cookies.setCookie("repeatVisit","Y",2000,siteDomain);
			cookies.setCookie("firstVisit","Y",1,siteDomain);
			cookies.setCookie("showRepeatBanner","Y",7,siteDomain);
		}
		*/
		if (this.partnerId) {
		    if (window.location.href.indexOf('https') != 0) {
		        this.url = '/WebServices/RenderControls.aspx?control=TargettedCampaignBanner&configuration=' + this.partnerId;
		    }
		    else {
		        this.url = '/WebServices/RenderControlsSecure.aspx?control=TargettedCampaignBanner&configuration=' + this.partnerId;
		    }
		    this.ajaxUpdateHandler();
		}
	},

	ajaxUpdate : function() {
		new Ajax.Request(this.url, {
			onComplete : function(transport) {
				var result = RemoveScriptFromAjaxResponse(CleanAjaxResponse(transport.responseText));
				if(transport.status == 200) {
					this.container.update(result);
				} 
			}.bind(this),
			method:'get'
		});
	}
};
