function randomSurvey(scale)
 {
    var expdate = new Date ();
    var surveyCookieName = "IExpress2005";
    var percentOfferedSurvey = 100;  //CHANGE THIS PARAMETER TO CONTROL SAMPLING RATE
    //var surveyLocation = "http://www.insightexpress.com/s/WebT79991?onfinish=close";
    var surveyLocation = "http://www.insightexpress.com/s/eMar88181?UID2=site";  //sep05 url
    var popupNewWindow = true;  //or show the survey in the same window.

    expdate.setTime (expdate.getTime() + (365 * 24 * 60 * 60 * 1000)); // 1 year from now
                  var stored_value = GetCookie(surveyCookieName);
    var dd=new Date();
    cn= Math.round(dd.getTime() / 100) % 100;
    if ((cn <= percentOfferedSurvey) && (stored_value == null))
    {
//            SetCookie(surveyCookieName, "alreadyOffered", expdate);
            SetCookie(surveyCookieName, "alreadyOffered");  //MJ 20041119  - by removing the date, the cookie will expire when they close the browser..
//        window.open(surveyLocation,'new_window','width=640,height=500,resizable=yes,scrollbars=yes');
        window.open(surveyLocation,'new_window','width=320,height=250,resizable=yes,scrollbars=yes');  //MJ 20041119 - making popup smaller
    }
    //MJ 20041119:
    else if (location.search.indexOf("popup=y") != -1)
    {
        window.open(surveyLocation,'new_window','width=320,height=250,resizable=yes,scrollbars=yes');  //MJ 20041119 - making popup smaller
    }

 }

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;
}

