
// ******************
// HOME PAGE SLIDER

var theInt = null;
var $crosslink, $navthumb;
var curclicked = 0;

theInterval = function(cur){
	clearInterval(theInt);
	
	if( typeof cur != 'undefined' )
		curclicked = cur;
	
	$crosslink.removeClass("active-thumb");
	$navthumb.eq(curclicked).parent().addClass("active-thumb");
		$(".stripNav ul li a").eq(curclicked).trigger('click');
	
	theInt = setInterval(function(){
		$crosslink.removeClass("active-thumb");
		$navthumb.eq(curclicked).parent().addClass("active-thumb");
		$(".stripNav ul li a").eq(curclicked).trigger('click');
		curclicked++;
		if( 6 == curclicked )
			curclicked = 0;
		
	}, 4000);
};

$(function(){
	
	$("#main-photo-slider").codaSlider();
	
	$navthumb = $(".nav-thumb");
	$crosslink = $(".cross-link");
	
	$navthumb
	.click(function() {
		var $this = $(this);
		theInterval($this.parent().attr('href').slice(1) - 1);
		return false;
	});
	
	theInterval();
});

// ******************
// ACCORDION MENU

$(document).ready(function () {

	$('#accordion li').click(function () {

		//slideup or hide all the Submenu
		$('#accordion li').children('ul').slideUp('slow	');

		//remove all the "Over" class, so that the arrow reset to default
		$('#accordion li > a').each(function () {
			if ($(this).attr('rel')!='') {
				$(this).removeClass($(this).attr('rel') + 'Over');
			}
		});

		//show the selected submenu
		$(this).children('ul').slideDown('slow');

		//add "Over" class, so that the arrow pointing down
		$(this).children('a').addClass($(this).children('li a').attr('rel') + 'Over');

	});

});

// ******************
// NEWS TICKER

$(document).ready(function () {
	createTicker();
}); 

function tickerIt(){
	if( i == tickerItems.length ){
		i = 0;
	}
	//change without effect
	//$('#ticker').html(tickerItems[i]);

	//change with effect
	$('#ticker').fadeOut("slow", function(){
		$(this).html(tickerItems[i]).fadeIn("slow");
		i++;
	});
	
	//repeat - change 5000 - time interval
	setTimeout("tickerIt()", 5000);
}

// CONTENT TOGGLE

$(document).ready(function () {
	$('#contentslider li').click(function () {
		var text = $(this).children('.contentslider_content');
		if (text.is(':hidden')) {
			text.slideDown('200');
			$(this).children('span').html('-');
		} else {
			text.slideUp('200');
			$(this).children('span').html('+');
		}
	});
});

