function main_init () {
	/**
	 * Causes all external links to open in a new window
	 */
	var local_domain = document.location.protocol + '//' + document.location.hostname;
	var a = document.getElementsByTagName ('A');
	var cnti = a.length;
	var ldl = local_domain.length;
	for (var i = 0; i < cnti; ++i) {
		if (a[i].href.substr(0, ldl) != local_domain) a[i].target = '_blank';
	}
	
	/**
	 * Centers the page
	 */
	window.__main_old_onresize = window.onresize;
	window.onresize = function() {
		var page = document.getElementById('page');
		page.style.top = ((document.body.clientHeight / 2) - (page.clientHeight / 2))+'px';
		if (typeof window.__main_old_onresize == 'function') window.__main_old_onresize ();
	}
	window.onresize();
	
	/**
	 * Fixing some image conflicts:
	 * - Microsoft Internet Explorer 6 does not support 24-bit transparent PNGs.
	 * - Firefox doesn't show the ALT-tag as TITLE-tag when no TITLE is given.
	 * Combining these two fixes is done for a better performance.
	 * Otherwise we had to loop through all images twice.
	 */
	var msie6 = navigator.userAgent.indexOf('MSIE 6') >= 0;
	var img = document.getElementsByTagName ('IMG');
	var cnti = img.length; for (var i = 0; i < cnti; ++i) {
		if (msie6) {
			if (img[i].src.substr (img[i].src.length - 4) == '.png') {
				if (img[i].clientWidth && img[i].clientHeight) {
					img[i].width = img[i].clientWidth;    // The spacer is 1x1 px
					img[i].height = img[i].clientHeight; // The spacer is 1x1 px
					img[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+img[i].src+"', sizingMethod='crop')";
				} else {
					img[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+img[i].src+"', sizingMethod='image')";
				}
				img[i].src = 'img/x.gif';
			}
		}
		if (img[i].title == '') img[i].title = img[i].alt;
	}
}

/**
 * Binds the init()-function to the onload-event.
 * If there is already an onload-event, it will be triggered next.
 */
window.__main_old_onload = window.onload;
window.onload = function () {
	main_init ();
	if (typeof window.__main_old_onload == 'function') window.__main_old_onload ();
}

function mout(e) {
	if(!e) var e = window.event;
	if(!e.target) e.target = e.srcElement;
	var button = e.target.id.substr(e.target.id.length-1);
	var img = document.getElementById('img_'+button);
	if(typeof img.old_src != 'undefined') {
		img.src = img.old_src;
		img.style.zIndex = '10';
	}
}


function mhover(e) {
	if(!e) var e = window.event;
	if(!e.target) e.target = e.srcElement;
	var button = e.target.id.substr(e.target.id.length-1);
	var img = document.getElementById('img_'+button);
	if(img.src.indexOf('img/fotos') >= 0) img.old_src = img.src;
	img.src = 'img/home_button'+button+'.gif';
	img.style.zIndex = '30';
}

