$.fn.equalHeights = function(px) {
	$(this).each(function(){
		var currentTallest = 0;
		$(this).children().each(function(i){
			if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
		});
		// for ie6, set height since min-height isn't supported
		if ($.browser.msie && $.browser.version == 6.0) { $(this).children().css({'height': currentTallest}); }
		$(this).children().css({'min-height': currentTallest}); 
	});
	return this;
};


$(document).ready(function()
{	
	// Add another text input
	$('span.add-another a').bind('click', function(e)
	{
		e.preventDefault();
		var cloneButton = $(this).parent();
		var currentInput = $(this).parent().prevAll('input').eq(0);
		var inputId = currentInput.attr('id');
		var inputClass = $(currentInput).attr('class');
		var newInputId = inputId.replace(/\d{1,4}$/,'') + $('.' + inputClass).length;
		currentInput.clone(true).attr('id', newInputId).insertBefore(cloneButton);
    });


	// Search enhancement 
	$('form.search label+input').wrap('<div class=\"hover-wrap\"><\/div>')
	.focus(function()
	{
		$(this).prev().hide();
	})
	.blur(function()
	{
		if ( !this.value ) $(this).prev().show()
	})
	.each(function()
	{
		$(this).before( $(this).parent().prev() );
		if ( this.value ) $(this).prev().hide();
	});
	
	
	// Add user panel
	$('div#AddUserPanel').hide();
	$('select#AddUser').change(function()
	{
		$("select#AddUser option:selected").each(function () 
		{
        	var str = $(this).text();
			if (str == 'Yes')
			{
				$('div#AddUserPanel').show();
			}
        });
	});
	
	
	$('ul.filmList, ul.peopleList').equalHeights();
	
	
	//$('ul.filmList').masonry({singleMode:true});
	
	/*$('#homepagecircles .tab-content').hide();
	$('#homepagecircles ul.tabs li:first').addClass('active');
	$('#homepagecircles .tab-content:first').show();
	
	$('#homepagecircles ul.tabs li').click(function() {
		$('#homepagecircles ul.tabs li').removeClass('active');
		$(this).addClass('active');
		var activeTab = $(this).find("a").attr("href"); //Find the href 
		$(".tab-content").fadeOut('slow', function() {
			$(activeTab).fadeIn('slow');
		});
		return false;
	});*/
	
	
});
