function limitChars(textid, limit, infodiv) {
	var text = $('#' + textid).val(); 
	var textlength = text.length;
	if(textlength > limit)
	{
		//$('#' + infodiv).html('You cannot write more then '+limit+' characters!');
		$('#' + infodiv).html('0 characters remaining.');
		$('#'+textid).val(text.substr(0,limit));
		return false;
	}
	else
	{
		$('#' + infodiv).html((limit - textlength) + ' characters remaining.');
		return true;
	}
}

function formatCurrency(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}

// Center an element on the screen
(function($){
        $.fn.extend({
                center: function (options) {
                        //var options =  $.extend({transition:300, minX:0, minY:0}, options);
                        return this.each(function() {
                                $(this).css('position', 'absolute');
                                var top = ($(window).height() - $(this).outerHeight())/2+$(window).scrollTop();
                                var left = ($(window).width() - $(this).outerWidth())/2+$(window).scrollLeft();
								$(this).css('left', left);
								$(this).css('top', top);
                                //$(this).animate({
                                //        top: (top > options.minY ? top : options.minY)+'px',
                                //        left: (left > options.minX ? left : options.minX)+'px'
                                //}, options.transition);
                                return $(this);
                        });
                }
        });
})(jQuery);
