//IE sucks
menuHover = function() {
	var mEls = document.getElementById("MainMenu").getElementsByTagName("li");
	for (var i=0; i<mEls.length; i++) {
		mEls[i].onmouseover=function() {
			this.className+=" menuHover";
		}
		mEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" menuHover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", menuHover);

//links
// Set paramethers:
var path_to_icon 		= 'images/icon.gif';
var link_alt_text 		= 'Otwórz w nowym oknie';
var link_title_text 	= 'Otwórz odnośnik w nowym oknie!';

function openNewWindow() {
	if (!document.getElementById || !document.createTextNode || !document.domain) return;
	var l = document.getElementsByTagName('a');
	var skipElement = false;
	for (var i = 0; i < l.length; i++) {
		skipElement = false;
		if (l[i].hasChildNodes()) {
			var children = l[i].childNodes;
			for (var j = 0; j < children.length; j++) {
				if (children[j].nodeName == 'IMG')
					skipElement = true;
			}
		}
		// just for off-site links
		if (l[i].href.indexOf('mailto') != 0)
		if (l[i].href.split('/')[2].replace(/www\./, '') != document.domain.replace(/www\./, '')
			&& !l[i].getAttribute('target')
			&& !l[i].getAttribute('rel')
			&& !l[i].parentNode.id.match(/^copy/)
			&& !skipElement) {

			// create new elements
			var nwl = document.createElement('a');
			var nwl_image = document.createElement('img');
			var space = document.createTextNode(' ');

			// setup image attributes
			nwl_image.setAttribute('src', path_to_icon);
			nwl_image.setAttribute('alt', link_alt_text);
			nwl_image.setAttribute('title', link_title_text);

			// set link attributes
			nwl.setAttribute('href', l[i].getAttribute('href'));
			nwl.setAttribute('target', '_blank');
			nwl.setAttribute('title', link_title_text);
			nwl.className = 'openNewWindow';

			// append new elements
			nwl.appendChild(nwl_image);
			l[i].parentNode.insertBefore(space, l[i].nextSibling);
			l[i].parentNode.insertBefore(nwl, l[i].nextSibling.nextSibling);
		}
	}
}
onload = openNewWindow;
