
var cookieControlEnabled = true;

//cookie functions
function writeCookie(nom, valeur) { var argv=writeCookie.arguments; var argc=writeCookie.arguments.length; var expires=(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=nom+"="+escape(valeur)+((expires==null) ? "" : ("; expires="+expires.toGMTString()))+((path==null) ? "" : ("; path="+path))+((domain==null) ? "" : ("; domain="+domain))+((secure==true) ? "; secure" : "");}
function getCookieVal(offset) { var endstr=document.cookie.indexOf (";", offset); if (endstr==-1) endstr=document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); }
function readCookie(nom) { var arg=nom+"="; 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 clearCookie(nom) { date=new Date; date.setFullYear(date.getFullYear()-1); writeCookie(nom,null,date); }

//video cookie test
function checkVideoView() { 
	var tt = readCookie("arjunaVideoCounter"); 
	var val = 1; if (!(tt==null)) { if (parseInt(tt)>0) { val=parseInt(tt);} val++; } var date=new Date; date.setMonth(date.getMonth()+1); writeCookie("arjunaVideoCounter", val,date); return val; }

function checkFirstVisit() {
	var out=true;
	if ((cookieControlEnabled)&&(checkVideoView()!=1)) { out=false; }
	return out;
}
