jQuery(document).ready(function() {

	jQuery("#content .nav li span a").vAlign();// Align the current nav box text

	jQuery("div.practice h3").each( function(){
		jQuery(this).addClass('clickable');
		jQuery(this).siblings().hide();
		jQuery(this).parent().css({paddingBottom: '0',marginTop: '3px'} );
		
		jQuery(this).click( function() {

			jQuery(this).siblings().slideToggle();
			jQuery(this).toggleClass('clickable');
			jQuery(this).toggleClass('clickableDown');
			if (jQuery(this).is('.clickableDown')){
				jQuery(this).parent().css({border: '2px solid #f0f'} );
			}else{
				jQuery(this).parent().css({border: '0'} );
			
			}
		});
	
	});
	
	
	// Replace list item with icon representing document
	
	jQuery("a[href*='.doc'],a[href*='.rtf']").parent().addClass("doc");
	jQuery("a[href*='.xls']").parent().addClass("xls");
	jQuery("a[href*='.pdf']").parent().addClass("pdf");
	jQuery("a[href*='.ppt']").parent().addClass("ppt");
	jQuery("a[href*='http']").parent().addClass("http");
		jQuery("a[href*='.jpg']").parent().addClass(".jpg");


/* My Calendar plug-in effect. Moved here from plug-in settings pages as it wasn't working
	*/

 jQuery(".calendar-event").children().not("h3").hide();
  jQuery(".calendar-event h3").toggle(
     function() {
     jQuery(".calendar-event").children().not("h3").hide();
	 jQuery(this).parent().children().not("h3").show("fast");
     }, 
     function() { 
     jQuery(".calendar-event").children().not("h3").hide("fast");
     }
     );
     
   jQuery(".calendar-event h3").css("cursor","pointer");
     


// Home page more intro
	jQuery("a#homeMore").show(); // show the link which is hidden for those without JavaScript
		jQuery("a#homeMore").text("Read more..."); // show the link which is hidden for those without JavaScript

	jQuery("div#homeIntro").hide();
	jQuery("a#homeMore").click( function(e) {
		e.preventDefault();
		jQuery("div#homeIntro").slideToggle();
		
		var text = jQuery(this).html();
	//	alert (text);
		
		if(text == "Read more..."){
			jQuery("a#homeMore").text('Hide text...');}else{
			jQuery("a#homeMore").text('Read more...');
		}
	
	});

});

// VERTICALLY ALIGN FUNCTION

(function ($) {
$.fn.vAlign = function() {

	return this.each(function(i){
	var ah = $(this).height();
	var ph = $(this).parent().height();

	var mh = (ph - ah - 50) / 2; // the -50 is to compensate for the default top padding of 25px. If that padding is changed, this has to be too. 
	$(this).css('padding-top', mh);
	$(this).css('padding-bottom', mh);

	});
};
})(jQuery);
