$(document).ready(function() {
	$("a.pop").bind("click", function() {
		var pop = window.open(this.getAttribute('href'));
		if (pop == null || typeof(pop)=="undefined") {
			return true;
		} else {
			return false;
		}
	});
	
	setClickTracks();
});




function setClickTracks() {
	// Check for and create persistent cookie
	var persist = $.cookie('CLICKTRACKS_PERSISTENT');
	if(persist == null) {
		persist = new Date().toGMTString() + "_" + Math.ceil(Math.random()*100);
		$.cookie('CLICKTRACKS_PERSISTENT',
			persist,
			{
				expires: 1000,
				path: "/",
				domain: window.location.hostname
			}
		);
	}
	
	// Check for session cookie.  Update expiration for 15 minutes.
	var session = $.cookie('CLICKTRACKS_SESSION');
	if(session == null)
		session = persist + '=' + new Date().toGMTString() + "_" + Math.ceil(Math.random()*100)
	$.cookie('CLICKTRACKS_SESSION',
		session,
		{
			expires: new Date( new Date().getMilliseconds  + (15 * 60 * 1000)),
			path: "/",
			domain: window.location.hostname
		}
	);
}


