//// Client side interactive cookie starring script
//// Writen by samuel odofin 2006. it is used as flagging on our psych site because of a collborative suggestion
////http://www.odofin.com/sam. Call on me at anytime samuelodofin[at]yahoo[dot]com

function seCook(){
if(navigator.cookieEnabled == '0'){
alert('you need to enable your cookies before you can use any of the star and researcher features');
}else{
}
}

function setCookie(name,value,days,path,domain,secure) {
  var expires, date;
  if (typeof days == "number") {
    date = new Date();
    date.setTime( date.getTime() + (days*24*60*60*1000) );
		expires = date.toGMTString();
  }
  document.cookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}
function getCookie(name) {
  var nameq = name + "=";
  var c_ar = document.cookie.split(';');
  for (var i=0; i<c_ar.length; i++) {
    var c = c_ar[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameq) == 0) return unescape( c.substring(nameq.length, c.length) );
  }
  return null;
}
//this i put to let users flush their starred pages, when they are tired of seeing them :)lol
function deleteCookie(name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}
var link = location.href;
var title = document.title;
var rup = link + "^" + title;
var bless = getCookie("starred");
if (bless == null){
var realval = rup;
}else{
var realval = getCookie("starred") + "," + rup;
}

function justdoit(){
var bless = getCookie("justdoit");
var pose = "yes";
if (bless == pose){
setCookie('starred',realval,360,'/')
window.alert('starring was succesful');
location.reload()
}else{
setCookie('starred',realval,360,'/')
window.alert('starring was succesful');
}
}

function setit(){
var ese = document.pref.auto.value;
var pose = "yes";
var npose = "no";
if (ese == pose){
setCookie('justdoit',pose,360,'/')
window.alert('Your preference has being set. Pages will now automatically reload when starred');
}else if(ese == npose){
setCookie('justdoit',npose,360,'/')
window.alert('Your preference has being set. Pages will not automatically reload when starred');
}else{
}
}
