$(document).ready(function() {
	
	(function() { // create and run an anonymous function
		$("#site-portal").css("cursor", "pointer");
		var str = window.location + "";
		if (str.indexOf("localhost") != -1) {
			$("#site-portal").click(function() {
				window.location = "http://localhost/Yorkshirenaturalhealing/blog/";
				return false;
			});
		} else if (str.indexOf(".com") != -1) {
			$("#site-portal").click(function() {
				window.location = "http://yorkshirenaturalhealing.com/blog/";
				return false;
			});
		}
		
		/*$("#course-date").css("background-color", "#d6c2ed");*/
		// $("#course-date").attr('disabled', true);
		$('a[href$="#booking"]').click(function() {
			var data = $(this).parent().parent().text(); // get booking data
			data = data.replace('Book your place now',''); // remove bits not needed
			$("#course-date").val(data); // put data in field to be submitted
			location.href = "#booking"; // scroll down
			$("#your-name").focus(); // focus on next field to fill in
			return false;
		});
		
		$("form").submit(function(){
			// $("#course-date").removeAttr('disabled'); // otherwise error with wordpress plugin reading the field
		})
		
		$(".toggle_container").hide(); 
		$("h3.trigger").css("cursor", "pointer");
		//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
		$("h3.trigger").click(function(){
			$(this).toggleClass("active").next().slideToggle("slow");
		});

	})();

});
