﻿var expDays = 30; // number of days the cookie should last

function GetThisCookie (name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
        return getCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
  return null;
}

function SetThisCookie (name, value) {
  var argv = SetThisCookie.arguments;
  var argc = SetThisCookie.arguments.length;
  var exdate = new Date();
  exdate.setDate(exdate.getDate() + 30);
  //var expires = exdate; //(argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) + ((exdate == null) ? "" : ("; expires=" + exdate.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
}

var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));


function getCookieVal(offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function checkCount() {
    var count = GetThisCookie('count');
    if (count == null) {
        alert("Aunque las apuestas financieras con margen ofrecen muchos provechos, tambien conllevan un alto nivel de riesgo. Por lo tanto sólo debe especular con dinero que puede permitirse perder. Puede perder más de su depósito y apuesta iniciales. Antes de abrir una cuenta, asegúrese de que las apuestas financieras con margen corresponden a sus objetivos de inversión, familiarícese con los riesgos implicados y si es necesario obtenga asesoría independiente.");
        SetThisCookie('count', 'fsa');
    }
}

window.onload=checkCount;