/**
*
* this script creates and retrieves cookies for the implementation of custom page
* views for the user
* author: rsharp, AShrivastava
* client: esfrs
* date created: 3/11/09
* version: 1.0.0
* since: 1.0.0
* 1.0.0 - 3/11/09 - version 1 created.
**/

/**
 * creates a cookie for the style
 * @param name
 * @param value
 * @param days for when cookie expires
 */
function setCookie(name,value,days) {
  var expires = "";
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    expires = "; expires="+date.toGMTString();
  }
  document.cookie = name+"="+value+expires+"; path=/";
}

/**
 * gets a cookie
 * @param name of cookie
 */
function getCookie(name) {
    if(document.cookie.length=="0") return null; // cookies have been deleted, desabled or not saved previously.
    var nameEq = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        c = c.strip();
        if (c.indexOf(nameEq) == 0){ return c.substring(nameEq.length,c.length);}
    }
    return null; // couldn't found cookie-value with passed name.
}
