
////////////////////////////////////////////////////////////////////////////////
//
//  Copyright 2010 Usability Sciences Corporation
//
//  This file contains all of the necessary functionality to conditionally
//  afford the current HTTP request the opportunity to opt-in to the WebIQ
//  feedback process.
//
//  The Opt-In Script can be referenced by using the following HTML snippet,
//  which can be placed in either the <head> or <body> elements:
//
//      <script type="text/javascript" language="JavaScript" src="WebIQ.OptIn.js"></script>
//
//  If the <script> element is included in the <body> element, the Opt-In
//  Process can be expedited by additionally including the following HTML
//  immediately before the <script> element:
//
//      <div id="DialogContainer" style="display:none"></div>
//      <iframe id="DialogContainer.Shadow" src="javascript:false;" style="display:none"></iframe>
//
//  If one or both of those elements are omitted, or if the <script> element
//  is included in the <head> element, the Opt-In Process will not start until
//  the page completely loads.
//
////////////////////////////////////////////////////////////////////////////////
debugger;

if((location.hostname.toLowerCase() == 'www.viagra.com') || (location.hostname.toLowerCase() == 'viagra.com'))
{
    var s_account_type="pfizerviagraprod,pfizercitadelglobal" //** Production 
}
else
{
    var s_account_type="pfizerviagradev" //** Test
}

if (/[\?&]DebugWebIQ=[^$&]+/i.test(document.URL)){debugger;}if (typeof WebIQ === "undefined"){var WebIQ = {};}if (typeof WebIQ.OptIn === "undefined"){WebIQ.OptIn = {};}(function(ns,config){ns = ns || {};config = config || {};ns.Version = 3;ns.ScriptGenerationDate = new Date(Date.parse("10/14/2010 17:53:24 GMT"));ns.Initialized = false;ns.Enabled = (typeof config.Enabled === "boolean") ? config.Enabled : true;ns.BaseUrl = ((document.location.protocol.length == 5) ? "http://" : "https://") + ((typeof config.BaseUrl === "string" && config.BaseUrl) || "");ns.ProjectID = (/[\?&]WebIQProjectID=(\{|%7B)?([\da-f]{8}-([\da-f]{4}-){3}[\da-f]{12})(\}|%7D)?/i.exec(document.URL) && ("{" + RegExp.$2 + "}")) || (typeof config.ProjectID === "string" && config.ProjectID) || "";ns.ProjectName = (typeof config.ProjectName === "string" && config.ProjectName) || "";ns.ProjectVersionName = (typeof config.ProjectVersionName === "string" && config.ProjectVersionName) || "";ns.DataType = (/[\?&]WebIQDataType=(\d)/i.exec(document.URL) && parseInt(RegExp.$1)) || ((typeof config.DataType === "number") ? config.DataType : 2);ns.SessionType = (/[\?&]WebIQSessionType=(\d)/i.exec(document.URL) && RegExp.$1) || (typeof config.SessionType === "string" && config.SessionType) || "1";ns.AuthResult = 0;ns.OverrideLanguageTags = (/[\?&]OLT=([^$&]+)/i.exec(document.URL))? RegExp.$1: (typeof config.OverrideLanguageTags === "string")? config.OverrideLanguageTags: "";ns.Modifiers = (typeof config.Modifiers === "object" && config.Modifiers) || {};ns.OnBeforeOptInDialogDisplay = (typeof config.OnBeforeOptInDialogDisplay === "function" && config.OnBeforeOptInDialogDisplay) || function(){};ns.OnOptInAccepted = function(){var s = new Date().valueOf();document.cookie = "WebIQSessionActive=1;path=/";if (ns.Dialog.Html){ns.Dialog.Hide();ns.SendScriptRequest("RecordOptInEvent.srf",{et : 3,seq : s,pid : ns.ProjectID},function(){if (ns.StartWindow.Type === 1){ns.StartWindow.Open(new Date().valueOf());}});}if (ns.StartWindow.Type === 2){ns.StartWindow.Open(s + 1);}};ns.OnOptInDeclined = function(){document.cookie = "WebIQSessionActive=0;path=/";if (ns.Dialog.Html){ns.Dialog.Hide();ns.SendScriptRequest("RecordOptInEvent.srf",{et : 4,seq : new Date().valueOf(),pid : ns.ProjectID});}};ns.Dialog = {_div : null,_iframe : null,Left : 0,Top : 0,Width : 0,Height : 0,Html : "",Show : function(){var d = ns.Dialog,addDIV = false,addIFRAME = false;if (!d.Html||!ns.Enabled){return;}d._div = document.getElementById("DialogContainer");d._iframe = document.getElementById("DialogContainer.Shadow");if (!d._div){d._div = document.createElement("div");d._div.id = "DialogContainer";addDIV = true;}if (!d._iframe){d._iframe = document.createElement("iframe");d._iframe.id = "DialogContainer.Shadow";d._iframe.src = "javascript:false;";addIFRAME = true;}var ds = d._div.style,is = d._iframe.style;ds.display = is.display = "none";ds.visibility = is.visibility = "hidden";ds.position = is.position = "absolute";ds.zIndex = 2147483647;ds.border = "1px solid #000000";ds.margin = "0px";ds.padding = "0px";ds.width = is.width = d.Width + "px";ds.height = is.height = d.Height + "px";ds.left = is.left = ((document.body.clientWidth - d.Width) / 2) + "px";ds.top = is.top = (document.body.scrollTop + d.Top) + "px";is.zIndex += 1000;d._div.innerHTML = d.Html;if (addIFRAME){document.body.appendChild(d._iframe);}if (addDIV){document.body.appendChild(d._div);}ns.OnBeforeOptInDialogDisplay();window.setTimeout(d.PollDisplayed, 100);ds.display = is.display = "block";ds.visibility = is.visibility = "visible";},Hide : function(){var d = ns.Dialog;if (d._div&&d._iframe){d._div.style.display = d._iframe.style.display = "none";d._div.style.visibility = d._iframe.style.visibility = "hidden";}},PollDisplayed : function(){var d = ns.Dialog;if (!d.Html||!ns.Enabled){return;}if (d._div&&d._div.style.display === "block"&&d._div.style.visibility === "visible"){ns.SendScriptRequest("RecordOptInEvent.srf",{et : 2,seq : new Date().valueOf(),pid : ns.ProjectID});}else{window.setTimeout(d.PollDisplayed, 100);}}};ns.StartWindow = {Type : 0,Top : 0,Left : 0,Height : 0,Width : 0,Open : function(s){if (!ns.Enabled){return;}var w = ns.StartWindow,url = ns.BaseUrl + "SelectSegment.srf?seq=" + s.toString() + "&PID=" + ns.ProjectID;if (w.Type === 1){window.top.location = url;}else{window.open(url,null,"top=" + w.Top + "px,left=" + w.Left + "px,height=" + w.Height + "px,width=" + w.Width + "px,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");}}};ns.CBM = [];ns.SendScriptRequest = function(resource,params,callback){if (!ns.Enabled){return;}var src,script,paramName;params = params || {};params.WebIQOptInVer = ns.Version;src = ns.BaseUrl + resource;if (!/\?Handler=\w+/i.test(src)){src += "?";}for (paramName in params){src += encodeURIComponent(paramName) + "=" + encodeURIComponent(params[paramName]) + "&";}src = src.replace(/&$/, "");if (callback){src += "&jsonp_cb=" + encodeURIComponent("WebIQ.OptIn.CBM[" + ns.CBM.length + "]");ns.CBM.push(callback);}script = document.createElement("script");script.setAttribute("type", "text/javascript");script.setAttribute("language", "JavaScript");script.setAttribute("src", src);document.getElementsByTagName("head")[0].appendChild(script);};ns.AddStyle = function(cssContent){if (typeof cssContent !== "string" || !cssContent){return;}var headElem = document.getElementsByTagName("head")[0],styleElem = document.createElement("style");styleElem.setAttribute("type", "text/css");if (styleElem.styleSheet){headElem.appendChild(styleElem);styleElem.styleSheet.cssText = cssContent;}else{styleElem.appendChild(document.createTextNode(cssContent));headElem.appendChild(styleElem);}};ns.Start = function(){if (ns.Enabled){if (ns.Initialized){ns.SendScriptRequest("CreateAuthCookie.srf",{pid : ns.ProjectID},function(){if (!ns.Enabled){return;}var params = {pid : ns.ProjectID,state : ns.SessionType,ourl : window.document.URL,olt : ns.OverrideLanguageTags,oiv : ns.Version,seq : new Date().valueOf(),webiq_dt : ns.DataType, s_account : s_account_type},mods = ns.Modifiers;if (typeof mods.SegmentChainID === "string"){params.SegmentChainMod = mods.SegmentChainID;}if (typeof mods.SelectionRate === "string"){params.SelectionRateMod = mods.SelectionRate;}if (typeof mods.SelectionProb === "string"){params.SelectionProbMod = mods.SelectionProb;}if (typeof mods.AcceptedRepeatSelectionFreq === "string"){params.AcceptedRepeatSelectionFreqMod = mods.AcceptedRepeatSelectionFreq;}if (typeof mods.RejectedRepeatSelectionFreq === "string"){params.RejectedRepeatSelectionFreqMod = mods.RejectedRepeatSelectionFreq;}ns.SendScriptRequest("AuthorizeOptInRequest.srf",params,function(p){if (!ns.Enabled){return;}var d = ns.Dialog,w = ns.StartWindow;p = p || {};ns.AddStyle(typeof p.DCSS === "string" ? p.DCSS : "");ns.AuthResult = typeof p.AuthResult === "number" ? p.AuthResult : 0;d.Left = typeof p.DL === "number" ? p.DL : 0;d.Top = typeof p.DT === "number" ? p.DT : 0;d.Width = typeof p.DW === "number" ? p.DW : 0;d.Height = typeof p.DH === "number" ? p.DH : 0;d.Html = typeof p.DHTML === "string" ? p.DHTML : "";w.Type = typeof p.WY === "number" ? p.WY : 0;w.Top = typeof p.WT === "number" ? p.WT : 0;w.Left = typeof p.WL === "number" ? p.WL : 0;w.Height = typeof p.WH === "number" ? p.WH : 0;w.Width = typeof p.WW === "number" ? p.WW : 0;if (ns.AuthResult === 1){if (d.Html){d.Show();}else if (w.Type === 1){w.Open(new Date().valueOf());}else{ns.OnOptInAccepted();}}else{if (typeof p.SA === "boolean"){document.cookie = "WebIQSessionActive=" + (p.SA ? "1" : "0") + ";path=/";}if (typeof p.RD === "string" && p.RD){window.top.location = ns.BaseUrl + "DataServer.dll?Handler=RenderDialogHtml&DDID=" + p.RD + "&Style=32&OLT=" + ns.OverrideLanguageTags + "&PID=" + ns.ProjectID + "&webiq_dt=" + ns.DataType;}}});});}else{window.setTimeout(ns.Start, 100);}}};if (!/WebIQSessionActive=[01]/i.test(document.cookie)){document.cookie = "WebIQSessionActive=0;path=/";}if (ns.Enabled){if (document.getElementById("DialogContainer")&&document.getElementById("DialogContainer.Shadow")){ns.Initialized = true;}else if (window.attachEvent){window.attachEvent("onload",function(){ns.Initialized = true;});}else if (window.addEventListener){window.addEventListener("load",function(){ns.Initialized = true;},false);}}})
(
    WebIQ.OptIn,
    {
        Enabled : true,
        BaseUrl : "webiq005.webiqonline.com/WebIQ/DataServer/",
        ProjectID : "{b273c485-7046-484d-bd43-7e3552196851}",
        ProjectName : "Viagra",
        ProjectVersionName : "",
        DataType : 2,
        SessionType : "",
		
		OnBeforeOptInDialogDisplay : function()
        {
            (
                function(cfg)
                {
                    var links = document.getElementById('uscdd-footer-links'), 
                        statement = document.getElementById('uscdd-footer-statement'), 
                        img = document.getElementById('uscdd-footer-logo'); 
                    if (img.src.indexOf("http") != -1) { 
                        // if the protocol was specified, fix it 
                        img.src = img.src.replace(/http[s]?/, (document.location.protocol.length == 5) ? "http" : "https"); 
                    } else { 
                        // if not, set the protocol 
                        img.src = ((document.location.protocol.length == 5) ? "http://" : "https://") + img.src; 
                    } 
                    if (cfg.statement) { 
                        statement.innerHTML = cfg.statement; 
                    } 
                    cfg.links = cfg.links || []; 
                    for (var i = 0; i < cfg.links.length; i++) { 
                        var a = document.createElement('a'); 
                        a.className = 'uscdd-footer-link uscdd-footer-text'; 
                        for (attr in cfg.links[i]) { 
                            a[attr] = cfg.links[i][attr]; 
                        } 
                        a.title = a.title || a.innerHTML; 
                        a.target = a.target || '_blank'; 
                        links.appendChild(a); 
                    }
                }
            )
            ({
                links : [
                    {
                        href : 'http://www.webiqonline.com/support-webhq.asp?pid=' + encodeURIComponent(WebIQ.OptIn.ProjectName + '-' + WebIQ.OptIn.ProjectVersionName + '_optin'),
                        innerHTML : 'Having Trouble?'
                    },
                    { 
                        href : 'http://www.usabilitysciences.com/privacy-policy#webiq',
                        innerHTML : 'Privacy Statement'
                    }
                ]
            });
        }
    }  
);


WebIQ.OptIn.Start();

