$(document).ready(function(){
	
	$('a[href*=#]').click(function() {
	if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
		//alert(this.hash);
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset - 100}, 500);
				return false;
			}
		}
	});
	
	//Secondary nav submenu
	if($('#nav_secondary ul ul').length > 0){	
		//Add hover event to parent list item
		var parentLi = $('#nav_secondary ul ul').parent();
		parentLi.hover(
			function(){
				//Show drop list
				$(this)
					.addClass('openmenu')
					.children('ul').show();
			},
			function(){
				//Hide drop list
				$(this)
					.removeClass('openmenu')
					.children('ul').hide();
			}
		);
	}
	
	//Share this button over-state
	if($('#sharthisbtn').length > 0){	
		$('#sharthisbtn').hover(
			function(){	$(this).fadeTo(200, .8); },
			function(){ $(this).fadeTo(200, 1); }
		);
	}	
	
	/*
	Rotating CS Photos
	*/
	var currCs = 2;
	
	
	function rotateCS() {
		/*
		//alert("custserv" + currCs);
		$("#custservicon em img").animate({"opacity": "hide"});
		//$("#custservicon img").removeClass("hideCS");
		$("#custservicon em img#custserv" + currCs).animate({"opacity": "show"});
		currCs++;
		if(currCs == 5) {
			currCs = 1;
		}
		*/
		//setTimeout(rotateCS, 5000);
	}
	/*
	$("#custservicon em img").addClass("hideCS");
	//$("#custservicon img#custserv1").removeClass("hideCS");
	$("#custservicon em img#custserv1").animate({"opacity": "show"});
	setTimeout(rotateCS, 5000);
	*/
	
});
