blogPosition 			= 0;
customerSliderPosition 	= 1;

$(document).ready(function(){
	
	// Blog Slider
	
	blogCount = $("#blog-agg .b-content").length - 1;
	
	$("#blog-forward").click(function(){
		$(".b-content").removeClass("on");
		if (blogPosition == blogCount){
			blogPosition = 0;
		} else {
			blogPosition++;
		}
		$("#b-content-"+blogPosition).addClass("on");
	});
	
	$("#blog-back").click(function(){
		$(".b-content").removeClass("on");
		if (blogPosition == 0){
			blogPosition = blogCount;
		} else {
			blogPosition--;
		}
		$("#b-content-"+blogPosition).addClass("on");
	});

	// Customer Slider
	
	customerSliderCount	= $(".customer-slider .img-wrap").length;
	
	$("#slide-control-forward").click(function(){
		$(".customer-slider .img-wrap").removeClass("on");
		if (customerSliderPosition == customerSliderCount){
			customerSliderPosition = 1;
		} else {
			customerSliderPosition++;
		}
		$("#customer-slider-"+customerSliderPosition).addClass("on");
	});
	
	$("#slide-control-back").click(function(){
		$(".customer-slider .img-wrap").removeClass("on");
		if (customerSliderPosition == 1){
			customerSliderPosition = customerSliderCount;
		} else {
			customerSliderPosition--;
		}
		$("#customer-slider-"+customerSliderPosition).addClass("on");
	});
	
	// Dropdown Menu
	
	$('ul#main-nav  li, ul#utility-nav  li').hover(function(){
		$(this).addClass('slctd');
	},function(){
		$(this).removeClass('slctd');
	});
	
	// Supporting Content Form
	
	$("#sup-show-form").click(function(){
		$("#schedule-form").slideDown(500);
		$(this).hide();
	});
	
	//Parse out all extra navigation for Focus Areas.  Unless you are in a section.
	var $subnav = $('ul#sub-nav'),
		selectedSize = $subnav.find('li.selected').size(),
		$selected = $subnav.find('li.selected:eq(0)'),
		header = '> li:has(ul > li) > a';
		
	
	//Will need to update if label changes from "FOCUS AREAS" -- Yes, this is hacky
	
	if($('.section-mark').size() > 0){
		var faText = $('.section-mark')[0].innerText.toUpperCase() == "FOCUS AREAS";
		if(faText && selectedSize >= 1) {
			//hide child nodes for other sections 
			$subnav.find('> li:not(.selected) > ul').hide();
			
			//$selected.eq(1).parent().parent().siblings().
		}		
		else if(faText && selectedSize < 1) {
			$subnav.find('> li > ul').hide();
		}
	}	
	/* My original code... Accordion won't work for them here. 
	 * 
	 

	
	$subnav.accordion({
		header: header,
		//event: 'mouseover',
		clearStyle: true,
		active: false,
		collapsible: true,
		changestart: function(e, ui){
			if(ui.newHeader.size() == 0){
				$subnav.accordion('option', 'disabled', true);
				document.location = ui.oldHeader.attr('href');
			}
		}		
	});
	
	if($selected.size() > 0){		
		$selected.find('> a').click();
	}
	
	$subnav.find(header).click(function(e){
		
		var $target = $(e.target);
		if($target.next('ul').is(':visible')){
			console.log('clicked');
			//document.location = $target.attr('href');
		}
		
		
	})
	
	*/
	
	
});
