$(document).ready(function() {


	// Set everything up - hide and show things	

 	$("#formcollapse:not(.haserrors,.expanded)").hide();
 	$('input[type="text"]').addClass("idle");
 	$('textarea').addClass("idle");

	
	$("#searchinput").addClass("grey");
	
	/* swop project and news(events) around in pull-out panel
	$("#newslink").addClass("grey");
	$("#eventsbox").hide();*/
	$("#eventslink").addClass("grey");
	//$("#newsbox").hide();
	$("#newsbox.both").hide();
	
	$("#eventslink").click(function(){
		$("#newslink").removeClass("grey")
		$("#eventslink").addClass("grey")
		$(".currentboxcontent").hide();
		$("#eventsbox").show();
		$("#headerlinks").css({
			'background-image':'url("images/bg_homepagecenterheaderidle.jpg")',
			'background-color':'#92B41D'
		});
		$("#newslink").css({
			'background-image':'url("images/bg_homepagecenterheaderidle.jpg")',
			'background-color':'#C1CE67'
		});
		$("#eventslink").css({
			'background-image':'url("images/bg_homepagecenterheaderactive.jpg")',
			'background-color':'#92B41D'
		});
		return false;
	});

	$("#newslink").click(function(){
		$("#eventslink").removeClass("grey")
		$("#newslink").addClass("grey")
		$(".currentboxcontent").hide();
		$("#newsbox").show();
		$("#headerlinks").css({
			'background-image':'url("images/bg_homepagecenterheaderactive.jpg")',
			'background-color':'#C1CE67'
		});
		$("#newslink").css({
			'background-image':'url("images/bg_homepagecenterheaderactive.jpg")',
			'background-color':'#C1CE67'
		});
		$("#eventslink").css({
			'background-image':'url("images/bg_homepagecenterheaderidle.jpg")',
			'background-color':'#92B41D'
		});
		return false;
	});
	$("#searchinput").focus(function(){
		$("#searchinput").removeClass("grey");
		$("#searchinput").addClass("white");
		return false;
	});
	$("#searchinput").blur(function(){
		$("#searchinput").removeClass("white");
		$("#searchinput").addClass("grey");
		return false;
	});
	
	
	// Toggling the comment form on news posts
	
	$('#postacomment').click(function(){
		$('#formcollapse').slideToggle();
		return false;
	});
	
	
	
	// Highlighting fields on forms when they have focus
	
	$('input[type="text"]:not(.search-input)').focus(function(){
		$(this).animate({
			borderTopColor:"#666",
			borderRightColor:"#666",
			borderBottomColor:"#666",
			borderLeftColor:"#666"},'fast');
     });  
     $('input[type="text"]:not(.search-input)').blur(function(){
     $(this).animate({
	     	borderTopColor:"#cccccc",
			borderRightColor:"#cccccc",
			borderBottomColor:"#cccccc",
			borderLeftColor:"#cccccc"},'fast');
     });
	$('textarea').focus(function() {  
		$(this).animate({
			borderTopColor:"#666",
			borderRightColor:"#666",
			borderBottomColor:"#666",
			borderLeftColor:"#666"},'fast');
     });  
     $('textarea').blur(function() {  
		$(this).animate({
			borderTopColor:"#cccccc",
			borderRightColor:"#cccccc",
			borderBottomColor:"#cccccc",
			borderLeftColor:"#cccccc"},'fast');
     });



});
