/*
 * uRoute - User Route Tracking (http://www.userfirst.com/)
 * @author Scott D. Brooks 
 * @created by UserFirst Interactive (creations@userfirstinteractive.com)
 * 
 */
	
$(document).ready(function() {
	var currentDomain = jQuery.url.attr("host");
	var website_route_cookie = $.cookie('siteRoute');
	var website_route = "";	
		
	if (website_route_cookie != undefined) {
		// before concating the new string, check to see if the code is attempting to save a duplicate of the current page
		// if the current path is at the end of the string, then just return
		if (($.cookie('siteRoute').lastIndexOf("|") == -1) && ($.cookie('siteRoute').lastIndexOf(jQuery.url.attr("relative")) > -1)) {
			// the the first entry for this cookie was the current page we are on, so return.
			return;
		}
		
		var lastDivider = $.cookie('siteRoute').lastIndexOf("|");
		
		if (lastDivider != -1) {
			var lastEntry = $.cookie('siteRoute').substring(lastDivider+1,$.cookie('siteRoute').length);
			if (jQuery.url.attr("relative") == lastEntry) {
				return;
			}
		}
		
		// ok, there is no duplication being attempted, so record the latest url
		website_route = $.cookie('siteRoute') + "|";
	} 
	website_route = website_route + jQuery.url.attr("relative");
	
	// set cookie to new path
	$.cookie('siteRoute', "", { expires: 1, path: '/', domain: currentDomain });
	$.cookie('siteRoute', website_route, { expires: 1, path: '/', domain: currentDomain });
});

