/**
 * Rajce User Interface
 * Martin Veverka, 2009
 */

(function($){
	// TODO enable, disable
	$.fn.createButton = function(options) {
		var defaults = {
			color: 'red'
		};
		var options = $.extend(defaults, options);
		return this.each(function() {
			if (!$(this).hasClass('imagelessBtn'))
			{
				buttonText = $.trim($(this).html());
				$(this).addClass('imagelessBtn');
				if (options.color == 'green')
				{
					$(this).addClass('greenButton');
				}
				$(this).html('<div class="imagelessBtnOuter"><div class="imagelessBtnInner"><div class="imagelessBtnPos"><div class="imagelessBtnGloss"></div><div class="imagelessBtnText">' + buttonText + '</div></div></div></div>');
			}
		});
	};
})(jQuery);

$(document).ready(function(){
	// Vytvoreni image-less tlacitek
	$('.redButton').createButton({ color: 'red' });
	$('.greenButton').createButton({ color: 'green' });
	// Nastaveni akce pro tlacitko hledej u vyhledavani
	$('#form-search').find('#searchSubmit').click(function(){
		$(this).parent().submit();
	});

	$('form input.submit').each(function(i){
		button = document.createElement('div');
		text = $(this).attr('value');
		$(button).html(text);
		$(button).width(text.length * 7); // css('width', '100px');
		$(button).createButton();
		$(button).click(function(){
			$(this).parents('form').submit();
		});
		$(button).insertBefore(this);
		$(this).hide();
	});
});
