$.fn.mega_nav = function (){
// this controls drop down menus
 var hangTime = 800
 var fadeTime = 400
 var dropdownPOS = $(this).height();
 
	$('li').children('.v_nav').wrap('<div class="drop_down">');										  
	$('li').children('.drop_down').css('top',dropdownPOS);
	$('li').children('.drop_down').hide();
	$('li').mouseenter( function(){
		$(this).clearQueue("queueFade");
		$(this).children('a').first().addClass('dropped');
		$(this).children('.drop_down').css('z-index',9998);
		$(this).children('.drop_down').fadeIn(fadeTime);
	});
	$('li').mouseleave( function(){
		$(this).delay(hangTime, 'queueFade').queue('queueFade', function(){ 
			$(this).children('a').first().removeClass('dropped');
			$(this).children('.drop_down').fadeOut(fadeTime);
		}).dequeue('queueFade');
		$(this).children('.drop_down').css('z-index',7777);
	});
}

$(document).ready(function() {
	$('#main_nav').mega_nav();
	$('#main_nav_fr').mega_nav();
	// Find each text button and wrap the internal text with a div.text
	$('a.txt_btn').wrapInner('<div class="text"></div>');
});


$(function() {
    $('#pause').click(function() { $('.feature_bg').cycle('pause'); return false; });
    $('#play').click(function() { $('.feature_bg').cycle('resume'); return false; });
    
    $('.feature').hover(
        function() { $('#controls').fadeIn(); },
        function() { $('#controls').fadeOut(); }
    );
    
    $('.feature_bg').cycle({
        fx:     'fade',
        speed:   600,
        timeout: 3000,
        next:   '#next',
        prev:   '#prev'
    });
});
