// 	jquery function calls
$(document).ready(function() {

// validate required form fields -- moved to below

	$('.signup #subscription, .signup #subscription2').validate({
	  rules: {
		"subscriber.email1": {
		  required: true,
		  email: true
		}
	  },
	  messages: {
		"subscriber.email1": "Please enter a valid email address"
	  },
	  submitHandler: function(form) {
			var url2 = 'http://www.healthinharmony.org/confirmation/';
			/* Send the data using post and put the results in a div */
			$.post( 
				url2, 
				$("#subscription2").serialize(),
				function( html) {
				  var content = $( html ).find('span.neonBody');
			//	  $( "#subscription2" ).html('<span class="neonBody">Thank You!</span>' );
				  $( ".signup .confirm" ).html('<span class="neonBody">Thank You!</span> In addition to our inspiring, informative newsletters, you&rsquo;ll now be among the first to learn about upcoming events and other ways you can make a difference. Thanks again for your interest in saving forests by saving lives.' );				  
				  $(".confirm").show();
				}); 
		//	});
   	  }
	});

// 	swaps submit inputs with <a href=""> link for easier button styling with CSS
// 	Degrades nicely for browsers w/o javascript and retains enter key submit trigger
// 	Nested in livequery plugin to bind AJAX added content. Works on current non-AJAX too.

	$('#subscription :submit, #subscription2 :submit').each(function() { 
      		var $this = $(this);
      		var f = this.form;
      		var link = $('<a class="submitButton" href="#">' + $this.val() + '</a>')
         		.bind('click',function() {
         		//	alert('test2');
              			$(f).trigger('submit'); 
              	// 		validation();
               			return false;
            		});
      		$this.after(link).css({position:'absolute', top:'-2000px'});
    });
    

	$('.nav li ul li').mouseover(function(){
		$(this).parent().parent().find('a.menuNav').addClass('onNav');
	});
	
	$('.nav li ul li').mouseout(function(){
		$(this).parent().parent().find('a.menuNav').removeClass('onNav');
	});

	$('li.about, li.results').mouseover(function(){
		var $this = $(this);
		$this.children('ul').addClass('showIE6');
	});
	
	$('li.about ul, li.results ul').mouseout(function(){
		var $this = $(this);
		$this.removeClass('showIE6');
	});
	
	$('.nav li').mouseover(function(){
		$('a.menuNav ul').removeClass('showIE6');
		var $this = $(this);
		$this.children('ul').addClass('showIE6');
	});
	
	$('.nav li ul').mouseout(function(){
		var $this = $(this);
		$this.removeClass('showIE6');
	});
});

