﻿// JScript File

var frequency=100;

function IsPromptNeeded()
{
    if (document.cookie.length > 0)
    {
        var cookieindex = document.cookie.indexOf("SurveyPrompted="); 
                
        if (cookieindex == -1)
        {

            var testvalue = Math.round(Math.random() * 100);
            
            if ( testvalue >= (100 - frequency))
            {
                window.open('popup.htm','_blank','width=600,height=300');
            }
        }
    }
    else
    {
         var testvalue = Math.round(Math.random() * 100);
        
        if ( testvalue >= (100 - frequency))
        {
            window.open('popup.htm','_blank','width=600,height=300');
        }
   
    }
}

function SurveyConfirm()
{

        var exdate = new Date();
        exdate.setDate(exdate.getDate()+ 90);
        document.cookie="SurveyPrompted=true;expires=" + exdate.toGMTString();
        surveywindow = window.open('http://www.cds.co.uk/esurvey/custom/CCRC/index.htm','Survey','width=800,height=600,scrollbars=yes');
        window.close();
       
}

function SurveyRefused()
{
        var exdate = new Date();
        exdate.setDate(exdate.getDate()+ 30);
        document.cookie="SurveyPrompted=true;expires=" + exdate.toGMTString();
        window.close();

}