$(document).ready(function() {
	defaultText();
		$("#join").focus(function() {
			var val = $(this).val();
			if(val == "Your email address") {
				 $(this).val("");
			}
		});
		$("#join").blur(function() {
			var val = $(this).val();
			if(val == "") {
				 $(this).val("Your email address");
			}
		});
		$(".clickableBox").css("cursor","pointer");
		$(".clickableBox").click(function() {
			window.location = $(".href",this).attr("href");
			return false;
		});
		$("#homeNewsPagination .pagination a").click(function() {
			$("#homeNewsPagination .pagination a").removeClass("selected");
			$("#homeNewsPagination #aTarg1").html("<img src=\"/inc/ajaxloader.gif\" />");
			$(this).addClass("selected");
			$.ajax({				
				type: "GET",
				url: "get-homenewsarchive.php",
				data: "page=" + $(this).attr("href").split("=")[1],
				success: function(msg){
					$("#homeNewsPagination #aTarg1").html(msg);		   			
				}
			});
			
			return false;
		});
		$("#eventsPagination .pagination a").click(function() {
			$("#eventsPagination .pagination a").removeClass("selected");
			$("#eventsPagination #aTarg1").html("<img src=\"/inc/ajaxloader.gif\" />");
			$(this).addClass("selected");
			$.ajax({				
				type: "GET",
				url: "get-eventsarchive.php",
				data: "page=" + $(this).attr("href").split("=")[1],
				success: function(msg){
					$("#eventsPagination #aTarg1").html(msg);		   			
				}
			});
			
			return false;
		});
		
		$("#galleryThumbs a").click(function() {
			$("#galleryThumbs a").removeClass("selected");
			$("#galleryLarge").attr("src","/gallery/loading.gif");
				var newimg = new Image();
				newimg.onload = function() {
					$("#galleryLarge").attr("src",newimg.src);
				}
				newimg.src = $(this).attr("href");
			$(this).addClass("selected")	
			return false;
		});
		
		$("#mailinglistsubmit").click(function() {
			$.ajax({
				type: "POST",
				url: "process-mailinglist.php",
				data: "join=" + $("#join").val(),
				success: function(msg){
					$("#tools").html(msg);		   			
				}
			});
			return false;
		});
		
		$("#mailinglistsubmit").hover(function(){
			$(this).attr("src","inc/go_over.gif");
		},function(){
			$(this).attr("src","inc/go_off.gif");
		});
		
		$(".treatmentsTable .description").hide()
		$(".treatmentsTable tr").hover(function(){
			$(this).addClass("hover")
		},function(){
			$(this).removeClass("hover")
		}).click(function(){
			$("a:eq(0)",this).click()
		}).css({cursor:"pointer"})
		
});

function showDescription(id) {
	$(".treatmentsTable .description").hide();
	$(".treatmentsTable tr").removeClass("selected")
	$(".treatmentsTable #t"+id+"Info").addClass("selected")
	$(".treatmentsTable #t"+id+"Description").show()
}


/* Remove default value and replace */
function defaultText() {
	$(".defaultText").unbind("focus,blur").focus(function () {		
		if ($(this).val() == $(this)[0].defaultValue) {
        	$(this).val("");
        }
	 }).blur(function() {
        if ($(this).val() == "") {
        	$(this).val($(this)[0].defaultValue);
     	}
	 });
}

function slideShow() {	
	var speed 		= 1000;
	var interval 	= 3000;
	var first = $("#slideshow li:eq(0)");
	first.hide();
	$("#slideshow").append(first);
	var slide = $("#slideshow li:last");
	newImage = new Image();
	newImage.onload = function() {		
		slide.fadeIn(speed,function(){
			if($("#slideshow li").size()>1) {
				setTimeout("slideShow()",interval);
			}			
		})
	}
	newImage.src = $("img",slide).attr("src");	
}