$(document).ready(function() {
	$("ul.contact").find("li.hidden").hide().end().find("li.visible").click(function() {
		var details = $(this).next();
		details.toggle();
	});
	$("#search-results").find("tr.hidden").hide().end().find("tr.visible").click(function() {
		var details = $(this).next();
		details.toggle();
	});
	$(".details tr").mouseover(function() {
		$(this).addClass("over");
	})
	.mouseout(function() {
		$(this).removeClass("over");
	});
	$(".details tr.visible:even").addClass("alt");
});

function Top() {
	var x1 = x2 = x3 = 0;
	var y1 = y2 = y3 = 0;
	if (document.documentElement){
		x1 = document.documentElement.scrollLeft || 0;
		y1 = document.documentElement.scrollTop || 0;
	}
	if (document.body){
		x2 = document.body.scrollLeft || 0;
		y2 = document.body.scrollTop || 0;
	}
	x3 = window.scrollX || 0;
	y3 = window.scrollY || 0;
	var x = Math.max(x1, Math.max(x2, x3));
	var y = Math.max(y1, Math.max(y2, y3));
	window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));
	if (x > 0 || y > 0){
		window.setTimeout("Top()", 25);
	}
}

var timeout = 0;

function extend() {
	var extendZone = document.getElementById("extend-zone");
	var extendButton = document.getElementById("extend-button");
	var height = extendZone.offsetHeight;
	clearTimeout(timeout);
	if (height <= 5) {
		extendZone.style.display = "block";
		extendZone.style.height = 0;
		animateExtend("show", 300)
		extendButton.innerHTML = "<img src='library/images/extend-close.gif' alt='' />";
	} else {
		animateExtend("hide", 0)
	}
}

function animateExtend(action, newH) {
	var extendZone = document.getElementById("extend-zone");
	var extendButton = document.getElementById("extend-button");
	var height = extendZone.offsetHeight;
	if (action == "show") {
		if (height >= newH){
			clearTimeout(timeout);
		} else {
			extendZone.style.height = height + (newH - height) / 6 + "px";
			timeout = setTimeout("animateExtend('show'," + newH + ")", 10);
		}
	} else if (action == "hide") {
		if (height <= 30) {
			extendZone.style.height = "0px";
			extendZone.style.display = "none";
			extendButton.innerHTML = "<img src='library/images/extend.gif' alt='' />";
			clearTimeout(timeout);
		} else {
			extendZone.style.height = height - 40 + "px";
			height = extendZone.offsetHeight;
			timeout = setTimeout("animateExtend('hide'," + newH + ")", 10);
		}
	}
}