function VoviciWebInterceptSurvey(){
	this.utils = new VoviciSurveyUtils();
	this.SurveyUrl = "";
	this.ExitSurveyUrl = "";
	this.ShoppingCartAbandonmentSurveyUrl = "";
	this.ShoppingCartCompletedSurveyUrl = "";
	this.FailoverToLayerWhenPopupsBlocked = false;
	this.ShoppingCartCookieName = "";
	this.ShoppingCartRegex="";
	this.PurchaseMadeCookieName = "";
	this.PurchaseMadeRegex="";
	this.WatcherJavascriptUrl = 'https://clarahost.clara.net/websurvey.spa-mr.com/CZ/VoviciSurveyInvite.js';
	this.NthVisitorToInvite = 1;
	this.SurveyInNewWindow = false;
	this.SurveyWindowWidth = 625;
	this.SurveyWindowHeight = 400;
	this.SurveyWindowLeftOffset = 200;
	this.SurveyWindowTopOffset = 100;
	this.SurveyWindowDecorationOptions = "scrollbars=yes, resizable=true, location=no, toolbar=no, menubar=no";
	this.SurveyWindowName = "VoviciSurvey";
	this.CookieDomain = "";
	this.CookieValue = "1";
	this.CookieDuration = "";
	this.CookiePath = "/";
	this.CookieName = "VOVICI_SURVEY_INVITE";
	this.LaunchExitSurveyCookieValue = "2";
	this.InviteStyle = 'popup';
	this.SurveyPrompt = "We'd like your input! Please take a few moments to complete a brief survey.";
	this.SurveyPromptDivInnerHtml = '<map name="VoviciSurveyPromptMap">'
	+ '<area id="VoviciSurveyPromptYesButton" shape="rect" coords="65,125,225,175" >'
	+ '<area id="VoviciSurveyPromptNoButton" shape="rect" coords="340,125,500,175" >'
	+ '<area shape="default" nohref>'
	+ '</map><img src="surveyinvite1.gif" border="0" usemap="#VoviciSurveyPromptMap">';
	this.SurveyPromptDivYesButtonId = "VoviciSurveyPromptYesButton";
	this.SurveyPromptDivNoButtonId = "VoviciSurveyPromptNoButton";
	this.SurveyPromptDivWidth = 575;
	this.SurveyPromptDivHeight = 179;
	this.SurveyPromptDivLeftOffset = 200;
	this.SurveyPromptDivTopOffset = 100;
	this.SurveyFrameName = "VoviciSurveyFrameOuterDiv";
	this.SurveyInnerFrameName = "VoviciSurveyFrameInnerDiv";
	this.SurveyDisplayFrameInnerHtml = '<div id="' + this.SurveyFrameName + '" style="background-color:#FFFFFF;border: 1px solid #E2E5E7;">'
	+ '  <div id="' + this.SurveyPromptDivNoButtonId + '" style="text-align:right; color: red">[x]</div>'
	+ '<div id="' + this.SurveyInnerFrameName + '" ></div>'
	+ '</div>';
	this.URLParameters = new Array();
	this.SurveyPromptDivName = "VoviciSurveyInvite_Prompt";
	this.div;
	this.toString = function () {
		return "VoviciWebInterceptSurvey internal state:"
		+ "\n\tDebuggingEnabled: " + this.utils.DebuggingEnabled
		+ "\n\tSurveyUrl: " + this.GetSurveyUrl()
		+ "\n\tNthVisitorToInvite: " + this.NthVisitorToInvite
		+ "\n\tInviteStyle: " + survey.InviteStyle		
		+ "\n"
		+ "\n\tSurveyPrompt: " + this.SurveyPrompt
		+ "\n\tSurveyPromptDivName: " + this.SurveyPromptDivName
		+ "\n\tSurveyPromptDivInnerHtml: " + this.SurveyPromptDivInnerHtml
		+ "\n\tSurveyPromptDivYesButtonId: " + this.SurveyPromptDivYesButtonId
		+ "\n\tSurveyPromptDivNoButtonId: " + this.SurveyPromptDivNoButtonId
		+ "\n\tSurveyPromptDivWidth: " + this.SurveyPromptDivWidth
		+ "\n\tSurveyPromptDivHeight: " + this.SurveyPromptDivHeight
		+ "\n\tSurveyPromptDivLeftOffset: " + this.SurveyPromptDivLeftOffset
		+ "\n\tSurveyPromptDivTopOffset: " + this.SurveyPromptDivTopOffset		
		+ "\n"
		+ "\n\tSurveyInNewWindow: " + this.SurveyInNewWindow
		+ "\n\tSurveyWindowWidth: " + this.SurveyWindowWidth
		+ "\n\tSurveyWindowHeight: " + this.SurveyWindowHeight
		+ "\n\tSurveyWindowLeftOffset: " + this.SurveyWindowLeftOffset
		+ "\n\tSurveyWindowTopOffset: " + this.SurveyWindowTopOffset
		+ "\n\tSurveyWindowDecorationOptions: " + this.SurveyWindowDecorationOptions
		+ "\n\tSurveyWindowName: " + this.SurveyWindowName		
		+ "\n"
		+ "\n\tSurveyFrameName: " + this.SurveyFrameName
		+ "\n\tSurveyInnerFrameName: " + this.SurveyInnerFrameName
		+ "\n\tSurveyDisplayFrameInnerHtml : " + this.SurveyDisplayFrameInnerHtml		
		+ "\n"
		+ "\n\tCookieDomain: " + this.CookieDomain
		+ "\n\tCookieName: " + this.CookieName
		+ "\n\tCookieValue: " + this.CookieValue
		+ "\n\tCookiePath: " + this.CookiePath
		+ "\n\tCookieDuration: " + this.CookieDuration
		+ "\n\nCookies:\n\n"
		+ "\n\t" + this.CookieName + ": " + this.utils.GetCookie(this.CookieName)		
		+ "\n"
		+ "\n\tLaunchExitSurvey: " + this.LaunchExitSurvey()
		+ "\n\tFailoverToLayerWhenPopupsBlocked: " + this.FailoverToLayerWhenPopupsBlocked
		+ "\n\tExitSurveyUrl: " + this.GetExitSurveyUrl()
		+ "\n\tShoppingCartAbandonmentSurveyUrl: " + this.GetShoppingCartAbandonmentSurveyUrl()
		+ "\n\tShoppingCartCompletedSurveyUrl: " + this.GetShoppingCartCompletedSurveyUrl()
		+ "\n\tShoppingCartCookieName: " + this.ShoppingCartCookieName
		+ "\n\tShoppingCartRegex: " + this.ShoppingCartRegex
		+ "\n\tPurchaseMadeCookieName: " + this.PurchaseMadeCookieName
		+ "\n\tPurchaseMadeRegex: " + this.PurchaseMadeRegex
		+ "\n\tWatcherJavascriptUrl: " + this.WatcherJavascriptUrl
		;
	}
	this.DebuggingEnabled = function(enabled){
		this.utils.DebuggingEnabled = enabled;
	}
	this.Load = function(){
	        var survey=this;
	        this.utils.DebugLog("Adding window.onload handler for Web Intercept Survey Load");
	        this.utils.AddEvent(window, "load",  function() { survey.CheckForInvite(); });
	}
	this.TestLoad = function(){
	        var survey=this;
	        this.utils.AddEvent(window, "load",  function() { survey.YesButtonClicked(); });
	}               
	this.CheckForInvite = function(){
		if ( this.utils.GetCookie(this.CookieName) == this.LaunchExitSurveyCookieValue ){
			if ( this.LaunchExitSurvey() ){
				this.ExitSurvey();
			}
		} else if ( this.utils.GetCookie(this.CookieName) != this.CookieValue ){
	                this.utils.SetCookie(this.CookieName, this.CookieValue, this.CookieDomain, this.CookieDuration, this.CookiePath);
	                if ( this.utils.GetRandom(this.NthVisitorToInvite) == this.NthVisitorToInvite ) {
	                	this.Invite();
	                }
	        } 
	}
	this.Invite = function(){
		if ( this.InviteStyle == 'popup' ){
                        if ( confirm(this.SurveyPrompt) ){
                        	this.YesButtonClicked();
                        }
                } else {
        		this.Create(this.SurveyPromptDivName, this.SurveyPromptDivInnerHtml, 
        			    this.SurveyPromptDivYesButtonId, this.SurveyPromptDivNoButtonId,
        			    this.SurveyPromptDivWidth, this.SurveyPromptDivHeight, 
        			    this.SurveyPromptDivLeftOffset, this.SurveyPromptDivTopOffset);
        	}	
	}
	this.Create = function (id, html, yesButtonId, noButtonId, width, height, left, top) { 
	   this.utils.DebugLog("VoviciWebInterceptSurvey.Create");	
	   var containerName = "VoviciSurveyPromptContainer_" + id;
	   this.SurveyPromptDivName = id;
	   var prompt = document.createElement('div');
	   prompt.style.display = 'none'; // hide until done with setup
	   prompt.setAttribute('id', containerName);
	   prompt.setAttribute('name', containerName);
	   prompt.innerHTML = html;
	   document.body.appendChild(prompt);
	   this.div = document.getElementById(this.SurveyPromptDivName);
	   this.div.style.width = width ? width : 575;
	   this.div.style.height = height ? height : 179;
	   if ((left || top) || (left && top)) {
	       this.div.style.position = "absolute";
	       this.div.style.left = left ? left : 200;
	       this.div.style.top = top ? top : 200;
	   }
	   var popup = this;
	   if ( yesButtonId ){
	   	var yes = document.getElementById(yesButtonId);
	   	if ( yes ){
	   		this.utils.AddEvent(yes, "click",  function() { popup.YesButtonClicked(); });
	   	}
	   }
	   if ( noButtonId ){
	   	var no = document.getElementById(noButtonId);
	   	if ( no ){
	   		this.utils.AddEvent(no, "click",  function() { popup.NoButtonClicked(); });
	   	}
	   }
	   prompt.style.display = 'block';
	} 
	this.YesButtonClicked = function (){
		this.Hide();
		if ( this.LaunchExitSurvey() ){
			
			//old line
            //this.utils.SetCookie(this.CookieName, this.LaunchExitSurveyCookieValue, this.CookieDomain, this.CookieDuration, this.CookiePath);
            
            //new line
			this.utils.SetCookie(this.CookieName, this.CookieValue, this.CookieDomain, this.CookieDuration, this.CookiePath);
			
			this.ExitSurvey();
		}else{
			if ( this.SurveyInNewWindow ){
				var options = "width=" + this.SurveyWindowWidth + ",height=" + this.SurveyWindowHeight + "," 
					    + "top=" + this.SurveyWindowTopOffset + ",left=" + this.SurveyWindowLeftOffset + "," 
					    + this.SurveyWindowDecorationOptions;
	        		var child = window.open(this.GetSurveyUrl(), this.SurveyWindowName, options);
				child.focus();
	        	}else{
	                	window.location=this.GetSurveyUrl();
	                }
        	}
		return false;
	}
	this.ExitSurvey = function (){
		var exitSurvey = new VoviciExitSurvey();
		exitSurvey.CookieDomain = this.CookieDomain;
		exitSurvey.CookieValue = this.CookieValue;
		exitSurvey.CookieDuration = this.CookieDuration;
		exitSurvey.CookiePath = this.CookiePath;
		exitSurvey.ShoppingCartCookieName = this.ShoppingCartCookieName;
		exitSurvey.ShoppingCartRegex = this.ShoppingCartRegex;
		exitSurvey.PurchaseMadeCookieName = this.PurchaseMadeCookieName;
		exitSurvey.PurchaseMadeRegex = this.PurchaseMadeRegex;
		exitSurvey.PromptToTakeTheSurvey = false;
		exitSurvey.WatcherJavascriptUrl = this.WatcherJavascriptUrl;
		exitSurvey.ExitSurveyUrl = this.ExitSurveyUrl;
		exitSurvey.ShoppingCartAbandonmentSurveyUrl = this.ShoppingCartAbandonmentSurveyUrl;
		exitSurvey.ShoppingCartCompletedSurveyUrl = this.ShoppingCartCompletedSurveyUrl;
		exitSurvey.FailoverToLayerWhenPopupsBlocked = this.FailoverToLayerWhenPopupsBlocked;
		exitSurvey.URLParameters = this.URLParameters;
		exitSurvey.SurveyWindowWidth = this.SurveyWindowWidth;
		exitSurvey.SurveyWindowHeight = this.SurveyWindowHeight;
		exitSurvey.SurveyWindowLeftOffset = this.SurveyWindowLeftOffset;
		exitSurvey.SurveyWindowTopOffset = this.SurveyWindowTopOffset;
		exitSurvey.SurveyWindowDecorationOptions = this.SurveyWindowDecorationOptions;
		exitSurvey.SurveyFrameName = this.SurveyFrameName;
		exitSurvey.SurveyInnerFrameName = this.SurveyInnerFrameName;
		exitSurvey.SurveyDisplayFrameInnerHtml = this.SurveyDisplayFrameInnerHtml;
		exitSurvey.DebuggingEnabled(this.utils.DebuggingEnabled);
		exitSurvey.SetupWatcher();
		return false;
	}
	this.NoButtonClicked = function (){
		this.utils.SetCookie(this.CookieName, this.CookieValue, this.CookieDomain, this.CookieDuration, this.CookiePath);
		this.Hide();
		return false;
	}
	this.Hide = function (){
		if ( this.div ){
			this.div.style.display = 'none';
		}
	}
	this.Show = function (){
		if ( this.div ){
			this.div.style.display = 'block';
		}
	}
	this.GetSurveyUrl = function(){
		return this.SurveyUrl;
	}
	this.GetExitSurveyUrl = function(){
		return this.utils.AddUrlParameters( this.ExitSurveyUrl, this.URLParameters);
	}
	this.GetShoppingCartAbandonmentSurveyUrl = function(){
		return this.utils.AddUrlParameters( this.ShoppingCartAbandonmentSurveyUrl, this.URLParameters);
	}
	this.GetShoppingCartCompletedSurveyUrl = function(){
		return this.utils.AddUrlParameters( this.ShoppingCartCompletedSurveyUrl, this.URLParameters);
	}
	this.AddUrlParameter = function(name, val){
		this.URLParameters[name] = val;
	}
	this.LaunchExitSurvey = function(){
		return this.ExitSurveyUrl != ""
			|| this.ShoppingCartAbandonmentSurveyUrl != ""
			|| this.ShoppingCartCompletedSurveyUrl != "";
	}
}
function VoviciExitSurvey(){
	this.utils = new VoviciSurveyUtils();
	this.WatcherJavascriptUrl = 'https://clarahost.clara.net/websurvey.spa-mr.com/CZ/VoviciSurveyInvite.js';
	this.ExitSurveyUrl = "";
	this.ShoppingCartAbandonmentSurveyUrl = "";
	this.ShoppingCartCompletedSurveyUrl = "";
	this.FailoverToLayerWhenPopupsBlocked = false;
	this.NthVisitorToInvite = 1;
	this.SurveyInNewWindow = false;
	this.SurveyWindowWidth = 625;
	this.SurveyWindowHeight = 400;
	this.SurveyWindowLeftOffset = 200;
	this.SurveyWindowTopOffset = 100;
	this.SurveyWindowDecorationOptions = "scrollbars=yes, resizable=true, location=no, toolbar=no, menubar=no";
	this.SurveyWindowName = "VoviciExitSurvey";
	this.CookieDomain = "";
	this.CookieValue = "1"; 
	this.CookieDuration = "1440";
	this.CookiePath = "/";
	this.CookieName = "VOVICI_EXIT_SURVEY_INVITE";
	this.ShoppingCartCookieName = "";
	this.ShoppingCartRegex="";
	this.PurchaseMadeCookieName = "";
	this.PurchaseMadeRegex="";
	this.PromptToTakeTheSurvey = true;
	this.InviteStyle = 'popup';
	this.SurveyPrompt = "We'd like your input! Please take a few moments to complete a brief survey.";
	this.SurveyPromptDivInnerHtml = '<map name="VoviciSurveyPromptMap">'
	+ '<area id="VoviciSurveyPromptYesButton" shape="rect" coords="65,125,225,175" >'
	+ '<area id="VoviciSurveyPromptNoButton" shape="rect" coords="340,125,500,175" >'
	+ '<area shape="default" nohref>'
	+ '</map><img src="surveyinvite1.gif" border="0" usemap="#VoviciSurveyPromptMap">';
	this.SurveyPromptDivYesButtonId = "VoviciSurveyPromptYesButton";
	this.SurveyPromptDivNoButtonId = "VoviciSurveyPromptNoButton";
	this.SurveyPromptDivWidth = 575;
	this.SurveyPromptDivHeight = 179;
	this.SurveyPromptDivLeftOffset = 200;
	this.SurveyPromptDivTopOffset = 100;
	this.WatcherMessageDivName = "VoviciWatcherMessage";
	this.WatcherMessage = '<div style="height:100px;text-align:left;padding-left:3px; font: bold 14px arial, helvetica, sans-serif; color:E20074;">Anketa n&aacute;v&#353;t&#283;vn&iacute;k&#367; T-Mobile se objev&iacute; v tomto okn&#283;, jakmile webovou str&aacute;nku opust&iacute;te. Nezav&iacute;rejte pros&iacute;m toto okno, chcete-li se ankety z&uacute;&#269;astnit.</div>';
	this.SurveyFrameName = "VoviciSurveyFrameOuterDiv";
    this.SurveyInnerFrameName = "VoviciSurveyFrameInnerDiv";
    this.SurveyDisplayFrameInnerHtml = '<div id="' + this.SurveyFrameName + '" style="background-color:#FFFFFF;border: 1px solid #E2E5E7;">'
	+ '  <div id="' + this.SurveyPromptDivNoButtonId + '" style="text-align:right; color: red">[x]</div>'
	+ '<div id="' + this.SurveyInnerFrameName + '" ></div>'
	+ '</div>';
	this.SurveyPromptDivName = "VoviciExitSurveyInvite_Prompt";
	this.TimerInterval = new Number(1000);
	this.TimerId;
	this.Watcher;
	this.WatcherWindowName = "VoviciExitSurveyWatcher";
	this.WatcherWindowDecorationOptions = "scrollbars=no, resizable=true, location=no, toolbar=no, menubar=no";
	this.URLParameters = new Array();
}
VoviciExitSurvey.prototype.DebuggingEnabled  = function(enabled){
	this.utils.DebuggingEnabled = enabled;	
}
VoviciExitSurvey.prototype.toString = function () {
	return "VoviciExitSurvey internal state:"
		+ "\n\tDebuggingEnabled: " + this.utils.DebuggingEnabled
		+ "\n\tFailoverToLayerWhenPopupsBlocked: " + this.FailoverToLayerWhenPopupsBlocked
		+ "\n\tExitSurveyUrl: " + this.GetExitSurveyUrl()
		+ "\n\tShoppingCartAbandonmentSurveyUrl: " + this.GetShoppingCartAbandonmentSurveyUrl()
		+ "\n\tShoppingCartCompletedSurveyUrl: " + this.GetShoppingCartCompletedSurveyUrl()
		+ "\n\tNthVisitorToInvite: " + this.NthVisitorToInvite
		+ "\n"
		+ "\n\tInviteStyle: " + this.InviteStyle
		+ "\n\tPromptToTakeTheSurvey: " + this.PromptToTakeTheSurvey
		+ "\n\tSurveyPrompt: " + this.SurveyPrompt
		+ "\n\tSurveyPromptDivName: " + this.SurveyPromptDivName
		+ "\n\tSurveyPromptDivInnerHtml: " + this.SurveyPromptDivInnerHtml
		+ "\n\tSurveyPromptDivYesButtonId: " + this.SurveyPromptDivYesButtonId
		+ "\n\tSurveyPromptDivNoButtonId: " + this.SurveyPromptDivNoButtonId
		+ "\n\tSurveyPromptDivWidth: " + this.SurveyPromptDivWidth
		+ "\n\tSurveyPromptDivHeight: " + this.SurveyPromptDivHeight
		+ "\n\tSurveyPromptDivLeftOffset: " + this.SurveyPromptDivLeftOffset
		+ "\n\tSurveyPromptDivTopOffset: " + this.SurveyPromptDivTopOffset
		+ "\n"
		+ "\n\tSurveyInNewWindow: " + this.SurveyInNewWindow
		+ "\n\tSurveyWindowWidth: " + this.SurveyWindowWidth
		+ "\n\tSurveyWindowHeight: " + this.SurveyWindowHeight
		+ "\n\tSurveyWindowLeftOffset: " + this.SurveyWindowLeftOffset
		+ "\n\tSurveyWindowTopOffset: " + this.SurveyWindowTopOffset
		+ "\n\tSurveyWindowDecorationOptions: " + this.SurveyWindowDecorationOptions
		+ "\n\tSurveyWindowName: " + this.SurveyWindowName
		+ "\n"
		+ "\n\tSurveyFrameName: " + this.SurveyFrameName
		+ "\n\tSurveyInnerFrameName: " + this.SurveyInnerFrameName
		+ "\n\tSurveyDisplayFrameInnerHtml : " + this.SurveyDisplayFrameInnerHtml
		+ "\n"
		+ "\n\tTimerInterval: " + this.TimerInterval
		+ "\n"
		+ "\n\tCookieDomain: " + this.CookieDomain
		+ "\n\tCookieName: " + this.CookieName
		+ "\n\tCookieValue: " + this.CookieValue
		+ "\n\tCookiePath: " + this.CookiePath
		+ "\n\tCookieDuration: " + this.CookieDuration
		+ "\n\nCookies:\n\n"
		+ "\n\t" + this.CookieName + ": " + this.utils.GetCookie(this.CookieName)
		;
}	
VoviciExitSurvey.prototype.GetExitSurveyUrl = function(){
	return this.utils.AddUrlParameters( this.ExitSurveyUrl, this.URLParameters);
}
VoviciExitSurvey.prototype.GetShoppingCartAbandonmentSurveyUrl = function(){
	return this.utils.AddUrlParameters( this.ShoppingCartAbandonmentSurveyUrl, this.URLParameters);
}
VoviciExitSurvey.prototype.GetShoppingCartCompletedSurveyUrl = function(){
	return this.utils.AddUrlParameters( this.ShoppingCartCompletedSurveyUrl, this.URLParameters);
}
VoviciExitSurvey.prototype.AddUrlParameter = function(name, val){
	this.URLParameters[name] = val;
}
VoviciExitSurvey.prototype.Load = function(){
        var survey=this;
        this.utils.DebugLog("Adding window.onload handler for SetupWatcher");
        this.utils.AddEvent(window, "load",  function() { survey.SetupWatcher(); });
}
VoviciExitSurvey.prototype.SetupWatcher = function(){
	this.utils.DebugLog("SetupWatcher starting..");
	var blnCheck = new Boolean(false);
	var blnSet = new Boolean(false);
	this.WatcherLaunch();
	this.Check(blnCheck, blnSet);
	var survey = this;
	this.utils.DebugLog("Setting timer for Check at interval " + this.TimerInterval);
	this.TimerId = setInterval( function () { survey.Check(blnCheck,blnSet);}, this.TimerInterval);
}
VoviciExitSurvey.prototype.WatcherLaunch = function(){
	var cookie = this.utils.GetCookie(this.CookieName);
	this.utils.DebugLog("WatcherLaunch: " + cookie);
	var blnCheck = new Boolean(true);
	var blnSet = new Boolean(true);
	if (!cookie || cookie == ""){
		this.Check(blnCheck, blnSet);
		this.utils.DebugLog("Opening watcher window");
		var left = (document.all) ? window.screenLeft : window.screenX;
		var top = (document.all) ? window.screenTop : window.screenY;
		var width = 300;
		var height = 50;
		var options = "width=" + width + ",height=" + height + "," 
				    + "top=" + top + ",left=" + left + "," 
				    + this.WatcherWindowDecorationOptions;
        	var watcherWindow = window.open('', this.WatcherWindowName, options);
        	if ( watcherWindow ){
        		this.Watcher = watcherWindow;
	        	var addParms = "";
	        	for (var key in this.URLParameters){
				addParms += "  	watcher.AddUrlParameter('" + key + "', '" + this.URLParameters[key] + "');\n"
			}
			this.Watcher.document.write("<html><head><title>Vovici Exit Survey Watcher</title>\n"
				+ "<script type='text/javascript' language='javascript' src='" + this.WatcherJavascriptUrl + "'></script>\n"
				+ "<script type='text/javascript' language='javascript'>\n"
				+ "<!--\n"
				+ "function LoadWatcher() {\n"
				+ "  var watcher = new VoviciSurveyWatcher();\n"
				+ "  watcher.DebuggingEnabled('" + this.utils.DebuggingEnabled + "');\n"
				+ "  watcher.ExitSurveyUrl ='" + this.ExitSurveyUrl + "';\n"
				+ "  watcher.ShoppingCartAbandonmentSurveyUrl ='" + this.ShoppingCartAbandonmentSurveyUrl + "';\n"
				+ "  watcher.ShoppingCartCompletedSurveyUrl ='" + this.ShoppingCartCompletedSurveyUrl + "';\n"
				+ addParms
				+ "  watcher.ShoppingCartCookieName ='" + this.ShoppingCartCookieName + "';\n"
				+ "  watcher.ShoppingCartRegex ='" + this.ShoppingCartRegex + "';\n"
				+ "  watcher.PurchaseMadeCookieName ='" + this.PurchaseMadeCookieName + "';\n"
				+ "  watcher.PurchaseMadeRegex ='" + this.PurchaseMadeRegex + "';\n"
				+ "  watcher.PromptToTakeTheSurvey = " + this.PromptToTakeTheSurvey + ";\n"
				+ "  watcher.WatcherMessageDivName='" + this.WatcherMessageDivName + "';\n"
				+ "  watcher.SurveyPromptDivName='" + this.SurveyPromptDivName + "';\n"
				+ "  watcher.SurveyPromptDivYesButtonId='" + this.SurveyPromptDivYesButtonId + "';\n"
				+ "  watcher.SurveyPromptDivNoButtonId='" + this.SurveyPromptDivNoButtonId + "';\n"
				+ "  watcher.SurveyPromptDivWidth= " + this.SurveyPromptDivWidth + ";\n"
				+ "  watcher.SurveyPromptDivHeight= " + this.SurveyPromptDivHeight + ";\n"
				+ "  watcher.SurveyPromptDivLeftOffset= " + this.SurveyPromptDivLeftOffset + ";\n"
				+ "  watcher.SurveyPromptDivTopOffset= " + this.SurveyPromptDivTopOffset + ";\n"
				+ "  watcher.SurveyWindowWidth= " + this.SurveyWindowWidth + ";\n"
				+ "  watcher.SurveyWindowHeight= " + this.SurveyWindowHeight + ";\n"
				+ "  watcher.SurveyWindowLeftOffset= " + this.SurveyWindowLeftOffset + ";\n"
				+ "  watcher.SurveyWindowTopOffset= " + this.SurveyWindowTopOffset + ";\n"
				+ "  watcher.WatcherLoad();\n"
				+ "}\n"
				+ "// -->\n"
				+ "</script>\n</head>\n<body onload='LoadWatcher()'>\n"
				+ "<div id='" + this.SurveyPromptDivName + "' style='display:none'>"
				+ this.SurveyPromptDivInnerHtml

				+ "</div>\n<div id='" + this.WatcherMessageDivName + "'>"
				+ this.WatcherMessage
				+ "</div>\n"
				+ "</body>\n</html>");	
			this.Watcher.document.close();
			if (!this.Watcher.opener) this.Watcher.opener = self;
			if ( !this.TimerId){
				var survey = this;
				this.TimerId = setInterval( function () { survey.Check(blnCheck,blnSet);}, this.TimerInterval);
			}
		}else if (this.FailoverToLayerWhenPopupsBlocked){
			var watcher = new VoviciSurveyWatcher();
			watcher.IsAPopup = false; // KEY to working
            		watcher.DebuggingEnabled(this.utils.DebuggingEnabled);
			watcher.ExitSurveyUrl = this.ExitSurveyUrl;
			watcher.ShoppingCartAbandonmentSurveyUrl = this.ShoppingCartAbandonmentSurveyUrl;
			watcher.ShoppingCartCompletedSurveyUrl = this.ShoppingCartCompletedSurveyUrl;
			watcher.URLParameters = this.URLParameters;
			watcher.ShoppingCartCookieName = this.ShoppingCartCookieName;
			watcher.ShoppingCartRegex = this.ShoppingCartRegex;
			watcher.PurchaseMadeCookieName = this.PurchaseMadeCookieName;
			watcher.PurchaseMadeRegex = this.PurchaseMadeRegex;
			watcher.PromptToTakeTheSurvey = this.PromptToTakeTheSurvey;
			watcher.WatcherMessageDivName = this.WatcherMessageDivName;
			watcher.SurveyPromptDivName = this.SurveyPromptDivName;
			watcher.SurveyPromptDivYesButtonId = this.SurveyPromptDivYesButtonId;
			watcher.SurveyPromptDivNoButtonId = this.SurveyPromptDivNoButtonId;
			watcher.SurveyPromptDivWidth = this.SurveyPromptDivWidth;
			watcher.SurveyPromptDivHeight = this.SurveyPromptDivHeight;
			watcher.SurveyPromptDivLeftOffset = this.SurveyPromptDivLeftOffset;
			watcher.SurveyPromptDivTopOffset = this.SurveyPromptDivTopOffset;
			watcher.SurveyWindowWidth = this.SurveyWindowWidth;
			watcher.SurveyWindowHeight = this.SurveyWindowHeight;
			watcher.SurveyWindowLeftOffset = this.SurveyWindowLeftOffset;
			watcher.SurveyWindowTopOffset = this.SurveyWindowTopOffset;
			watcher.SurveyFrameName = this.SurveyFrameName;
		    watcher.SurveyInnerFrameName = this.SurveyInnerFrameName;
		    watcher.SurveyDisplayFrameInnerHtml = this.SurveyDisplayFrameInnerHtml;
			watcher.Activate(); 
		}
	}else{
		this.Test(true);
	}	
}
VoviciExitSurvey.prototype.ChangeLinks = function(){
	this.utils.DebugLog("ExitSurveyChangeLinks..");
	var objObjects = document.getElementsByTagName("a");
	var survey = this;
	for (var i = 0; i < objObjects.length; i++){
		if (objObjects[i].href != ""){
			this.utils.DebugLog("Adding ExitSurveyWatcherLaunch to link to " + objObjects[i].href);
			var obj = objObjects[i];
			objObjects[i].onclick = function () { survey.ExitSurveyWatcherLaunch(); };
		}
	}
}
VoviciExitSurvey.prototype.Check = function(blnCheck, blnSet){
	if (blnCheck == false){
		if (this.utils.GetCookie(this.CookieName) != ""){
			this.Update();
			return null;
		}
	}else{
		if (blnSet == true){
			this.Update();
			return null;
		}else if (this.utils.GetCookie(this.CookieName) != ""){
			this.Update();
			return null;
		}else{
			this.Clear();
			return null;
		}
	}
}
VoviciExitSurvey.prototype.Update = function(){
	this.utils.SetCookie(this.CookieName, Date(), this.CookieDomain, this.CookieDuration, this.CookiePath);
}
VoviciExitSurvey.prototype.CheckCookie = function(c_name){
	strDate=this.utils.GetCookie(c_name);
	if (strDate!=null && strDate!=""){
		return true;
	}else {
		return false;
	}
}
VoviciExitSurvey.prototype.Clear = function(){
	if (this.TimerId){
		clearTimeout(this.TimerId);
	}
	if (this.utils.GetCookie(this.CookieName) != ""){
		this.utils.DeleteCookie(this.CookieName);
	}
	return null;
}
VoviciExitSurvey.prototype.Test = function(blnExists){
	var strCookie = this.utils.GetCookie(this.CookieName);
	if (blnExists == false){
		if (strCookie != ""){
			this.utils.DebugLog("ExitSurveyTest: " + strCookie);
		}
	}else{
		this.utils.DebugLog("Watcher Window already launched! Close the watcher window and try again!");
	}
}
function VoviciSurveyWatcher(){
	this.utils = new VoviciSurveyUtils();
	this.CookieName = "VOVICI_EXIT_SURVEY_INVITE";
	this.PromptToTakeTheSurvey = true;
	this.ExitSurveyUrl = "";
	this.ShoppingCartAbandonmentSurveyUrl = "";
	this.ShoppingCartCompletedSurveyUrl = "";
	this.ShoppingCartCookieName = "";
	this.ShoppingCartRegex="";
	this.PurchaseMadeCookieName = "";
	this.PurchaseMadeRegex="";
	this.SurveyUrl ="";
	this.SurveyPromptDivName = "VoviciSurveyInvite_Prompt";
	this.SurveyPromptDivYesButtonId = "VoviciSurveyPromptYesButton";
	this.SurveyPromptDivNoButtonId = "VoviciSurveyPromptNoButton";
	this.WatcherMessageDivName = 'VoviciWatcherMessage';
	this.SurveyPromptDivWidth = 575;
	this.SurveyPromptDivHeight = 179;
	this.SurveyPromptDivLeftOffset = 200;
	this.SurveyPromptDivTopOffset = 100;
	this.SurveyWindowWidth = 400;
	this.SurveyWindowHeight = 600;
	this.SurveyWindowLeftOffset = 100;
	this.SurveyWindowTopOffset = 100;
	this.SurveyFrameName = "VoviciSurveyFrameOuterDiv";
    this.SurveyInnerFrameName = "VoviciSurveyFrameInnerDiv";
    this.SurveyDisplayFrameInnerHtml = '<div id="' + this.SurveyFrameName + '" style="background-color:#FFFFFF;border: 1px solid #E2E5E7;">'
	+ '  <div id="' + this.SurveyPromptDivNoButtonId + '" style="text-align:right; color: red">[x]</div>'
	+ '<div id="' + this.SurveyInnerFrameName + '" ></div>'
	+ '</div>';
	this.TimerId;
	this.TimerInterval = new Number(8000); 
	this.IsAPopup = true;
	this.IFrameObj; 
	this.URLParameters = new Array();
}
VoviciSurveyWatcher.prototype.DebuggingEnabled  = function(enabled){
	this.utils.DebuggingEnabled = enabled;	
}
VoviciSurveyWatcher.prototype.Load = function(){
	this.utils.AddEvent( window, "load", function() { watcher.WatcherLoad(); });
}
VoviciSurveyWatcher.prototype.WatcherLoad = function(){
	this.utils.DebugLog("Load");
	self.blur();
	var watcher = this;
	this.utils.AddEvent( window, "unload", function() { watcher.Unload(); });
	watcher.StartChecking();
}
VoviciSurveyWatcher.prototype.StartChecking = function(){
	this.utils.DebugLog("StartChecking");
	this.Blur();
	this.Clear();
	this.CheckCondition();
	var watcher = this;
	this.TimerId = setInterval( function () { watcher.CheckCondition();}, this.TimerInterval);
}
VoviciSurveyWatcher.prototype.Unload = function(){
	this.utils.DebugLog("Unload");
	this.Clear();
	window.self.focus();
	this.utils.DeleteCookie(this.CookieName);
}
VoviciSurveyWatcher.prototype.Blur = function(){
	this.utils.DebugLog("Blur");
	if ( ! this.utils.DebuggingEnabled ){
		window.self.blur();
	}
}
VoviciSurveyWatcher.prototype.CheckCondition = function(){
	this.utils.DebugLog("CheckCondition");
	var objDate = new Date();
	var objDate_Old;
	var objDate_New;
	var strCookie = this.utils.GetCookie(this.CookieName);
	var intWatcher_Interval = new Number(-1);
	if (strCookie != ""){
		objDate_Old = new Date(strCookie);
		objDate_New = new Date();
		objDate_New.setDate(objDate.getDate());
		objDate_New = new Date(objDate_New.toGMTString());
		intWatcher_Interval = objDate_New - objDate_Old;
		this.Hide();
		this.Test();
	}else{
		this.Clear();
		this.Activate();
		return null;
	}
	if ( (intWatcher_Interval == -1) || (intWatcher_Interval >= this.TimerInterval) ){
		this.Clear();
		this.Activate();
		return null;
	}
}
VoviciSurveyWatcher.prototype.Clear = function(){
	if (this.TimerId){
		clearTimeout(this.TimerId);
	}
	return null;
}
VoviciSurveyWatcher.prototype.Hide = function(){
	this.Blur();
}
VoviciSurveyWatcher.prototype.GetExitSurveyUrl = function(){
	return this.utils.AddUrlParameters( this.ExitSurveyUrl, this.URLParameters);
}
VoviciSurveyWatcher.prototype.GetShoppingCartAbandonmentSurveyUrl = function(){
	return this.utils.AddUrlParameters( this.ShoppingCartAbandonmentSurveyUrl, this.URLParameters);
}
VoviciSurveyWatcher.prototype.GetShoppingCartCompletedSurveyUrl = function(){
	return this.utils.AddUrlParameters( this.ShoppingCartCompletedSurveyUrl, this.URLParameters);
}
VoviciSurveyWatcher.prototype.AddUrlParameter = function(name, val){
	this.URLParameters[name] = val;
}
VoviciSurveyWatcher.prototype.Activate = function(){
	this.utils.DeleteCookie(this.CookieName);
	if ( ! this.IsAPopup ){
		window.focus();
	}
	var messageDiv = document.getElementById(this.WatcherMessageDivName);
	if ( messageDiv ) messageDiv.style.display = 'none';
	if ( this.PromptToTakeTheSurvey ){
		try {
			window.resizeTo(this.SurveyPromptDivWidth,this.SurveyPromptDivHeight);
			window.moveTo(this.SurveyPromptDivLeftOffset, this.SurveyPromptDivTopOffset);
		} catch (error) {}
		var promptDiv = document.getElementById(this.SurveyPromptDivName);
		if ( promptDiv )promptDiv.style.display = 'block';
		var prompt = this;
		if ( this.SurveyPromptDivYesButtonId ){
			var yes = document.getElementById(this.SurveyPromptDivYesButtonId);
			if ( yes ){
				this.utils.AddEvent(yes, "click",  function() { prompt.YesButtonClicked(); });
			}
		}
		if ( this.SurveyPromptDivNoButtonId ){
			var no = document.getElementById(this.SurveyPromptDivNoButtonId);
			if ( no ){
				this.utils.AddEvent(no, "click",  function() { prompt.NoButtonClicked(); });
			}
		} 
	}else{
		this.YesButtonClicked();	
	}
}
VoviciSurveyWatcher.prototype.HidePrompt = function (){
	var promptDiv = document.getElementById(this.SurveyPromptDivName);
	if ( promptDiv ){
		promptDiv.style.display = 'none';
	}
	var surveyDiv = document.getElementById(this.SurveyFrameName);
        if ( surveyDiv ){
        	surveyDiv.style.display = 'none';
        }
}
VoviciSurveyWatcher.prototype.YesButtonClicked = function (){
	if ( this.IsAPopup ){
		try {
			window.resizeTo(this.SurveyWindowWidth,this.SurveyWindowHeight);
			window.moveTo(this.SurveyWindowLeftOffset, this.SurveyWindowTopOffset);
		} catch (error) {}
		window.location=this.GetExitSurveyUrl();
		return false;
	}else{
		this.HidePrompt();
		var messageDiv = document.getElementById(this.SurveyFrameName);
		if ( messageDiv && messageDiv.parentNode && messageDiv.parentNode.removeChild){
			messageDiv.parentNode.removeChild(messageDiv);
		}
		var noDiv = document.getElementById(this.SurveyPromptDivNoButtonId);
		if ( noDiv && noDiv.parentNode && noDiv.parentNode.removeChild){
                        noDiv.parentNode.removeChild(noDiv);
                }
 		var obj = this;
                this.SurveyLayer = this.utils.CreateLayer(this.SurveyFrameName, this.SurveyDisplayFrameInnerHtml,
                obj, '', this.SurveyPromptDivNoButtonId, this.SurveyWindowWidth, this.SurveyWindowHeight,
                 this.SurveyWindowLeftOffset, this.SurveyWindowTopOffset);
		this.LoadSurveyInIFrame();
	}
}
VoviciSurveyWatcher.prototype.NoButtonClicked = function (){
	if ( this.IsAPopup ){
		window.close();
	}else{
		this.HidePrompt();
	}
	return false;
}
VoviciSurveyWatcher.prototype.LoadSurveyInIFrame = function () {
  if (!document.createElement) {return true}' + this.SurveyInnerFrameName + ';
  var messageDiv = document.getElementById(this.SurveyInnerFrameName);
  if ( !messageDiv) {return true}; 
  var IFrameDoc;
  if (!this.IFrameObj && document.createElement) {
   try {
      var tempIFrame=document.createElement('iframe');
      tempIFrame.setAttribute('id','VoviciSurveyIFrame');
      tempIFrame.style.position = "relative";
      tempIFrame.style.border='0px';
      tempIFrame.style.width='100%';
      tempIFrame.style.height='100%';
      this.IFrameObj = messageDiv.appendChild(tempIFrame);
      
      if (document.frames) {
        this.IFrameObj = document.frames['VoviciSurveyIFrame'];
      }
    } catch(exception) {
      iframeHTML='\<iframe id="VoviciSurveyIFrame" style="';
      iframeHTML+='position:relative;';
      iframeHTML+='border:0px;';
      iframeHTML+='width:100%;';
      iframeHTML+='height:100;';
      iframeHTML+='"><\/iframe>';
      messageDiv.innerHTML+=iframeHTML;
      this.IFrameObj = new Object();
      this.IFrameObj.document = new Object();
      this.IFrameObj.document.location = new Object();
      this.IFrameObj.document.location.iframe = document.getElementById('VoviciSurveyIFrame');
      this.IFrameObj.document.location.replace = function(location) {
      this.iframe.src = location;
      }
    }
  }
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !this.IFrameObj.contentDocument) {
    setTimeout(this.LoadSurveyInIFrame,10);
    return false;
  }
  if (this.IFrameObj.contentDocument) {
    IFrameDoc = this.IFrameObj.contentDocument; 
  } else if (this.IFrameObj.contentWindow) {
    IFrameDoc = this.IFrameObj.contentWindow.document;
  } else if (this.IFrameObj.document) {
    IFrameDoc = this.IFrameObj.document;
  } else {
    return true;
  }
  IFrameDoc.location.replace(this.GetExitSurveyUrl());
  return false;
}
VoviciSurveyWatcher.prototype.Test = function(){
this.utils.DebugLog("cookie: "  + this.utils.GetCookie(this.CookieName) );
}
function VoviciSurveyUtils(){
	this.DebuggingEnabled = false;
	this.DebugDivName = "VoviciSurveyInvite_DebugOutput";
	this.DebugDiv;
	this.DebugLog = function (text){
		if ( this.DebuggingEnabled ){
			this.CreateDebugDiv();
			if ( this.DebugDiv ){
				this.DebugDiv.appendChild(document.createTextNode(text));
				this.DebugDiv.appendChild(document.createElement('br'));	
			}else{
			}
		}	
	}
	this.CreateDebugDiv = function (){
		if ( !this.DebugDiv ){
			var div = document.getElementById(this.DebugDivName);
			if ( div ){
				this.DebugDiv = div;	
			}else{
				if ( document.body ){
					this.DebugDiv = document.createElement('div');
					this.DebugDiv.id = this.DebugDivName;
					document.body.appendChild(this.DebugDiv);
				}
			}
		}
	}
	this.AddEvent = function (obj, evType, fn){
	 if (obj.addEventListener){
	    obj.addEventListener(evType, fn, false);
	    return true;
	 } else if (obj.attachEvent){
	    var r = obj.attachEvent("on"+evType, fn);
	    return r;
	 } else {
	    return false;
	 }
	}
	this.RemoveEvent = function (obj, evType, fn){
	 if (obj.removeEventListener){
	    obj.removeEventListener(evType, fn, false);
	    return true;
	 } else if (obj.detachEvent){
	    var r = obj.detachEvent("on"+evType, fn);
	    return r;
	 } else {
	    return false;
	 }
	}
	this.SetCookie = function(name, value, domain, duration, path){
	        var cookie=name + "=" + value + ";";
	        if ( domain ) cookie += " domain=" + domain + ";";
	        if ( path ) cookie += " path=" + path + ";";
	        
	        var expire = this.GetCookieExpireDate(duration);
	        if (expire) cookie += " expires=" + expire.toGMTString() + ";";
	        
	        document.cookie=cookie;
	}
	this.GetCookie = function(name) {
	   arg=name+"=";
	   alen=arg.length;
	   clen=document.cookie.length;
	   i=0;
	   while (i<clen) {
	      j=i+alen;
	      if (document.cookie.substring(i,j) == arg) {
	          return this.GetCookieValue(j);
	      }
	      i=document.cookie.indexOf(" ",i) + 1;
	      if (i === 0) {break;}
	   }
	}
	this.GetCookieValue = function(offset){
	   endstr=document.cookie.indexOf(";",offset);
	   if (endstr == -1) {endstr=document.cookie.length;}
	   return unescape(document.cookie.substring(offset,endstr));
	}
	this.GetCookieExpireDate = function(duration){
		if ( duration == '' || duration == 0 ){
			return '';	
		}
		if ( duration == 'today' ){
			var tomorrow = new Date();
		        tomorrow.setDate(tomorrow.getDate()+1);
		        tomorrow.setHours(0)
		        tomorrow.setMinutes(1);
		       	tomorrow.setSeconds(0);
		       	tomorrow.setMilliseconds(0);
		        return tomorrow;
		}else{
		        var date = new Date();
		        date.setTime(date.getTime() + duration * 60 * 1000);
		        return date;
		}
	}
	this.DeleteCookie = function(cookie_name){
	  var cookie_date = new Date(); 
	
	  cookie_date.setTime(cookie_date.getTime() - 1);
	  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
	}
	this.GetRandom = function(max){
		if ( max == 1 ){
			return 1;
		}else{
	        	return (Math.floor(Math.random()*max)) + 1;
	        }
	}
	this.CookieMatchesRegex = function(cookieName, regex){
		var cookie = this.GetCookie(cookieName);
		if ( cookie){
			return cookie.match(new RegExp(regex));
		}
		return false;
	}
	this.AddUrlParameters = function( baseUrl, parameters){
		if ( parameters ){
			var out = baseUrl;
			if ( ! /\?/.test(out) ){
			   	out += "?";
			}
			var count = 0;
			for (var key in parameters){
				out += (count > 0 ? "&" : "") + key + "=" + escape(parameters[key]);
			}
			return out;
		}else{
			return baseUrl;	
		}	
	}
	this.GetLayerWidth = function(widthIn){
		var myWidth = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			myWidth = window.innerWidth;
		} else if ( document.documentElement && document.documentElement.clientWidth ) {
			myWidth = document.documentElement.clientWidth;
		} else if ( document.body && document.body.clientWidth ) {
			myWidth = document.body.clientWidth;
		}	
		if ( widthIn ){
			return Math.min(widthIn,myWidth);
		}else{
			return myWidth;
		}
	}
	this.GetLayerHeight = function(heightIn){
		var myHeight = 0;
		if( typeof( window.innerHeight ) == 'number' ) {
			myHeight = window.innerHeight;
		} else if( document.documentElement && document.documentElement.clientHeight ) {
			myHeight = document.documentElement.clientHeight;
		} else if( document.body && document.body.clientHeight ) {
			myHeight = document.body.clientHeight;
		}	
		if ( heightIn ){
			return Math.min(heightIn,myHeight);
		}else{
			return myHeight;
		}
	}
	this.CreateLayer = function (id, html, obj, yesButtonId, noButtonId, lwidth, lheight, lleft, ltop) { 
	   var containerName = "VoviciSurveyPromptContainer_" + id;
	   var layer = document.createElement('div');
	   layer.style.display = 'none';
	   layer.setAttribute('id', containerName);
	   layer.setAttribute('name', containerName);
	   layer.innerHTML = html;
	   document.body.appendChild(layer);

	   var div = document.getElementById(id);
	   
	   var pageWidth = this.GetLayerWidth();
	   var pageHeight = this.GetLayerHeight();
	   var layerWidth = lwidth ? this.GetLayerWidth(lwidth) : (pageWidth * 0.9);
       var layerHeight = lheight ? this.GetLayerHeight(lheight) : (pageHeight * 0.9);

	   div.style.width = layerWidth;
	   div.style.height = layerHeight;
	   div.style.position = "absolute";
       div.style.left = lleft ? lleft : Math.abs(pageWidth - layerWidth)/2;
       div.style.top = ltop ? ltop : Math.abs(pageHeight - layerHeight)/2;
	   if ( yesButtonId ){
	   	var yes = document.getElementById(yesButtonId);
	   	if ( yes ){
	   		this.AddEvent(yes, "click", function() { obj.YesButtonClicked(); });
	   	}
	   }
	   if ( noButtonId ){
	   	var no = document.getElementById(noButtonId);
	   	if ( no ){
	   		this.AddEvent(no, "click", function() { obj.NoButtonClicked(); });
	   	}
	   }
	   layer.style.display = 'block';
	   return layer;
	}
}