/**
 *  Usage:
 *    Without Cookie check: crpop(nth)
 *              where nth is the nth sample
 *    With Cookie check: crpop(nth,cookiename,cookievalid)
 *              where cookiename is the name of the cookie to check
 *              and cookievalid is the number of days for cookie to stay valid
 *  Returns: 0 for nopop
 *                       1 for pop
 **/
function crpop(nth,cookiename,cookievalid) {
        var rnd = Math.random() * 10000;
        if (rnd<=10000/nth) {
                if (cookiename!=undefined){
                        var allcookies = document.cookie;
                        //alert(allcookies);
                        if (allcookies.indexOf(cookiename+"=")!=-1){
                                return 0;
                        }
                        else {
                                if (cookievalid==undefined){
                                        cookievalid=30;
                                }
                                var currentdate = new Date();
                                var cookievalidtil = new Date(currentdate.getTime() + cookievalid * 1000 * 60 * 60 * 24);
                                //alert(cookievalidtil.toGMTString());
                                document.cookie=cookiename + "=yes; expires=" + cookievalidtil.toGMTString();
                                return 1;
                        }
                }
                else {
                        //alert('no cookie');
                        return 1;
                }
        }
        else {
                return 0;
        }
}


/**
 *  Pop-up:
**/
function popsur() {
        // Currently set to every 75th person. Change value of first argument to modify.
        if(crpop(500,"cr15673",30) == 1){
     /**  window.open("http://sp02.netcrimson.com/15673/invite.htm","stakes","width=400,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,copyhistory=no,resizable=no");  **/
        O_LC();
        }
}
//Acquisitions Pop-Up function start
function popsur_acqs() {
        // Currently set to every 5th person. Change value of first argument to modify.
        if(crpop(20,"cr15673",30) == 1){
     /**  window.open("http://sp02.netcrimson.com/15673/invite.htm","stakes","width=400,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,copyhistory=no,resizable=no");  **/
        O_LC();
        }
}
//Acquisitions Pop-Up function end
function popsur1() {
        // Currently set to every 75th person. Change value of first argument to modify.
        if(crpop(1,"cr15673",30) == 1){
/**     window.open("http://sp02.netcrimson.com/15673/invite.htm","stakes","width=400,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,copyhistory=no,resizable=no");      **/
        O_LC();
        }
}
/**
 *  Pop-up for ShopDiscover:
**/
function popsur_shopdiscover() {
        // Currently set to every 10th person. Change value of first argument to modify.
        if(crpop(10,"cr15673",30) == 1){
     /**  window.open("http://sp02.netcrimson.com/15673/invite.htm","stakes","width=400,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,copyhistory=no,resizable=no");  **/
        O_LC();
        }
}
/**
 *  Pop-up for giftcard:
**/
function popsur_giftcard(){
        // Currently set to every 10th person. Change value of first argument to modify.
        if(crpop(10,"cr15673",30) == 1){
     /**  window.open("http://sp02.netcrimson.com/15673/invite.htm","stakes","width=400,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,copyhistory=no,resizable=no");  **/
        O_LC();
        }
}

/**
 *  Pop-up for brighter:
**/
function popsur_brighter(){
        // Currently set to every 10th person. Change value of first argument to modify.
        if(crpop(50,"cr15673",30) == 1){
     /**  window.open("http://sp02.netcrimson.com/15673/invite.htm","stakes","width=400,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,copyhistory=no,resizable=no");  **/
        O_LC();
        }
}
