//benodigde functie voor foto overzichts bouwsteen
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var popupscherm=0;

function popup_afbeelding(filename, fileid, width, height, scrollbars, resizable, menubar, toolbar, status, location) {
	if (popupscherm && ! popupscherm.closed)	popupscherm.close();
	if (!filename || filename=="")				filename="http://www.grundel.nl";
	if (!fileid || fileid=="")					fileid="Grundel";
	if (!width || width=="")					width="50";
	if (!height || height=="")					height="50";
	if (!scrollbars || scrollbars=="")			scrollbars="no";
	if (!resizable || resizable=="")			resizable="no";
	if (!menubar || menubar=="")				menubar="no";
	if (!toolbar || toolbar=="")				toolbar="no";
	if (!status || status=="")					status="no";
	if (!location || location=="")				location="no";
	popupscherm=0;
	var args = "height=" + height + ", width=" + width + ", scrollbars=" + scrollbars + ", resizable=" + resizable +  ", menubar=" + menubar + ", toolbar=" +toolbar + ", status=" + status + " ,location=" + location;
	popupscherm = open(filename, fileid, args);
	if (!InternetExplorer) 						popupscherm.focus();
}

window.onload = function () {
	// plaats een klein icoontje achter een externe link en achter links die naar bestanden wijzen
	// standaard: http://, ftp://, mailto:
	// doc, xls, pdf
	
	// de icoontjes staan in de dir css/images/
	// 	en hebben de zelfde naam als de extensie
	// doc => css/images/doc.gif
	
	// voeg eventueel extra types (bestandsextenties toe)
	tagAhref.setType('pdf');
	
	// plaats het icoontje links, ipv rechts
	// boolian: true of false;
	tagAhref.left = true;
	
	// start met het toevoegen van icoontjes
	// geef eventueel een rootnode op
	// bijvoorbeeld tagAhref.init('maintable');
	tagAhref.init('maintable');

}
/**
* tagAhref class
* tag all the A tag's with a icon
* check on the href tag, and the type of the href makes an other icon
*
* methods:  init(), setType ()
* properties: left : boolian
*/
var tagAhref = {
	init:function (element) {
		
		//for (el in window.location)alert (el + "\n" +  window.location[el])
		//alert(window.location.host.toString());
		
		this.left = this.left===true? 'Left': 'Right';
		element = document.getElementById(element) || document.body;
		
		if (!element)
			return false;

		var loc, el, result, ext, a = element.getElementsByTagName('A');
		loc = new RegExp ('^' + document.location.protocol + '\/\/' + document.location.host,'i');
		ext = new RegExp ('^(https?|ftp|mailto):|\.(' + this.types + ')$|\.(p3.php)+', 'i');

		for (el=0;el<a.length;el++) {

			result = a[el].href.replace (loc, '').match(ext);
			if (result) {
				if (a[el].innerHTML.toLowerCase().indexOf('<img') == -1) {
					a[el].style.backgroundImage = 'url(/images/' + (typeof result[3]=='undefined' || result[3]==''?(typeof result[1]=='undefined' || result[1]==''? result[2]: result[1]):result[3]) +'.gif)';
					a[el].style.backgroundPosition = this.left + ' top';
					a[el].style.backgroundRepeat = 'no-repeat';
					a[el].style['padding' + this.left] = '18px';
					a[el].style.paddingBottom = '2px';
				}
			}
		}
	},

	/**
	* add more file types
	*/
	setType: function (arg) {
		if (typeof arg !='string')
			return false;

		if (!new RegExp('\\|'+arg+'\\|','i').test('|'+this.types+'|'))
			this.types += '|' + arg;
	},

	types: 'pdf|xls|doc|zip', 
	left:false
}
