$(function() {
        var watermark = 'Enter your search terms...';
        
        $('#search-form #s').focus(function() {
                if ($(this).val() == watermark) {
                        $(this).val('');
                }
        }).blur(function() {
                if ($(this).val() == '') {
                        $(this).val(watermark);
                }
        }).val(watermark);
        
        $(function() {
                $('.share-links a.twitter').unbind('click').bind('click', function(event) {
                        event.preventDefault();
                        window.open($(this).attr('href'), 'Connect', 'width=700,height=400');           
                });
                
                var sidebar = $('#sidebar');
                
                if (sidebar.length && sidebar.height() < $('#main .left').height()) {
                        sidebar.height($('#main .left').height());
                }
                
                var testimonials = $('.testimonial');
                
                var length = testimonials.length;
                var index = 0;
                
                if (length) {
                        testimonials.eq(0).show();
                        
                        var next = function() {
                                testimonials.eq(index).fadeOut(500, function() {
                                        index++;
                                        
                                        if (index >= length) {
                                                index = 0;
                                        }
                                        
                                        testimonials.eq(index).fadeIn();
                                        
                                        setTimeout(next, 20000);
                                });
                        };

                        setTimeout(next, 20000);
                }
                
        });
        
        var path = window.location.pathname;
	$('#header .links a').each(function() {
		if ( $(this).attr('href').indexOf('tour') > 0 ) {
			if (path.indexOf('tour') > 0 ) {
				$(this).addClass('active');
			}
		}
        	else if ( $(this).attr('href').indexOf('blog') > 0 ) {
                	if (path.indexOf('blog') > 0 ) {
                        	$(this).addClass('active');
                	}
        	} 
		else if ($(this).attr('href') == path) {
                	        $(this).addClass('active');
                }
	});
});

