// all scripts at the bottom of the page should be added here

/*	this is to add class on "a" w/ submenu for p7mon support
	just change #main-menu to whatever parent class or id of the p7menu
	Revome script if not using p7menu
	Revome script if using p7 tab menu*/
jQuery("#main-menu ul li:has(ul) > a").addClass("p7PMtrg");

var sliderMenu = [];
$('.banner-navigator ul li a span').each(function(){
  	sliderMenu.push($(this).html());
});

if($('ul#homepage_slider')[0]){
	
	function formatText(index, panel) {
			return sliderMenu[index - 1];
	}

	$('ul#homepage_slider').anythingSlider({
		delay           : 6000,
		width           : 930,   // Override the default CSS width
		height			: 297,   // Override the default CSS height
		pauseOnHover        : false, 
		hashTags            : false, 
		autoPlayLocked  : true,  // If true, user changing slides will not stop the slideshow
		resumeDelay     : 6000, // Resume slideshow after user interaction, only if autoplayLocked is true (in milliseconds).
		navigationFormatter : formatText,
		onSlideComplete : function(slider){
			$('.start-stop').remove();
		},
		stopAtEnd : false,  // true if slider will stop at the end of the slide, false if slider is continuous
		onShowStop : function(e, slider){
			setTimeout(function(){
				if (slider.currentPage === slider.pages) { slider.gotoPage(1); }
			}, 6000);
		}
	});

	$('.banner-navigator').hide();
	
	$('.banner-item .anythingControls ul.thumbNav li').each(function(i){
		$(this).addClass('btn'+(i+1));
	});
	
	$('.banner-item .anythingControls').addClass('banner-navigator');
	

}
	
	
jQuery.fn.BCmenuHover = function() {
    var _menu = $(this);
	
	if(_menu.find('li.selected')[0]){
		_menu.find('li.selected').children('ul').addClass('p7PMshow');
	}

	$('#main-menu').mouseleave(function(){
		setTimeout(function() { _menu.find('li.selected').children('ul').addClass('p7PMshow'); }, 500);
	});

}

$(document).ready(function() {

	$('ul#forum-acc a.heading').click(function() {
		$(this).css('outline','none');
		if($(this).parent().hasClass('current')) {
			$(this).siblings('div').slideUp('slow',function() {
				$(this).parent().removeClass('current');
				$.scrollTo('#forum-acc',1000);
			});
		} else {
			$('ul#forum-acc li.current div').slideUp('slow',function() {
				$(this).parent().removeClass('current');
			});
			$(this).siblings('div').slideToggle('slow',function() {
				$(this).parent().toggleClass('current');
			});
			// $.scrollTo('.current',1000);
		}
		return false;
	});

	$('.back-top').click(function(){
			$.scrollTo('.bread-crumbs',1000);
	});
	
	if($('.blog-container')[0]){
		$('.bread-crumbs').html('<a href="/home">Home</a><a href="/_blog/Blog">Blog</a><div class="clr"></div>');
	}
	
    if($('.rounded-table .rt-row')[0]){
		$('.rounded-table .rt-row:odd').addClass('even');
	}
	
	// menu
	$('#nav_793307').BCmenuHover();

});
