// JavaScript Document
$(function() {
$('.default-value').each(function() {
    var default_value = this.value;
    $(this).css('color', '#7a7a7a'); // this could be in the style sheet instead
    $(this).focus(function() {
        if(this.value == default_value) {
            this.value = '';
            $(this).css('color', '#7a7a7a');
        }
    });
    $(this).blur(function() {
        if(this.value == '') {
            $(this).css('color', '#7a7a7a');
            this.value = default_value;
        }
    });
});
});


  function processForm()
  {
    $p('button').disabled = true;
    $p('button').value = "...wait";

    $p('enquiry_form').request({
      onSuccess: function(transport)
      {
        if(transport.responseText.match(/^OK/) != null) {
          alert('Your enquiry has been sent!');
          $p('enquiry_form').reset();
        } else {
          alert(transport.responseText);
        }

        $p('button').value = 'Send';
        $p('button').disabled = false;
      }
    });

    return false;
  }
  
  function processContactForm()
  {
    $p('button2').disabled = true;
    $p('button2').value = "...wait";

    $p('contact_form').request({
      onSuccess: function(transport)
      {
        if(transport.responseText.match(/^OK/) != null) {
          alert('Your enquiry has been sent!');
          $p('contact_form').reset();
        } else {
          alert(transport.responseText);
        }

        $p('button2').value = 'Submit';
        $p('button2').disabled = false;
      }
    });

    return false;
  }
  
$(function() {

	$("ul.subnav").parent().append(""); //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").fadeOut('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"
	});

});
