/* ui.js

(c)2012 Copyright Louisa County Department of Economic Development

*/

$(function() {
	
	// featured slideshow
	$('div#featured-slideshow div#slides').cycle({ 
    	fx:'fade',
    	speed:800,
    	timeout:10000,
    	//random:1,
    	pager:'div#slide-pagination ul', 
     
    	// callback fn that creates a thumbnail to use as pager anchor 
    	pagerAnchorBuilder: function(idx, slide) { 
        	return 'div#slide-pagination ul li:eq(' + idx + ') a'; 
    	} 
	});
	
	// developments slideshow
	$('div#development-slideshow div#development-slides').cycle({ 
    	fx:'fade',
    	speed:800,
    	timeout:10000,
    	//random:1,
    	pager:'div#development-slide-pagination ul', 
     
    	// callback fn that creates a thumbnail to use as pager anchor 
    	pagerAnchorBuilder: function(idx, slide) { 
        	return 'div#development-slide-pagination ul li:eq(' + idx + ') a'; 
    	} 
	});
	$('div#development-slide-pagination ul li a').click(function(){
		$('div#development-slideshow div#development-slides').cycle('pause');
	});
	
	// main navigation - menus
	$('div#main-navigation li.menu').hover(
		function () {
			$('div#main-navigation li.menu ul').hide();
			$('div#main-navigation li.menu').removeClass('active');
			$(this).addClass('active').children('ul').show();
		}, 
		function () {
			$(this).children('ul').fadeOut(150, function(){$(this).parents('li').removeClass('active');});		
	});
	
	//images
	$('div.article img').each(function(){
		
		if ($(this).css('float') == 'right') {$(this).addClass('imgRight');} else {$(this).addClass('imgLeft');}
		
	});
	
	//prettyPhoto
	$('a[rel="modal"]').prettyPhoto({
		social_tools:false,
		deeplinking:false
	});
	$('a[rel="modal"]').addClass('modal');
	$('a.modal').append('<span>Click to enlarge</span>');
	
	//toggle
	$('.toggle-this').slideUp();
	$('a.toggle-next').click(function(){
		$(this).next('.toggle-this').slideToggle();
		
		if ($(this).hasClass('hide-after')) {$(this).hide(100);};
		
		return false;
	});

});
