// JavaScript Document

$(document).ready(function(){
  /* register any elements that need validation 
	*	force validation on field change*/
	
	$("div.newsitem a").click(function(e) {
		container = $(this).parent();
		$.post("/resources/helpers/news/get.php",
			{ unique_id: this.id , scope: 'full' },
			function(data){
				container.fadeOut("fast",function(){container.html(data);container.fadeIn("fast")});
			}
		);
		e.preventDefault();
	});

	$("#search").submit(function(e) {
		$.post("/resources/helpers/search.php",
			{ search_string: $(this).parent().find("#search_string").val() },
			function(data){
					$("#main").html(data);
			}
		);
		e.preventDefault();
	});

	$("#search_button").click(function(e) {
		$.post("/resources/helpers/search.php",
			{ search_string: $(this).parent().find("#search_string").val() },
			function(data){
					$("#main").html(data);
			}
		);
		e.preventDefault();
	});

	$("#find_osteopath").click(function(e) {
		$.post("/resources/helpers/user/get.php",
			{ postcode: $('#user').find("#postcode").val(),radius: $('#user').find("#radius").val(),name: $('#user').find("#name").val(), country: $('#user').find("#country").val() },
			function(data){
				$("#searchresult").fadeOut("fast",function(){$("#searchresult").html(data);$("#searchresult").fadeIn("fast")});
				//$("#searchresult").html(data);
			}
		);/*
		alert("state: "+$(this).parent().find("#state").val());*/
		e.preventDefault();
	});

	$("#promo_left .accordian_p li a").click(function(e) {
		$("#promo_left .accordian_p li p").each(function(e){
			if ($(this).parent().find("p").css("display") != 'none')
				$(this).parent().find("p").hide('slow');
		});
		if ($(this).parent().find("p").css("display") != 'none'){
			$(this).parent().find("p").hide('slow');
		}else{
			$(this).parent().find("p").show('slow');
		}
		e.preventDefault();

	});

	$("#main .accordian_p li a").click(function(e) {
		if ($(this).parent().find("div").css("display") != 'none'){
			$(this).parent().find("div").hide('slow');
		}else{
			$(this).parent().find("div").show('slow');
		}
		e.preventDefault();
	});

	/*$("#navigation > li").hover(function(e) {
			$(this).find(".bgon").fadeIn("fast");
		},function(e) {
			$(this).find(".bgon").fadeOut("slow");
		});
	*/
});