function setAdCookie(name,value,expires,path,domain,secure)
{
   var curCookie = name + "=" + escape(value) +
         	 ((expires) ? "; expires=" + expires.toGMTString() : "") +
	         ((path) ? "; path=" + path : "") +
		 ((domain) ? "; domain=" + domain : "") +
                 ((secure) ? "; secure" : "");
   document.cookie = curCookie;
}

function getAdCookie(name)
{
   var dc = document.cookie;
   var prefix = name + "=";
   var begin = dc.indexOf("; " + prefix);
   if( begin == -1)   {
      begin = dc.indexOf(prefix);
      if( begin != 0) return null;
   }
   else   {
      begin += 2;
   }
   
   var end = document.cookie.indexOf(";", begin);
   if( end == -1) end = dc.length;
   return unescape( dc.substring(begin + prefix.length, end));
}

function killAdCookie(name)
{
   var dc = document.cookie;
   var prefix = name + "=";
   var begin = dc.indexOf("; " + prefix);

   if( begin == -1)   {
       return false;
   }   else   {
       this.document.cookie = prefix;
       return true;
   }
}


function EmitMyCookieDays( strName, counterstr, days)
{
   cres = getAdCookie( strName);
   
   if(!cres)
   {
      var expires = new Date();
      var sec = expires.getTime() + ( days * 24 * 60 * 60 * 1000);
      expires.setTime(sec);
	
      setAdCookie( strName, "sososo", expires, "/", "nickles.de");
      return true;
   }
   else
        return false;
}

function EmitMyCookieWeek( strName, counterstr)		
{
   return EmitMyCookieDays( strName, counterstr, 7);
}
function EmitMyCookieSession( strName, counterstr)
{
 return EmitMyCookie( strName, counterstr);
}

function EmitMyCookie( strName, counterstr)
{
   cres = getAdCookie( strName);
   
   if(!cres)
   {
      setAdCookie( strName, "sososo", "", "/", "nickles.de");
      return true;
   }
   else
      return false;
}

//   window.navigator.cookieEnabled liefert true zurück wenn der
//   browser prinzipiell cookies kann. sagt allerdings nicht
//   ob cookies auch vom user erlaubt sind

function MyCookieEnabled()
{
  document.cookie = "arecookiesenabled=1";
  if( document.cookie.indexOf( "arecookiesenabled") >= 0)
     return true;
  else
     return false;
}

function MyCookieEnabled2()
{
   return MyCookieEnabled();
}

