function cp_SetCookie(cname, value, days){
  var date = new Date();
  date.setDate(date.getDate()+days);
  document.cookie = cname + '=' + escape(value) + ((days == null) ? "" : ";expires=" + date.toGMTString());
}

function cp_GetCookie(cname){
  if(document.cookie.length > 0){
    cstart = document.cookie.indexOf(cname + "=");
    if(cstart != -1){
      var cstart = cstart + cname.length+1;
      var cend = document.cookie.indexOf(";", cstart);
      if(cend == -1){
        cend = document.cookie.length;
      }
      return unescape(document.cookie.substring(cstart, cend));
    }
  }
  return "";
}

function cp_LoadStyle(){
  var theCookie = cp_GetCookie('stylesheet');
  if(theCookie != ""){
    document.getElementById('style').href = theCookie;
  }
  else {
    cp_SetCookie('stylesheet', document.getElementById('style').href);
  }
}

function cp_SetStyle(url){
  cp_SetCookie('stylesheet', url);
  cp_LoadStyle();
}

function cp_DummyFunction(){}

window.onload = cp_DummyFunction();