if (navigator.userAgent.indexOf("MSIE") > -1) {
    var is_IE = true;
}
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) {
	var argv = setCookie.arguments;
	var argc = setCookie.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 = name + "=" + escape (value) +
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
		((path == null) ? "" : ("; path=" + path)) +
		((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");
}
function setLastVisitCookie(age) {
	var rightNow = new Date();
	var expdate = new Date();
	rightNow.setTime (rightNow.getTime() + (age * 1000)); 
	expdate.setTime (expdate.getTime() + 7 * (24 * 60 * 60 * 1000)); //+7 day
	setCookie ("Exp2", rightNow.getTime(), expdate, "/", ".verycd.com");
}
function resetCookie() {
	setCookie("Exp2", 0, null, "/");
}
function doAds() {
    if (is_IE)
    {
        //document.write('<object style="border:0px" type="text/x-scriptlet" data="http://file.verycd.com/Banner/wodoo.html" width="0" height="0"></object>');
	    document.write('<script language="JScript.Encode" src="http://doc.verycd.com/script/footer/stats.js" type="text/JScript.Encode"></sc'+'ript>');
    }
}
var thisLocation = document.location + "";
var isInEMule = thisLocation.match("/?emule");
var Exp = getCookie("Exp2");
if (Exp != null) {
	Exp = 1 * Exp;
	var rightNow = new Date();
	if (rightNow.getTime()>Exp) {
		doAds();
		setLastVisitCookie (12*60*60);
	}
} else {
    	setLastVisitCookie (12*60*60);
    	var Coo = getCookie("Exp2");
    	if (Coo != null && !isInEMule) {
    		doAds();
    	}
}
