/* Functions are actioned in the order that they are registered */


$(document).ready(function() {
						   
						   
	/* Add row striping to tables */
	$('tbody.events tr:nth-child(odd)').addClass('odd_rows_events'); /* Events */
	$('tbody.events_archive tr:nth-child(odd)').addClass('odd_rows_events_archive'); /* Events archives */
	
	
		
	/* ---------------------- Toggle - show/hide paragraph ------------------- */
		
	// The NPC thanks Andy Langton for his show/hide/mini-accordion - updated 23/11/2009
	// Latest version @ http://andylangton.co.uk/jquery-show-hide
	
	// Create vars to display text or image that user clicks to activate show/hide effect
	var showText='View more / Close';
	var hideText='View more / Close';
	
	// visibility status var
	var is_visible = false;
	
	// append show/hide links to the element directly preceding the element with a class of "toggle"
	$('.toggle').prev().append(' (<a href="#" class="toggleLink">'+showText+'</a>)');
	
	// hide all of the elements with a class of 'toggle'
	$('.toggle').hide();
	
	// capture clicks on the toggle links
	$('a.toggleLink').click(function() {
		
		// switch visibility
		is_visible = !is_visible;
		
		// change the link depending on whether the element is shown or hidden
		$(this).html( (!is_visible) ? showText : hideText);
		
		// toggle the display - uncomment the next line for a basic "accordion" style
		//$('.toggle').hide();$('a.toggleLink').html(showText);
		$(this).parent().next('.toggle').toggle('slow');
		
		// return false so any link destination is not followed
		return false;
	
	});
	
/*
// Change to a slide effect
// change the link text depending on whether the element is shown or hidden
if ($(this).text()==showText) {
$(this).text(hideText);
$(this).parent().next('.toggle').slideDown('slow');
}
else {
$(this).text(showText);
$(this).parent().next('.toggle').slideUp('slow');
}

*/
	
	/* ---------------------- End of Toggle ------------------- */





	
	
/* ---------------------------------------------------------------------------------------------------------------------- */	
	
	/* Add icons */
	
	/* Add PDF icons to relevant links - adds a class from the CSS */
	$('a[href$=.pdf]').addClass('pdf_link');
	
	/* Powerpoint */
	$('a[href$=.ppt]').addClass('pp_link');
	
	/* Word */
	$('a[href$=.doc]').addClass('doc_link');
	
	/* Flash swf */
	$('a[href$=.swf]').addClass('flash_link');
	
	/* Flash flv */
	$('a[href$=.flv]').addClass('flash_link');
	
	/* Add External icons to relevant links */
	$('a').filter(function() {
		return this.hostname && this.hostname != location.hostname;
	}).addClass('external_link');
	
	
/* ---------------------------------------------------------------------------------------------------------------------- */	
	 /* Original search code
	 
	 Show / hide the Search box text value when user clicks into / out of search box 
	 document.getElementById("searchfield").onfocus = function(){  
         if(this.value == "Search NPC") this.value = "";  
     };  
     document.getElementById("searchfield").onblur = function(){  
         if(this.value == "") this.value = "Search NPC";  
     };
	 
	 
	 /* Swap image - Search RO effect - change btn from blue to green 
	$('#searchbtn').hover(function() {
		$(this).attr("src","http://www.npci.org.uk/development/6month/html/images/global/search_btn_ro.png");
			}, function() {
		$(this).attr("src","http://www.npci.org.uk/development/6month/html/images/global/search_btn.png");
	});
	*/




	/* Amended jQuery to work with Googlised search parameters */
	
	 /* Show / hide the Search box text value when user clicks into / out of search box */
	 document.getElementById("q").onfocus = function(){  
         if(this.value == "Search NPC") this.value = "";  
     };  
     document.getElementById("q").onblur = function(){  
         if(this.value == "") this.value = "Search NPC";  
     };
	 
	 
	 /* Swap image - Search RO effect - change btn from blue to green */
	$('#sa').hover(function() {
		$(this).attr("src","http://www.npci.org.uk/development/6month/html/images/global/search_btn_ro.png");
			}, function() {
		$(this).attr("src","http://www.npci.org.uk/development/6month/html/images/global/search_btn.png");
	});


/* ---------------------------------------------------------------------------------------------------------------------- */	




	
}); /* Close document.ready function */








