//expiration days of the cookie
var expDays = 365;
var exp = new Date();
var expires = 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 GetCookie (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 SetCookie (name,value,expires) {
path = '/';
document.cookie = name + "=" + escape (value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "");
//((domain) ? "; domain=" + domain : "") +
//((secure) ? "; secure" : "");
}
function set_name(name,value) {
var expdate = new Date ();
expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 31));
SetCookie (name, value, expdate);
}
// eSc(=euroShell cards) specific method for redirection)
function CheckCookie(siteID) {
var url = "/home/euroshell_ga/html/iwgen/euroshell_directory.html";
var url2= "/home/Framework?siteId=";
var str=GetCookie("eScCookie");
if(siteID == 'fi') {
   url = "/home/euroshell_ga/html/iwgen/splash_pages/finland/finland.htm";
}

if(str != null) {
   var pos=str.indexOf('_' + siteID);
   if (pos>=0) {
   url2 = url2 + str;
   document.location.href = url2;
   } else {
      document.location.href = url;
   }
} else {
   document.location.href = url;
}
}
// end eSc(=euroShell cards) specific method for redirection)