function GetCookie (nombre) {
  var nomIgual = nombre + "=";
  var nomIgualLargo = nomIgual.length;
  var cLargo = document.cookie.length;
  var i = 0;
  while (i < cLargo) {
    var j = i + nomIgualLargo;
    if (document.cookie.substring(i, j) == nomIgual)
    return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

function SetCookie (name, value) {
  var arrCookie = SetCookie.arguments;
  var arrCookieLargo = SetCookie.arguments.length;
  var expires = (arrCookieLargo > 2) ? arrCookie[2] : null;
  var path = (arrCookieLargo > 3) ? arrCookie[3] : null;
  var domain = (arrCookieLargo > 4) ? arrCookie[4] : null;
  var secure = (arrCookieLargo > 5) ? arrCookie[5] : false;
  // Escritura de la cookie
  document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {
  var exp = new Date();
  exp.setTime (exp.getTime() - 1);
  var cval = GetCookie (name);
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function amt(){
  var cuenta = GetCookie('cuenta')
  if(count == null) {
    SetCookie('cuenta','1')
    return 1
  } else {
    var newCuenta = parseInt(cuenta) + 1;
    DeleteCookie('cuenta')
    SetCookie('cuenta',newCuenta,exp)
    return cuenta
  }
}

function getCookieVal(offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

