$(document).ready(function(){



        $('div.topLevel').hide().fadeIn(1000);


	$("ul.tabs").css('display','block');
	$(".content1").css('display','none');
	$(".content2").css('display','none');
	$(".content3").css('display','none');

	$("ul.tabs li#showContent1").click( function(){
		$(".content1").fadeIn();
		$(".content2").fadeOut('fast');
		$(".content3").fadeOut('fast');
		$("div.entry").fadeOut('fast');
		$(this).addClass('current-active');
		$("ul.tabs li#showContent2").removeClass('current-active');
		$("ul.tabs li#showContent3").removeClass('current-active');
	return false;
	});

	$("ul.tabs li#showContent2").click( function(){
		$(".content2").fadeIn();
		$("div.entry").fadeOut('fast');
		$(".content1").fadeOut('fast');
		$(".content3").fadeOut('fast');
		$(this).addClass('current-active');
		$("ul.tabs li#showContent1").removeClass('current-active');
		$("ul.tabs li#showContent3").removeClass('current-active');
	return false;
	});

	$("ul.tabs li#showContent3").click( function(){
		$(".content3").fadeIn();
		$("div.entry").fadeOut('fast');
		$(".content1").fadeOut('fast');
		$(".content2").fadeOut('fast');
		$(this).addClass('current-active');
		$("ul.tabs li#showContent1").removeClass('current-active');
		$("ul.tabs li#showContent2").removeClass('current-active');
	return false;
	});

	// readmore function 
	
	var $div = $('div.more');
    var height = $div.height();
    $div.hide().css({ height : 0 });

    $('.readmore').click(function () {
        if ($div.is(':visible')) {
            $div.animate({ height: 0 }, { duration: 900, complete: function () {
                $div.hide();
            } });
        } else {
            $div.show().animate({ height : height }, { duration: 900 });
            $(".readmore").hide();
        }
        
        return false;
    });
    
    $('.readless').click(function () {
        if ($div.is(':visible')) {
            $div.animate({ height: 0 }, { duration: 900, complete: function () {
                $div.hide();
                $(".readmore").show();
            } });
        } else {
            $div.show().animate({ height : height }, { duration: 900 });
            
        }
        
        return false;
    });
    
    
    
    
    ///////second read more
    
	var $second_div = $('div.more2');
    var $second_height = $second_div.height();
    $second_div.hide().css({ height : 0 });

    $('.readmore2').click(function () {
        if ($second_div.is(':visible')) {
            $second_div.animate({ height: 0 }, { duration: 900, complete: function () {
                $second_div.hide();
            } });
        } else {
            $second_div.show().animate({ height : height }, { duration: 900 });
            $(".readmore2").hide();
        }
        
        return false;
    });
    
    $('.readless2').click(function () {
        if ($second_div.is(':visible')) {
            $second_div.animate({ height: 0 }, { duration: 900, complete: function () {
                $second_div.hide();
                $(".readmore2").show();
            } });
        } else {
            $second_div.show().animate({ height : height }, { duration: 900 });
            
        }
        
        return false;
    });
    
    ///////third read more
    
    var $third_div = $('div.more3');
    var $third_height = $third_div.height();
    $third_div.hide().css({ height : 0 });

    $('.readmore3').click(function () {
        if ($third_div.is(':visible')) {
            $third_div.animate({ height: 0 }, { duration: 900, complete: function () {
                $third_div.hide();
            } });
        } else {
            $third_div.show().animate({ height : height }, { duration: 900 });
            $(".readmore3").hide();
        }
        
        return false;
    });
    
    $('.readless3').click(function () {
        if ($third_div.is(':visible')) {
            $third_div.animate({ height: 0 }, { duration: 900, complete: function () {
                $third_div.hide();
                $(".readmore3").show();
            } });
        } else {
            $third_div.show().animate({ height : height }, { duration: 900 });
            
        }
        
        return false;
    });
    


$("#contactForm").hide();

$(".open_slide").click(function(){
	
   if ($("#contactForm").is(":hidden")){
    $("#contactForm").slideDown("slow");
    
    }
   else{
   $("#contactForm").slideUp("slow");
    }
    return false;
    });

	    
// Cache Header Images
var cache=[];
$.preloadBG=function(){
	var args_len=arguments.length;
	for(var i=args_len;i--;){
	var cacheImage=document.createElement('img');
	cacheImage.src=arguments[i];cache.push(cacheImage);
	}
}


//Search Vars (Temp)) 
var searchBoxes = $(".text");  
var searchBox = $("#searchbox");  
var searchBoxDefault = "Search this site";

//Searchbox show/hide default text if needed
searchBox.focus(function(){
if($(this).attr("value") == searchBoxDefault) $(this).attr("value", "");
});
searchBox.blur(function(){
if($(this).attr("value") == "") $(this).attr("value", searchBoxDefault);
});


//Logout Staff Page
$('.logout_staff_page').bind('click', function(e) {
    document.cookie = 'wp-postpass_800db9e6a12fad4290fa571feaadca38 = dead; expires=Fri, 01 Jan 2010 00:00:00 UTC; path=/'
    window.location = "http://www.friends.org.uk/home/staff/"
	return false;
});





});


