var img=new Image();
var spinnerWidth = 0;
var spinnerHeight = 0;
$(img).load(function(){
    spinnerWidth = img.width;
    spinnerHeight = img.height;
});
img.src=base+"img/spinner.gif";

jQuery.fn.spinner = function() 
{
	w=this.width();
	if (w<spinnerWidth+4)
		w=spinnerWidth+4;
	h=this.height();
	if (h<spinnerHeight+4)
		h=spinnerHeight+4;

	this.html('<div style="height: '+(h-4)+'px; width: '+(w-4)+'px; background: center no-repeat url('+img.src+')"></div>'); 
};

jQuery.fn.loads = function(url, msgOk, msgErr) 
{
	$(this).spinner();
	
	if (url.href)
		url=url.href;
	else
		url=base+url;
		
	var id=this;
	$.get(url, function(data){
	    if (typeof msgOk == 'undefined') 
	    	$(id).html(data);
	    else
	    {
	    	if (data.substr(0,2)=='ok')
	    		$(id).html(msgOk);
	    	else
	    	{
	    		if (typeof msgErr != 'undefined') 
	    			$(id).html(msgErr);
	    		else
	    			$(id).html(msgOk);
		    }
	    }
	});
};

function log(msg)
{
	if (typeof console=='object')
		console.log(msg);
}
