$(function(){
	
	
	
    $('.blink').
        focus(function() {
            if(this.title==this.value) {
                this.value = '';
            }
        }).
        blur(function(){
            if(this.value=='') {
                this.value = this.title;
            }
        });
	$('#navigation li').hover(
		function(){ $(this).find('.sub-menu').show(); },
		function(){ $(this).find('.sub-menu').hide(); }
	);
	
	$('.show-all-posts-link').click(function(){
		var div = $('.all-posts:eq(0)');
		
		if( div.css('display') == 'none' )
			div.fadeIn();
		else
			div.fadeOut();
		
		return false;
	});
	
	$('.gallery-tabs a').live('click', function() {
		jQuery.each($('.gallery-tabs a'), function() {
			$($(this).attr('href')).hide();
		});
		$($(this).attr('href')).show();
		if ($(this).hasClass('first')) {
			$('.gallery-tabs').removeClass('gallery-tabs-active-second').addClass('gallery-tabs-active-first');
		} else if ($(this).hasClass('second')) {
			$('.gallery-tabs').removeClass('gallery-tabs-active-first').addClass('gallery-tabs-active-second');
		};
		return false;
	});
	
	$('#past-season .thumb a').live('click', function() {
		$('#past-season').hide();
		$('#current-season').show();
		$('#tabs').removeClass('gallery-tabs-active-second').addClass('gallery-tabs-active-first');
		return false;
	});
	
	$('#current-season .thumbs a').live('click', function() {
		var img_src = $(this).attr('href');
		$('#gallery .placeholder-big').find('img').attr({'src': img_src});
		$('#current-season .thumbs a').removeClass('active');
		$(this).addClass('active');
		return false;
	});
	
	$('.featured-destination #tabs a').live('click', function() {
		var this_id = $(this).attr('id');
		if ($(this).attr('id')=='tab1') {
			$('.featured-destination #tabs').removeClass('featured-tabs-active-tab2').addClass('featured-tabs-active-tab1');
			$('.featured-destination .about').hide();
		} else if($(this).attr('id')=='tab2') {
			$('.featured-destination #tabs').removeClass('featured-tabs-active-tab1').addClass('featured-tabs-active-tab2');
			$('.featured-destination .about').show();
		};
		return false;
	});
	
	$('#vacation-guide-destination .right-box #tabs a#tab1, #vacation-guide-destination .right-box #tabs a#tab2').live('click', function() {
		var href = $(this).attr('href');
		var id = $(this).attr('id');
		$('#vacation-guide-destination .right-box .tab-content').hide();
		$(href+'-content').show();
		$('#vacation-guide-destination .right-box #tabs').removeClass('search-tabs-active-tab1').removeClass('search-tabs-active-tab2').addClass('search-tabs-active-'+id);
		return false;
	});
	
	$('#vacation-guide-destination .right-box .destination-search .cnt a').live('click', function() {
		var cnt = $(this).parents('.cnt:eq(0)');
		if (cnt.find('select').is(':visible')) {
			return false;
		};
		$(this).parents('.destination-search:eq(0)').find('.cnt').addClass('cnt-hidden').find('select').hide();
		cnt.find('select').show('fast');
		cnt.removeClass('cnt-hidden');
		return false;
	});
	
	var currentPage = 1;
    $('.simple-slider .buttons a').live('click', function() {
    	var fragment = $(this).parents('.simple-slider:eq(0)').find('.fragment');
        var fragments_count = fragment.length;
        var fragment_width = parseInt(fragment.css('width'));
        var perPage = 1;
        var numPages = Math.ceil(fragments_count/perPage);
        var stepMove = fragment_width*perPage;
        var container = $(this).parents('.simple-slider:eq(0)').find('.content');
        var firstPosition = 0;
        var lastPosition = -((numPages-1)*stepMove);
        
        if ($(this).hasClass('next')) {
            currentPage ++;
            if (currentPage > numPages) {
                currentPage = 1;
                container.animate({'left': firstPosition});
                return false;
            };
            container.animate({'left': -((currentPage - 1)*stepMove)});
        };
        if ($(this).hasClass('prev')) {
            currentPage --;
            if (currentPage < 1) {
                currentPage = numPages;
                container.animate({'left': lastPosition});
                return false;
            };
            container.animate({'left': -((currentPage-1)*stepMove)});
        };
        return false;
    });
    
    try {
    	jQuery('#mycarousel, #mycarousel2').jcarousel({ scroll: 1 });	
    }catch(e) {}
    
	
	
    $('.gallery li a').hover( 
    	function(){ $(this).parent().find('.caption').show(); }, 
    	function(){ $(this).parent().find('.caption').hide(); }
	);
    
	
	$('.article span a').click(function(){
		var recap = $(this).parents('.article').find('.recap');
		
		recap.toggle();
		if(recap.is(':visible')) {
			$(this).html('Full Recap -');
		}
		else {
			$(this).html('Full Recap +');
		}
		
		return false;
		
		
	});
	
    
})

function show_destination_media(media) {
	$('#photo_container').hide();
	$('#video_container').hide();
	$('#' + media + '_container').show();
}


