var decipherCounterTimer = 0;
var decipherT = setInterval(function () {
try {
if (jQuery !== undefined) {
decipherInit(jQuery);
clearInterval(decipherT);
}
decipherCounterTimer ++;
if (decipherCounterTimer > 25) {
clearInterval(decipherT);
}
} catch (noJquery) {}
}, 100);

var decipherInit = function ($j) {
window.decipher = {
style: {
animation: "slideIn",
animationSettings: "290",
compat: "27",
popUnder: false,
newDate: true,
newTime: false,
cookieOnlyOnPop: true,
cookieOnlyOnYes: false,
cookieExpireDaysFrom: 30,
stealthReplacement: false,
yesDisableReplacement: false,
onScriptStartReplacement: true,
onDecipherReadyReplacement: false,
injectReplacement: false,
markup: unescape("\ \ \ \ \<div\ id\=\"decipherInviteBox\"\ style\=\"background\-color\:\ \#F3F0E9\;\ display\:\ block\;\ position\:\ absolute\;\ z\-index\:\ 25000\;\ top\:\ 150px\;\ left\:\ 270px\;\ text\-align\:\ left\;\ width\:\ 363px\;\ height\:\ 170px\;\ border\:\ solid\ 2px\ \#B72F5F\;\ \-moz\-border\-radius\:\ 15px\;\ border\-radius\:\ 15px\;\ font\-family\:\ tahoma\,arial\;\ padding\-bottom\:\ 10px\;\ font\:\ 13px\/1\.231\ sans\-serif\ \!important\;\ baseline\:\ 0px\;\ color\:\ \#444444\;\ margin\:\ 0\;\"\>\ \ \ \ \ \ \ \ \<div\ class\=\'DECcontainer\'\ style\=\"font\-family\:\ tahoma\,arial\"\>\ \ \ \ \ \ \ \ \ \ \ \ \<div\ class\=\'DECheader\'\ style\=\"background\-color\:\ \#B72F5F\;\ color\:\ white\;\ margin\-top\:\ 25px\;\ padding\-left\:\ 15px\"\>\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \<span\ class\=\'DECstrong\'\ style\=\"font\-size\:\ 15px\;\"\>\<strong\>Lifetime\ Moms\<\/strong\>\<\/span\>\ \ \ \ \ \ \ \ \ \ \ \ \<\/div\>\ \ \ \ \ \ \ \ \ \ \ \ \<div\ class\=\'DECbody\'\ style\=\"padding\-left\:\ 15px\;\ padding\-right\:\ 15px\;\ padding\-top\:\ 15px\;\"\>\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \<h2\ class\=\'DECfeedback\'\ style\=\"margin\-top\:\ 0px\;\ color\:\ \#333333\;\ font\-size\:\ 12px\;\ line\-height\:\ 16px\;\ margin\:\ 0\ 0\ 12px\;\ padding\:\ 0\;\"\>\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \<strong\ class\=\'DECstrong\'\ style\=\"font\-family\:\ tahoma\,arial\"\>\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Lifetimemoms\.com\ would\ like\ your\ feedback\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \<\/strong\>\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \<\/h2\>\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \<p\ class\=\'DECfeedback\'\ style\=\"margin\-top\:\ 0px\;\ color\:\ \#333333\;\ font\-size\:\ 12px\;\ line\-height\:\ 16px\;\ margin\:\ 0\ 0\ 12px\;\ padding\:\ 0\;\"\>Will\ you\ take\ a\ short\ survey\?\<\/p\>\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \<div\ style\=\"text\-align\:\ center\;\ padding\-top\:\ 10px\;\"\>\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \<a\ class\=\'DECbutton\_yes\'\ style\=\'cursor\:pointer\;\ border\:\ 1px\ solid\;\ padding\:\ 5px\;\ text\-decoration\:\ none\;\ width\:\ 50px\;\ color\:\ \#333333\;\ font\-size\:\ 12px\;\'\ onmouseover\=\"this\.style\.color\=\'\#4f6ad7\'\;\"onmouseout\=\"this\.style\.color\=\'\#333333\'\;\"\ href\=\'\_\_SURVEY\_URL\_\_\'\ onclick\=\"decipher\.hide\(\)\;\"\ target\=\"\_blank\"\>\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;Yes\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\<\/a\>\&nbsp\;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \<a\ class\=\'DECbutton\_no\'\ style\=\'cursor\:pointer\;\ border\:\ 1px\ solid\;\ padding\:\ 5px\;\ text\-decoration\:\ none\;\ width\:\ 50px\;\ color\:\ \#333333\;\ font\-size\:\ 12px\;\'\ onmouseover\=\"this\.style\.color\=\'\#4f6ad7\'\;\"onmouseout\=\"this\.style\.color\=\'\#333333\'\;\"\ href\=\'\#\'\ onclick\=\"decipher\.hide\(\)\;\"\>No\ thanks\<\/a\>\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \<\/div\>\ \ \ \ \ \ \ \ \ \ \ \ \<\/div\>\ \ \ \ \ \ \ \ \ \ \ \ \<div\ class\=\'DECfooter\'\>\<\/div\>\ \ \ \ \ \ \ \ \<\/div\>\ \ \ \ \<\/div\>\ \ \ \ ")
},
survey: "/survey/caa/caa11006",
rawUrl: "http://static.decipherinc.com/survey/caa/caa11006",
chance: 0.00,  // percent chance that popup appears (e.g.: 0.1==10%)
markup: this.markup,
cookie: {// Cookie settings for intercept cookie
name: "decipherSurvey",
value: "set",
path: "/",
expire: ""
},
stealthWindow : function () {
//
// Default if function to overwrite wasn't given
if (!this.style.stealthReplacement) {
var exiturl = "";
var win2 = window.open();
win2.screenX = screen.width;
win2.screenY = screen.height;
if (this.style.popUnder) {
win2.blur();
if (!win2 || win2.closed) {
window.focus();
} else {
setTimeout(window.focus, 200);
}
if (win2.focus()) {
window.focus();
}
}
}
},
setCookie: function() {
//
// Set cookie based on configuration from XML
var c=this.cookie;
var now=new Date();
if (this.style.newTime) {
now.setHours();
}
if (this.style.newDate) {
now.setFullYear(2011,11,31);
}
if (!this.style.newTime && !this.style.newDate) {
now.setTime(now.getTime()+1000*60*60*24*this.style.cookieExpireDaysFrom);
}
document.cookie=[c.name,"=",escape(c.value),"; expires=",c.expires ? c.expires : now.toGMTString(),c.path ? "; path=" + c.path : ''].join('');
},
getCookie: function(name) {
// Check if cookie is set already
var cookies = document.cookie;
var startAt = cookies.indexOf(name + "=");
if(startAt !== -1) {
startAt = startAt + name.length + 1;
var endAt = cookies.indexOf(";", startAt);
if (endAt == -1) {
endAt = cookies.length;
}
return unescape(cookies.substring(startAt, endAt));
}
return null;
},
getFakeArgs: function() {
// Find decipher script tag on HTML page
var sx, gotUrl, qmIndex;
var rex = new RegExp('http://static.decipherinc.com/apps/intercept/js/caa/caa11006');
var matchUrl = function (s) {
if (!s) {
return false;
}
return s.search(rex) >= 0;
};
var scripts = document.getElementsByTagName('script');
for (var i = 0; i < scripts.length; i++) {
sx = scripts[i];
if (matchUrl(sx.getAttribute('src'))) {
break;
}
}
gotUrl = sx.getAttribute('src');
if (gotUrl.indexOf('#') != -1) {
qmIndex = gotUrl.indexOf('#');
} else if (gotUrl.indexOf('?') != -1) {
qmIndex = gotUrl.indexOf('?');
}
if (qmIndex < 0) {
return '';
}
var ret = gotUrl.slice(qmIndex + 1);
return ret;
},
mergeUrl: function(url, args) {
//
// Get survey url with extra variables
if (url.toString().search('#')){
url = url.split('#')[0];
}
if (args == "") {
return url;
}
var qmIndex = url.indexOf('?');
if (qmIndex < 0) {
return url + '?' + args;
}
return url + '&' + args;
},
yesDisable: function() {
//
// Set intercept cookie
if (!this.style.yesDisableReplacement) {
this.setCookie();
} else {

}
},
checkCookie: function() {
//
// Check if cookie is set or force=1
var fakeArgs = this.getFakeArgs();
var forceSet = fakeArgs.match('force=1');
if(this.getCookie(this.cookie.name) != this.cookie.value || forceSet) {
return false;
} else {
return true;
}
},
checkRandom: function () {
//
// Check if randomness is met
var r = Math.random();
if (r >= (1.0 - this.chance)) {// chance is equal to 1-n
return true;
} else {
return false;
}
},
inject: function () {
//
// Append decipher div(s) to the HTML Body
if (this.style.injectReplacement) {

} else {
var surveyUrl = this.mergeUrl(this.rawUrl, this.getFakeArgs());
var markup = this.style.markup.replace('__SURVEY_URL__', surveyUrl);

if (this.style.cookieOnlyOnPop) {
this.setCookie(this.cookie);
}

// if force=1 add disclaimer to intercept
if ( this.getFakeArgs().match('force=1') && this.style.compat >= 28) {
var msg = "** Forcing intercept to show! This message will go away once you <u>remove</u> 'force=1' from the JavaScript tag. **";
var forceMsg = $j('<div style="color: red; background: #FFF; font-size: 12pt; padding: 5px 5px;">' + msg + '</div>');
$j('body').append($j(markup).append(forceMsg));
} else {
$j('body').append(markup);
}
}
},
onScriptStart: function () {
// Run this code first and run other code for overwrites
if (this.style.onScriptStartReplacement) {


var me = this;
setTimeout(function() {me.onDecipherReady();}, 3000);


} else {
this.onDecipherReady();
}
},
onDecipherReady: function () {
//
// Default code to run after start
var isCookieSet = this.checkCookie();
var random = this.checkRandom();
this.jQueryVersion = $j().jquery;
if (this.style.onDecipherReadyReplacement) {

} else {
if (isCookieSet) {
return;
}
if (!random){
return;
}
if (!this.style.cookieOnlyOnPop && !this.style.cookieOnlyOnYes) {
this.setCookie(this.cookie);
}
this.inject();
this.effects();
}
},
effects: function (id, effect, options) {
//
// Pretty animations to show intercept
id = id || '#decipherInviteBox';
effect = this.style.animation;
if(effect === "slideIn") {
$j(id).show();
$j(id).animate({"left": "+="+this.style.animationSettings+"px"}, "slow");
} else {
options = options || "slow";
$j(id).fadeIn(options);
}
},
hide: function (id, effect, options) {
//
// Pretty animations to hide intercept
id = id || '#decipherInviteBox';
effect = effect || "fadeIn";
options = options || "slow";
$j(id).fadeOut(options);
}
};

$j(document).ready(function () {
decipher.onScriptStart();
});
};
