try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

function  getCookie(name)
{
	var ck = document.cookie.split(";");
	if (ck.length == 0) return "";

	for (var i = 0; i < ck.length; i++) {
		var tmp = ck[i].split("=");
		if (tmp[0] == name) return unescape(tmp[1]);
	}
	return  "";
}

function setCookie(name, value) {
	var Sys = {};
	var ua = navigator.userAgent.toLowerCase();
	if (window.ActiveXObject)
		Sys.ie = ua.match(/msie ([\d.]+)/)[1]
	else if (document.getBoxObjectFor)
		Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1]
	else if (window.MessageEvent && !document.getBoxObjectFor)
		Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1]
	else if (window.opera)
		Sys.opera = ua.match(/opera.([\d.]+)/)[1]
	else if (window.openDatabase)
		Sys.safari = ua.match(/version\/([\d.]+)/)[1];

	if(Sys.ie) setIECookie(name, value);
    else setFFCookie(name, value);
}

function  setFFCookie(name,  value)
{
	var  expdate  =  new  Date();
	var  argv  = setCookie.arguments;
	var  argc  =  setCookie.arguments.length;
	var  expires  =  (argc  >  2)  ?  argv[2]  :  10000;	//default is 10000 days
	var  path  =  (argc  >  3)  ?  argv[3]  :  null;
	var  domain  =  (argc  >  4)  ?  argv[4]  :  null;
	var  secure  =  (argc  >  5)  ?  argv[5]  :  false;
	if(expires!=null)  expdate.setTime(expdate.getTime()  +  (  expires  * 24*60*60* 1000  ));
	document.cookie  =  name  +  "="  +  escape  (value)  +((expires  ==  null)  ?  ""  :  (";  expires="+  expdate.toGMTString()))
	+((path  ==  null)  ?  ""  :  (";  path="  +  path))  +((domain  ==  null)  ?  ""  :  (";  domain="  +  domain))
	+((secure  ==  true)  ?  ";  secure"  :  "");
}

function setIECookie(name, value) {
	var cookie_path = window.location.pathname;  
	//var cookie_name = encodeURIComponent(cookie_path.substring(cookie_path.lastIndexOf('/') + 1));  
	var cookie_name = 'Apache';
	cookie_path = cookie_path.substring(0, cookie_path.lastIndexOf('/') + 1);  
	var cookie_value = value;  
	expires = new Date();  
	expires.setTime(expires.getTime() + 86400 * 1000 * 10000);  
	  
	document.cookie = cookie_name + "=" + encodeURIComponent(cookie_value)  
			+ "; expires=" + expires.toGMTString() + "; path=/";// + cookie_path;  
}

function checkCookie() {
	var ck = getCookie('Apache');
	if (ck == '') {
		setCookie('Apache', getRandom());
	}
}

function getRandom() {
	var txt = Math.round(Math.random() * (Math.pow(10,16))).toString();
	while (txt.length < 16) {
		txt += '0';
	}
	return txt;
}

if(window.onload==null){
	window.onload = checkCookie;
}else{
        var fnc = window.onload.toString();
	if (fnc.indexOf('checkCookie') < 0) {
		eval("wtempfunction="+window.onload.toString());
		window.onload=function(){wtempfunction(); checkCookie();}
	}
}
