/* Author: James King, Little Tree Software */

	

$(function(){

	
	$('.rotate').cycle({
		 'random': 1
	});
	
	$('.box.quotes ul').cycle({
		 'random': 1,
		 'fx': 'scrollLeft'
	});	
	
		
	
	subNavigation();
	
});

function carouselControls(carousel) {
	
	// Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
	
}

function subNavigation() {
	
	if ($('.secondary-navigation').length > 0) {
		
		$('.secondary-navigation ul li').each(function() {
			if ($(this).find('ul').length > 0) {
				$(this).find('a').eq(0).addClass('has-children');
			}
		});
		
		initialExClass = "open";
		
		 $('.secondary-navigation .has-children').wrap('<div class="has-children-wrap clear" />');
		 
		 var expcoll = $('<a />')
       			.attr('href', '#')
				.attr('class', 'arrow')
       			.html('<span class="' + initialExClass + '">show/hide</span>');		
				
		$(".has-children-wrap").prepend(expcoll);
		
		$('.secondary-navigation .has-children-wrap a.arrow').click(function() {
					
				$(this).parent().next().slideToggle(200);
				$(this).children().toggleClass("close", 500);
				return false;
		});
		
	}
	
}



















