var iversion = -1;
var roll = version();
var buttons = new Object();
window.name = 'contentframe';

function version() {
	if (iversion != -1) return roll;
	if (navigator.appName.indexOf("Netscape") != -1) {
		if (navigator.userAgent.indexOf("Mozilla/") != -1) {
			iversion = parseFloat(navigator.appVersion);
		} else {
			iversion = 1;
		}
		roll = (iversion>=3);
	} else {
		if (navigator.appName.indexOf("Internet Explorer") != -1) {
			if (navigator.userAgent.indexOf("Mozilla/") != -1) {
				iversion = parseFloat(navigator.appVersion);
			} else {
				iversion = 1;
			}
		} else {
			iversion = 1;
		}
		roll = (iversion>3);
	}
	return roll;
}

function addButton(name, src_normal, src_over, status) {
	if (roll) {
		buttons[name] = new Object();
		buttons[name].img_n = new Image();
		buttons[name].img_n.src = src_normal;
		buttons[name].img_o = new Image();
		buttons[name].img_o.src = src_over;
		buttons[name].status = status;
	}
}

function mouseOver(name, pos) {
	if (roll) {
		suffix = (typeof pos != "undefined")? "_" + pos: "";
		document.images[name + suffix].src = buttons[name].img_o.src;
		window.status = buttons[name].status;
	}
	return true;
}

function mouseOut(name, pos) {
	if (roll) {
		suffix = (typeof pos != "undefined")? "_" + pos: "";
		document.images[name + suffix].src = buttons[name].img_n.src;
		window.status = '';
	}
	return true;
}

function showFlash(arg) {
	if (arg!='vast' && arg!='vastr') {
		if (document.layers && document.layers[arg]) {
			document.layers[arg].visibility = 'visible';
		} else if (document.all) {
			document.all[arg].style.visibility = 'visible';
		}
	}
}

function rollout(arg, locatie) {
	var expdate = new Date();
	var jaar = expdate.getYear();
	expdate.setYear(jaar+1);
	var pagina = escape(location.href);
	var oldstring = getCookie("zibbpagina");

	if (oldstring!=null) {
		document.cookie = "zibbpagina="+pagina+"|"+oldstring+"; path=/";
	} else {
		document.cookie = "zibbpagina="+pagina+"; path=/";
	}

	locatie = unescape(locatie);
	var qstring = locatie.indexOf("?")
	var HasPortalNaam = locatie.indexOf("portalnaam=") > -1? true: false;

	if (!HasPortalNaam) {
		if (qstring > 0) {
			locatie = locatie + "&portalnaam=" + portalnaam;
		} else {
			locatie = locatie + "?portalnaam=" + portalnaam;
		}
	}

	if (navigator.platform == "MacPPC") {
		location.href = locatie;
		return;
	}
	else if (navigator.appName == "Netscape") {
		location.href = locatie;
		return;
	}
	else if (actualVersion==0) {
		location.href = locatie;
		return;
	}
	else if (!((navigator.appName.indexOf("Internet Explorer") != -1) && (navigator.userAgent.indexOf("Mozilla/") != -1) && parseFloat(navigator.appVersion) < 3)) {
		self.scroll(0, 0);
	}
	showFlash(arg);
	if (arg!='vast' && arg!='vastr') {
		window.document["swf"+arg].SetVariable("action", "go");
	}
	locatie = locatie.replace(/'/, "$12$");
	todo = "window.location='"+locatie+"'";
	var oldstring = getCookie("zibbpagina");
	if (arg!='vast' && arg!='vastr') {
		window.setTimeout(todo, 2800);
	} else {
		window.setTimeout(todo, 0);
	}
}

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 '';
}


function clearCookie(cname) {
	document.cookie = cname+"=; path=/; expires=Fri, 02-Jan-1970 00:00:00 GMT";
}


function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) {
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset, endstr));
}

function trimCookie(cname) {
	var t = getCookie(cname);
	if (t!=null) {
		var i = t.indexOf ("|", 0);
		if (i>-1) {
			document.cookie = cname+"="+(t.substring(i+1, t.length))+"; path=/";
			return t.substring(0, i);
		} else {
			clearCookie(cname);
			return t;
		}
	} else {
		clearCookie(cname);
	}
	return null;
}

function rollinSpeciaal(arg, locatie) {
	if (locatie == null) {
		locatie = '/index.asp';
	}
	locatie = trimCookie("zibbpagina");
	locatie = locatie.replace(/$12$/, "'");

	if (navigator.platform == "MacPPC") {
		if (locatie)
		{
			location.href = locatie;
		}
		else
		{
			location.href = '/index.asp';
		}
		return;
	}
	else if (navigator.appName == "Netscape") {
		if (locatie)
		{
			location.href = locatie;
		}
		else
		{
			location.href = '/index.asp';
		}
		return;
	} else if (actualVersion==0) {
		if (locatie)
		{
			location.href = locatie;
		}
		else
		{
			location.href = '/index.asp';

		}
		return;
	}
	else if (!((navigator.appName.indexOf("Internet Explorer") != -1) && (navigator.userAgent.indexOf("Mozilla/") != -1) && parseFloat(navigator.appVersion) < 3)) {
		self.scroll(0, 0);
	}

	if (locatie.length == 0) {
		locatie = '/index.asp';
	}

	if (locatie) {
		window.location = locatie;
	} else {
		location.href('/index.asp');
	}
}

function rollin(arg, locatie) {
	if (locatie == null) {
		locatie = '/index.asp';
	}
	locatie = trimCookie("zibbpagina");
	//Aanpassing om ervoor te zorgen dat de apostrophe weer terug komt in de URL
	locatie = locatie.replace(/$12$/, "'");

	if (navigator.platform == "MacPPC") {
		if (locatie) {
			location.href = locatie;
		} else {
			location.href = '/index.asp';
		}
		return;
	} else if (navigator.appName == "Netscape") {
		if (locatie) {
			location.href = locatie;
		} else {
			location.href = '/index.asp';
		}
		return;
	} else if (actualVersion==0) {
		if (locatie) {
			location.href = locatie;
		} else {
			location.href = '/index.asp';
		}
		return;
	} else if (!((navigator.appName.indexOf("Internet Explorer") != -1) && (navigator.userAgent.indexOf("Mozilla/") != -1) && parseFloat(navigator.appVersion) < 3)) {
		self.scroll(0, 0);
	}
	showFlash(arg);
	if (arg!='vast' && arg!='vastr') {
		window.document["swf"+arg].SetVariable("action", "go");
	}

	if (locatie.length == 0) {
		locatie = '/index.asp';
	}

	if (locatie) {
		todo = "window.location='"+locatie+"'";
	} else {
		todo = "location.href('/index.asp')";
	}
	if (arg!='vast' && arg!='vastr') {
		window.setTimeout(todo, 2800);
	} else {
		window.setTimeout(todo, 0);
	}
}

function WeerWindow(pagina) {
	window.open(pagina, "venster", "height=600,width=800,scrollbars=yes,directories=no,location=no,menubar=no,status=no,toolbar=no");
}

function NieuwWindow(pagina, hoogte, breedte, popup) {
	var features = "height=" + hoogte + ",width=" + breedte + ",scrollbars=yes";

	if (popup != "popup") {
		features += ",directories=yes,location=yes,menubar=yes,status=yes,toolbar=yes,resizable=yes";
	} else {
		features += ",directories=no,location=no,menubar=no,status=no,toolbar=no,resizable=no";
	}

	window.open(pagina, "venster", features);
}

function popup(url, hoogte, breedte) {
	if (isNaN(hoogte)) {
		hoogte = '475';
	}
	if (isNaN(breedte)) {
		breedte = '600';
	}
	newWindow = window.open(url, "venster", "resizable=yes,height="+hoogte+",width="+breedte);
	if (window.focus) {
		newWindow.focus();
	}
}


var requiredVersion = 4;
var useRedirect = false;
var flash2Installed = false;
var flash3Installed = false;
var flash4Installed = false;
var flash5Installed = false;
var maxVersion = 5;
var actualVersion = 0;
var hasRightVersion = false;
var jsVersion = 1.0;

var isIE = (navigator.appVersion.indexOf("MSIE") != -1)? true: false;
var isWin = (navigator.appVersion.indexOf("Windows") != -1)? true: false;

jsVersion = 1.1;

if (isIE && isWin) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
	document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
	document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
	document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
	document.write('</SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
}

function detectFlash() {

	if (navigator.plugins) {
		if (navigator.plugins["Shockwave Flash 2.0"]
			|| navigator.plugins["Shockwave Flash"]) {

			var isVersion2 = navigator.plugins["Shockwave Flash 2.0"]? " 2.0": "";
			var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
			var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
			flash2Installed = flashVersion == 2;
			flash3Installed = flashVersion == 3;
			flash4Installed = flashVersion == 4;
			flash5Installed = flashVersion == 5;
		}
	}

	for (var i = 2; i <= maxVersion; i++) {
		if (eval("flash" + i + "Installed") == true) actualVersion = i;
	}

	if (navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 2;

	if (actualVersion >= requiredVersion) {
		hasRightVersion = true;

		if (useRedirect) {
			if (jsVersion > 1.0) {
				window.location.replace(flashPage);
			} else {
				window.location = flashPage;
			}
		}
	} else {
		if (useRedirect) {
			if (jsVersion > 1.0) {
				window.location.replace((actualVersion >= 2)? upgradePage: noFlashPage);
			} else {
				window.location = (actualVersion >= 2)? upgradePage: noFlashPage;
			}
		}
	}
}

detectFlash();
