jQuery.fn.log = function (msg)
{
  console.log("%s: %o", msg, this);
  return this;
};

function ajaxLoadingBUI()
{
	$.blockUI({ 
		message: '<div class="ajaxLoader">' + Lang.aguardeUnMomento + '</div>',
		onUnblock: null,
		css: { 
			border: 'none', 
			padding: '15px', 
			backgroundColor: '#000', 
			'-webkit-border-radius': '10px', 
			'-moz-border-radius': '10px', 
			opacity: '1', 
			color: '#fff'
		}		
	});	
}


function bindBtnCloseBUI()
{
	$('.btnCloseBUI').click(function(){
		$.unblockUI();
		$(this).unbind('click');
	});
}



function ajaxError(idContainer)
{
	$('#' + idContainer).ajaxError(function(event, request, settings)
	{
		$.get('/includes/ajaxError.php',
			  {
			   url: settings.url
			  },
			  function(data){
				  $('#' + idContainer).html(data);
		});

	});
	$.unblockUI();
}


function bloquearPantalla(mensaje, autoClose)
{
	
	if(!autoClose)
		mensaje = mensaje + '<br /><input type="button" class="btnCloseBUI" value="' + Lang.Cerrar + '" />';
	
    $.blockUI({
        message: mensaje,
        onUnblock: null,
        css: {
            border: 'none',
            padding: '15px',
            backgroundColor: '#000',
            '-webkit-border-radius': '10px',
            '-moz-border-radius': '10px',
            opacity: '1',
            color: '#fff'
        }
    });
	
	if(!autoClose)
		bindBtnCloseBUI();
}



function habilitarPantalla()
{
    var pos = $("#wrapper").offset();
    $("html").animate(
    {
        scrollTop: pos.top + "px"
    },

    {
        duration: 1000
    }, setTimeout($.unblockUI, 1100)
        );
	
}

function doDow(dow)
{
    for(var i = 0; i < dow.length; i++)
        eval(dow[i]);
}



function demoInstanceInfo(myPlayer, myInfo) {
	var jPlayerInfo = "<p>This jPlayer instance is running in your browser using ";
	if(myPlayer.jPlayerGetInfo("html5")) {
		jPlayerInfo += "<strong>HTML5</strong> with ";
		if(myPlayer.jPlayerGetInfo("canPlayOGG")) {
			jPlayerInfo += "<strong>OGG</strong>";
		} else {
			jPlayerInfo += "<strong>MP3</strong>";
		}
	} else {
		jPlayerInfo += "<strong>Flash</strong> with <strong>MP3</strong>";
	}
	jPlayerInfo += " files.<br />This instance has the constructor option ";
	if(myPlayer.jPlayerGetInfo("oggSupport")) {
		jPlayerInfo += "set to <code>$(\"#jpId\").jPlayer({oggSupport: true})</code>";
	} else {
		jPlayerInfo += "defaulting to <code>$(\"#jpId\").jPlayer({oggSupport: false})</code>";
	}
	jPlayerInfo += "</p>";
	myInfo.html(jPlayerInfo);
}


String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}
