if(typeof(DM) == "undefined") { DM={}; }

DM.reveals = {

	isover: false,
	current: '',
	delay: 200,
	to: null,
	showmore: false,

	over: function(c) {
		clearTimeout(this.to);
		this.hideall();
		this.current = c;
		this.isover = true;
		$("div#highlights h2#"+c).addClass("current");
		$("div#highlights div#detail-"+c).addClass("reveal-show");
	},

	out: function(c) {
		this.isover = false;
		this.to = setTimeout('DM.reveals.toCallback()',this.delay);
	},

	toCallback: function(c) {
		if(!this.isover) this.hideall();
	},

	hideall: function() {
		clearTimeout(this.to);
		$("div#highlights div.reveal").removeClass("reveal-show");
		$("#detailedInfo").addClass("hidden");
		$("div#highlights h2.hHeading").removeClass("current");
	},

	moreinfo: function() {
		this.hideall();
		this.showmore = !this.showmore;
		if(this.showmore) {
			$("#detailedInfo").removeClass("hidden");
		}

	}
}

$(function(){

	// top menus
	$("ul.sf-menu").superfish({delay: 200});

	// external Links
	$("a[rel='external']").click(function(){
		window.open($(this).attr("href"));
		return false;
	})

	// create highlights events
	$("div#highlights h2.hHeading").hover(

		function(){$(this).addClass("hover"); DM.reveals.over($(this).attr("id"))},
		function(){$(this).removeClass("hover"); DM.reveals.out()}
	);
	$("div#highlights div.reveal").hover(
		function(){ DM.reveals.over($(this).attr("id").substring(7))},
		function(){ DM.reveals.out() }
	)

	// more info
	$("#more").click(function(){ DM.reveals.moreinfo() })

	// image fading
	$('#highlightImages').cycle({ fx: 'fade', speed:  2500,timeout: 8000, random: 1 });

	// search box
	$("#s").focus(function(){ if($(this).val() == "Search") $(this).val("") })
	$("#s").blur(function(){ if($(this).val() == "") $(this).val("Search") })

})