﻿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("Spread Trading carries a high degree of risk to your capital. Losses can quickly and substantially exceed your initial investment. Spread Trading is not suitable for all investors. You should fully understand the risks and seek independent advice if necessary.");
        SetThisCookie('count', 'fsa');
    }
}

window.onload=checkCount;
