
function getInternetExplorerVersion () {
    var rv = -1; // Return value assumes failure.
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) != null)
            rv = parseFloat(RegExp.$1);
    }
    return rv;
}

function LeetMenu () {
	this.suitableIds = new Array();
	this.suitableIds.push("conference__location");
	this.suitableIds.push("tourism");
	this.suitableIds.push("conference__location-pre");
	this.suitableIds.push("tourism-pre");
	
	this.okId = this.verifyIfImNeeded();
	this.ie = (window.attachEvent && document.all && !window.opera) ? true : false;
	this.ie7 = (this.ie && window.XMLHttpRequest);
	
	if( this.okId != null) {
		if( !(this.ie) || getInternetExplorerVersion() >= 8.0) { 
			this.selected = this.sharpie(location.href);
			
			this.subtitles = document.getElementById(this.okId).getElementsByTagName('h3');
			
			if( this.selected != "") {
				this.showOnly(this.selected);
			} else {
				this.showOnly(this.subtitles[0].id);
			}
			
			this.modTheMenu();
		}
	}
}
	LeetMenu.prototype.verifyIfImNeeded = function () {
		if(this.suitableIds != null) {
			for (var i = 0; i < this.suitableIds.length; i++ ) {
				if( document.getElementById( this.suitableIds[i]) != null) {
					return this.suitableIds[i];
				}
			}
			return null;
		} else {
			return document.getElementByClass('content').id;
		}
	}
	LeetMenu.prototype.showOnly = function (headerId) {
		for (var i = 0; i < this.subtitles.length; i++ ) {
			this.hide(this.subtitles[i].id);
		}
		this.unhide(headerId);
	}
	LeetMenu.prototype.hide = function (headerId) {
		document.getElementById(headerId).style.display = 'none';
		document.getElementById(headerId + '-div').style.display = 'none';
	}
	LeetMenu.prototype.unhide = function (headerId) {
		document.getElementById(headerId).style.display = 'block';
		document.getElementById(headerId + '-div').style.display = 'block';
	}
	LeetMenu.prototype.sharpie = function (uri) {
		var returnValue = "";
		var isSharpie = false;
		for (var i = 0; i < uri.length; i++ ) {
			if( isSharpie) { returnValue += uri[i]; }
			if( uri[i] == '#') { isSharpie = true; }
		}
		
		return returnValue;
	}
	LeetMenu.prototype.preSharpie = function (uri) {
		var returnValue = "";
		var isSharpie = false;
		for (var i = 0; i < uri.length; i++ ) {
			if( uri[i] == '#') { isSharpie = true; }
			if( !isSharpie) { returnValue += uri[i]; }
		}
		
		return returnValue;
	}
	LeetMenu.prototype.modTheMenu = function () {
		var links = document.getElementById('leetmenu').getElementsByTagName('a');
		
		for (var i = 0; i < links.length; i++ ) {
			links[i].setAttribute('onClick','myLeetMenu.showOnly("'+ this.sharpie(links[i].getAttribute('href')) +'")');
		}
		/*
		var links2 = document.getElementById('where-div').getElementsByTagName('a');
		
		for (var i = 0; i < links2.length; i++ ) {
			if( 
			links2[i].setAttribute('onClick','myLeetMenu.showOnly("'+ this.sharpie(links2[i].getAttribute('href')) +'")');
		}
		*/
	}



if (window.addEventListener) {
	window.addEventListener("load",initLeetMenu,false);
} else if (window.attachEvent) {
	window.attachEvent("onload",initLeetMenu);
} else {
	window.onload = function() {initLeetMenu();}
}

function initLeetMenu() { myLeetMenu = new LeetMenu(); }
//document.getElementById('conference__location').getElementById.('leetmenu').style.color='red';