
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
		window.onload = func;
	} else {
		window.onload = function(){
			oldonload();
			func();
		}
	}
}

function checkActiveLinks(base) {
	if(typeof(base) == 'undefined' && typeof(document.path) != 'undefined') base = document.path;

	linksArray = $$('a');

	var url = window.location;

	for(i = 0; i < linksArray.length; ++i ){
		var a = linksArray[i];

		url = new String(window.location);

		var link = a.href
		if(link.substring(link.length-4, link.length) == '.ait') link = link.substring(0, link.length-4)

		if(link == url || (link != base && link != (base + '/') && link == url.substring(0, link.length))) {
			if(link == url || (link + '/') == url || link == (url + '/')) {
				a.className += ' active_exact';
			}
			if(url.length <= link.length || (url.length > link.length && (url.substring(link.length, link.length+1) == '/' || url.substring(link.length, link.length+4) == '.ait'))) {
				a.className += ' active';
			}
		}
	}
}

function preLoad(images) {
	document.preLoad = new Array();

	if (document.images) {
		for(i = 0; i < images.length; ++i) {
			document.preLoad[i] = new Image();
			document.preLoad[i].src = images[i];
		}
	}
}

function mouseOver(element, image) {
	if(typeof(element.src_out) == 'undefined' || element.src_out == null) {
		element.src_out = element.src;
		if(typeof(image) != 'undefined') {
			element.src = image;
		} else {
			element.src = element.src.substring(0, element.src.length - 4) + '_up' + element.src.substring(element.src.length - 4, element.src.length);
		}
	}
}

function mouseOut(element) {
	if(typeof(element.src_out) != 'undefined' && element.src_out != null) {
		element.src = element.src_out;
		element.src_out = null;
	}
}
