var CFI = {
        Version: '1.0.0',
        Enabled: true,
        CookieExpires: 90, // Set to null to disable persistent cookies
        CookiePath: '/',
        WebMonPath: Salmon.PageContext.JSDIR + '/WebMon/',
        DaysBetweeenAccept: 90,
        DaysBetweenDecline: 90,
        RequiredPageLoads: 5, // This will ensure the survey pops up on the 4th click on our website (it is correct that is should be 5 and not 4)
        SurveyVisitorPercent: 25,
        DialogDelaySeconds: 2,
        PopUnder: true,

	SurveyURL: 'https://svy.cfigroup.com/cgi-bin/qwebcorporate.dll?idx=HHD86G',
	SurveyCode: 'HHD86G',
	BrowserCode: 'brwsr',
	ResolutionCode: 'scrn',
	OSCode: 'opsys',
	ScreenWidthCode: 'rsw',
	ScreenHeightCode: 'rsh',
	PageViewCode: 'pv',
	AdditionalParameters: '&SOURCE=0',

/* DO NOT CHANGE ANYTHING BEYOND THIS POINT */
SessionData:{PageViews:0},PersistentData:{LastAccept:null,LastDecline:null,Version:0},loadSessionData:function()
{try
{var cookieData=jQuery.cookie('CFIWebMonSession-'+CFI.SurveyCode);}
catch(err)
{alert(err);}
if(cookieData)
{CFI.SessionData=JSON.parse(cookieData);}},saveSessionData:function()
{if(!CFI.isObject(CFI.SessionData)){throw new Error('JSONCookie data must be an object');}
cookieData=JSON.stringify(CFI.SessionData);jQuery.cookie('CFIWebMonSession-'+CFI.SurveyCode,cookieData,{path:this.CookiePath});},loadPersistentData:function()
{try
{var cookieData=jQuery.cookie('CFIWebMonPersistent-'+CFI.SurveyCode);}
catch(err)
{alert(err);}
if(cookieData)
{CFI.PersistentData=JSON.parse(cookieData);}},savePersistentData:function()
{if(!CFI.isObject(CFI.PersistentData)){throw new Error('JSONCookie data must be an object');}
cookieData=JSON.stringify(CFI.PersistentData);jQuery.cookie('CFIWebMonPersistent-'+CFI.SurveyCode,cookieData,{expires:CFI.CookieExpires,path:CFI.CookiePath});},launchSurvey:function()
{this.PersistentData.LastAccept=new Date().getTime();this.openWindow();},notInterested:function()
{this.PersistentData.LastDecline=new Date().getTime();},openWindow:function()
{var browserString="&"+CFI.BrowserCode+"=";if(jQuery.browser.webkit)
{browserString+="3";}
else if(jQuery.browser.opera)
{browserString+="2";}
else if(jQuery.browser.msie)
{browserString+="0";}
else if(jQuery.browser.mozilla)
{browserString+="1";}
else
{browserString+="4";}
var resString="&"+CFI.ResolutionCode+"=";if(screen.width==1024&&screen.height==768)
{resString+="0";}
else if(screen.width==800&&screen.height==600)
{resString+="1";}
else if(screen.width==640&&screen.height==480)
{resString+="2";}
else
{resString+="3";}
var rawResString="&"+CFI.ScreenWidthCode+"="+screen.width+"&"+CFI.ScreenHeightCode+"="+screen.height;var userAgent=navigator.userAgent.toLowerCase();var osString="&"+CFI.OSCode+"=";if(userAgent.indexOf("win")!=-1)
{osString+="0";}
else if(userAgent.indexOf("mac")!=-1)
{osString+="1";}
else if(userAgent.indexOf("linux")!=-1)
{osString+="2";}
else if(userAgent.indexOf("x11")!=-1)
{osString+="3";}
else
{osString+="4";}
var pageCountString="&"+CFI.PageViewCode+"="+CFI.SessionData.PageViews;var windowURL=CFI.SurveyURL+browserString+resString+osString+rawResString+pageCountString+CFI.AdditionalParameters;CFI.surveyWindow=window.open(windowURL,"CFIMonWin","channelmode=0,directories=0,fullscreen=0,location=1,menubar=1,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=0,");if(this.PopUnder)
{try
{CFI.surveyWindow.blur();}
catch(err)
{}}},pageLeave:function()
{this.saveSessionData();this.savePersistentData();},createPopup:function()
{jQuery.get(CFI.WebMonPath+'content/dialog.html',function(data){jQuery('body').append(data);jQuery('#dialog').dialog({autoOpen:false,modal:true,width:400,buttons:{"Yes":function(){CFI.launchSurvey();jQuery(this).dialog("close");},"No thanks":function(){CFI.notInterested();jQuery(this).dialog("close");}}});setTimeout(function(){jQuery('#dialog').dialog('open');return false;},CFI.DialogDelaySeconds*1000);});},checkEligibility:function()
{if((CFI.Enabled)&&((Math.random()*100)<=CFI.SurveyVisitorPercent)&&(this.SessionData.PageViews>=CFI.RequiredPageLoads)&&((this.PersistentData.LastAccept==null)||(((new Date()-CFI.PersistentData.LastAccept)/86400000)>=this.DaysBetweenAccept))&&((this.PersistentData.LastDecline==null)||(((new Date()-CFI.PersistentData.LastDecline)/86400000)>=this.DaysBetweenDecline)))
{return true;}
return false;},registerPageCount:function()
{this.SessionData.PageViews++;},isObject:function(x)
{return(typeof x==='object')&&!(x instanceof Array)&&(x!==null);},loadWebMon:function()
{this.PersistentData.Version=CFI.Version;this.loadSessionData();this.loadPersistentData();this.registerPageCount();jQuery(window).unload(function(){CFI.pageLeave();return false;});}}
jQuery(function(){CFI.loadWebMon();if(CFI.checkEligibility())
{CFI.createPopup();}});function includeCSS(source)
{var ref=document.createElement('link');ref.setAttribute("rel","stylesheet");ref.setAttribute("type","text/css");ref.setAttribute("href",source);document.getElementsByTagName('head')[0].appendChild(ref);}
function loadScript(source)
{jQuery.ajax({async:false,url:source,dataType:'script'});}
$(window).load(function(){
	includeCSS(CFI.WebMonPath+"css/redmond/jquery-ui-1.7.2.custom.css");
	//loadScript(CFI.WebMonPath+"jquery-ui-1.7.2.custom.min.js");
	//loadScript(CFI.WebMonPath+"json2.min.js");
	//loadScript(CFI.WebMonPath+"jquery.cookie.min.js");
});
