/** @file generic site wide javascript */

$(document).ready(function() {	

	/// append asterisks to the end of required form fields
	$(".required").append("<img src='/assets/img/forms/asterisk.gif' alt='*' title='this field is required'/>");

	/// fades in saved notification
	$("ul.saved").css("display","none");
	$("ul.saved").fadeIn(1000);


	/// show or hide blog edit based on errors
	if ( $("#testimonial-edit .error_block").length > 0 ) {
		$("#testimonial-edit").css("display", "show");
	} else {
		$("#testimonial-edit").css("display", "none");
	};

	/// toggle business edit
	$("#edit-business-details").css("display", "none");
	$("#edit-business-details-link").click(function () {
		$("#edit-business-details").toggle();
		return false;
	});

	/// toggle post help text
	$("#admin-posts").css("display", "none");
	$("#admin-posts-link").click(function () {
		$("#admin-posts").toggle();
		return false;
	});

	/// toggle post help text
	$("#blog-edit").css("display", "none");
	$("#post-blog").click(function () {
		$("#blog-edit").toggle();
		return false;
	});

	/// toggles testimonial widget
	$("#edit-testimonial").click(function () {
		$("#testimonial-invite").css("display", "none");
		$("#testimonial-edit").slideToggle();
		return false;
	});


	$(".trustmark-colour").click( function() {
		var clicked_value = $(this).attr('id');
		clicked_value = clicked_value.replace(/colour([0-9]+)/g, '$1');
		$('#join_form_trustmark_colour, #edit_settings_trustmark_colour_id').val( clicked_value );
		return false;
	});
	
});

