// dropdown function
function initDrop(){
    
	var _menuEl = $('.navigation > li');
	var _d = 200;
	var _index = -1;
	var _ha = 0;
	var _slide = $('#nav');
    var _slide_h = $('#nav').height();
    
    _slide.hover(function(){
        // Nothing
    }, function(){
	    
        if ( $('#nav .active').length ) {
            _drop = $('#nav .active').siblings('.drpdwn');
            _slide_h = _drop.innerHeight(true);
            if( _drop.is(':visible') == false ){
                _drop.fadeIn('slow');
            }
        }
        
        // Resize or hide main back drop on leaving whole area
	    _slide.animate({
            height: _slide_h
        },{
            duration:_d, 
            queue: false
        });
            
	});
    
	_menuEl.each(function(){
        
		var _this = $(this);
		var _drop  = $('.drpdwn > ul', _this);
        
        // If there are sub-nav items
		if ( _drop.length ){
            
            // Position them horizontally with their parent item
			_drop.css({marginLeft: _this.position().left + 20+'px'});
            
			if ( _this.children('a:eq(0)').hasClass('active') ){
				
                var _h = $(this).find('.drpdwn:eq(0)').innerHeight(true);
				_slide.animate({
                    height: _h
                }, 0);
                
                $(this).find('.drpdwn:eq(0)').fadeIn('slow');
            
				_index = _menuEl.index(_this);
				_ha = _h;
                
			}
            
		}

		_this.hoverIntent(function(){
			
            if( $(this).find('.drpdwn:eq(0)').is(':visible') == false ){
                $('.drpdwn').hide();
            
                // Rezise dropdown to size of nav group
                var _h = $(this).find('.drpdwn:eq(0)').innerHeight(true);
                _slide.animate({
                    height: _h
                },{
                    duration:_d, 
                    queue: false
                });
     
                // Fade in nav group
                $('.drpdwn', _this).fadeIn('slow');
            }
            
		}, function(){
			
            if( !$('.drpdwn', _this).siblings('a.active').length ) {
                // Fade out nav group
                $('.drpdwn', _this).fadeOut('fast');
            }
            
		});
        
	});
}

function onBeforeCy() {
    $('.header-add04 > h2').fadeOut('slow'); 
    $('.header-add10 > p').fadeOut('slow'); 
}
function onAfterCy() {
    $('.header-add04 > h2').html($(this).attr('title')).fadeIn('slow'); 
    $('.header-add10 > p').html($(this).attr('desc')).fadeIn('slow'); 
}

$(document).ready(function(){
    $("#tour-holder #tab0").addClass('active');    
	initDrop();
    $(window).resize(function(){
	    $('.slideshow-image > .img-holder > img, img.introimg').each(function(){
            fixImages( $(this) );
        });
	});
	
});

