//custom page tracking functions, look up tracking information from the 
//page location and the page title and make these variables available in
//page. tracking functions used in the flash versions of content on the 
//site.


	// Set Variables
	var arTrackSite 	= "Baileys";
	var arTrackPage 	= "";
	var arTrackLocale 	= "";
	var arTrackCategory = "";

	// Retrieve tracking info from url and page title
	var arTrackUrlString 	= window.location.href.replace( /https?:\/\//, "" );
	var arTrackUrlSplit 	= arTrackUrlString.split( "/" );

	// Replace '_' with ':' and assign to variable
	if ( arTrackUrlSplit.length > 1 )
	{
		arTrackLocale 	+= arTrackUrlSplit[1].replace("-", ":").toUpperCase();
		arTrackSite 	+= " : " + arTrackUrlSplit[1].toLowerCase();
	}


	// 
	if ( arTrackUrlSplit.length > 2 && !arTrackUrlSplit[ 2 ].match( /\./ ) )
	{
		arTrackCategory += arTrackUrlSplit[2].replace( /[^a-zA-Z0-9]/, "" ).toUpperCase();
		arTrackPage 	+= arTrackUrlSplit[2] + " : " ;
	}


	// 
	if ( arTrackUrlSplit.length > 3 && !arTrackUrlSplit[ 3 ].match( /\./ )  &&  arTrackUrlSplit[ 3 ] != "")
	{
		arTrackCategory += ":" + arTrackUrlSplit[3].replace( /[^a-zA-Z0-9]/, "" ).toUpperCase();
		arTrackPage 	+=  arTrackUrlSplit[3];
	}


	arTrackPage += document.title.replace( /^.+\|\s?/, "" );


	// PAGEVIEW TAG 
	// required on everypage (HTML, FLash)
	function arTrackPageview(page,category)
	{
		/*alert(arTrackSite + " : " + page , arTrackLocale + ":" + category);*/
		cmCreatePageviewTag( arTrackSite + " : " + page , arTrackLocale + ":" + category );
	}


	// GATEWAY CONVERSION TAG
	// Tracking Gateway to Homepage (HTML, Flash)
	function arGatewayConversion(page,conversion,category,entry)
	{
		cmCreateConversionEventTag(page,conversion,category,entry);
		//alert(page + ' ' + conversion + ' ' + category + ' ' + entry);
	}


	// GATEWAY PAGEVIEW TAG - required on everypage (HTML, FLash)function arTrackPageview(page,category)
	function arGWTrackPageview(page)
	{
		/*alert(page);*/
		cmCreatePageviewTag(page,"",null);
	}


	// Tracking for regestration page.
	function arRegistrationTrackPage2(page,category)
	{
		cmCreatePageviewTag( arTrackSite + " : " + page + " Page 2" , arTrackLocale + ":" + category );
	}


	// CONVERSION TAG - required on user journeys (HTML, FLash)
	function arTrackConversion(page,category,conversion,status,value)
	{
		cmCreateConversionEventTag( arTrackSite + " : " + page + " : " + conversion, status, arTrackSite + ":" + category, value ); 
	}


	// HOME PAGE || FLASH SITE CONVERSION TAGS - (HTML, FLash)
	function arTrackConversionTag(page,category,conversion,value)
	{
		/*alert(page + " : " + arTrackLocale, category, arTrackLocale + ":" + conversion, value);*/
		cmCreateConversionEventTag( page + " : " + arTrackSite, category, arTrackSite + ":" + conversion, value );
	}


	// CONVERSION TAG - REGISTRATION TAG FOR FORM: (HTML)
	function arRegistrationTag(email,town,postcode)
	{
		/*alert('Regestration Test' + email + town + postcode);*/
		cmCreateRegistrationTag( email, null, town, postcode, null, null );
	}


	// CONVERSION TAG - DRINKS PAGE:  (HTML, FLash)
	function arCreateConversionEventTag(name,num,value)
	{
		/*alert(name + ":" + arTrackLocale + ":" + num + ":" + "EN-ROW:THEDRINKS" + ":" + value);*/
		cmCreateConversionEventTag( name + ":" + arTrackLocale, num, arTrackLocale + ":THEDRINKS", value );
	}


	// CLICK TAG - required on clicks (HTML, Flash)
	function arTrackClick(page,click,link)
	{
		cmCreateManualLinkClickTag( link, arTrackSite + " : " + page + " : "  + click );
	}

	// CLICK TAG - Baileys Homepage Winter 2008(Flash)
	function arLipsClick(recipe,page)
	{
		cmCreateManualLinkClickTag( recipe, arTrackSite + " : " + page );
	}

	// Presume this is for the "Americans"
	function arTrackConversion1(page,category,conversion,status,value)
	{
		cmCreateConversionEventTag( " Baileys : US-EN : Registration : " + conversion, status, category, value ); 
	}
	//for debugging alert tracking variables
	//alert( " arTrackSite: " + arTrackSite + "\n arTrackPage: " + arTrackPage + "\n arTrackLocale: " + arTrackLocale + "\n arTrackCategory: " + arTrackCategory );
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	