﻿function showPopupResults (delay) {	setTimeout(function() 	{ $.fn.colorbox({											width:"540px", 											height:"348px", 											iframe:true, 											opacity:.6, 											transition:"none",											speed:1, 											overlayClose:false, 											href:'http://www.independent.org/popup/popup_content4.html'}) 										}, 					delay);			}		$(document).ready(function() {	//alert('start show popup');		var cookie_name_a = 'tii_has_viewed_a_page';	var cookie_name_a2 = 'tii_has_viewed_a_page_blog';		var cookie_name_b = 'tii_has_seen_popup';	var cookie_name_b2 = 'tii_has_seen_popup_blog';		var cookie_name_c = 'tii_subscribed';	var cookie_name_c2 = 'tii_subscribed_blog';			//get cookie values from client	c_value_a = $.cookie(cookie_name_a);	c_value_a2 = $.cookie(cookie_name_a2);		c_value_b = $.cookie(cookie_name_b);	c_value_b2 = $.cookie(cookie_name_b2);		c_value_c = $.cookie(cookie_name_c);	c_value_c2 = $.cookie(cookie_name_c2);			if (c_value_c == null && c_value_c == null) {		// visitor has not subscribed previously.				if (c_value_a == null && c_value_a2 == null) {			//client has NOT viewed a page before this.  create cookies recording that a page was viewed.			//alert('creating cookie a');			$.cookie(cookie_name_a, '1', {expires: 3000, path: '/', domain: 'independent.org'});			$.cookie(cookie_name_a2, '1', {expires: 3000, path: '/', domain: 'independent.org'});						//get cookie values from client			c_value_a_after = $.cookie(cookie_name_a);			c_value_a2_after = $.cookie(cookie_name_a2);						if (c_value_a_after == '1' && c_value_a2_after == '1')  {				//if the client accepted the first cookies and				//is still on page after 3 seconds, show popup and add cookie recording that popup was shown				setTimeout(function() 	{ $.cookie(cookie_name_b, '1', {expires: 90, path: '/', domain: 'independent.org'}) }, 3000);				setTimeout(function() 	{ $.cookie(cookie_name_b2, '1', {expires: 90, path: '/', domain: 'independent.org'}) }, 3000);							showPopupResults (3000);			}		}					else if (c_value_b == null && c_value_b2 == null && (c_value_a == '1' || c_value_a2 == '1')) {			//alert('trying to show popup');			//client has not seen the popup and this is the 2nd page they have viewed.					$.cookie(cookie_name_b, '1', {expires: 90, path: '/', domain: 'independent.org'});			$.cookie(cookie_name_b2, '1', {expires: 90, path: '/', domain: 'independent.org'});						showPopupResults (10);		}	}			});
