var o = null; // object to be used to examine href target
function SetObject()
{
    o = window.event.srcElement;
}

function SurveyCheck()
{   
   return true;
    // checks to see where user is going before calling survey
    // var arrExcludedSites = Array(".bcentral.",".bcentralhost.com",".siteowner.com","msbigday.com","greatplains.com","cj.com",".microsoft.com",":DoHelp",".interactservices.com","void(0)");
    /*
    if (o != null)
    {
        if (o.tagName == "A") 
        {
            var strHref = o.href;
            if ( strHref.indexOf(".bcentral.",8) != -1 )  return nthing(10);        
        }
    }
    else
    {
        // no idea where they are going because nothing was clicked
        // cases: refresh, favourites, typed in url, exit
        return nthing(10);
    }
    */
}


function nthing(nthvalue)
{
// if (m_bCancelSurvey == 1) { return false }; // bail if clicked "Sign up"

var surveyCookieName = "bCentral_Survey";
// var strC = document.cookie.toLowerCase();
var loc = location.href;
var ru = GetCookie("bcm") == "1" ? "1" : "0";
var ref= GetCookie("cobrand" == "msn") ? "1" : "0"; // entry point flag "msn" or "not"
var surveyPage="http://www2.survey-poll.com/survey/1800/1870mt/1870mt.html?log=accept&ref="+ref+"&ru="+ru+"&loc="+loc;

var windowOptions = "width=640,height=480,location=0,menubar=0,toolbar=0,scrollbars=1,resizable=1";
var msg="\Thank you for visiting bCentral. \n" +
        "Please help us improve our site by taking a short survey."
    var expdate = new Date ();
    var td=new Date();
    var xval=12345;
    expdate.setTime (expdate.getTime() + (90 * 24 * 60 * 60 * 1000)); // 90 days from now
    var stored_value = GetCookie(surveyCookieName);
    var dd=new Date();
    var nthwin;

    yval = ((Math.round(Math.abs(Math.cos(td.getTime()))*xval)%xval));
    if ( ((yval % nthvalue) == 0) && (stored_value == null) )
    {
        SetCookie(surveyCookieName, "alreadyOffered", expdate,"/");
      
        if ( confirm(msg) )
            nthwin = window.open(surveyPage,'survey',windowOptions);
    }
}

function SetCookie (name,value,expires,path,domain,secure)
{
        document.cookie = name + "=" + escape (value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookieVal (offset)
{
        var endstr = document.cookie.indexOf (";", offset);
        if (endstr == -1)
                endstr = document.cookie.length;
        return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name)
{
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        if( (document.cookie == null) || (document.cookie.length == null))
        {
                return null;
        }
        var i = 0;
        while (i < clen)
        {
                var j = i + alen;
                if (document.cookie.substring(i, j) == arg)
                        return getCookieVal (j);
                i = document.cookie.indexOf(" ", i) + 1;
                if (i == 0) break;
        }
        return null;
}

