
(function($) {

	print_mode = false;


	$(document).ready(function() {
		$("div#header ul.nav>li").bind("mouseover", function() {
			$(this.getElementsByTagName('a')[0]).addClass('tsel');
			$("ul", this).show();
		});
		$("div#header ul.nav>li").bind("mouseout", function() {
			$(this.getElementsByTagName('a')[0]).removeClass('tsel');
			$("ul", this).hide();
		});
			
		setClickTracks();
		
		popPiney();
	});

	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
			}
		);
	}

	function popPiney() {
		$("a.piney").bind("click", function() {
			var pop = window.open(this.getAttribute('href'), 'popup', 'width=800,height=630,status=yes,scrollbars=yes,resizable=1');
			if (pop == null || typeof(pop)=="undefined") {
				return true;
			} else {
				return false;
			}
		});
	}

})(jQuery);

