function jqid( id ) {
	return '#' + jqstr( id );
}

function jqstr( id ) {
	return id.replace( /(:|\.|\%)/g, '\\$1' );
}


function isInView(el){
	var docViewTop = $(window).scrollTop();
	var docViewBottom = docViewTop + $(window).height();
	var elTop = $(el).offset().top;
	return ( (elTop >= docViewTop) && (elTop <= docViewBottom) );
}


function buttonise(el){
	el.find('input:submit, input:button, button').button();
}


$(document).ready(function(){
	var al = $('#ajaxLoading');
	al.hide().ajaxStart(function() { $(this).show(); }).ajaxStop(function() { $(this).hide(); });
	$(document).ajaxError( function (event, XMLHttpRequest, ajaxOptions, thrownError) { $.jGrowl('<p></p>' + thrownError, { theme: 'ui-widget ui-state-error', header: 'AJAX Error' } ); } );
	$(window).scroll( function(){ al.stop().animate( { 'marginTop': $(window).scrollTop() + 'px' }, 'fast' ); } );

	$('div > .item:first-child, .modulecore .pitem:first-child, ul li:first-child').addClass('first-child');
	$('div > .item:last-child, .modulecore .pitem:last-child, ul li:last-child').addClass('last-child');
	buttonise( $('body') );
} );

