function ExtractParametersFromUrl(debug) {
/*-------------------------------------
Description:
Extracts the complete paramter string from a URL.
eg "xyx.com?param1=AAA&param2=BBB" will return "?param1=AAA&param2"

Author: JL May '09
Dependencies:
Updates:
-------------------------------------*/
	var theUrl = window.location.href;
	var paramStart = theUrl.indexOf("?");
	
	// if no parameter string then exit
	if(paramStart == -1){
		return -1;
	}

	var paramString = theUrl.substring(paramStart, theUrl.length);
	if (debug) {alert('ExtractParametersFromUrl.paramString = ' + paramString);}
	
	return paramString;
}

$(document).ready(function(){
/*-------------------------------------
Description:
Run this code as soon as the page loads.
Updates the links with extra tracker from disney

Author: JL May '09
Dependencies: jquery.js, jq.cookie.js
Updates:
-------------------------------------*/
	debug =false; //set to true to see values and debug
	trackCode = ExtractParametersFromUrl();
	
	if (debug){
		alert('inital cookie is ' + $.cookie('disneyTracker'));
		alert('This URL track code is ' + trackCode);
	}
	
	//check if tracker is the same as the one cookie and don't update cookie if no trackCode
	if ($.cookie('disneyTracker') != trackCode && trackCode != -1){
		$.cookie('disneyTracker', trackCode);
		//alert('new set cookie is ' + $.cookie('disneyTracker'));
	}
	
	var theUrl = window.location.href;
	theUrl.indexOf("?")
	
	//modify all links with a class  "dlrpLink" by adding the disneyTracker code from the stored cookie
	if ($.cookie('disneyTracker') != null){
		var theUrl = window.location.href;
		
		//if parameters "?" do not exist already then use the original entry code
		if ($('.dlrpLink').attr("href") == -1){
			newLink = $('.dlrpLink').attr("href") + $.cookie('disneyTracker');
			$('.dlrpLink').attr("href",newLink);
			if (debug) {alert(newLink);}
		}
		else //there is an existing parameter, tag in the tracker using "&" but remove the original "?" held in cookie
		{ 
			newLink = $('.dlrpLink').attr("href") + "&" + $.cookie('disneyTracker').substr(1);
			$('.dlrpLink').attr("href",newLink);
			if (debug) {alert(newLink);}
		}

	}
});