$(document).ready(function(){

  // Some Rounded Corners Fun
  $("#content_sec").corner("25px bl");
  $(".twitterStatus").corner("15px");

  // Search Box
  $("#search").click(function () { 
	if ($(this).val() == "Search"){$(this).val("");}

  }); 

  // Main Menu
  //$("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 span").click(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('fast'); //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"
  });
	
  // Header Toggle
  function hideAll() {
      $("#branding_3").hide();
      $("#branding_2").hide();
      $("#branding_1").hide();
	   	   
      return false;
  }

  $("#menu_button_1").hover(function (){hideAll()});
  
  $("#menu_button_2").hover(function () {
      $("#branding_1").show();
	   	   
      return false;
  },function() {hideAll()});

  $("#menu_button_3").hover(function () {
      $("#branding_2").show();
      $("#branding_1").show();
	   	   
      return false;
  },function() {hideAll()});


  $("#menu_button_4").hover(function () {
      $("#branding_3").show();
      $("#branding_2").show();
      $("#branding_1").show();
	   	   
      return false;
  },function() {hideAll()});

  // Contact Form
  $("#contactLink").click(function(){
  	if ($("#contactForm").is(":hidden")){$("#contactForm").slideDown("slow");}
    else{$("#contactForm").slideUp("slow");}
  }).hover(function(){$(this).addClass('contactLinkHover');}, function(){$(this).removeClass('contactLinkHover');});

  $("#contact_form").submit(function() {  
	var str = $("#contact_form").serialize();
      $.ajax({  
          type: "POST",  
      url: "blog",  
          data: str,  
          success: function(data){  

			messageHTML = $("#messageContent",data).html();
			messageTEXT = jQuery.trim($("#messageContent",data).text());
			
			$("#messageSent").html(messageHTML).show("slow");
			if(messageTEXT == "Your email message has been sent."){setTimeout('$("#messageSent").hide();$("#contactForm").slideUp("slow")', 2000);}
          }  
      });  
  return false;  
  });  

});
