function BTrck(url, crb) {
	this.trk_mems = new Trck();
	this.trk_mems.initFCookie();
	var index = (this.trk_mems.creferer.indexOf(":") != -1) ? this.trk_mems.creferer.indexOf(":") + 1 : ((this.trk_mems.creferer.indexOf("%3A") != -1) ? this.trk_mems.creferer.indexOf("%3A") + 3 : -1);
	this.csrc= index != -1 ? this.trk_mems.creferer.substr(index) : '';
	if (typeof member!="undefined" && typeof profile!="undefined") {
			this.trk_mems.init(member, profile);
	}

	this.ctag='';
	this.crb=crb;
	this.urldwnld=url;

	this.openexitstatus=1;
 
	this.exitPage = function(lang, msg) {
		this.exiturl = this.trk_mems.readCookie("banner_exiturl");
		if (this.exiturl) {
			this.exiturl = unescape(this.exiturl);
		}
		if (this.openexitstatus==0 || this.exiturl=="-") return false;

		var exitsiteurl="http://banner.casinodelrio.com/cgi-bin/redir.cgi?id=N&member="+this.trk_mems.member+"&profile=exitk&lang=es";
		var exiturl = "";
		if (this.isURL(this.exiturl)) {
			if (this.exiturl.substr(0, 4) == "http") {
				exiturl=this.exiturl;
			} else {
				exiturl="http://" + this.exiturl;
			}
		} else {
			exiturl="http://www.casinobellini.com/trcpromo-"+(this.exiturl=="@" ? "campx-"+this.trk_mems.member+"-" : this.trk_mems.member+"-exitc-")+"pmail200-es";
		}

		if(confirm(msg)) {
			window.open(exitsiteurl,"","toolbar, location=yes, width=814, height=728, menubar=yes, status=yes, resizable=yes, scrollbars=yes, directories=yes");
		} else {
			window.open(exiturl,"exitwin","toolbar, location=yes, width=850, height=728, menubar=yes, status=yes, resizable=yes, scrollbars=yes, directories=yes");
		}
		return true;
	}

	this.trckImg = function(_url) {
		var url=_url+(_url.indexOf("?") == -1 ? "?": "&")+this.trk_mems.getQuery();

		try {
			var img=document.createElement('img');
			img.src = url;
			img.setAttribute('width', 0);
			img.setAttribute('height', 0);
			img=document.body.appendChild(img);
			img.style.visibility="hidden";
			img.style.display="none";
			return true;
		}
		catch (ex) { }
		return false;
	}

	this.trackImg = function()
	{

		if (this.trk_mems.readCookie('make_impr') != '') {
			return this.trckImg('http://banner.casinodelrio.com/cgi-bin/banner.cgi?id=N');
		}
	}

	this.isURL = function(str) {
		if (str == '@' || str == '-') {
			return false;
		}
		if (typeof str == "string") {
			return (str.search(/^(http:\/\/)?[a-zA-Z0-9][a-zA-Z0-9\.\-_]+/) != -1);
		} else {
			return false;
		}
	}

	this.updateRef = function(cr) {
		if (this.csrc || this.ctag || (this.crb && cr)) {
			var p= this.csrc ? 'source:'+escape(this.csrc)+';' : '';
	   		p+= this.ctag ? 'tag:'+escape(this.ctag)+';' : '';
			p+=(this.crb && cr) ? 'dp:'+escape(this.crb)+'+'+escape(cr) : '';
			this.trk_mems.creferer = p;
		}
	}

	this.download = function(cr, win, src_page) {
		this.updateRef(cr);
		var query = this.trk_mems.getQuery();
		if (src_page) {
			query = query.replace('+download+', '+' + src_page + '+');
		}
		this.openexitstatus=0;
		win.location.href = this.urldwnld + (this.urldwnld.indexOf('?') > 0 ? '&' : '?') + query;
		return true;
	}

	this.downloadgo = function(cr, win) {
		this.updateRef(cr);
		this.openexitstatus=0;
		var dwldurl = this.urldwnld + (this.urldwnld.indexOf('?') > 0 ? '&' : '?') + this.trk_mems.getQuery();
		window.open(dwldurl, "Download","width=1,height=1,top=0,left=0");
		win.location.href='download.html';
		return true;
	}

	this.dwldurl = function(cr) {
		this.updateRef(cr);
		return this.urldwnld + (this.urldwnld.indexOf('?') > 0 ? '&' : '?') + this.trk_mems.getQuery();
	}

	this.downloadRedirect = function (cr, win, page, src_page) {
		this.openexitstatus=0;
		if (document.readyState) {
			this.updateRef(cr);
			win.location.href=this.urldwnld + (this.urldwnld.indexOf('?') > 0 ? '&' : '?') + this.trk_mems.getQuery();
			if (document.readyState && document.readyState=='loading') {
				win.status = document.readyState;
				setTimeout('downloadpage("' + page + '")', 200);
				return false;
			}
		} else {
			var parts = this.crb.split('+');
			//alert(this.crb + ' ||| ' + parts[parts.length - 1] + ' ||| ' + cr);
			document.cookie = 'page=' + parts[parts.length -1];
			document.cookie = 'cr=' + cr;
		}
		return true;
	}

	this.dnldAfterRedir = function(win) {
		if (!document.readyState)  {
			var src_page = this.trk_mems.readCookie('page');
			var src_crb = this.trk_mems.readCookie('cr');
			if (src_page && src_crb) {
				this.download(src_crb, win, src_page);
				document.cookie = 'page=; expires=Fri, 3 Aug 2001 20:47:11 UTC; path=/';
				document.cookie = 'cr=; expires=Fri, 3 Aug 2001 20:47:11 UTC; path=/';
			}
		}
	}

}
function downloadpage(page) {
		if (document.readyState=='loading') {
			setTimeout('downloadpage("' + page + '")', 200);
		} else {
			location.href=page;
		}
	}