  // The Cookie Handler main object
  function cookieGet(n){  // Function for getting cookies
	//alert("cookie value : " + document.cookie + " domain : " + document.domain);
    var re=new RegExp(n+'=([^;]*);?','gi');  // Create regex for cookies fetching
	//alert ("document cookie: " + document.cookie);
	if ((document.cookie != null) && (document.cookie != "")) {
    	var r=re.exec(document.cookie)||[];  // Fetch cookie using regex
    	return unescape(r.length>1?r[1]:"");  // Return unescaped cookie
	} else {
		return "";
	}
  }
  function cookieSet(n,v,e,p,d,s){  // Function for setting cookies
    var t=new Date;  // Get current time and date
    if(e)  // If days to expiry is set
      t.setTime(t.getTime()+(e*8.64e7));  // calculate expiry date
	//alert(n+'='+v+(!e?'':'; expires='+t.toUTCString())+(!p?'':'; path='+p)+(!d?'':'; domain='+d)+(!s?'':'; secure'));
    document.cookie=n+'='+v+(!e?'':'; expires='+t.toUTCString())+(!p?'':'; path='+p)+(!d?'':'; domain='+d)+(!s?'':'; secure')  // Set cookie
  }
  function cookieDel(n,p,d){  // Function for deleting cookies
    var t=cookie.Get(n);  // Get cookie
    document.cookie=n+'='+(!p?'':'; path='+p)+(!d?'':'; domain='+d)+'; expires=Monday, 01-Jan-01 00:00:01 GMT';  // Delete cookie
    return t  // Return the deleted cookie
  }
  function cookieSupp(){  // Function for detecting a BV cookie support
    var val = cookie.Get('BV_IDS');  // Return whether dummy was written
	//alert("cookie value : " + val + " domain : " + document.domain);
	return ((val != "null" && val != "") ? true : false);
  }
  
  function cookieSupp2(){  // Function for detecting a BV cookie support
    var val = cookie.Get('EP_CHECK_COOKIE');  // Return whether dummy was written
	//alert("cookie value : " + val + " domain : " + document.domain);
	return ((val != "null" && val != "") ? true : false);
  }
  function cookieObj() {
  	this.Get = cookieGet;
	this.Set = cookieSet;
	this.Del = cookieDel;
	this.Supp = cookieSupp;
	this.Supp2 = cookieSupp2;
  }

  var cookie= new cookieObj();


