// JavaScript Document

$(document).ready(function() {
    	
	$('div#bottom-wrapper').organicTabs();	
	
	var initialPad = Math.max(($(window).width() - 900)/2,0);
 	$('section#posts').css({
		'padding-left'	:	initialPad,
		'padding-right'	:	initialPad
	});
	
	$(window).resize(function() {
		var differential = Math.max(($(window).width() - 900)/2,0);
 		$('section#posts').css({
			'padding-left'	:	differential,
			'padding-right'	:	differential
		});
	});
	
	// clear autoPager elements and insert a clear div after every third post
	$('ul#thumbs li:nth-child(3n+1)').addClass('clear'); 
	
	// text input prompt
	$('input[type=text][title],input[type=password][title],textarea[title]').each(function(i){
		$(this).addClass('input-prompt-' + i);
		var promptSpan = $('<span class="input-prompt"/>');
		$(promptSpan).attr('id', 'input-prompt-' + i);
		$(promptSpan).append($(this).attr('title'));
		$(promptSpan).click(function(){
		  $(this).hide();
		  $('.' + $(this).attr('id')).focus();
		});
		if($(this).val() != ''){
		  $(promptSpan).hide();
		}
		$(this).before(promptSpan);
		$(this).focus(function(){
		  $('#input-prompt-' + i).hide();
		});
		$(this).blur(function(){
		  if($(this).val() == ''){
			$('#input-prompt-' + i).show();
		  }
		});
    });
		
});
