$.noConflict();
jQuery(document).ready(function($){	
	// Set up the cookies and interstitial:
	if( undefined == $.cookie('views') ){
		// Set the cookie:
		$.cookie('views', '1', { expires: 3, path: '/', domain: 'chancellorsonline.com' });
	} else{
		//Increment Cookie
		$.cookie('views', (parseInt($.cookie('views')) + 1), { expires: 3, path: '/', domain: 'chancellorsonline.com' });

		// Determine if we should show the interstitial:
		if((parseInt($.cookie('views')) === 3 || (parseInt($.cookie('views')) % 6) === 0) && undefined == $.cookie('action')){
			if(parseInt($.cookie('views')) === 3) {
				// Set cookie to 6 so that it will show every 6th page after the first 3
				$.cookie('views', '6', { expires: 3, path: '/', domain: 'chancellorsonline.com' });
			}
			// Show the interstitial:
			var interstitial = $('#interstitial').dialog({
				dialogClass: "module",
				draggable: false,
				modal: true,
				resizable: false,
				width: '470',
				open: function() {
					try {
						pageTracker._trackEvent("Interstitial", "Show");
					} catch(err) {}

					$('.ui-widget-overlay').click(function() {
						$(interstitial).dialog("close");
						try {
							pageTracker._trackEvent("Interstitial", "Click Behind");
						} catch(err) {}
						return false;
					});
					$('.module .exit_modal').click(function() {
						$(interstitial).dialog("close");
						try {
							pageTracker._trackEvent("Interstitial", "Close");
						} catch(err) {}
						return false;
					});
					$(".module .close_modal").click(function() {
						$(interstitial).dialog("close");
						$.cookie('action', 'nothanks', { expires: 30, path: '/', domain: 'chancellorsonline.com' });
						try {
							pageTracker._trackEvent("Interstitial", "No Thanks");
						} catch(err) {}
						return false;
					});
					$(".module .dismiss_modal").click(function() {
						$(interstitial).dialog("close");
						$.cookie('action', 'maybelater', { expires: 15, path: '/', domain: 'chancellorsonline.com' });
						try {
							pageTracker._trackEvent("Interstitial", "Maybe Later");
						} catch(err) {}
						return false;
					});
				}
			
			});
		}
	} 
		// Determine if we should show the interstitial:
		if($.cookie('first') != 'shown'){
		}
});