		var exp = new Date();
		var expDays = 60; // number of days the cookie should last
		var pCount = 3; // number of pages before the popup should occur
		var PercentOpen = 100;  //The percentage in which the popup will trigger.
		var inviteBox = 0; //Activate Invitation Box. 1 = On, 0 = Off.
		var link;
		exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
		var theWidth  = 900; 
		  var theHeight;
		   if (screen.height >= 1024)
		     theHeight = 700;
		    else if (screen.height >= 864)
		     theHeight = 700;
		    else if (screen.height >= 768)
		        theHeight = 700;
		    else if (screen.height >= 600)
		     theHeight = 500;
		    else
		     theHeight = 700;
	
			theTop=(screen.availHeight/2)-(theHeight/2)
			theLeft=(screen.availWidth/2)-(theWidth/2)
			var features='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=no,height='+theHeight+',width='+theWidth+',top='+theTop+',left='+theLeft;
		
		var hRange = 100; //Change the upper range to modify the probablity of an eCollector call 
		
		//RTPopup(link);
		//initInviteBox(link); 

		function RTPopup(link) //Calling function for the popup window on page load.
		{
		
			var count = GetCookie('Resp');
					
			if (count == null) 
			{
				count=1;
				SetCookie('Resp', count, exp, '/', null,false);
				
			}
			else 
			{
				if (count == pCount)	// This is the number of pages hit before the eCollector is popped up.
				{

				//Institate code to call AJAX window here.
				count++;
				SetCookie('Resp', count, exp, '/', null,false);
				var rndNum; 
           		rndNum = Math.floor(Math.random()*hRange); 
           			if (inviteBox == 1 && rndNum <= PercentOpen) 
					{
						confirmation()
					}
						
					else if (rndNum <= PercentOpen)
					{
						var wOpen
					
						wOpen = window.open(link, 'RTCollector', features);
						wOpen.focus();	
					}
					else 
					{
						
					}
				}
				else
				{
					count++;
					SetCookie('Resp', count, exp, '/', null,false);
				}
				}
	    	}
	
		function RTeClick(link) // Activates popup on click and increase count above pCount.
		{
			count=pCount + 2;
			SetCookie('Resp', count, exp, '/', null,false);
	
			var wOpen
			wOpen = window.open(link, 'RTCollector', features);
			wOpen.focus();
		}

		function confirmation() {
			displayInviteBox();

//			var answer = confirm("We value customer feedback and invite you to complete a short survey about your customer experience.")
//			if (answer){
//			}
//			else{
//				
//			}
		}
		function initInviteBox(link) {
			jQuery('#inviteBox').css({
				'width': '420px',
				'left': (jQuery(window).width()/2 - 230)
			});
			jQuery('#inviteBox #close_survey').click(function() {
				jQuery('#inviteBox').fadeOut();
			});
			jQuery('#inviteBox #do_survey').click(function() {
				var wOpen;
				jQuery('#inviteBox').fadeOut();
				wOpen = window.open(link, 'RTCollector', features);
				wOpen.focus();
			});
			
		}
		
		function displayInviteBox() {
			jQuery('#inviteBox').fadeIn();
		}


