function slideImages(){
    //jQuery(".single-slider:first").addClass("active");
    var current_img = $("#home-slider").find(".current");
    
    current_img.fadeOut(1000, function(){
    	$(this).removeClass('current');
    });
    if(current_img.next().attr('id') != 'travelers-menu-wrapper' && current_img.next().attr('id') != 'slider-menu-tabs')
    {
    	current_img.next().fadeIn(1000).addClass('current');
    }else{
    	$(".single-slider:first").fadeIn(1000).addClass('current');
  	}
}



$(document).ready(function(){
    $(".single-slider:first").addClass('current').fadeIn('slow');
    $(".single-caption:first").addClass('current').fadeIn('slow');
    setInterval("slideImages()", 5000);
    
    
	jQuery().ready(function() {
    	jQuery("p.wp-caption-text").each(function(n) {
    		this.innerHTML = this.innerHTML.replace(new RegExp("{link:([^}]*)}([^{]*){/link}"), "<span><a href=\"$1\" target=\"_blank\">$2</a></span>");
		});
	});
    
    
    //$("#travelers-menu-wrapper").height($("#travelers-menu-tab").height() + $(".travelers-menu").height());
    //$("#press-menu-wrapper").height($("#press-menu-tab").height() + $(".press-menu").height());
    
    
    
    setTimeout(function(){
    	if($("#travelers-menu-wrapper").height() > $("#press-menu-wrapper").height())
    	{
    		$("#press-menu-wrapper").height($("#travelers-menu-wrapper").height());
    		$("#slider-menu-columns").height($("#travelers-menu-wrapper").height() + 5);
	    }else{
    		$("#travelers-menu-wrapper").height($("#press-menu-wrapper").height());
    		$("#slider-menu-columns").height($("#press-menu-wrapper").height() + 5);
    	}
    }, 20);
    
    
    
    var tabs_are_visible = false;
    var tabs_top_val;
    var menu_top_val;
    var current_tab;
    function toggle_tabs(menu_to_show){
    
    
    	if(menu_to_show == 'travelers')
    	{
    		
    		
    		$("#travelers-menu-tab").addClass('active').removeClass('inactive').attr('title', 'Close');
    		$("#press-menu-tab").removeClass('active').addClass('inactive').attr('title', 'View Press & Media Links');
    		
    		$("#travelers-menu-wrapper").css('display', 'block');
    		$("#press-menu-wrapper").css('display', 'none');
    		
    		if(current_tab != menu_to_show && typeof current_tab != 'undefined')
    		{
    			current_tab = menu_to_show
    			return false;
    		}else{
    			current_tab = menu_to_show;
    		}
    	}
    	
    	if(menu_to_show == 'press')
    	{
    		$("#press-menu-tab").addClass('active').removeClass('inactive').attr('title', 'Close');
    		$("#travelers-menu-tab").removeClass('active').addClass('inactive').attr('title', 'View Traveler Links');
    		
    		$("#press-menu-wrapper").css('display', 'block');
    		$("#travelers-menu-wrapper").css('display', 'none');
    		
    		if(current_tab != menu_to_show && typeof current_tab != 'undefined')
    		{
    			current_tab = menu_to_show
    			return false;
    		}else{
    			current_tab = menu_to_show;
    		}
    	}
    	
    
    	if(!tabs_are_visible){
    	
    		//top_val = $("#home-slider").height() - $('#travelers-menu-wrapper').height();
    		
    		tabs_top_val = $("#home-slider").height() - $('#slider-menu-tabs').height() - $("#slider-menu-columns").height() + 4;
    		menu_top_val = $("#home-slider").height() - $("#slider-menu-columns").height();
    		
    		
    		$('#slider-menu-tabs').animate({
    			top: tabs_top_val
    		}, {
	    		duration: 400,
    	    	specialEasing: {
    		    	top: 'easeOutQuart'
    		    }
	    	});
	    	
	    	$('#slider-menu-columns').animate({
    			top: menu_top_val
    		}, {
	    		duration: 380,
    	    	specialEasing: {
    		    	top: 'easeOutQuart'
    		    }
	    	});

	    	
	    	tabs_are_visible = true;
    	}else{
    		
    		current_tab = undefined;
    		tabs_top_val = 255;
    		menu_top_val = 302;

    		$("#press-menu-tab").removeClass('active').removeClass('inactive').attr('title', 'View Press & Media Links');
    		$("#travelers-menu-tab").removeClass('active').removeClass('inactive').attr('title', 'View Traveler Links');
    		
    		$('#slider-menu-tabs').animate({
    			top: tabs_top_val
    		}, {
	    		duration: 400,
    	    	specialEasing: {
    		    	top: 'easeOutQuart'
    		    }
	    	});
	    	
	    	$('#slider-menu-columns').animate({
    			top: menu_top_val
    		}, {
	    		duration: 420,
    	    	specialEasing: {
    		    	top: 'easeOutQuart'
    		    }
	    	});
	    	
	    	tabs_are_visible = false;
    	}
    
    }
    
    $("#travelers-menu-tab").click(function(){
    	toggle_tabs('travelers');
    });
    
    $("#press-menu-tab").click(function(){
    	toggle_tabs('press');
    });
    
    
    
    /*
    $("#travelers-menu-tab").click(function(e){
    
    	e.preventDefault();
    	
    	
    	if($("#travelers-menu-wrapper").position().top == 254)
    	{
    		topVal = $("#home-slider").height() - $('#travelers-menu-wrapper').height();
    	}else{
    		topVal = 254;
    	}
    	
    	$('#travelers-menu-wrapper').animate({
    		top: topVal
    	}, {
    		duration: 600,
    	    specialEasing: {
    	    	top: 'easeOutQuart'
    	    }
    	});
    });
    
    
    

    $("#press-menu-tab").click(function(e){
    
    	e.preventDefault();
    	
    	
    	if($("#press-menu-wrapper").position().top == 254)
    	{
    		topVal = $("#home-slider").height() - $('#press-menu-wrapper').height();
    	}else{
    		topVal = 254;
    	}
    	
    	$('#press-menu-wrapper').animate({
    		top: topVal
    	}, {
    		duration: 400,
    	    specialEasing: {
    	    	top: 'easeOutQuart'
    	    }
    	});
    });
    */
    
    
    
    $("#social-tabs-menu").click(function(e){
    	
    	if(e.target.tagName == 'SPAN'){
    		e.target = $(e.target).parent();
    	}
    	
    	
    	$("#social-tabs-content").children().hide();
    	$("#social-tabs-content ." + $(e.target).parent().attr('class')).show();
    	
    	$("#social-tabs-menu").find('.current').removeClass('current');
    	$(e.target).parent().addClass('current');
    });
    
    
    getTwitters('twitter-feed', { 
  		id: 'RockinPorch', 
  		count: 3, 
  		enableLinks: true, 
  		ignoreReplies: true, 
		clearContents: true,
  		template: '"%text%" <a class="time" href="http://twitter.com/%user_screen_name%/statuses/%id_str%/">%time%</a>'
	});
}); // end document ready event
