function Stub()
{
    this.survey = "qst/qst09011";
    this.rawUrl = "http://survey.questus.com/survey/qst/qst09011";
    this.chance = 0;  // percent chance that popup appears (e.g.: 0.1==10%)
    this.markup = '<div id="decipherInviteBox" style=\n    "display:none;border: 1px; position: absolute; z-index:25000; top: 150px; left: 42%; height: 313px; width: 313px;">\n\n\n<img style="border:0px" \n    src="http://survey.questus.com/survey/qst/qst09011/foxsurvery_popup1.jpg"\n    usemap="#decipherInviteMap"/>\n<script language="javascript" type="text/javascript">\ndecipher = {\n    hide: function() {\n        document.getElementById(\'decipherInviteBox\').style.display=\'none\';\n    },\n    fadeLoop : function (o, opacity) {\n        decipher.setOpacity(o, opacity);\n        if (opacity < 100)\n        {\n            opacity += 4;\n            if (opacity > 100) opacity = 100;\n            window.setTimeout(\n               function () { decipher.fadeLoop(o, opacity) },\n                50);\n        }\n    },\n    setOpacity : function (o, opacity) {\n        o.style.filter = "alpha(style=0,opacity:" + opacity + ")";  // IE\n        o.style.KHTMLOpacity = opacity / 100; // Konqueror\n        o.style.MozOpacity = opacity / 100; // Mozilla (old)\n        o.style.opacity = opacity / 100; // Mozilla (new)\n    },\n    box: document.getElementById(\'decipherInviteBox\')\n}\nsetTimeout(function() {\ndecipher.setOpacity(decipher.box, 0);\ndecipher.box.style.display = \'\';\ndecipher.fadeLoop(decipher.box, 100);\n}, 5000);\n</script>\n<map name=\'decipherInviteMap\'>\n    <!-- close button -->\n<area shape="rect" style="cursor:pointer" coords="257,7,305,24"" onclick="decipher.hide()" style=\'cursor: pointer\' />\n<area style="cursor:pointer" style="cursor:pointer" shape="rect" coords="127,238,192,257" onclick="decipher.hide()" style=\'cursor:pointer\' />\n<area style="cursor:pointer" style="cursor:pointer" shape="rect" coords="97,195,218,228" onClick="window.open(\'__SURVEY_URL__\',\'Survey\',\'type=height=600,width=800,scrollbars=yes,toolbar=no,status=no,menubar=no\');decipher.hide();" />\n</map>\n\n\n</div>\n';

//    this.markup = '<div id="decipherInviteBox" style=\n    "display:none;border: 1px; position: absolute; z-index:25000; top: 150px; left: 42%; height: 255px; width: 255px;">\n\n\n<img id="imgpop" style="border:0px" \n    src="http://v2.decipherinc.com/survey/qst/qst09011/foxsurvery_popup1.jpg"\n  usemap="#decipherInviteMap"/>\n <script language="javascript" type="text/javascript">\ndecipher = {\n    hide: function() {\n        document.getElementById(\'decipherInviteBox\').style.display=\'none\';\n    }\nsetTimeout(function() {\ndecipher.show();}, 0);\n</script>\n<map name=\'decipherInviteMap\'>\n    <!-- close button -->\n<area style="cursor:pointer" shape="rect" coords="257,7,305,24" onclick="decipher.hide()" />\n<area style="cursor:pointer" shape="rect" coords="127,238,192,257" onclick="decipher.hide()" />\n<area style="cursor:pointer" shape="rect" coords="97,195,218,228" href="__SURVEY_URL__" />\n</map>\n\n\n</div>\n';
    // cookie settings
    this.cookie = {
        name: "decipherinc_seen_popup",
        value: "set",
        path: "/",
        expire: ""
    };
}

Stub.prototype = {
    setCookie: function()
    {
        var c=this.cookie;
        var now=new Date();
        now.setTime(now.getTime()+1000*60*60*24*3);
        document.cookie=[c.name,"=",escape(c.value),"; expires=",c.expires ? c.expires : now.toGMTString(),c.path ? "; path=" + c.path : ''].join('');
    },
    getCookie: function(name)
    {
        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()
    {
        var rex = new RegExp('/survey/' + this.survey);
        var matchUrl = function (s) { return s.search(rex) >= 0; }
        scripts = document.getElementsByTagName('script');
        for (var i=0; i<scripts.length; i++) {
            var sx = scripts[i];
            if (matchUrl(sx.getAttribute('src')))  break;
        }
        var gotUrl = sx.getAttribute('src');
        var qmIndex = gotUrl.indexOf('?');
        if (qmIndex < 0) return '';
        var ret = gotUrl.slice(qmIndex + 1);
        return ret;
    },
    mergeUrl: function(url, args) {
        var qmIndex = url.indexOf('?');
        if (qmIndex < 0) return url + '?' + args;
        return url + '&' + args;
    },
    begin: function()
    {
        // cookie here keeps iframe from loading more than once
        if(this.getCookie(this.cookie.name) != "set")
        {

            this.setCookie(this.cookie);
            var r = Math.random();
            if (r >= (1.0 - this.chance))// chance is equal to 1-n
            {
                

                var fakeArgs = "";
                var surveyUrl = this.mergeUrl(this.rawUrl, fakeArgs);
                var markup = this.markup.replace('__SURVEY_URL__', 'http://survey.questus.com/survey/qst/qst09011?list=6');
		//surveyUrl);
                document.write(markup);
            }
        }
    }
}

Serve = new Stub();
Serve.begin();

// vim:set ft=javascript:
