/*
Site-wide JS
*/

$(function(){
	//HTML view slideshow
	$(function() {    
		 	 $('#slideshow').cycle({
			 	prev:   '#prev',
		        next:   '#next',
				fx:     'scrollHorz', 
			    timeout: 5000, 
			    before:  onBefore, 
			    after:   onAfter 
	});
	
	function onBefore() {
		$('#output').html("");
		document.getElementById("output").style.border ="none";
	} 
		
		function onAfter() { 
   			$('#output').html( this.alt );
			if(this.alt) {
				document.getElementById("output").style.borderTop="1px solid #7f0000"; 
			} else {
				document.getElementById("output").style.border ="none";
			}
       	}
	});
	
	
	//Show the description from the alt attribute of the slides
	function onAfter(){
		if(this.alt){
			$('#desc').html("<hr/>").append('<p>' + this.alt + '</p>');			
		} else {
			$('#desc').html("");
		}
	}
	
	function pauseShow(){
			$('#slideshow').cycle('pause');
	}
		
	function startShow(){
		$('#slideshow').cycle('resume');
	}
	
	//Pretty up the contact section_nav
	//Tack on a /html to the home link so when viewing in HTML mode the home link is forced to html
	$('#menu_home_link a').each(function () {
	        $(this).attr('href', $(this).attr('href') + '/html');
	});
});