$(document).ready(function() {
	$('div#speaker1').show();
	$('#brownbag1').each(function() {
		this.srcOut = this.src;
		this.srcOver = this.src.substring(0, this.src.lastIndexOf('.png')) + '_over' + '.png';
	})

	$("#programmeLink").click(function () {
		$('div#programme').show();
		$('#closeProgram').show();
		$('#programmeLink').hide(); 
	})
	$("#closeProgrammeLink").click(function () {
		$('div#programme').hide();
		$('#closeProgram').hide();
		$('#programmeLink').show(); 
	})
});

/* makes links with attribute rel="external" open in a new window */
function externalLinks() { 
	if (!document.getElementsByTagName) return; 
	var anchors = document.getElementsByTagName("a"); 
	for (var i = 0; i < anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			anchor.target = "_blank"; 
		}
	}
}

if (window.addEventListener) {
	window.addEventListener('load', externalLinks, false); 
} else if (window.attachEvent) { 
	window.attachEvent('onload', externalLinks);
}

String.prototype.trim = function () {
    return this.replace(/^\s*/,'')
                     .replace(/\s*$/,'');
};

$(document).ready(function() {
		var curLocation = document.location.toString().split("/");

		var realLocation = curLocation[3];
 		if (realLocation == "events")
		{
			$('#subMenu').show();
		}
		if (realLocation == "") {
				var style = 'homeactive'; 
				var selector = 'home'
		} 
		else 
		{
				var style = realLocation+'active'; 
				var selector = realLocation;
		}	
		$('a#' + selector).addClass(style);
	
		if (curLocation[4] != undefined)
		{
			 var style = curLocation[4]+'active'; 
			 var selector = curLocation[4];
			$('a#' + selector).addClass(style);
		}
});

$(document).ready(function() {
	$("#Map1").mouseover(function () {
		if ($('div#popupSeminar').is(":hidden")) {
			$('div#popupSeminar').show();
		} 
	})
	$("#Map1").bind('mouseout', function () {
		$('div#popupSeminar').hide();
	});
	
	$("#Map4").bind('mouseout', function () {
		$('div#popupBook').hide();
	});
	$("#speakerLink1").click(function () {
		$('div.speakers').hide(); 
		$('div#speaker1').show();
	})
	$("#speakerLink2").click(function () {
		$('div.speakers').hide(); 
		$('div#speaker2').show(); 
	})
	$("#speakerLink3").click(function () {
		$('div.speakers').hide(); 
		$('div#speaker3').show(); 
	})
	$("#speakerLink4").click(function () {
		$('div.speakers').hide(); 
		$('div#speaker4').show(); 
	})
	$("#speakerLink5").click(function () {
		$('div.speakers').hide(); 
		$('div#speaker5').show(); 
	})
	$("#speakerLink6").click(function () {
		$('div.speakers').hide(); 
		$('div#speaker6').show(); 
	})
	$("#speakerLink7").click(function () {
		$('div.speakers').hide(); 
		$('div#speaker7').show(); 
	})
});
