// Email updates form

$(document).ready(function() {

	// Email updates input value
	$('#email_updates_box_form_content input').val("Your email address");
	
	$('#email_updates_box_form_content input').focus(function() {
		if ($(this).val() == "Your email address") {
			$(this).val("");
		}
	});
	
	// Email updates box show
	$('#email_updates_box a').click(function() {
  		$('#email_updates_box_form').show('300');
	  	return false;
	});

	// Email updates box hide
	$('#closeEmailBoxPopup').click(function(){
    	$('#email_updates_box_form').hide('300');
	});

	// Email updates AJAX
	$('#subEmailSubmit').click(function(){
	   	var data = $('#email_updates_box_form_content').serialize();	
	            			
	    $.ajax({
	        url: "/site_scripts/Subscriber.Add.php",
	        type: "GET",	
	        data: data,
	        cache: false,
	        success: function (html) {
	            if (html==1) {					
	              $('#email_updates_box_form').fadeOut('');
	                                    
	              $('#email_updates_submitted').fadeIn('slow').delay(1000).fadeOut(1500);
	                
	        	} else alert('Sorry, unexpected error. Please try again later.');				
	        }		
	    });
	    return false;
	});

	// Bolding labels on Training Search by Region
	$('#trainingListRegList ul li input').click(function() {
		$parent = $(this).parent();
		$label = $parent.children('label');

		if ($label.hasClass('ticked')) {
			$label.removeClass('ticked');
		} else {
			$label.addClass('ticked');
		}
		
		if ($(this).is(':checked')) { 
			$('#trainingListRegButton').show();
		} else {
			if ($("#trainingListRegList input:checked").length == 0) {
				$('#trainingListRegButton').hide();
			}
		}
	});
	
	// Print this page link
	$("#backToTop").after(" <a id=\"printPage\" href=\"#\" onclick=\"window.print();\">Print this page</a>");
	
	// FAQ Accordion effect
	$("#faqEntries").tabs("#faqEntries dd", {tabs: 'dt', effect: 'slide', initialIndex: null});

});
