/*CUFON
=====================================*/
//Cufon.replace('', {hover: true});
Cufon.replace('h1, h2, h3', { fontFamily: 'Myriad Pro' });

/*DIVER
=====================================*/
$(function(){
	$("ul#submenu li:first").addClass("first");
	$("ul#submenu li:last").addClass("last");

	$("table tr:even").addClass("even");
	$("table tr:odd").addClass("odd");

	$("ul#submenu").each( function() {
		if ($(this).children().length == 0) {
			$(this).remove();
		}
	});

});

/*DEFAULT TEXT
=====================================*/
$(function(){
	$(".defaultText").focus(function(){
		if ($(this).val() == $(this).attr("default"))
		{
			$(this).removeClass("defaultTextActive");
			$(this).val("");
		}
	});
	
	$(".defaultText").blur(function(){
		if ($(this).val() == "")
		{
			$(this).addClass("defaultTextActive");
			$(this).val($(this).attr("default"));
		}
	});
});

/* MENU
=====================================*/
$(function(){
	$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
	$("ul.topnav li a") .mouseover(function() { //When trigger is clicked...
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click
		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.subnav").slideUp('medium'); //When the mouse hovers out of the subnav, move it back up
		});
		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});

});

/* TOGGLE
-------------------------*/
$(function(){
	$("div.collapse").each(function() {
		if (!$(this).next().next().hasClass("collapse")) {
			$(this).css({
				"margin-bottom": "0"
			}).find("div.block").css({
				"margin-bottom": "0"
			})
		}
	});

	$(".toggle_container").hide();
	$("span.trigger").click(function(){
		if ($(this).attr("active") == "true") {
			$(this).removeAttr("active");
			$(this).removeClass("active").next(".toggle_container").slideUp("slow");
		} else {
			$("span.trigger").removeClass("active").removeAttr("active");	
			$(this).attr("active", "true");
			$(".toggle_container").slideUp();
			$(this).addClass("active").next(".toggle_container").slideToggle("slow");
		}
	});
	//$("span.trigger").eq(0).click();
});
