// A4 © 2005
// it's recommended to compress this file before upload to site for descreasing download time: delete all double spaces, returns, comments.


//  CONFIG
var domainName    = "sousmacouette.com";
var confirmText1  = 'Vous devez etre majeur pour acceder a ce site!';      //first  popup text
var confirmText2  = 'Vous confirmez avoir plus de 18ans ?';                    //second popup text
var redirectURL   = 'http://www.kouaa.com/';            //where to go if user isn't agree
//var cookieExpires = 'Friday,01-Jan-2010 12:00:00 GMT'; //when cookie becomes too old and user will be asked again

// FUNCTIONS
function GetValue(Offset){
var End=document.cookie.indexOf (";", Offset);
if (End==-1)
  End=document.cookie.length;
return unescape(document.cookie.substring(Offset, End));
}



function GetCookie (Name) {
         if ( document.cookie) { // Le cookie est-il valide ?
                  index = document.cookie.indexOf(Name);
                  if ( index != -1) {
                           nDeb = (document.cookie.indexOf( "=", index) + 1);
                           nFin = document.cookie.indexOf( ";", index);
                           if (nFin == -1) {nFin = document.cookie.length;}
                           return unescape(document.cookie.substring(nDeb, nFin));
                  }
         }
         return null;
}

/*
function GetCookie(Name)
{
  var Len=Name.length;
  var i=0;

  while (i<document.cookie.length)
  {
    var j=i+Len+1;
    if (document.cookie.substring(i,j)==(Name+"="))
      return GetValue(j);
    i=document.cookie.indexOf(" ", 1)+1;
    if (i==0)
      break;
  }
  return null;
}
*/

function SetCookie(name, value, expires, path, domain, secure)
{
    str = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");

    document.cookie = str;
}

// this deletes the cookie when called
function DeleteCookie(name, path, domain)
{
    if (GetCookie(name))
    {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

//THE CODE

var CanSee=GetCookie('CanSeeThePage');

if (!(CanSee!=null && CanSee=='yes'))
{
	if (confirm(confirmText1) && confirm(confirmText2))
	{
		//    SetCookie('CanSeeThePage', 'yes','','/',document.location.hostname);
    	SetCookie('CanSeeThePage', 'yes','','/',domainName,'');
	}
  	else
  	{
  		document.location.href=redirectURL;    //go away!!
  	}
}

