// JavaScript Document

$(document).ready(function(){

    $(".topnav a").each(function() {
        if(this.href == window.location || this.href == document.location.protocol + "//" + window.location.hostname + window.location.pathname){
                $(this).parent().addClass("active");
        }
    });
       
    $(".subnav a").each(function() {
        if(this.href == window.location || this.href == document.location.protocol + "//" + window.location.hostname + window.location.pathname){
            $(this).parent().parent().parent().addClass("active");
        }
    });
    
	$(" ul.topnav li a").mouseover(function() { //When trigger is clicked... // "ul.topnav li span"

	$(this).addClass("rollColour"); 
	$(this).parent().addClass("addRollNav"); 

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click
		
		

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up

		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"

		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
			$(this).parent().removeClass("addRollNav"); 
			$(this).removeClass("rollColour"); 



	});
	
		$(" ul.subnav").mouseover(function() {
				$(this).parent().addClass("addRollNav"); 
				$(this).addClass("rollColour"); 



	});
	
	$(" ul.subnav").mouseout(function() {
				$(this).parent().removeClass("addRollNav");
				$(this).removeClass("rollColour"); 
 


	});
	
	
	var $search = $('#search');//Cache the element for faster DOM searching since we are using it more than once
	original_val = $search.val(); //Get the original value to test against. We use .val() to grab value="Search"
	$search.focus(function(){ //When the user tabs/clicks the search box.
		if($(this).val()===original_val){ //If the value is still the default, in this case, "Search"
			$(this).val('');//If it is, set it to blank
		}
	})
	.blur(function(){//When the user tabs/clicks out of the input
		if($(this).val()===''){//If the value is blank (such as the user clicking in it and clicking out)...
			$(this).val(original_val); //... set back to the original value
		}
	});

	
    $('#slider').nivoSlider({
		
		  effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
		   captionOpacity:0.7, // Universal caption opacity
		   animSpeed:500, // Slide transition speed
        	pauseTime:4000, // How long each slide will show
			directionNavHide:false, // show nav arrow at all time
		
		});
		
		
	 $('.Sslideshow').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
	
});








