jQuery(function($) {
				
//Home Buttons

$('.home-box').hover(function(){
	$(".hover-text", this).stop().animate({top:'-200px'},{queue:false,duration:300});
	$(".hover-text2", this).stop().animate({top:'0px'},{queue:false,duration:300});
}, function() {
	$(".hover-text", this).stop().animate({top:'-130px'},{queue:false,duration:300});
	$(".hover-text2", this).stop().animate({top:'200px'},{queue:false,duration:300});
});


$('#featured-entry').cycle({
	fx:     'scrollHorz',
	easing: 'easeInOutBack',
	prev:   '#prev', 
	next:   '#next',
	pause: 	true,
	timeout: 5000,
	after: onAfter
});
function onAfter(curr,next,opts) {
	var caption = $(next).find('.text').clone();
	$('#caption').html(caption);
}

$(".featured-image").hover(function() { //On hover...
	var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'
	//Set a background image(thumbOver) on the &lt;a&gt; tag 
	$(this).find("a.feature-thumb").css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});

	//Fade the image to 0 

	$(this).find("span").stop().fadeTo('normal', 0 , function() {
		$(this).hide() //Hide the image after fade
	}); 

} , function() { //on hover out...
	//Fade the image to 1 
	$(this).find("span").stop().fadeTo('normal', 1).show();
});



$('ul.accordion').accordion({
	active: 0,
	autoHeight: false,
	header: ".opener",
	collapsible: true,
	event: "click"
});

function initNav() {
    var nav = $("#menu-primary-navigation");
    var duration = 260;
    $(nav).find(".sub-menu").css({
        left: 0
    });
    $(nav).find("> li").each(function () {
        var height = $(this).find("> .drop").height();
        $(this).find("> .drop").css({
            display: "none",
            height: 0,
            overflow: "hidden"
        });
        $(this).find(".drop li > .drop").css({
            display: "none",
            width: 0
        });
        if (!$.browser.msie) {
            $(this).find("> .drop").css({
                "opacity": 0
            });
            $(this).find(".drop li > .drop").css({
                "opacity": 0
            })
        }
        $(this).mouseenter(function () {
            $(this).addClass("hover");
            var drop = $(this).find("> .drop");
            if ($.browser.msie) {
                $(drop).css({
                    display: "block"
                }).stop().animate({
                    "height": height
                }, duration, function () {
                    $(this).css({
                        "overflow": "visible"
                    })
                })
            } else {
                $(drop).css({
                    display: "block"
                }).stop().animate({
                    "height": height,
                    "opacity": 1
                }, duration, function () {
                    $(this).css({
                        "overflow": "visible"
                    })
                })
            }
        }).mouseleave(function () {
            var _this = $(this);
            if ($.browser.msie) {
                $(this).find("> .drop").stop().css({
                    "overflow": "hidden"
                }).animate({
                    "height": 0
                }, duration, function () {
                    $(_this).removeClass("hover")
                })
            } else {
                $(this).find("> .drop").stop().css({
                    "overflow": "hidden"
                }).animate({
                    "height": 0,
                    "opacity": 0
                }, duration, function () {
                    $(_this).removeClass("hover")
                })
            }
        });
        $(this).find(".drop ul > li ").mouseenter(function () {
            $(this).addClass("hover");
            var pageW = getPageSize()[2];
            if (pageW < $(this).offset().left + 236 * 2) {
                $(this).find("> .drop").css({
                    left: 'auto',
                    right: 236
                })
            }
            if ($.browser.msie) {
                $(this).find("> .drop").css({
                    display: 'block'
                }).stop().animate({
                    "width": 236
                }, duration, function () {
                    $(this).css({
                        overflow: 'visible'
                    })
                })
            } else {
                $(this).find("> .drop").css({
                    display: 'block'
                }).stop().animate({
                    "width": 236,
                    "opacity": 1
                }, duration, function () {
                    $(this).css({
                        overflow: 'visible'
                    })
                })
            }
        }).mouseleave(function () {
            $(this).removeClass("hover");
            if ($.browser.msie) {
                $(this).find("> .drop").stop().css({
                    overflow: 'hidden'
                }).animate({
                    width: 0
                }, duration, function () {
                    $(this).css({
                        display: 'none'
                    })
                })
            } else {
                $(this).find("> .drop").stop().css({
                    overflow: 'hidden'
                }).animate({
                    width: 0,
                    "opacity": 0
                }, duration, function () {
                    $(this).css({
                        display: 'none'
                    })
                })
            }
        })
    })
}


(function(B){B(document).ready(function(){var mainNav=B('#menu-primary-navigation');var lis=mainNav.find('li');var shownav=$("#menu-primary-navigation");lis.children('ul').wrap('<div class="c" / >');var cElems=B('.c');cElems.wrap('<div class="drop" / >');cElems.before('<div class="t"></div>');cElems.after('<div class="b"></div>');$(shownav).find(".sub-menu").css({display:"block"});initNav()})})($);(function(C){C(document).ready(function(){$("#menu-primary-navigation li:has(ul)").addClass("parent")})})($);
$("#nav-main a[href='#']").click(function(e) {e.preventDefault();});


//Meet the Staff
if ($('.staff-member').size()>0) {
	
	$('.staff-member a.thumb').click(function(e) {
		e.preventDefault();
	});	
	
	$('.staff-member').mouseenter(function(){
		var thumbOver = $(this).find("img").attr("src");//Get image url and assign it to 'thumbOver'
		$(this).find("a.thumb").css({'background' : 'url(' + thumbOver + ') no-repeat scroll bottom left'});//Set a background image(thumbOver) on the <a> tag - Set position to bottom
		$(this).addClass('overMe');
		
		$('.staff-member:not(".overMe")').each(function()
	    {
			var thumbOverT = $(this).find("img").attr("src");
			$(this).find("a.thumb").css({'background' : 'url(' + thumbOverT + ') no-repeat scroll bottom left'});	
			$(this).find('span').hide();
		});
		//$('.staff-member:not(".overMe")').find("a.thumb").css({'background' : 'no-repeat scroll bottom left !important'});
		
		$('.bio',this).stop(true, true).fadeIn();
		
	}).mouseleave(function(){
		$('.staff-member:not(this)').find("span").stop().fadeTo('normal', 1).show();//Fade the image to full opacity
		$('.bio',this).stop(true, true).fadeOut(100);
		$('.overMe').removeClass('overMe');
	})
};



//Footer Tabs
var tabContainers = $('.tab-content');
tabContainers.hide().filter(':first').show();

$('.tab a').click(function () {
	tabContainers.hide();
	tabContainers.filter(this.hash).fadeIn();
	$('.tab a').removeClass('selected');
	$(this).addClass('selected');
	return false;
}).filter(':first').click();

//Gallery Rollover
$(".ngg-gallery-thumbnail a").append("<img src='/wp-content/themes/redridge/img/magnify.jpg' class='magnify' />");
	$(".magnify").css({"opacity": 0});
	
	$(".ngg-gallery-thumbnail a").hover(function(){
		$(this).children(".magnify").stop(true, true).animate({"opacity": 0.88});						
	}, function(){
		$(this).children(".magnify").stop(true, true).animate({"opacity": 0});	
});

//FAQ
	$("#questions ul li a").click(function(e){
	   e.preventDefault();
		var selected = $(this).attr('href');	
		selected += '"'+selected+'"'
		/*--Removing the Current class and the top button from previous current FAQs---*/
		$('.top-button').remove();
		$('.current-faq').removeClass();
		$.scrollTo(selected, 400 ,function(){ 
			$(selected).addClass('current-faq',400,function(){
				$(this).append('<a href="#" class="top-button">TOP</a>');
			});
		});		
	});
	$('.top-button').live('click',function(e){
		e.preventDefault();
		$('.top-button').remove();
		$('.current-faq').removeClass('current-faq',400,function(){
			$.scrollTo('0px', 800); 
		});				
	});	
	
//Gallery Album Dropdown

var albumDrop = $('#nav-gallery .drop');
$(albumDrop).hide();
$('.select-album a').click(function(e) {
	e.preventDefault();
	$(albumDrop).stop().slideToggle('slow');
});


// Select Styling
 $('select.select').each(function(){
	var title = $(this).attr('title');
	if( $('option:selected', this).val() != ''  ) title = $('option:selected',this).text();
	$(this)
		.css({'z-index':10,'opacity':0,'-khtml-appearance':'none'})
		.after('<span class="select">' + title + '</span>')
		.change(function(){
			val = $('option:selected',this).text();
			$(this).next().text(val);
			})
});

$('.search-container .hentry:nth-child(3n+1)').after('<br class="cb" />');



});//end jquery

