function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

jQuery(document).ready(function() {
	var came_from = new RegExp('[\\?&]cf=([^&#]*)').exec(window.location.href);
	if (came_from) {
		came_from = came_from[1];
			
		var notification_url = "/site_move_notification.html";
		var cookie_name = '';
		var do_show = false;
		
		// Determine what to show
		if (came_from == 'tlb') {
			cookie_name = "TLB_Redir_Notification_Shown";
			if (!readCookie(cookie_name)) {	
				createCookie(cookie_name, "True", 365);
				do_show = true;
			}
		} else if (came_from == 'cs') {
			cookie_name = "CS_Redir_Notification_Shown";
			if (!readCookie(cookie_name)) {		
				createCookie(cookie_name, "True", 365);
				do_show = true;
			}
		}
		
		// Show it
		if (do_show) {
			jQuery.fancybox({
			    'type': 'iframe',
			    'showCloseButton': true,
			    'hideOnOverlayClick': true,
			    'width': 800,
			    'height': 260,
			    'padding': 0,
			    'overlayOpacity': 0.6,
			    'title': "",
			    'content': notification_url
		    });
		}
	}
});
