var startTime;

function alert(str) {
	//console.log(str);
}

function getBench(reset) {
	var endTime=new Date().getTime();
	var out=((endTime-startTime)/1000)+'s';
	if (reset) {startTime=endTime;}
	return out;
}

$(document).ready(function() {
	startTime=new Date().getTime();
});

function debug(v) {
	$('#debug').show().append(
		$('<div>').attr('innerHTML',v)
	);
}

function rand(from,to) {
	return from+Math.floor(Math.random()*(to-from+1));
}

/*
jQuery.extend(
	jQuery.expr[":"],{
		red: (
			"jQuery(.tile).data('data').c=='red'"
		)
	}
);
*/

String.prototype.repeat = function(l){
	return new Array(l+1).join(this);
};

jQuery(function($) {
    $.fn.reverse = function() {
        return this.pushStack(this.get().reverse(), arguments);
    };
    $.each( ['prev', 'next'], function(unusedIndex, name) {
        $.fn[ name + 'ALL' ] = function(matchExpr) {
            var $all = $('body').find('*').andSelf();
            $all = (name == 'prev')
                 ? $all.slice(0, $all.index(this)).reverse()
                 : $all.slice($all.index(this) + 1)
            ;
            if (matchExpr) $all = $all.filter(matchExpr);
            return $all;
        };
    });
});