//
// cookie code for PlayNetwork web player
//
// Programed by LUX Media, 10/2005
// This code is based upon code initially written by Danny Goodman and Bill Dortch
//

// Be sure to adjust the width & height parameters in the first function 
// to accomodate the size of your pop-up window

function getCookie(name) {
    // parses through the cookie to extract the player preference by calling getCookieVal
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var zz = document.cookie;
        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;
    }
   
function getCookieVal (offset) {
    // extracts player preference from the PN_player cookie
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
    }

function setCookie(cookieName, cookieVal){ 
    // sets a cookie using the passed parameters
	var expire = getExpireDate();
	document.cookie = cookieName + "=" + cookieVal + ((expire==null ? "":(";expires=" + expire.toGMTString())));
	} 
	 
function getExpireDate(){
    // generates a cookie expiration date one year from today
	var expires = new Date(); 
	expires.setTime((new Date().getTime()) + 1000*60*60*24*365); 
	return expires; 
} 

