$(document).ready(function(){
	// Adds glow around entire search field when active
	$('#menubar .search input[type=text]').bind('focus',function(){
		$(this).parent().parent().addClass('focused');
	});
	$('#menubar .search input[type=text]').bind('blur',function(){
		$(this).parent().parent().removeClass('focused');
	});
	
	/* Inputs that remember their values */
	var origValue = [];
	$('input.remember').each ( function (currentIndex)
	{
	       origValue.push ( $(this).val () );
	       $(this).focus ( function ()
	       {
	               $(this).removeClass("unfocused");
	               var defaultText = $(this).val();
	               if ( $(this).val () == origValue [ currentIndex ] )
	               {
	                       $(this).val('');
	               }

	               $(this).blur(function()
	               {
	                       var userInput = $(this).val();
	                       if (userInput == '')
	                       {
	                               $(this).val(defaultText);
	                               $(this).addClass("unfocused");
	                       }
	               });
	       });
	});
	
	Shadowbox.init({
		counterType: 'skip'
	});
	
	$('#slideshow').before('<ul id="ss_nav">').cycle({ 
	    fx:     'fade', 
	    timeout: 0, 
		speed: 500,
	    pager:  '#ss_nav', 

	    // callback fn that creates a thumbnail to use as pager anchor 
	    pagerAnchorBuilder: function(idx, slide) { 
	        return '<li><a href="#">' + idx + '</a></li>'; 
	    } 
	});
	
	$('.tweetlist').each(function(){
		var username = $(this).text();
		$(this).text('').tweet({
			username: username,
			join_text: 'auto',
			count: 3,
			template: "{text}<br /><span class='tt'>{tweet_relative_time}</span>",
			loading_text: 'loading tweets...'
		});
	});
	
	$('#commentform').submit(function(){
		if($(this).find('input[name="url"]').val() == 'website')
			$(this).find('input[name="url"]').val('');
	});
});
