// JavaScript Document

(function($){
	
    $(document).ready(function() {		
		$('#drop-nav:first').children().hover(
    		function(){
				$(this).addClass('hover').find('ul').hide();;
				$('ul', this).slideDown();
    		},
    		function(){
        		if($(this).has('ul').length)
				{
					$('ul', this).slideUp('fast', function(){
						$(this).parent('li').removeClass('hover');
					});
				}
				else {
					$(this).removeClass('hover');
				}
				
    		}
    	);
		var navWidth = 0;
		$('#drop-nav:first').children().each(function(){
			navWidth += $(this).width();
		});
		$('#drop-nav').width(navWidth);
		if($('#carousel'))
		{
			$('#carousel-nav').empty();
			$('#carousel').height($('#carousel #slides').children().height());
			$('#carousel #slides').cycle({
				fx: 'fade',
				speed: 'slow',
				timeout: 10000,
				containerResize: 0,
				cleartype: true,
				cleartypeNoBg: true,
				pager: '#carousel-nav',
				pagerAnchorBuilder: function(idx, slide) {
						   return '<li><a href="#">&bull;</a></li>';
				}
			});
		}
		$('#searchTerm').example('Search');
		
		if($('.content-sidebar').height() > $('.content-main').height())
		{
			$('.content-main').height($('.content-sidebar').height());
		}
		else if($('.content-sidebar').height() < $('.content-main').height())
		{
			$('.content-sidebar').height($('.content-main').height());
		}
		
		$('.fancy').fancybox({
			prevEffect	: 'fade',
			nextEffect	: 'fade',
			helpers	: {
				title	: {
					type: 'outside'
				},
				overlay	: {
					opacity : 0.8,
					css : {
						'background-color' : '#000'
					}
				},
				thumbs	: {
					width	: 150,
					height	: 150
				}
			}
		});
		
		$('.iframe').fancybox({
			'width'				: 500,
			'height'			: 500,
			'autoScale'     	: false,
			'type'				: 'iframe',
			'padding'			: 0
		});
    });
})(jQuery);
