$(document).ready(function(){
	//ie menu hover fix
	checkHeight();
	if (window.attachEvent) {$("#nav li").hover(
		function(){$(this).addClass("iehover");},
		function(){$(this).removeClass("iehover");}
	);};
	//email functions
	$("span.sendmail").each(function(i) {
		//	username+domain+com+[display}
		var a = $(this).text().split("+");
		a[3] = a[3] || a[0]+"@"+a[1]+"."+a[2];
		$(this).text("").html('<a href="mailto:'+a[0]+'@'+a[1]+'.'+a[2]+'">'+a[3]+'</a>');
	});
	//show hide div
	$("div[id^='shd']").each(function(i) {$(this).hide();});
	$("a[id^='shd']").click(function(){
		var id = $(this).attr("id");
		id = id + "d";
		$("div[id^='shd']").not("#"+id).slideUp("slow");
		$("#"+id).slideDown("slow");
		return false;
	});
	//attorney SHD
	$("div[id^='att']").each(function(i) {$(this).hide();});
	$("a[id^='att']").click(function(){
		var id = $(this).attr("id");
		$("a[id^='att'] img").not("#"+id+" img").animate({"opacity":".5"});
		$("#"+id+" img").animate({"opacity":"1.0"});
		id = id + "d";
		$("div[id^='att']").not("#"+id).slideUp("slow");
		$("#"+id).slideDown("slow");
		return false;
	});	
	//toggle div
	$("div[id^='tog']").each(function(i) {$(this).hide();});
	$("a[id^='tog']").click(function(){
		var id = $(this).attr("id");
		id = id + "d";
		$("#"+id).slideToggle("slow");
		return false;
	});
	//flash movies
	$("div.flashmov").each(function(i){
		// url+w+h
		var a = $(this).text().split("+"); 
		var str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+a[1]+'" height="'+a[2]+'"><param name="movie" value="'+a[0]+'"> <param name="quality" value="high"><param name="wmode" value="transparent"><embed src="'+a[0]+'" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+a[1]+'" height="'+a[2]+'"></embed></object>';
		$(this).html(str);
	});
	// no label forms, with minimal no label validation
	$("form.nolabel label").each(function(i){
		if ($(this).attr("type") !== "radio" && $(this).attr("type") !== "checkbox") {
			if ($("#"+$(this).attr("for")).val() !== null) {$(this).css({'top':'-1000px','left':'-1000px'});}
			var that = $(this).hide().css("cursor","text");
			var pos = $("#"+$(this).attr("for")).offset();
			pos.left += 5;
			$(this).css({'position':'absolute','z-index':'30','top':pos.top+'px','left':pos.left+'px','color':'#000000;'}).show();
			$("#"+$(this).attr("for")).focus(function(){
				$(that).css({'top':'-1000px','left':'-1000px'});
			}).blur(function(){
				if ($(this).val() === "") {$(that).css({'top':pos.top+'px','left':pos.left+'px'});}
			});
		}
	});
	//clear & replace text
	$("input.crt").each(function(){
		if ($(this).val()==="") {$(this).val($(this).attr("title"));}
	}).focus(function(){
		if ($(this).attr("title")===$(this).val()) {$(this).val("");}
		else {$(this).val($(this).attr("title"));}
	}).blur(function(){
		if ($(this).val()==="") {$(this).val($(this).attr("title"));}
	});
	$("a[href='#top']").click(function() {
		$('html, body').animate({scrollTop:0},'slow');
		return false;
	});
});

var AdminDelete = function(id,title,folder) {
	var msg = "Are you sure you wish do delete the item named '"+title+"'? This action cannot be undone.";
	if (confirm(msg)) {window.location = "/admin/"+folder+"/Delete.asp?ID="+id;}
};
var checkHeight = function() {
	var h = ($("#indexback").height() > $("#rightnavback").height()) ? $("#indexback").height() : $("#rightnavback").height();
	if (h) {$("#rightnavback").css("height",h+"px");}
};
