/*Homepage accordian settings*/
ddaccordion.init({
	headerclass: "expandable", //Shared CSS class name of headers group that are expandable
	contentclass: "categoryitems", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [0], //index of content(s) open by default [index1, index2, etc]. [] denotes no content
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: false, //persist state of opened contents within browser session?
	toggleclass: ["hp-news-down", "hp-news-up"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["prefix", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "normal", //speed of animation: "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})

/*Homepage carousel settings*/
/*jQuery(document).ready(function() {
	jQuery('#content-scroll').jcarousel({
		vertical: true,
		scroll: 1
	});
});

$("h3.hp-news-up").hover(function(){
	$(this).addClass("hp-news-hover");
}, function() {
	$(this).removeClass("hp-news-hover");
});*/



/*slideshow*/
var $clicArray = new Array;
var $clicCount = 0;
var $clicCurrent = 0;
var $clicStop = 0;
function clicSelect(x) {
	if (x!==$clicCurrent) {
		$("ul.clicItems li:nth-child("+($clicCurrent+1)+")").css({display:"none"});
		$("ul.clicItems li:nth-child("+(x+1)+")").fadeIn(600);
		$clicCurrent = x;
		clicListOn(x);
	};
};
function clicPrev() {
	if ($clicCurrent == 0) {
		clicSelect($clicCount-1);
	} else {
		clicSelect($clicCurrent-1)
	};
}
function clicNext() {
	if ($clicCurrent == $clicCount-1) {
		clicSelect(0);
	} else {
		clicSelect($clicCurrent+1)
	};
}
function clicListOn(y) {
	$("ul.clicList li.item").removeClass("on");
	$("ul.clicList li.item:nth-child("+(y+2)+")").addClass("on");
}
function clicTimerStart (){
	$("body").everyTime(5000,function(){
		clicNext();
	});
};
function clicTimerStop (){
	$("body").stopTime();
}

$(document).ready(function(){
	//overlay reveal
	$(".container").hoverIntent(function() {
		$("> .reveal > .hidden",this).slideToggle(250);
	},function(){
		$("> .reveal > .hidden",this).slideToggle(250);
	});
	
	//slide show for clic items
	$("ul.clicItems").css({width:"168px",height:"86px",overflow:"hidden"});
	//hide all items except first
	$("ul.clicItems li:not(:first)").each(function(){$(this).css({display:"none"})});
	
	//count all items & set counter
	$clicArray = $("div.highlights ul li");
	$clicCount = $clicArray.length;
	
	//make a list of the clic items
	if ($clicCount > 1) {
		//var $clicList = "<ul class='clicList'><li class='prev'><a href='javascript:clicPrev();clicTimerStop();'><img src='img/prev-arrow.gif' title='Previous' alt='Previous' /></a></li>";
		var $clicList = "<ul class='clicList'><li class='prev'><a href='javascript:clicPrev();'><img src='img/prev-arrow.gif' title='Previous' alt='Previous' /></a></li>";
		var i = 1;
		for (i=1;i<=$clicCount;i++) {
			if (i==1) {
				//$clicList = $clicList + "<li class='item on'><span></span><a href='javascript:clicSelect("+(i-1)+");clicTimerStop();'><img src='img/item.gif' title='"+i+"' alt='"+i+"' /></a></li>";
				$clicList = $clicList + "<li class='item on'><span></span><a href='javascript:clicSelect("+(i-1)+");'><img src='img/item.gif' title='"+i+"' alt='"+i+"' /></a></li>";
			} else {
				//$clicList = $clicList + "<li class='item'><span></span><a href='javascript:clicSelect("+(i-1)+");clicTimerStop();'><img src='img/item.gif' title='"+i+"' alt='"+i+"' /></a></li>";
				$clicList = $clicList + "<li class='item'><span></span><a href='javascript:clicSelect("+(i-1)+");'><img src='img/item.gif' title='"+i+"' alt='"+i+"' /></a></li>";
			};
		}
		//$clicList = $clicList + "<li class='next'><a href='javascript:clicNext();clicTimerStop();'><img src='img/next-arrow.gif' title='Next' alt='Next' /></a></li></ul>";
		$clicList = $clicList + "<li class='next'><a href='javascript:clicNext();'><img src='img/next-arrow.gif' title='Next' alt='Next' /></a></li></ul>";
		$("div#jsList").html($clicList);
	};

	$("ul.clicItems").hover(function(){
		clicTimerStop();
	}, function(){
		if ($clicStop == 0) {
			clicTimerStart();
		};
	});
	$("ul.clicList").hover(function(){
		clicTimerStop();
	}, function(){
		if ($clicStop == 0) {
			clicTimerStart();
		};
	});
	
	$("ul.clicList a").click(function(){
		$clicStop = 1;
	});
	
	clicTimerStart();
});