function createCookie(name,value,hours,minutes) 
{
   var date = new Date();
   date.setTime(date.getTime()+(hours*minutes*60*1000));
   var expires = date.toGMTString();
   document.cookie = name+"="+value+"; expires="+expires+"; path=/";
}

function readCookie(name) 
{
  var flag = 0;
  var dcmntCookie = document.cookie.split(';');
  for(var i=0;i < dcmntCookie.length;i++) 
  {
      var ck = dcmntCookie[i];
      while (ck.charAt(0)==' ')
      {
         ck = ck.substring(1,ck.length);
      }
      if(ck)
      {
        cparts = ck.split('=');
        if (cparts[0]==name)
           flag=1;
     }              
  }     
  if(flag)
  { 
     return true; 
  }
  else
  {
     return false; 
  }  
}

function checkCookie(name)
{
  if(readCookie(name))
  {

  }
  else {
    var url = String(window.location);
	var index = url.indexOf("?");
	var data = url.substr(index+1);

	var splitted = data.split("=");
	event = splitted[0];
	act = splitted[1];
	
	if(index == -1){
		createCookie(name,"Bebe Boutique Homepage Advertising",1,30);
	} else if(event == "minutes"){
		createCookie(name,"Bebe Boutique Homepage Advertising",1,act);
	} else {
		createCookie(name,"Bebe Boutique Homepage Advertising",1,30);
	}
	
	Dialog.alert({url: "/popup-content/index.html", options: {method: 'get'}}, {className: "alphacube", width:400, okLabel: "Inchide"});	
// Scoate commentul de pe linia de mai sus pentru a activa cookieul

//	  createCookie(name,"basco productions actor",1); 
  }
//  Dialog.alert({url: "/popup-content/index.html", options: {method: 'get'}}, {className: "alphacube", width:510, okLabel: "Inchide"});	
}

