String.prototype.repeat = function(num) {
	return new Array(isNaN(num)? 1 : ++num).join(this);
}


$(document).ready(function(){
	$('#ajaxLoading').hide().ajaxStart(function() { $(this).show(); }).ajaxStop(function() { $(this).hide(); });
	$(window).scroll( function(){ $('#ajaxLoading').stop().animate( { 'marginTop': $(window).scrollTop() + 'px' }, 'fast' ); } );
	$.jGrowl.defaults.position = 'bottom-right';

	$(document).ajaxError( function (event, XMLHttpRequest, ajaxOptions, thrownError) {
		$.jGrowl( '<p></p>' + 'error in: ' + ajaxOptions.url + '\nerror: ' + ( thrownError ? thrownError : xhr.responseText ), { theme: 'ui-state-error', header: 'AJAX Error' } );
	} );

	$('.item:first-child, .listItem:first-child, ul li:first-child').addClass('first-child');
	$('.item:last-child, .listItem:last-child, ul li:last-child').addClass('last-child');
	$('input[type=submit], input[type=button], button, ul.dropbutton').button();
	$('.gotoTop').click( function() { $('html, body').animate( { scrollTop: 0 }, 0 ); return false; } );
} );

