var objPageHandler = new PageHandler();

window.onload = function (){
	objPageHandler.OnLoad();
}

function viewImage(src, width, height){
    var widthAndHeight = "width=" + width + ",height=" + height;
    var newWindow = window.open(src, "ViewImageWindow", "toolbar=no, location=no, status=no, menubar=no, scrollbars=no, resizable=no, fullscreen=no,"+ widthAndHeight);
    newWindow.document.clear();
    newWindow.document.focus();
    newWindow.document.writeln('<html> <head><title> Axel Johnson<\/title> <\/head> <body style="padding: 0; margin: 0;">');
    newWindow.document.writeln('<img src=' + src + '  \/>');
    newWindow.document.writeln('<\/body> <\/html>');
    newWindow.document.close();
    newWindow.focus();
}

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}
 
function PageHandler() {
	this.OnLoad = function() {
		this.InitzializeMenu("mainNavigation");
		this.InitzializeMenu("bottomNavigation");
	}

	this.InitzializeMenu = function(Navigation) {
		var navDiv = document.getElementById(Navigation);
		if(navDiv != null) {
			navChildren = navDiv.childNodes;
			
				var lists = navDiv.childNodes;
				for (var j = 0; j < lists.length; j++) {
					var listItems = lists[j].childNodes;
					for (var k = 0; k < listItems.length; k++) {
						var item = listItems[k];
						item.onclick = this.toogleDropDown;											
					}
				}
		}
	}
	
	this.toogleDropDown = function() {
		var uls = this.getElementsByTagName("ul");
		if(uls.length > 0){
			var ul = uls[0];
				if(ul.style.display == 'none' || ul.style.display == ''){
				ul.style.display = 'block';
			} else {
				ul.style.display = 'none';
			}		
		}
	}
	
	function closeMenus(index) {
		var navDiv = document.getElementById("mainNavigation");
		if(navDiv != null){
			navChildren = navDiv.childNodes;
			var lists = navDiv.childNodes;
			for (var j = 0; j < lists.length; j++){
				var listItems = lists[j].childNodes;
				for (var k = 0; k < listItems.length; k++){
					var item = listItems[k];
					
					if (item.className != index)this.hideMenu;
				}
        	}
		}
	}
	
	this.hideMenu = function() {
		var uls = this.getElementsByTagName("ul");
		if(uls.length > 0){
			ul.style.display = 'none';
			
		}
		
	}
	
	this.IsIE = function() {
		var agt = navigator.userAgent.toLowerCase();
		return ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	}
}