/** Voorbeeld functie die onderstaand class aanroept.

	// voeg eventueel extra types (bestandsextenties toe)
	//	tagAhref.setType('doc');
	//	tagAhref.setType('xls');
	
	// plaats het icoontje links, ipv rechts
	// boolean: true of false;
	tagAhref.left = true;
	
	// plaats het icoontje boven uitgelijnd ipv onder
	// string
	tagAhref.top = 'top';
	
	// start met het toevoegen van icoontjes
	// geef eventueel een rootnode op
	// bijvoorbeeld tagAhref.init('maintable');
	tagAhref.init();
}
**/

/**
* tagAhref class
* tag all the A tag's with a icon
* check on te href tag, and the type of the href makes an other icon
*
* methods:  init(), setType ()
* properties: left : boolian
*/
var tagAhref = {
	init:function (element) {
		
		if (/\/admin\//.test(document.location))
			return false;
		
		this.left = this.left===true? 'Left': 'Right';
		element = document.getElementById(element) || document.body;
		if (!element)
			return false;

		var loc, el, localsite, result, ext, type, a = element.getElementsByTagName('A');
		loc = new RegExp ('^' + document.location.protocol + '\/\/' + document.location.host,'i');
		ext = new RegExp ('^(https?|ftp|mailto):|\.(' + this.types + ')$', 'i');
		type = new RegExp ('\.(' + this.types + ')$', 'i');
		
		for (el=0;el<a.length;el++) {
			
			try {
				result = a[el].href.replace(loc, '').match(ext);
			} catch (e) {}
			
			if (result) {
				if (a[el].getAttribute('icon') == 'false')
					continue;
				else {
					if (type.test(a[el].href)) 
						this.setIcon (a[el], (typeof result[1]=='undefined' || result[1]==''? result[2]: result[1]))
					else {
						if (this.externurl !== false)
							this.setIcon (a[el], (typeof result[1]=='undefined' || result[1]==''? result[2]: result[1]))
					}
				}
			}

			else {
				try {
					if (a[el].href.match (loc) && this.localurl) {
						if (a[el].getAttribute('icon') == 'false')
							continue;
						else
							this.setIcon(a[el], this.localurl);
					}
				} catch (e) {}
			}
		}
	},
	/**
	 * function to set the backgroudimage
	 */
	setIcon: function (a, name) {
		if (this.left == 'Left')
			a.innerHTML = '<img src="/images/icons/'+name+'.gif" border=0 style="vertical-align:top;text-align:left;margin-right:4px;">' + a.innerHTML;
		else
			a.innerHTML = a.innerHTML + '<img src="/images/icons/'+name+'.gif" border=0 style="vertical-align:top;text-align:left;margin-left:3px;">';
	},
	
	/**
	* add more file types
	*/
	setType: function (arg) {
		if (typeof arg !='string')
			return false;

		if (!new RegExp('\\|'+arg+'\\|','i').test('|'+this.types+'|'))
			this.types += '|' + arg;
	},

	// possible types file to add a icon
	types: 'pdf|xls|doc',
	
	// left or right of the <a href>abx</a> and the belonging padding
	left:false,
	top:'bottom',
	padding:'18',
	
	// the name of the icon for the local urls
	// if you do not want any icon for local url's 
	// do this: localurl:false
	localurl:'local',
	
	// specify if you want icons for external urls or not
	externurl:true
}
