var Berlin;
if (Berlin && (typeof Berlin != "object" || Berlin.NAME)) {
	throw new Error("Namespace 'Berlin' already exists");
}

// Create our namespace, and specify some meta-information
Berlin = {};
Berlin.NAME = "Berlin";    // The name of this namespace
Berlin.VERSION = 1.0;    // The version of this namespace


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

Berlin.$ = function(id) {
	return document.getElementById(id);
};

Berlin.addClass = function(elem,cname) {
	if (elem.className) {
		elem.className = elem.className + " " + cname;
	} else {
		elem.className = cname;
	}
};

Berlin.removeClass = function(elem,cname) {
	var cnames = elem.className.split(" ");
	var newClassName = '';
	for (var i=0;i<cnames.length;i++) {
		if (cname != cnames[i]) {
			newClassName = newClassName + " " + cnames[i];
		}
	}
	elem.className = newClassName;
};

Berlin.hasClass = function(elem,cname) {
	var cnames = elem.className.split(" ");
	for (var i=0;i<cnames.length;i++) {
		if (cname == cnames[i]) {
			return true;
		}
	}
	return false;
};

Berlin.iniImgSwap = function() {
	var getlinks = document.getElementsByTagName('a');
	for (i=0; i<getlinks.length; i++) {
		if ("splash_art" == getlinks[i].className) {
			getlinks[i].onmouseover = function () {
			var imgtarget = Berlin.$('art_container');
			imgtarget.style.background = 'url(images/building_bottom.gif) 560px -86px no-repeat';
			};
			getlinks[i].onmouseout = function () {
			var imgtarget = Berlin.$('art_container');
			imgtarget.style.background = 'url(images/building_bottom.gif) 560px 0 no-repeat';
			};
		}
		if ("splash_building" == getlinks[i].className) {
			getlinks[i].onmouseover = function () {
			var imgtarget = Berlin.$('art_container');
			imgtarget.style.background = 'url(images/building_bottom.gif) 560px -172px no-repeat';
			var imgtarget2 = Berlin.$('film_container');
			imgtarget2.style.background = 'url(images/building_top.gif) 628px -83px no-repeat';
			};
			getlinks[i].onmouseout = function () {
			var imgtarget = Berlin.$('art_container');
			imgtarget.style.background = 'url(images/building_bottom.gif) 560px 0 no-repeat';
			var imgtarget2 = Berlin.$('film_container');
			imgtarget2.style.background = 'url(images/building_top.gif) 628px 0px no-repeat';
			};
		}
	}
};

Berlin.start_menu = function() {
	navRoot = document.getElementById("nav");
	if (document.all&&document.getElementById) {
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

Berlin.addLoadEvent(function() {
	Berlin.iniImgSwap();
	Berlin.start_menu();
});