﻿
var _strPath;
var _strDomain;
var _blnSecure;
var _strExpires;

function Params(strPath, strDomain, blnSecure, strExpiresInMin)
{
   this._strPath = strPath;
   this._strDomain = strDomain;
   this._blnSecure = blnSecure;
   var today = new Date();
   today.setTime( today.getTime() );
   this._strExpires = new Date( today.getTime() + strExpiresInMin *60*1000 );
}

Params.prototype._strPath;
Params.prototype._strDomain;
Params.prototype._blnSecure;
Params.prototype._strExpires;

var _strName;
var _strValue;

function IoloCookie(name, value, arrParams)
{
   this._strName = name;
   this._strValue = value;
   Params.call(this, arrParams[0], arrParams[1], arrParams[2], arrParams[3]);
}
IoloCookie.prototype._strName;
IoloCookie.prototype._strValue;
IoloCookie.prototype = new Params();

IoloCookie.prototype.GetCookie = function() {

   var start = document.cookie.indexOf(this._strName+"=");
   if (start != -1)
   {
     var len = start+(this._strName).length+1;
     if ((!start) && (this._strName != document.cookie.substring(0,this._strName.length))) return null;
     if (start == -1) return null;
     var end = document.cookie.indexOf(";",len);
     if (end == -1) end = document.cookie.length;
     return unescape(document.cookie.substring(len,end));
   }
   return null;
   
}

IoloCookie.prototype.SetDefinitionsPath = function(sPath)
{
   this._strValue = sPath;
}

IoloCookie.prototype.SetCookie = function() {

    var cookieString = this._strName + "=" +escape(this._strValue) +
       ( (this._strExpires) ? ";expires=" + this._strExpires.toGMTString() : "") +
       ( (this._strPath) ? ";path=" + this._strPath : "") +
       ( (this._strDomain) ? ";domain=" + this._strDomain : "") +
       ( (this._blnSecure) ? ";secure" : "");
    document.cookie = cookieString;
}

IoloCookie.prototype.DeleteCookie = function(){

   if (this.GetCookie(this._strName)) document.cookie = this._strName + "=" +
      ( (this._strPath) ? ";path=" + this._strPath : "") +
      ( (this._strDomain) ? ";domain=" + this._strDomain : "") +
      ";expires=Thu, 01-Jan-70 00:00:01 GMT";
} 