// //
// Copyright 2008 comScore Networks. All rights reserved.

// Page: Propecia
// Date: 2009-04-29


// Multiple script protection.
if (!window.SiteRecruit_Globals) {

// Create the configuration, globals, and constants namespaces.
var SiteRecruit_Config = new Object();
var SiteRecruit_Globals = new Object();
var SiteRecruit_Constants = new Object();

// Validation variables.
SiteRecruit_Globals.parseFlag = false;
SiteRecruit_Globals.empty = false;

// Browser information.
SiteRecruit_Constants.browser = new Object();
SiteRecruit_Constants.browser.internetExplorer = 'Microsoft Internet Explorer';
SiteRecruit_Constants.browser.mozilla = 'Netscape';
SiteRecruit_Constants.browser.opera = 'Opera';

// Check browser information.
SiteRecruit_Globals.browserName = navigator.appName; 
SiteRecruit_Globals.browserVersion = parseInt(navigator.appVersion);

// Initialize browser flags.
SiteRecruit_Globals.isInternetExplorer = false;
SiteRecruit_Globals.isMozilla = false;
SiteRecruit_Globals.isInternetExplorer7 = false;

// Check for Internet Explorer based browsers.
if (SiteRecruit_Globals.browserName == SiteRecruit_Constants.browser.internetExplorer)
{
    if (SiteRecruit_Globals.browserVersion > 3)
    {
        // Only 5.5 and above.
        var a = navigator.userAgent.toLowerCase();
        if (a.indexOf("msie 5.0") == -1 && a.indexOf("msie 5.0") == -1)
        {
            SiteRecruit_Globals.isInternetExplorer = true;
        }
        
        // Check for 7.
        if (a.indexOf("msie 7") != -1)
        {
            SiteRecruit_Globals.isInternetExplorer7 = true;
        }
    }
}

// Check for Mozilla based browsers.
if (SiteRecruit_Globals.browserName == SiteRecruit_Constants.browser.mozilla)
{
    if (SiteRecruit_Globals.browserVersion > 4)
    {
        SiteRecruit_Globals.isMozilla = true;
    }
}

// Since Opera 9.02, they no longer use 'Mozilla' in the browser name
if (SiteRecruit_Globals.browserName == SiteRecruit_Constants.browser.opera)
{
	SiteRecruit_Globals.isMozilla = true;	// treat the same as Mozilla
}



// Cookie lifetime.
SiteRecruit_Constants.cookieLifetimeType = new Object();
SiteRecruit_Constants.cookieLifetimeType.duration = 1;
SiteRecruit_Constants.cookieLifetimeType.expireDate = 2;
    
// Invitation type.
SiteRecruit_Constants.invitationType = new Object();
SiteRecruit_Constants.invitationType.standard = 0;
SiteRecruit_Constants.invitationType.email = 1;
SiteRecruit_Constants.invitationType.domainDeparture = 2;
SiteRecruit_Constants.invitationType.emailDomainDeparture = 3;
    
// Cookie type flags.
SiteRecruit_Constants.cookieType = new Object();
SiteRecruit_Constants.cookieType.alreadyAsked = 1;
SiteRecruit_Constants.cookieType.inProgress = 2;
SiteRecruit_Constants.cookieType.emailDomainDeparture = 3;

// Alignment types.
SiteRecruit_Constants.horizontalAlignment = new Object();
SiteRecruit_Constants.horizontalAlignment.left = 0;
SiteRecruit_Constants.horizontalAlignment.middle = 1;
SiteRecruit_Constants.horizontalAlignment.right = 2;
SiteRecruit_Constants.verticalAlignment = new Object();
SiteRecruit_Constants.verticalAlignment.top = 0;
SiteRecruit_Constants.verticalAlignment.middle = 1;
SiteRecruit_Constants.verticalAlignment.bottom = 2;

// Survey cookie configuration.
SiteRecruit_Config.cookieName = 'propeciaresearch';
//The following code has been added to check the location URL for loading testing and production versions
SR_loc = window.location.toString().toLowerCase();
SR_Domain_FLAG = false;
if(SR_loc.indexOf('propecia.com')== -1)
{
	SiteRecruit_Config.cookieDomain = '';
}else{
	SiteRecruit_Config.cookieDomain = 'propecia.com';
	SR_Domain_FLAG = true;
}
SiteRecruit_Config.cookiePath = '/';

SiteRecruit_Constants.cookieJoinChar = ':';

// Settings for cookie lifetime.
SiteRecruit_Config.cookieLifetimeType = 1;

    // Duration of the cookie in days.
    SiteRecruit_Config.cookieDuration = 90 * 86400000;

// Duration of the rapid cookie.
SiteRecruit_Config.rapidCookieDuration = 0 * 86400000;

// URL of the email domain dep server.
SiteRecruit_Config.listenerUrl = '';// //
// Copyright 2008 comScore Networks. All rights reserved.

// Class to read and write cookies.
function SiteRecruit_CookieUtilities()
{
    // Cookie removal date.
    this.cookieRemovalDate = 'Fri, 02-Jan-1970 00:00:00 GMT';

    // Attach methods.
    this.setSurveyCookie = CookieUtilities_setSurveyCookie;
    this.setSurveyCookieX = CookieUtilities_setSurveyCookieX;
    this.setEmailDomainDepartureCookie = CookieUtilities_setEmailDomainDepartureCookie;
    this.getSurveyCookie = CookieUtilities_getSurveyCookie;
    this.getCookieValue = CookieUtilities_getCookieValue;
    this.removeSurveyCookie = CookieUtilities_removeSurveyCookie;
    this.surveyCookieExists = CookieUtilities_surveyCookieExists;

    // Set the cookie to the standard cookie string.
    function CookieUtilities_setSurveyCookie(cookieType)
    {
        this.setSurveyCookieX(cookieType, false);
    }

    // New cookie method to optionally support rapid cookies.
    function CookieUtilities_setSurveyCookieX(cookieType, useRapidCookie)
    {
        var currentDate = new Date();  
        var expireDate = new Date();
        
        var duration = SiteRecruit_Config.cookieDuration;
        if (useRapidCookie)
        {
            duration = SiteRecruit_Config.rapidCookieDuration;
        }
        
        if (SiteRecruit_Config.cookieLifetimeType == SiteRecruit_Constants.cookieLifetimeType.duration)
        {
            expireDate.setTime(currentDate.getTime() + duration);
        }
        else
        {
            expireDate.setTime(Date.parse(SiteRecruit_Config.cookieExpireDate));
        }        
        
        var c = '=' + cookieType;
        if (cookieType == SiteRecruit_Constants.cookieType.inProgress)
        {
            var j = SiteRecruit_Constants.cookieJoinChar;
            c += ':' + escape(document.location) + ':' + currentDate.getTime() + ':0';
        }        
        c += '; path=' + SiteRecruit_Config.cookiePath;

        if (cookieType == SiteRecruit_Constants.cookieType.alreadyAsked) c += '; expires=' + expireDate.toGMTString();
        if (SiteRecruit_Config.cookieDomain != '') c += '; domain=' + SiteRecruit_Config.cookieDomain;

        document.cookie = SiteRecruit_Config.cookieName + c;
        
        return true;
    }
    
    // Sets a email domain dep cookie with a generated user ID.
    function CookieUtilities_setEmailDomainDepartureCookie(userId, trackingDuration)
    {
        var expireDate = new Date();
        expireDate.setTime(expireDate.getTime() + trackingDuration);
           
        var c = '=' + SiteRecruit_Constants.cookieType.emailDomainDeparture
            + ':' + userId
            + '; path=' + SiteRecruit_Config.cookiePath
            + '; expires=' + expireDate.toGMTString();
            
        if (SiteRecruit_Config.cookieDomain != '') c += '; domain=' + SiteRecruit_Config.cookieDomain;
        document.cookie = SiteRecruit_Config.cookieName + c;
    }
        
    // Grabs the value of the survey cookie.
    function CookieUtilities_getSurveyCookie()
    {
        return this.getCookieValue(SiteRecruit_Config.cookieName);
    }
    
    // Grabs the value of a cookie.
    function CookieUtilities_getCookieValue(cookieName)
    {
        var c = document.cookie.toString();
        var index = c.indexOf(cookieName);
        if (index == -1) return null;
        var endc = c.length;
        c = c.substring(index, endc);
        var ind1 = c.indexOf(';');
        if (ind1 != -1) c = c.substring(0, ind1);
        var ind2 = c.indexOf('=');
        c = c.substring(ind2 + 1);        
        return c;
    }

    // Removes the cookie by setting to an expired date.
    function CookieUtilities_removeSurveyCookie()
    {
        var c = SiteRecruit_Config.cookieName + '='
            + '; path=' + SiteRecruit_Config.cookiePath
            + '; expires=' + this.cookieRemovalDate;

        if (SiteRecruit_Config.cookieDomain != '')
        {
            c += '; domain=' + SiteRecruit_Config.cookieDomain;
        }

        document.cookie = c;
    }

    // Returns true if a survey cookie exists. Call optionally with a type.
    function CookieUtilities_surveyCookieExists(cookieType)
    {
        var t = '';
        if (cookieType) t = cookieType;
        
        return (document.cookie.indexOf(SiteRecruit_Config.cookieName + '=' + t) != -1)
    }
}

// Create an instance of the utils.
SiteRecruit_Globals.cookieUtils = new SiteRecruit_CookieUtilities();
// //
// Copyright 2008 comScore Networks. All rights reserved.

// Misc utilities and helpers
function SiteRecruit_Utilities()
{
	// wire up methods
	this.GetScreenWidth = Utilities_GetScreenWidth;
	this.GetScreenHeight = Utilities_GetScreenHeight;
	
	this.GetWindowWidth = Utilities_GetWindowWidth;
	this.GetWindowHeight = Utilities_GetWindowHeight;
	this.GetWindowLeft = Utilities_GetWindowLeft;
	this.GetWindowTop = Utilities_GetWindowTop;

	// ************************************************************
	// Window utilities
	// ************************************************************
	
	function Utilities_GetScreenWidth()
	{
		return self.screen.availWidth;
	}
	
	function Utilities_GetScreenHeight()
	{
		return self.screen.availHeight;
	}
	
	function Utilities_GetWindowLeft(win)
	{
		return (win.screenX == null ? win.screenLeft : win.screenX);	
	}
	
	function Utilities_GetWindowTop(win)
	{
		return (win.screenY == null ? win.screenTop : win.screenY);	
	}
	
	function Utilities_GetWindowWidth(win)
	{
		return (win.outerWidth == null ? win.document.body.scrollWidth + 12 : win.outerWidth);		
	}
	
	function Utilities_GetWindowHeight(win)
	{
		var height = 0;
		
		// handle tricky IE window height
		if (SiteRecruit_Globals.isInternetExplorer)
		{
			if (win.document.documentElement && win.document.documentElement.clientHeight) 
				height = win.document.documentElement.clientHeight;
			else 
				height = win.document.body.clientHeight;
				
			if (height < win.document.body.scrollHeight) 
				height = win.document.body.scrollHeight;
				
			if (height < win.document.body.offsetHeight) 
				height = win.document.body.offsetHeight; 
		}
		else
			height = win.outerHeight;
			
		return height;
	}
}

// Create an instance of the utils.
SiteRecruit_Globals.Utils = new SiteRecruit_Utilities();
// //
// Copyright 2008 comScore Networks. All rights reserved.
//The following code has been added to check the location URL for loading testing and production versions
if(!SR_Domain_FLAG)
{
	// Frequency of the popup.
	SiteRecruit_Config.frequency = 1;
	// Skips the cookie test. Use for debugging.
	SiteRecruit_Config.useCookie = false;	
}else{
	// Frequency of the popup.
	SiteRecruit_Config.frequency = 1.0;
	// Skips the cookie test. Use for debugging.
	SiteRecruit_Config.useCookie = true;
}

// Invitation constructor - sets necessary defaults.
function SiteRecruit_InvitationConfiguration()
{
    this.otherCookies = new Array();
    this.otherVariables = new Array();    
}

// MOD: Respondent Groups
function SR_findGrp(SR_u, browserFlag) 
{
	// Get Referrer
	var SR_ref = document.referrer.toString().toLowerCase();
	
	// If no Referrer and not IE7, they are Organic non-referred
	if (SR_ref == '' && !browserFlag) { return 4; }
	
	// If Referrer indicates freebie site, they are organic
	var SR_exc = "totallyfreestuff,freestuff,sweepsadvantage,slickdeals,online-sweepstakes,freesamplesite,freebie,ezboard,lilbitofheaven,forum,bigbigsavings,itsfree,proboards,thread,gottadeal,forums";
	var SR_excAr = SR_exc.split(',');
	var SR_isExc = false;
	for (var SR_p in SR_excAr) { if (SR_ref.indexOf(SR_excAr[SR_p]) != -1) { SR_isExc = true;	} }
	if (SR_isExc == true) { return 5; }
	
	SR_u = window.location.toString().toLowerCase();
	var SR_n = SR_u.indexOf('src=');
	if ( SR_n == -1 ) { 
		// If no SRC, no referrer, IE7 is true(Flash Bug) reset to Organic non-referred
		if(SR_ref == ''){
			return 4;
		}
		else{// If no SRC, but a referrer, they are Unpaid Organic Search
			return 3;
		}
	}
}


var SR_grp = false, src_1 =0, src_2 =0,src_3 =0;
var SR_u = window.location.toString().toLowerCase();
var SR_n = SR_u.indexOf('src=');
if (!(SR_n == -1)) { 
	SR_u = SR_u.substring(SR_n,SR_u.length);
	src_1 =SR_u.substring(4,5);
	src_2 =SR_u.substring(5,6);
	src_3 =SR_u.substring(6,7);
	if(src_1 == 1){	
		//Paid Search
		SR_grp=2;
	}else{
		//Media Search
		SR_grp=1;
	}
}

if(!SR_grp){
	var SR_grp = SR_findGrp(SR_u,SiteRecruit_Globals.isInternetExplorer7);
	//DO NOT RECRUIT FOR Freebie visitors
	if(SR_grp == 5){
		SiteRecruit_Config.frequency = 0;
	}
}
var grp = SR_grp;
SR_grp = '&mtd=' + grp;
SR_grp += '&src_1=' + src_1 + '&src_2=' + src_2 + '&src_3=' + src_3;

// The array of survey configurations.
SiteRecruit_Config.invitations = new Array();

// Iterate through the survey configurations.
          
        SiteRecruit_Config.invitations[0] = new SiteRecruit_InvitationConfiguration();
        SiteRecruit_Config.invitations[0].weight = 100;
        SiteRecruit_Config.invitations[0].projectId = 'p21249182';
        SiteRecruit_Config.invitations[0].invitationType = 2;
        SiteRecruit_Config.invitations[0].acceptUrl = 'https://survey2.securestudies.com/wix/p21249182.aspx';
        SiteRecruit_Config.invitations[0].viewUrl = 'https://web.survey-poll.com/tc/CreateLog.aspx';
        SiteRecruit_Config.invitations[0].acceptParams = '&site=621' + SR_grp;
        SiteRecruit_Config.invitations[0].viewParams = 'log=comscore/view/p21249182-view.log&site=621';
        SiteRecruit_Config.invitations[0].invitationContent = '<table width="394" cellpadding="3" cellspacing="0" border="0" bgcolor="#FFFFFF"><tr><td><table width="100%" cellpadding="0" cellspacing="0" style="border:1px solid #999999;" bgcolor="#FFFFFF"><tr valign="top"><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td><img src="/siterecruit/PR_top.gif" /></td><td><a href="Close" onclick="@declineHandler"><img border="0" src="/siterecruit/PR_close.gif" /></a></td></tr></table> <table width="100%" cellpadding="5"><tr><td>  <!-- Intro text. --> <p><div style="font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px; color: #000000;text-align:left; margin: 0 20px 0 10px; padding: 0;line-height:12px;">We value your opinion, and we are asking for your participation in a short survey about your experience today visiting propecia.com.<br /><br />This survey should take only about 10 minutes to complete. Please be assured that this survey is for research purposes only and that your privacy will be respected and your responses will remain strictly confidential.<br /> <br />If you agree to participate in this survey by clicking on the "Yes" button below, you will be returned to propecia.com. The survey will be delivered to you when you <strong><u>leave</u></strong> propecia.com.<br /><br />Any data collected in pursuant to this survey will be handled in accordance to VoiceFive\'s Privacy Policy, which can be found <a href="http://www.voicefive.com/Priv.aspx" target="_blank">here</a>.<br /><br />Your responses to this survey will be kept strictly confidential and <b>WILL NOT</b> be used to contact you or sell you products or information.<br /><br />This survey is hosted by VoiceFive Technologies. VoiceFive is a market research company that studies and reports on trends and behaviors across a wide variety of topics.  VoiceFive is commissioned to conduct research on numerous topics of concern to industry leaders in diverse fields, including travel, pharmaceuticals, and publishing. For more information: <a href="http://www.voicefive.com" target="_blank">click here</a>.<br /><br />This survey is sponsored by Merck & Co., Inc. &nbsp;</div></p>  <!-- Invite form. --> <div align="center" style="margin:0; padding: 0; line-height: 12px;"> <table height="26" cellspacing="6" cellpadding="5" style="margin-bottom: 12px; margin-top: 12px; background-color: #BACDD1; width: 100%; text-align: left;"> <tr> <td width="80" style="padding-top: 5px;padding-bottom: 5px; padding-left: 8px;" > <input type="button" onclick="@acceptHandler" value="  Yes  " /></td> <td style="font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 12px; color: #000000; padding-top: 5px; padding-bottom: 5px; vertical-align: middle;" ><strong>Yes, I want to participate in this survey.</strong></td> </tr> </table> </div>  <!-- Footer text.  <div style="font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 10px; color: #7b7b7b; margin: 0 0 4px 8px; line-height:12px;">To view VoiceFive\'s Privacy Policy <a href="http://www.voicefive.com/Priv.aspx"target="_blank">click here</a>.</div>--></td></tr></table> <img src="/siterecruit/PR_btm.gif" /></td></tr></table> </td></tr></table>';
        SiteRecruit_Config.invitations[0].invitationHeight = 290;
        SiteRecruit_Config.invitations[0].invitationWidth = 310;
        SiteRecruit_Config.invitations[0].revealDelay = 1000;
        SiteRecruit_Config.invitations[0].horizontalAlignment = 1;
        SiteRecruit_Config.invitations[0].verticalAlignment = 0;
        SiteRecruit_Config.invitations[0].horizontalMargin = 0;
        SiteRecruit_Config.invitations[0].verticalMargin = 0;
        SiteRecruit_Config.invitations[0].hideBlockingElements = false;
        SiteRecruit_Config.invitations[0].autoCentering = true;
    
            
            
                    SiteRecruit_Config.invitations[0].trackerUrl = '/siterecruit/SiteRecruit_Tracker_Propecia.htm';
            
            //(features, width, height, orientation, offsetX, offsetY)
            SiteRecruit_Config.invitations[0].trackerWindowConfig = { "width":400,
																		"height":270,
																		"orientation":'Center',
																		"offsetX":0,
																		"offsetY":0,
																		"autoFocus":true,
																		"hideToolbars":true };
                
        SiteRecruit_Config.invitations[0].useRapidCookie = false;
        
                
       
        
    
// //
// Copyright 2008 comScore Networks. All rights reserved.

// Class to test for frequencies and eligibility and start surveys.
function SiteRecruit_Primer()
{
    // Attach methods.
    this.isEligible = Primer_isEligible;
    this.srandom = Primer_srandom;

    // Custom random number generator.
    function Primer_srandom()
    {
        var n = 1000000000;
        
        function ugen(old, a, q, r, m)
        {
            var t = Math.floor(old / q);
            t = a * (old - (t * q)) - (t * r);
            return Math.round((t < 0) ? (t + m) : t);
        }
        
        var m1 = 2147483563;
        var m2 = 2147483399;
        var a1 = 40014;
        var a2 = 40692;
        var q1 = 53668;
        var q2 = 52774;
        var r1 = 12211;
        var r2 = 3791;
        var x = 67108862;
        var shuffle = new Array(32);
        var g1 = (Math.round(((new Date()).getTime() % 100000)) & 0x7FFFFFFF);
        var g2 = g1;
        var i = 0;
        
        for (; i < 19; i++)
        {
            g1 = ugen(g1, a1, q1, r1, m1);
        }
        for (i = 0; i < 32; i++)
        {
            g1 = ugen(g1, a1, q1, r1, m1);
            shuffle[31 - i] = g1;
        }
        g1 = ugen(g1, a1, q1, r1, m1);
        g2 = ugen(g2, a2, q2, r2, m2);
        var s = Math.round((shuffle[Math.floor(shuffle[0] / x)] + g2) % m1);
    
        return Math.floor(s / (m1 / (n + 1))) / n;
    }

    // Decide whether to hit the user with the invitation.
    function Primer_isEligible()
    {
        if (!SiteRecruit_Config.useCookie || !SiteRecruit_Globals.cookieUtils.surveyCookieExists())
        {
            // Roll the dice, and inject the survey scripts if the user is chosen.
            if (SiteRecruit_Config.frequency > this.srandom())
            {
                return true;
            }
                    }
                
        return false;
    }
}

// Run the builder only if it qualifies below.
SiteRecruit_Globals.startBuilder = false;

// Only kick things off if it's a known browser.
if (SiteRecruit_Globals.isInternetExplorer || SiteRecruit_Globals.isMozilla)
{
    // Create a primer and try to run a survey.
    SiteRecruit_Globals.primer = new SiteRecruit_Primer();
    if (SiteRecruit_Globals.primer.isEligible())
    {  
        SiteRecruit_Globals.startBuilder = true;
        
            }    
}// //
// Copyright 2008 comScore Networks. All rights reserved.

// Class to intercept users and take them to invitations.
function SiteRecruit_InvitationBuilder()
{
    // Other cookie and variables join and equality character.
    this.othersJoinChar = ';';
    this.othersEqualityChar = ':';
    
    // Name of invitation layer and form.
    this.invitationLayerName = 'SiteRecruit_invitationLayer';
    this.invitationFormName = 'SiteRecruit_invitationForm';
    
    // Substitution tags.
    this.acceptHandlerTag = '\\@acceptHandler';
    this.declineHandlerTag = '\\@declineHandler';
    
    // Handler function calls.
    this.acceptHandlerCode = 'return SiteRecruit_Globals.builder.onAccept(this)';
    this.declineHandlerCode = 'SiteRecruit_Globals.builder.onDecline(this); return false';
    
    // The time to wait before hiding the invitation.
    this.acceptHideTimeout = 500;
    this.declineHideTimeout = 20;
    
    // The code to call to hide the invite.
    this.hideInvitationCode = 'SiteRecruit_Globals.builder.hideInvitation()';
    
    // URL parameter names.
    this.versionParamName = 'version';
    this.frequencyParamName = 'frequency';
    this.weightParamName = 'weight';
    this.locationParamName = 'location';
    this.referrerParamName = 'referrer';
    this.otherCookiesParamName = 'otherCookies';
    this.otherVariablesParamName = 'otherVariables';
    this.projectIdParamName = 'projectId';

    // Invitation randomization tags.
    this.randomTag = '@random';
    this.itemTag = '@item';
    this.endTag = '@end';

    // The created invitation runtime.
    this.runtime = null;
    
    // The email domain dep user Id.
    this.userId = null;
    
    // Saved blocking objects.
    this.blockingElements = new Array();

    // Attach utility methods.
    this.getVariableValue = InvitationBuilder_getVariableValue;
    this.submitViaImage = InvitationBuilder_submitViaImage;
    this.validateEmailAddress = InvitationBuilder_validateEmailAddress;

    // Attach core methods.
    this.start = InvitationBuilder_start;
    this.chooseInvitation = InvitationBuilder_chooseInvitation;

    // Attach invitation methods.
    this.injectInvitation = InvitationBuilder_injectInvitation;
    this.getPageLeftOffset = InvitationBuilder_getPageLeftOffset;
    this.getPageTopOffset = InvitationBuilder_getPageTopOffset;
    this.getPageWidth = InvitationBuilder_getPageWidth;
    this.getPageHeight = InvitationBuilder_getPageHeight;
    this.setInvitationPosition = InvitationBuilder_setInvitationPosition;
    this.showInvitation = InvitationBuilder_showInvitation;
    this.hideInvitation = InvitationBuilder_hideInvitation;
    this.hideBlockingElements = InvitationBuilder_hideBlockingElements;
    this.showBlockingElements = InvitationBuilder_showBlockingElements;
    this.onAccept = InvitationBuilder_onAccept;
    this.onDecline = InvitationBuilder_onDecline;
    this.addParam = InvitationBuilder_addParam;
    this.processTags = InvitationBuilder_processTags;
    this.processRandom = InvitationBuilder_processRandom;
    this.processItem = InvitationBuilder_processItem;
    
    // Safely attempts to grab a form variable.
    function InvitationBuilder_getVariableValue(expression)
    {
        var r = '';
        
        // Split the expression into form and variable name.
        var values = expression.split('.');
        if (values.length == 2)
        {
            formName = values[0];
            variableName = values[1];
            
            var f = document.forms[formName];
            if (f)
            {
                v = document.forms[formName].elements[variableName];
                if (v)
                {
                    r = v.value;
                }
            }
        }
        
        return r;
    }
    
    // Submits a request via an image link.
    function InvitationBuilder_submitViaImage(url)
    {
        var i = new Image();
        i.src = url + '&' + (new Date()).getTime();
    }
       
    // Returns true if an email address is valid.
    function InvitationBuilder_validateEmailAddress(address)
    {
        return (address.indexOf('.') > 2) && (address.indexOf('@') > 0);
    }
    
    // Start a survey invitation.
    function InvitationBuilder_start()
    {
        var invitations = SiteRecruit_Config.invitations;
        
        if (invitations.length > 0)
        {
            // Determine which survey to run.
            var invitation = this.chooseInvitation(invitations);
            
            // Store the chosen invitation in the globals.
            SiteRecruit_Globals.chosenInvitation = invitation;

			// only write the alreadyAsked cookie here if we are not in test mode or if we are in testmode and tracking hasn't started already	
			if (!SiteRecruit_Globals.cookieUtils.surveyCookieExists(SiteRecruit_Constants.cookieType.inProgress) && !SiteRecruit_Globals.cookieUtils.surveyCookieExists(SiteRecruit_Constants.cookieType.emailDomainDeparture))
			{
				
				SiteRecruit_Globals.cookieUtils.setSurveyCookieX(SiteRecruit_Constants.cookieType.alreadyAsked,
					invitation.useRapidCookie);
	        
				// Bail if the cookie doesn't set properly.
				if (!SiteRecruit_Globals.cookieUtils.surveyCookieExists(SiteRecruit_Constants.cookieType.alreadyAsked))
				{
						        
					return;
				}
            }               
           
                     
            this.runtime = new SiteRecruit_InvitationRuntime();
            this.injectInvitation(invitation);
            
            if (invitation.revealDelay > 0)
            {
                setTimeout('SiteRecruit_Globals.builder.showInvitation()', invitation.revealDelay);
            }
            else
            {
                this.showInvitation();
            }
        }
                
    }
    
    // Chooses an invitation to run based on the configured weightings.
    function InvitationBuilder_chooseInvitation(invitations)
    {
        var invitation = null;
        
        var f = invitations[0].weight;
        
        var totalWeight = 0;
        var realWeightInvitations = new Array();
        
        // Find the spot.
        for (var s = 0; s < invitations.length; s++)
        {
            if (invitations[s].weight >= 1)
            {
                totalWeight += invitations[s].weight;
                realWeightInvitations[realWeightInvitations.length] = s;
            }
        }
        
        // Only choose an invitation if the weight is sensible.
        if (totalWeight >= 1)
        {
            var r = Math.floor(Math.random() * totalWeight) + 1;
            
            var currentSum = 0;
            for (var s = 0; s < realWeightInvitations.length; s++)
            {
                var newInvitationNum = realWeightInvitations[s];
                currentSum += invitations[newInvitationNum].weight;
            
                if (r <= currentSum)
                {
                    invitation = invitations[newInvitationNum];
                    break;
                } 
            }
        }
        else
        {
            // Remove cookie, as this person didn't get hit.
            this.removeCookie();
        }
        
        return invitation;
    }
        
    // Processes any tags in the invitation content.
    function InvitationBuilder_processTags(s)
    {    
        var t = '';
        var c = 0;
        
        // Find the first random (if any).
        var randomStart = s.indexOf(this.randomTag);           
        while (randomStart != -1)
        {
            // Grab the text before.
            t += s.substring(c, randomStart);
            
            // Process the random.
            var r = this.processRandom(s, randomStart, 1);
            t += r[0];
            c = r[1];
            
            // Find the next one.
            randomStart = s.indexOf(this.randomTag, c);
        }
    
        // Add anything remaining.
        t += s.substring(c);
            
        return t;
    }
    
    // Processes a single random tag within a larger string.
    function InvitationBuilder_processRandom(s, start, depth)
    {        
        var items = [];
        
        // Advance past the start tag.
        var c = start + this.randomTag.length;
        
        var moreItems = true;
        while (moreItems)
        {
            // See if there is an item closer than end.
            var itemStart = s.indexOf(this.itemTag, c);
            var endStart = s.indexOf(this.endTag, c);
            
            if (itemStart == -1 || endStart < itemStart)
            {
                // Advance past the end tag and break.
                c = endStart + this.endTag.length;
                moreItems = false;
            }
            else
            {
                var r = this.processItem(s, itemStart, ++depth);
                items.push(r[0]);
                c = r[1];
            }
        }
        
        // Shuffle the items to create the result string.
        t = '';
        while (items.length > 0)
        {
            t += items.splice(Math.floor(SiteRecruit_Globals.primer.srandom() * items.length), 1);
        }
        return [t, c];
    }
    
    // Processes a single item tag in a larger string.
    function InvitationBuilder_processItem(s, start, depth)
    {   
        var t = '';
        
        // Advance past the start tag.
        var c = start + this.itemTag.length;
        
        var moreRandoms = true;
        while (moreRandoms)
        {
            var randomStart = s.indexOf(this.randomTag, c);
            var endStart = s.indexOf(this.endTag, c);
            if (randomStart == -1 || endStart < randomStart)
            {
                // Take all of the text up to the end tag, advance, and break.
                t += s.substring(c, endStart);
                c = endStart + this.endTag.length;
                moreRandoms = false;
            }
            else
            {
                // Take all of the text before the tag.
                t += s.substring(c, randomStart);
                r = this.processRandom(s, randomStart, ++depth);
                t += r[0];
                c = r[1];
            }
        }
        return [t, c];
    }
        
    // Injects the survey invitation layer.
    function InvitationBuilder_injectInvitation(invitation)
    {
        // First register the view.
        var fullViewUrl = invitation.viewUrl + '?' + invitation.viewParams
            + '&location=' + escape(window.location.toString())
            + '&referrer=' + escape(document.referrer); 
        this.submitViaImage(fullViewUrl);

        // Replace all of the template vars.
        var ar = new RegExp(this.acceptHandlerTag, 'g');
        var dr = new RegExp(this.declineHandlerTag, 'g');
        var content = invitation.invitationContent.replace(ar, this.acceptHandlerCode);
        content = content.replace(dr, this.declineHandlerCode);
        
        // Process the randomization tags.
        content = this.processTags(content);

        // Write the layer and the content.
        document.write('<div id="' + this.invitationLayerName
            + '" style="position:absolute'
            + '; left:0'
            + '; top:0'
            + '; z-index:10001'
            + '; visibility: hidden">');
        document.write(content);
        document.write('</div>');
    }
    
    // Returns the left offset of the page.
    function InvitationBuilder_getPageLeftOffset()
    {
        var x = 0;
        var d = document;
        
        if (typeof(window.pageYOffset) == 'number')
        {
            x = window.pageXOffset;
        }
        else if (d.body && (d.body.scrollLeft || d.body.scrollTop))
        {
            x = d.body.scrollLeft;
        }
        else if (d.documentElement && (d.documentElement.scrollLeft || d.documentElement.scrollTop))
        {
            x = d.documentElement.scrollLeft;
        }
        
        return x;
    }
    
    // Returns the top offset of the page.
    function InvitationBuilder_getPageTopOffset()
    {
        var y = 0;
        var d = document;
        
        if (typeof(window.pageYOffset) == 'number')
        {
            y = window.pageYOffset;
        }
        else if (d.body && (d.body.scrollLeft || d.body.scrollTop))
        {
            y = d.body.scrollTop;
        }
        else if (d.documentElement && (d.documentElement.scrollLeft || d.documentElement.scrollTop))
        {
            y = d.documentElement.scrollTop;
        }
        
        return y;
    }

    // Returns the window width.
    function InvitationBuilder_getPageWidth()
    {
        var w = 0;
        var d = document;
        
        if (typeof(window.innerWidth) == 'number')
        {
            w = window.innerWidth;
        }
        else if (d.documentElement && (d.documentElement.clientWidth || d.documentElement.clientHeight))
        {
            w = d.documentElement.clientWidth;
        }
        else if (d.body && (d.body.clientWidth || d.body.clientHeight))
        {
            w = d.body.clientWidth;
        }
        
        return w;
    }
    
    // Returns the window height.
    function InvitationBuilder_getPageHeight()
    {
        var h = 0;
        var d = document;
        
        if (typeof(window.innerWidth) == 'number')
        {
            h = window.innerHeight;
        }
        else if (d.documentElement && (d.documentElement.clientWidth || d.documentElement.clientHeight))
        {
            h = d.documentElement.clientHeight;
        }
        else if (d.body && (d.body.clientWidth || d.body.clientHeight))
        {
            h = d.body.clientHeight;
        }
        
        return h;
    }
    
    // Moves the invitation around.
    function InvitationBuilder_setInvitationPosition(x, y)
    {    
        document.getElementById(this.invitationLayerName).style.left = x + 'px';
        document.getElementById(this.invitationLayerName).style.top = y + 'px';
    }

    // Shows the invitation layer.
    function InvitationBuilder_showInvitation()
    {
        var invitation = SiteRecruit_Globals.chosenInvitation;
        
        var x = 0;
        var y = 0;

        var h = invitation.horizontalAlignment;
        var v = invitation.verticalAlignment;

        if (h == SiteRecruit_Constants.horizontalAlignment.left)
        {
            x = invitation.horizontalMargin;
        }
        else if (h == SiteRecruit_Constants.horizontalAlignment.middle)
        {
            x = (this.getPageWidth() - invitation.invitationWidth) / 2;
        }
        else if (h == SiteRecruit_Constants.horizontalAlignment.right)
        {
            x = this.getPageWidth() - invitation.invitationWidth - invitation.horizontalMargin;
        }
        
        if (v == SiteRecruit_Constants.verticalAlignment.top)
        {
            y = invitation.verticalMargin;
        }
        else if (v == SiteRecruit_Constants.verticalAlignment.middle)
        {
            y = (this.getPageHeight() - invitation.invitationHeight) / 2;
        }
        else if (v == SiteRecruit_Constants.verticalAlignment.bottom)
        {
            y = this.getPageHeight() - invitation.invitationHeight - invitation.verticalMargin;
        }

        this.setInvitationPosition(x, y);

        if (invitation.hideBlockingElements)
        {
            // Collect the visible blocking elements.
            var objects = document.getElementsByTagName('OBJECT');
            for (var i = 0; i < objects.length; i++)
            {
                if (objects.item(i).style.visibility != 'hidden')
                {
                    this.blockingElements.push(objects.item(i));
                }
            }

            var selects = document.getElementsByTagName('SELECT');
            for (var i = 0; i < selects.length; i++)
            {
                if (selects.item(i).style.visibility != 'hidden')
                {
                    this.blockingElements.push(selects.item(i));
                }
            }

            this.hideBlockingElements();
        }

        // Shows the invite.
        document.getElementById(this.invitationLayerName).style.visibility = 'visible';
        
        this.runtime.init(x, y);
    }   
    
    // Hides the invitation layer.
    function InvitationBuilder_hideInvitation()
    {
        document.getElementById(this.invitationLayerName).style.visibility = 'hidden';
    }
        
    // Makes blocking elements visible.
    function InvitationBuilder_showBlockingElements()
    {
        for (var i = 0; i < this.blockingElements.length; i++)
        {
            this.blockingElements[i].style.visibility = 'visible';
        }
    }
    
    // Hides blocking elements.
    function InvitationBuilder_hideBlockingElements()
    {
        for (var i = 0; i < this.blockingElements.length; i++)
        {
            this.blockingElements[i].style.visibility = 'hidden';
        }
    }
        
    // Event handler for an accept.
    function InvitationBuilder_onAccept(el)
    {
		var invitation = SiteRecruit_Globals.chosenInvitation;
                
        // if EDDS, set cookie to start keepalive on next page
        if (invitation.invitationType == SiteRecruit_Constants.invitationType.emailDomainDeparture)
        {
			// only write the cookies here if we are not in test mode or if we are in testmode and tracking hasn't started already	           
			if (!SiteRecruit_Globals.cookieUtils.surveyCookieExists(SiteRecruit_Constants.cookieType.emailDomainDeparture))
			{
				// userId is random + 5 millisecond digits
				var d = new Date();
				d = d.getTime().toString();
				this.userId = SiteRecruit_Globals.primer.srandom().toString().substr(2) + d.substring(d.length-5, d.length);
				SiteRecruit_Globals.cookieUtils.setEmailDomainDepartureCookie(this.userId, invitation.trackingDuration);
		        
							}
			else
			{
				
				return false;
			}
        }
                
        // Grab the frequency.
        var frequencyString = SiteRecruit_Config.frequency.toString();
        var weightString = invitation.weight.toString();
        
        // And the version, filtering stuff out.
        var versionString = '';
        var version = '$Name$';
        var re = /\$Name\:\s*(.*)\s*\$/;
        var matches = version.match(re);
        if (matches && matches[1])
        {
            versionString = matches[1];
        }
        else
        {
            versionString = '0';
        }

        // Grab sniffer items.
        var locationString = escape(window.location.toString());
        var referrerString = escape(document.referrer);
        
        // Grab the other cookies.
        var otherCookiesString = '';
        var otherCookies = invitation.otherCookies;
        for (var i = 0; i < otherCookies.length; i++)
        {
            var c = SiteRecruit_Globals.cookieUtilities.getCookieValue(otherCookies[i]);
            if (!c)
            {
                c = '';
            }
            otherCookiesString += otherCookies[i] + this.othersEqualityChar
                + escape(c) + this.othersJoinChar;
        }
        otherCookiesString = escape(otherCookiesString);
    
        // Grab the other variables.
        var otherVariablesString = '';
        var otherVariables = invitation.otherVariables;
        for (var i = 0; i < otherVariables.length; i++)
        {
            var v = this.getVariableValue(otherVariables[i]);
            if (!v)
            {
                v = '';
            }
            otherVariablesString += otherVariables[i] + this.othersEqualityChar
                + escape(v) + this.othersJoinChar;
        }
        otherVariablesString = escape(otherVariablesString);
        
        
        var values = [];

        // Pop in all of the regular params.
        values.push({'n': this.versionParamName, 'v': versionString});
        values.push({'n': this.frequencyParamName, 'v': frequencyString});
        values.push({'n': this.weightParamName, 'v': weightString});
        values.push({'n': this.locationParamName, 'v': locationString});
        values.push({'n': this.referrerParamName, 'v': referrerString});
        values.push({'n': this.otherCookiesParamName, 'v': otherCookiesString});
        values.push({'n': this.otherVariablesParamName, 'v': otherVariablesString});
        values.push({'n': this.projectIdParamName, 'v': invitation.projectId});

        // Add any extra params.
        var p = invitation.acceptParams;
        if (p)
        {
            // Split by &'s.
            var pairs = p.split(/&/);
            
            for (var i = 0; i < pairs.length; i++)
            {
                // Split by ='s.
                var nv = pairs[i].split(/=/);
                
                // Pull out the name and value.
                var name = nv[0];
                var value = nv[1];
                
                if (name != '')
                {
                    values.push({'n': name, 'v': value});
                }
            }
        }

        // Stop the centering, show hidden elements, and hide the layer.
        clearInterval(this.runtime.savedIntervalId);
        setTimeout(this.hideInvitationCode, this.acceptHideTimeout);
        if (invitation.hideBlockingElements)
        {
            this.showBlockingElements();
        }
        
        var url = invitation.acceptUrl;
        
        // Set some shortcut flags to make the code below more palatable.
        var isEmail = invitation.invitationType == SiteRecruit_Constants.invitationType.email;
        var isDomainDeparture = invitation.invitationType == SiteRecruit_Constants.invitationType.domainDeparture;
        var isEmailDomainDeparture = invitation.invitationType == SiteRecruit_Constants.invitationType.emailDomainDeparture;
        
        // Set the appropriate URL.
        if (isDomainDeparture)
        {
            url = invitation.trackerUrl;
        }
        else if (isEmailDomainDeparture)
        {
            url = SiteRecruit_Config.listenerUrl;
        }
       
		// Create query string from values.
		
		// append ? to qs if needed
		url += (url.indexOf('?') == -1 ? '?' : '&');
		
		var len = values.length;
		for (var i = 0; i < len; i++)
		{
			url += values[i]['n'] + '=' + values[i]['v'];
			
			if (i != len-1)
				url += '&';
		}
            
        if (isEmail || isEmailDomainDeparture)
        {
            if (isEmailDomainDeparture)
            {
                url += '&action=register&user=' + this.userId;
            }
                        
            this.submitViaImage(url);
        }
        else if (isDomainDeparture)
        {
			var settings = SiteRecruit_Globals.chosenInvitation.trackerWindowConfig;
			
			SiteRecruit_Globals.chosenInvitation.trackerWindow = new SiteRecruit_TrackerWindow(settings.width, settings.height, settings.orientation, settings.offsetX, settings.offsetY, settings.autoFocus, settings.hideToolbars);
			SiteRecruit_Globals.chosenInvitation.trackerWindow.open(url);
        }
        else	// standard invitation
        {
			window.open(url, '', 'location=1,menubar=1,resizable=1,scrollbars=1,toolbar=1');
        }
                            
        // Suppress the submit.
        return false;
    }
    
    // Event handler for a decline.
    function InvitationBuilder_onDecline(el)
    {
        var invitation = SiteRecruit_Globals.chosenInvitation;

        // Stop the centering, show hidden elements, and hide the layer.
        clearInterval(this.runtime.savedIntervalId);
        setTimeout(this.hideInvitationCode, this.declineHideTimeout);
        
        if (invitation.hideBlockingElements)
        {
            this.showBlockingElements();
        }
    }   
    
    // Helper function to add extra accept parameters.
    function InvitationBuilder_addParam(name, value)
    {
        var invitation = SiteRecruit_Globals.chosenInvitation;
        invitation.acceptParams += '&' + name + '=' + escape(value);
    }
}

// Class to control invitation behaviour at runtime.
function SiteRecruit_InvitationRuntime()
{
    this.delay = 5;
    
    this.i = null;
    this.b = null;
    this.w = this.h = 0;
    this.lastX = this.lastY = 0;
    this.marginX = this.marginY = 0;
    this.savedIntervalId = 0;

    this.init = InvitationRuntime_init;
    this.adjust = InvitationRuntime_adjust;

    // Initializes the invitation event handlers and centering.
    function InvitationRuntime_init(x, y)
    {
        this.i = SiteRecruit_Globals.chosenInvitation;
        this.b = SiteRecruit_Globals.builder;
        this.w = this.i.invitationWidth;
        this.h = this.i.invitationHeight;

        if (this.i.autoCentering)
        {
            this.lastX = x;
            this.lastY = y;
            this.savedIntervalId = setInterval('SiteRecruit_Globals.builder.runtime.adjust()', this.delay);
        }
    }
    
    // Polled to center the invitation.
    function InvitationRuntime_adjust()
    {
        this.marginX = Math.round(this.b.getPageWidth() / 2) - Math.round(this.w / 2);
        this.marginY = Math.round(this.b.getPageHeight() / 2) - Math.round(this.h / 2);

        var t = this.delay;
        
        var x = this.lastX;
        var y = this.lastY;

        var dx = Math.abs(this.b.getPageLeftOffset() + this.marginX - x);
        var dy = Math.abs(this.b.getPageTopOffset() + this.marginY - y);
        var d = Math.sqrt(dx * dx + dy * dy);
        var c = Math.round(d / 50);
       
        if (this.b.getPageLeftOffset() + this.marginX > x) { x = x + t + c; }
        if (this.b.getPageLeftOffset() + this.marginX < x) { x = x - t - c; }
        if (this.b.getPageTopOffset() + this.marginY > y) { y = y + t + c; }
        if (this.b.getPageTopOffset() + this.marginY < y) { y = y - t - c; }
        
        // Repeat for stubborn elements.
        if (this.i.hideBlockingElements)
        {
            this.b.hideBlockingElements();
        }
        
        this.b.setInvitationPosition(x, y);

        this.lastX = x;
        this.lastY = y;       
    }
}





if (SiteRecruit_Globals.startBuilder)
{
    // Start the manager and runtime going.
    SiteRecruit_Globals.builder = new SiteRecruit_InvitationBuilder();
    SiteRecruit_Globals.builder.start();
}

// Multiple script protection.
}
// //
// Copyright 2008 comScore Networks. All rights reserved.
										
SiteRecruit_TrackerWindow.Orientation = { "Default":"Default",
										"Center":"Center",
										"BottomCenter":"BottomCenter",
										"BottomLeft":"BottomLeft",
										"BottomRight":"BottomRight" };										

function SiteRecruit_TrackerWindow(width, height, orientation, offsetX, offsetY, autoFocus, hideToolbars)
{
	this.features = "";
	this.width = width;
	this.height = height;
	this.orientation = orientation;
	this.offsetX = offsetX;
	this.offsetY = offsetY;	
	this.autoFocus = autoFocus;
	this.hideToolbars = hideToolbars;
	
	// wireup methods
	this.open = TrackerWindow_Open;
	this.getFeatures = TrackerWindow_GetFeatures;

	function TrackerWindow_GetFeatures()
	{
		// standard window features
		var f = "";
		
		if (this.hideToolbars)		
			f = "location=0,menubar=0,resizable=1,scrollbars=1,toolbar=0,";
		else
			f = "location=1,menubar=1,resizable=1,scrollbars=1,toolbar=1,";
		
		if (this.width && this.height && this.orientation)
		{			
			if (this.width > 0 || this.height > 0)
				f += "width=" + this.width + ",height=" + this.height + ",";
			
			var screenWidth = SiteRecruit_Globals.Utils.GetScreenWidth();
			var screenHeight = SiteRecruit_Globals.Utils.GetScreenHeight();
		
			var offsetX = (this.offsetX ? this.offsetX : 0);
			var offsetY = (this.offsetY ? this.offsetY : 0);
				
			// move window
			var moveToX;
			var moveToY;
				
			if (this.orientation == SiteRecruit_TrackerWindow.Orientation.Center)
			{
				moveToX = (screenWidth/2) - (this.width/2);
				moveToY = (screenHeight/2) - (this.height/2);
			}	
			else if (this.orientation == SiteRecruit_TrackerWindow.Orientation.BottomCenter)
			{
				moveToX = (screenWidth/2) - (this.width/2);
				moveToY = screenHeight - this.height;
			}	
			else if (this.orientation == SiteRecruit_TrackerWindow.Orientation.BottomLeft)
			{
				moveToX = 0;
				moveToY = screenHeight - this.height;
			}	
			else if (this.orientation == SiteRecruit_TrackerWindow.Orientation.BottomRight)
			{
				moveToX = screenWidth - this.width;
				moveToY = screenHeight - this.height;
			}
			
			if (moveToX != null && moveToY != null)
			{
				moveToX += offsetX;
				moveToY += offsetY;
				
				f += "left=" + moveToX + ",top=" + moveToY;
			}
		}			
		
		this.features = f;
		
		return this.features;
	}
	
	function TrackerWindow_Open(url)
	{
		window.open(url, '', this.getFeatures());
		
			}	
	

}

// KeepAlive class definition.
function SiteRecruit_KeepAlive()
{
    // Time between page checks.
    this.keepAlivePollDelay = 1000;

    // Unique (well, sorta) ID for this page.
    this.id = Math.random();

    // Attach methods.
    this.attemptStart = KeepAlive_attemptStart;
    this.checkCookie = KeepAlive_checkCookie;
    this.inProgressCookieExists = KeepAlive_inProgressCookieExists;
    this.cookieExists = KeepAlive_cookieExists;

    // Check for either domain dep or email domain dep cookies and act accordingly.
    function KeepAlive_attemptStart()
    {
        if (this.inProgressCookieExists())
        {
            setInterval('SiteRecruit_Globals.keepAlive.checkCookie()', this.keepAlivePollDelay);
        }
        else
        {
            if (this.cookieExists(SiteRecruit_Constants.cookieType.emailDomainDeparture))
            {
                var c = document.cookie.toString();
                var index = c.indexOf(SiteRecruit_Config.cookieName + '=' + SiteRecruit_Constants.cookieType.emailDomainDeparture);
                var endc = c.length;
                c = c.substring(index, endc);
                var ind1 = c.indexOf(';');
                if (ind1 != -1) c = c.substring(0, ind1);        
                var ind2 = c.indexOf('=');
                c = c.substring(ind2 + 1);
                var values = c.split(':');
                if (values.length == 2)
                {
                    var url = SiteRecruit_Config.listenerUrl;
                    
                    // append ? to qs if needed
					url += (url.indexOf('?') == -1 ? '?' : '&');
					
                    url += 'action=log'
                        + '&user=' + values[1]
                        + '&location=' + escape(window.location);
                    
                    setTimeout("var i = new Image(); i.src = '" + url + "&' + (new Date()).getTime(); ", 5);
                }
            }
        }
    }
    
    // Check and update the cookie.
    function KeepAlive_checkCookie()
    {
        if (this.inProgressCookieExists())
        {
            var c = SiteRecruit_Config.cookieName + '=' + SiteRecruit_Constants.cookieType.inProgress
                + ':' + escape(document.location)
                + ':' + (new Date()).getTime()
                + ':' + this.id
                + '; path=' + SiteRecruit_Config.cookiePath;
            
            if (SiteRecruit_Config.cookieDomain != '')
            {
                c += '; domain=' + SiteRecruit_Config.cookieDomain;
            }
            
            document.cookie = c;
        }
    }

    // Return true if an in-progress cookie exists.
    function KeepAlive_inProgressCookieExists()
    {
        return this.cookieExists(SiteRecruit_Constants.cookieType.inProgress);
    }
    
    // Return true if a cookie of the given type exists.
    function KeepAlive_cookieExists(cookieType)
    {
        var c = SiteRecruit_Config.cookieName + '=' + cookieType;
        if (document.cookie.indexOf(c) != -1)
        {
            return true;
        }
        return false;
    }
}

// Create the KeepAlive if a suitable cookie exists.
SiteRecruit_Globals.keepAlive = new SiteRecruit_KeepAlive();
SiteRecruit_Globals.keepAlive.attemptStart();