
jQuery.cookie = function( key, value, settings ) {
if( arguments.length > 1 ) {
  /* Initialize options */
  var o = {
    expires: 365,
    path: '/'
  };
  jQuery.extend( o , settings || {} );
  if( value === null || value === undefined ) {
    value = '';
    o.expires = -1;
	}
	if( o.expires.constructor != Date ) {
    var today = new Date();
    today.setDate(today.getDate() + o.expires);
    o.expires = today;
  }
  // Create the cookie string
	document.cookie = 
    key + '=' + value +
    '; expires=' + o.expires.toUTCString() +
    (o.path? '; path=' + (o.path) : '') +
    (o.domain? '; domain=' + (o.domain) : '') +
    (o.secure? '; secure' : '');
    return this;
  } else {
    var result;
    if( result = new RegExp( key+"=(.*?)(?:;|$)" ).exec( document.cookie ) ) {
				return decodeURIComponent(result[1]);
    } else {
      return false;
    }
  }
};
