function checkGCF() {
	if (detectIE678() != -1 && checkGCFcookie()) {
		if (!installedGCF()) {
			if (confirm("If you use one of old or not supported by us browsers the layout of opvizor might be broken. " +
					"This issue might be fixed if you install the Google Chrome Frame. " +
					"Google Chrome Frame is an add-on for Internet Explorer. " +
					"It is an open source plug-in that allows those utilizing it to give IE the power to use Chrome's open web technology." +
					"If you want to install Google Chrome Frame press Install button. Press Cancel to skip the installation.")) {

				window.location = 'http://www.google.com/chromeframe';
			} else {
				setGCFcookie();
			}
		}
	}
}

function checkGCFcookie() {
	var i,x,y,ARRcookies = document.cookie.split(";");
	for (i = 0; i < ARRcookies.length; i++) {
		x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
		y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
		x = x.replace(/^\s+|\s+$/g, "");
		if (x == "GCFcookie") {
			return false;
		}
	}
	return true;
}

function setGCFcookie() {
	var exDate = new Date();
	exDate.setDate(exDate.getDate() + 30);
	document.cookie = "GCFcookie=GCFcookie; expires=" + exDate.toUTCString();
}

function installedGCF() {
	if (navigator.userAgent.toLowerCase().indexOf("chromeframe") >= 0) {
		return true;
	}
	if (typeof window.ActiveXObject != "undefined") {
		try {
			var a = new ActiveXObject("ChromeTab.ChromeFrame");
			if (a) {
				a.registerBhoIfNeeded();
				return true
			}
		} catch(b) {
		}
	}
	return false
}

function detectIE678() {
	var rv = -1;
	if (navigator.appName == 'Microsoft Internet Explorer') {
		var ua = navigator.userAgent;
		var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null) {
			rv = parseFloat(RegExp.$1);
		}
		// exclude veresions >9
		if (rv > 8) {
			rv = -1
		}
	}
	return rv;
}
