var doc = {}
doc.fIElte6 = (/MSIE [0-6]\./.test(navigator.userAgent));

var site="/totesport/cheltenham/";
var _hbEC;
var hbx;
function setVarious() {
	var pn="";
	var mlc="";
	var i=0;
	if (location.pathname.indexOf(site)==0) {
		// plant the folder and file
		i=location.pathname.lastIndexOf('/')+1;
		if (i<0) {return;}
		pn=location.pathname.substr(i,location.pathname.length);
		mlc=location.pathname.substr(0,i);
	} else {return;}
	hbx.pn=pn;
	hbx.mlc=mlc;
}

if (location.pathname.indexOf(site)==0) {
	//WEBSIDESTORY CODE HBX2.0 (Universal)
	//COPYRIGHT 1997-2005 WEBSIDESTORY,INC. ALL RIGHTS RESERVED. U.S.PATENT No. 6,393,479B1. MORE INFO:http://websidestory.com/privacy
	_hbEC=0,_hbE=new Array;function _hbEvent(a,b){b=_hbE[_hbEC++]=new Object();b._N=a;b._C=0;return b;}
	hbx=_hbEvent("pv");hbx.vpc="HBX0200u";hbx.gn="ehg-logantod.hitbox.com";
	//BEGIN EDITABLE SECTION
	//CONFIGURATION VARIABLES
	hbx.acct="DM560829MNWM";//ACCOUNT NUMBER(S)
	hbx.pn="PUT+PAGE+NAME+HERE";//PAGE NAME(S)
	hbx.mlc="CONTENT+CATEGORY";//MULTI-LEVEL CONTENT CATEGORY
	hbx.pndef="title";//DEFAULT PAGE NAME
	hbx.ctdef="full";//DEFAULT CONTENT CATEGORY
	
	//ACTION SETTINGS
	hbx.fv="";//FORM VALIDATION MINIMUM ELEMENTS OR SUBMIT FUNCTION NAME
	hbx.lt="auto";//LINK TRACKING
	hbx.dlf="n";//DOWNLOAD FILTER
	hbx.dft="n";//DOWNLOAD FILE NAMING
	hbx.elf="n";//EXIT LINK FILTER
	
	//SEGMENTS AND FUNNELS
	hbx.seg="";//VISITOR SEGMENTATION
	hbx.fnl="";//FUNNELS
	
	//CAMPAIGNS
	hbx.cmp="";//CAMPAIGN ID
	hbx.cmpn="";//CAMPAIGN ID IN QUERY
	hbx.dcmp="";//DYNAMIC CAMPAIGN ID
	hbx.dcmpn="";//DYNAMIC CAMPAIGN ID IN QUERY
	hbx.dcmpe="";//DYNAMIC CAMPAIGN EXPIRATION
	hbx.dcmpre="";//DYNAMIC CAMPAIGN RESPONSE EXPIRATION
	hbx.hra="";//RESPONSE ATTRIBUTE
	hbx.hqsr="";//RESPONSE ATTRIBUTE IN REFERRAL QUERY
	hbx.hqsp="";//RESPONSE ATTRIBUTE IN QUERY
	hbx.hlt="";//LEAD TRACKING
	hbx.hla="";//LEAD ATTRIBUTE
	hbx.gp="";//CAMPAIGN GOAL
	hbx.gpn="";//CAMPAIGN GOAL IN QUERY
	hbx.hcn="";//CONVERSION ATTRIBUTE
	hbx.hcv="";//CONVERSION VALUE
	hbx.cp="null";//LEGACY CAMPAIGN
	hbx.cpd="";//CAMPAIGN DOMAIN
	
	//CUSTOM VARIABLES
	hbx.ci="";//CUSTOMER ID
	hbx.hc1="";//CUSTOM 1
	hbx.hc2="";//CUSTOM 2
	hbx.hc3="";//CUSTOM 3
	hbx.hc4="";//CUSTOM 4
	hbx.hrf="";//CUSTOM REFERRER
	hbx.pec="";//ERROR CODES
	
	//END EDITABLE SECTION
}

/* PopupHandler begin */

/*constructor*/ function PopupHandler(aPopup) {
	var l=document.getElementsByTagName('a');
	for (var i=0; i<l.length; i++) {
		var ph=this; // copy reference for use in inner functions
		for (var p=0; p<aPopup.length; p++) {	// Loop through array of popup window types.
			var popup=aPopup[p];
			if (l[i].className.indexOf(popup.className)>-1) {
				l[i].popup=popup;	// Associate popup properties with anchor.
				l[i].onclick=function() {	// onclick handler
					ph.fnLaunchPopup(this);
					return false;
				};
			}
		}
	}
}

/* Launch popup window using properties and href from anchor */
PopupHandler.prototype.fnLaunchPopup=function(a) {
	var top=(window.screenY?window.screenY:window.screenTop)+50;
  var left=(window.screenX?window.screenX:window.screenLeft)+50;
	var popup=a.popup;
  window.open(a.href,popup.className,"width="+popup.width+",height="+popup.height+",top="+top+",left="+left+popup.features).focus();
}

/* Popup properties */
function cPopup(className,width,height,features) {
	this.className=className;
	this.width=width;
	this.height=height;
	this.features=features;
}

/* PopupHandler end */

/* DeferredScript begin - used to load external scripts that may otherwise cause an unacceptable delay before 'onload' is triggered */

/*constructor*/ function DeferredScript(id, src) {
	var placeholder;
	if (id) { // use given id
		placeholder=document.getElementById(id);
	} else { // append child in body
		var b=document.getElementsByTagName('body');
		if (b==null) {
			return;
		}
		placeholder=b[0];
	}
	if (placeholder==null) {
		return;
	}
	var oScript=document.createElement('script');
	if (oScript)
	{
		oScript.type="text/javascript";
		oScript.src=src;
		placeholder.appendChild(oScript);
	}
}

/* DeferredScript end */

// onload function
doc.fnOnLoad = function() {
	// Handle popup windows.
	new PopupHandler([new cPopup("popupFlash",760,580,""),
										new cPopup("popupRadio",700,500,""),
										new cPopup("popupSite",780,500,",location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes"),
										new cPopup("popupContent",560,500,",scrollbars=yes")]);
	if (location.pathname.indexOf(site)==0) {
		// totesport client side behaviour extension for hbx
		setVarious();
		var l=location.protocol+"//"+location.host;
		if (location.port!="") {l+=":"+location.port;}
		var newl=l+site+"scripts/hbx.js?v1_0";
		new DeferredScript(0, newl);
	}
};

// Generic onload function - CCL www.brothercake.com
//
function AddOnload(fnOnLoad) {
	if (typeof window.addEventListener != 'undefined') {
		//.. gecko, safari, konqueror and standard
		window.addEventListener('load',fnOnLoad,false);
	} else if (typeof document.addEventListener != 'undefined') {
		//.. opera 7
		document.addEventListener('load',fnOnLoad,false);
	} else if (typeof window.attachEvent != 'undefined') {
		//.. win/ie
		window.attachEvent('onload',fnOnLoad);
	} else {
		//.. mac/ie5 and anything else that gets this far
		if(typeof window.onload == 'function') {
			//store existing onload function
			var fnOnLoadExisting=onload;
			//add new onload handler
			window.onload=function() {
				fnOnLoadExisting();//call existing onload function
				fnOnLoad();//call generic onload function
			};
		} else {
			window.onload=fnOnLoad();//setup onload function
		}
	}
}

AddOnload(doc.fnOnLoad);
