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.csrc='';
	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.casinotropez.com/cgi-bin/redir.cgi?id=N&member="+this.trk_mems.member+"&profile=exit&lang=en";
		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.craps.com/trcpromo-"+(this.exiturl=="@" ? "campx-"+this.trk_mems.member+"-" : this.trk_mems.member+"-exit-")+"pmail1-en";
		}

		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.craps.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) {
		this.updateRef(cr);
		this.openexitstatus=0;
		win.location.href = this.urldwnld + (this.urldwnld.indexOf('?') > 0 ? '&' : '?') + this.trk_mems.getQuery();
		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.downloadRedir = function(openerwin) {
		var win = openerwin.open('', "Download","width=1,height=1,top=0,left=0");
		if (win) {
			win.document.write('<!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><title> New Document </title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta name="title" content="" /><meta name="author" content="" /><meta name="subject" content="" /><meta name="language" content="en" /><meta name="keywords" content="" /></head><body><script type="text/javascript">function redir(){window.opener.location.href="download.html";self.close();}setTimeout("redir()", 2000);</script></body></html>');
		}
	}

	this.downloadRedirect = function (cr, win, page) {
		alert(document.readyState);
		if (document.readyState) {
			this.updateRef(cr);
			this.openexitstatus=0;
			win.location.href=this.urldwnld + (this.urldwnld.indexOf('?') > 0 ? '&' : '?') + this.trk_mems.getQuery();
			if (document.readyState && document.readyState=='loading') {
				setTimeout('downloadpage("' + page + '")', 200);
				return false;
			}
		}
		return true;
	}


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