// ------------------------------------------------------------------------

/**
 * Fairhaven Spam Protected Mailto Link
 *
 * Create a spam-protected mailto link written in Javascript
 *
 */
function safe_mail (part1, part2, text, aclass) {
	seperator = '@';
	complete = part1 + seperator + part2;
	if (text.substring(0,4) == 'IMG-') {
		path = '<img src="' + text.substring(4, text.length) + '" border="0" alt="Send Email" />';
		text = path;
	}
	if (text.length == 0) {
		text = complete;
	}
	document.write ('<a href="mailto:' + complete + '"');
	if (aclass.length > 0) {
		document.write(' class="' + aclass + '"');
	}
	document.write ('>' + text + '</a>');
}


// ------------------------------------------------------------------------

/**
 *
 * Fixes CSS for browsers that have Java ENABLED
 *
 */
function java_warning() {
	document.getElementById('no_js').className = 'js_enabled';
	document.getElementById('wrapper').className = 'no_top_margin';
}


// ------------------------------------------------------------------------

/**
 *
 * Controls the open/close of the navigation and related links
 *
 */

var toggled=false;
var section = '';

$(document).ready(function(){
	
	/*
	Initialize the menu as closed
	
	if (section) {
		$('#nav > li ~ ul:not(#'+section+')').css({'display' : 'none'});
	} else {
		$('#nav > ul').css({'display' : 'none'});
	}*/
	
	/*
	Controls navigation menu toggling
	
	$("#nav > li").click(function(){
		if ($(this).next().is('ul')) {
			$(this).next().slideToggle("fast");	
		}
	});*/
	
	show_text = "[+] Show Details";
	hide_text = "[-] Hide Details";
	$("a.show_hide").html(show_text);
	$("a.show_hide").show();
	$(".show_hide_content").hide();
	$("a.show_hide").click(function(){
		
		if ($(this).next().is('.show_hide_content')) {
			$(this).nextAll(".show_hide_content:first").slideToggle();
		} else {
			$(this).parent().nextAll(".show_hide_content:first").slideToggle();
		}
		
		if($(this).html() == show_text) {
			$(this).html(hide_text);
		} else {
			$(this).html(show_text);
		}
		
	});
	
	
	
	
	if (section) {
		$('#nav .submenu:not(#'+section+')').hide();
	} else {
		$(".submenu").hide();
	}
	
	$("ul#nav div p").click(function(){
	
			if($(this).is(".active")) {
			    $(this).toggleClass("active");
			    $(this).parent().next(".submenu").slideToggle();
			    return false;
			} else {
				/*
				$(".submenu:visible").slideUp("slow"); // close all visible divs with the class of .content
								$("p.active").removeClass("active");  // remove the class active from all p's with the class of .active*/
				
				$(this).toggleClass("active");
				$(this).parent().next(".submenu").slideToggle();
				return false;
			}
	
	});	
	
});