onError = null;

// determine type of browser
var IE4 = document.all ? 1 : 0;

function CalculateTop(o) {
	var t = o.offsetTop;
	var p = o.offsetParent;
	while (p) {
		t += p.offsetTop;
		p = p.offsetParent;
	}
	return t;
}

function CalculateLeft(o) {
	var l = o.offsetLeft;
	var p = o.offsetParent;
	while (p) {
		l += p.offsetLeft;
		p = p.offsetParent;
	}
	return l;
}

document.writeln('<SPAN ID="AltText"></SPAN>');
function ShowAltText(o, text, extraVerticalOffset) {
	// show an alttext pop-up at the mouseover location using the layer defined above
	if ((IE4) && (text!="")&& (text!=" ")) {
		var t = CalculateTop(o);
		var l = CalculateLeft(o);
		var horizontalOffset = 18;
		if (l>618) horizontalOffset -= 60;
		var verticalOffset = 16;
		if (extraVerticalOffset != 0) {verticalOffset = extraVerticalOffset - 2;}
		document.all['AltText'].innerHTML = text;
		document.all['AltText'].style.top = t + verticalOffset;
		document.all['AltText'].style.left = l + horizontalOffset;
		document.all['AltText'].style.visibility = 'visible';
	} else {
		status = text;
	}
}
function HideAltText() {
	if (IE4) {
		document.all['AltText'].style.visibility = 'hidden';
	} else {
		status = '';
	}
}

var toHandler = new Array();
function FadeTo(id, endvalue, stepsize, delay) {
	//clear all other looping faders for this id
	clearTimeout(toHandler[id]);
	toHandler[id] = null;
	
	//make sure the object is visible
	if (document.all[id].style.visibility != 'visible') document.all[id].style.visibility = 'visible';
	
	//get the current opacity value
	var startOpacity = document.all[id].filters.alpha.opacity;
	
	//make sure the current opacity is within the valid range (0..100)
	if (startOpacity < 0) document.all[id].filters.alpha.opacity = 0;
	if (startOpacity > 100) document.all[id].filters.alpha.opacity = 100;

	//move the opacity towards its endvalue
	if (startOpacity < endvalue) document.all[id].filters.alpha.opacity += stepsize;
	else document.all[id].filters.alpha.opacity -= stepsize;

	//get the current opacity value
	var curOpacity = document.all[id].filters.alpha.opacity;

	//check whether the opacity has reached is endvalue
	if (((curOpacity>=startOpacity) && (curOpacity>=endvalue)) || ((curOpacity<=startOpacity) && (curOpacity<=endvalue))) {
		//set the opacity to the exact endvalue
		document.all[id].filters.alpha.opacity = endvalue;
		
		//if the endvalue is very low, hide the object
		if (endvalue<=10) document.all[id].style.visibility = 'hidden';
		
		//empty the timeout reference
		toHandler[id] = null;
	} else {
		//get ready for the next step
		toHandler[id] = setTimeout('FadeTo(\'' + id + '\', ' + endvalue + ', ' + stepsize + ', ' + delay + ');', delay);
	}
}

function openWindow(url, width, height) {
	// opens a default window for handling forms etc.
	//width = 570;
	//height = 470;
	defaultParam = 'toolbar=no,menubar=yes,scrollbars=auto,resizable=no';
	
	// extra width for netscape because of the different size in form elements
	if(!IE4) {width += 50;}
	
	if ((url!="") && (url!=" ")) {
		var ADPopupWindow = window.open(url, 'ADPopup', defaultParam + ',width=' + width + ',height=' + height);
	}
	return false;
}

function ShowFlash(id, width, height, path, head) {
	// opens a window and displays a flash movie if the flash plug-in is installed
	// otherwise an error window will appear
	
	var ShockMode = 0;
	
	// browser differences workaround
	var extraWindowWidth = 0;
	var extraWindowHeight = 0;
	
	if (IE4) {
		// IE will install the Flash plug-in automatically
		ShockMode = 1;
	} else {
		// Netscape can check wether the plug-in is installed
		if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
			if (navigator.plugins && navigator.plugins["Shockwave Flash"]){
				// plug-in is installed
				ShockMode = 1;
				extraWindowWidth = 16;
				extraWindowHeight = 16;
			}
		}
	}
	
	var defaultParam = 'toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no';
	
	var windowWidth = extraWindowWidth + (1 * width);
	var windowHeight = extraWindowHeight + (1 * height);
	
	if (ShockMode) {
		// open a unique window for each flash movie
		flashWindow = window.open('', id , defaultParam + ',width=' + windowWidth + ',height=' + windowHeight);

		// write HTML containing the Flash embed statements
		flashWindow.document.write('<HTML><HEAD>\n<TITLE>');
		flashWindow.document.write(head);
		flashWindow.document.write('</TITLE>\n<BODY BGCOLOR=#FEFAE4 LEFTMARGIN=0 TOPMARGIN=0>\n\n');
		flashWindow.document.write('<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version=3,0,0,0\" ID=BeeldmateriaalFlash');
		flashWindow.document.write(' WIDTH=' + width + ' HEIGHT=' + height + '>\n');
		flashWindow.document.write('<PARAM NAME=\"movie\" VALUE=\"/beeldmateriaal/' + path + '\">\n');
		flashWindow.document.write('<PARAM NAME=\"quality\" VALUE=\"autohigh\">\n');
		flashWindow.document.write('<PARAM NAME=\"play\" VALUE=\"true\">\n');
		flashWindow.document.write('<PARAM NAME=\"menu\" VALUE=\"false\">\n');
		flashWindow.document.write('<FONT SIZE=\"-30\" COLOR=\"#FFFFFF\">\n');
		flashWindow.document.write('<EMBED SRC=\"/beeldmateriaal/' + path + '\"');
		flashWindow.document.write(' PLAY=\"true\" MENU=\"false\"');
		flashWindow.document.write(' WIDTH=' + width + ' HEIGHT=' + height);
		flashWindow.document.write(' QUALITY=\"autohigh\"');
		flashWindow.document.write(' TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\">\n');
		flashWindow.document.write('</EMBED>\n');
		flashWindow.document.write('<NOEMBED>&nbsp;</NOEMBED>\n<NOSCRIPT>&nbsp;</NOSCRIPT>\n</FONT></OBJECT>\n');
		flashWindow.document.write('</BODY>\n</HTML>\n');
		
		// stop writing
		flashWindow.document.close();
	} else {
		// open a window containing an error message
		errorWindow = window.open('', 'errorMessage' ,defaultParam + ',width=320,height=60');
		errorWindow.document.write('<HTML><HEAD>\n<TITLE>Het Algemeen Dagblad</TITLE>\n<BODY BGCOLOR=#FEFAE4>\n\n');
		errorWindow.document.write('<FONT FACE=\"verdana\" SIZE=\"2\"><B>');
		errorWindow.document.write('Om het filmpje te kunnen zien heeft u Macromedia Flash nodig.<BR/ >&#187;<A HREF=\"http://www.macromedia.com/shockwave/download/\" TARGET=\"_blank\" onClick=\"top.close();return true;\">download flash</A>.');
		errorWindow.document.write('</B></FONT>\n');
		errorWindow.document.write('</BODY>\n</HTML>\n');
		errorWindow.document.close();
	}
	return false;
}

function writeFavorite(url, title) {
	if (IE4 && (navigator.userAgent.toLowerCase().indexOf("mac") < 0)) {
		document.write('<SPAN STYLE="cursor: hand" onClick="makeFavorite(' + url + ',' + title + ')"><IMG SRC="/extras/media/favorites.gif" WIDTH=17 HEIGHT=13 BORDER=0 alt="voeg toe aan favorieten"><IMG SRC="/media/nix.gif" WIDTH="10" HEIGHT="5" BORDER="0"></SPAN>')
	}
}

function makeFavorite(url, title){
 	window.external.AddFavorite(url, 'Euro' + title);
}

function mailLink(url) {
	width = 490;
	height = 280;
	defaultParam = 'toolbar=no,menubar=no,scrollbars=auto,resizable=no';
	
	// extra width for netscape because of the different size in form elements
	if(!IE4) {width += 130;}
	
	window.open('/extras/maillink.html?ADMailLink=' + escape(url), 'Maillink', defaultParam + ',width=' + width + ',height=' + height);
	return false; 
}

function parseADMailLink(url) {
	separator = "?ADMailLink=";
	divLoc = url.lastIndexOf(separator) + separator.length;
	mailUrl = unescape(url.substring(divLoc, url.length));
	return mailUrl;
}
