jQuery.fn.orderForm = function() {

	this.find('#groups a').click(function () {
			$('#groups a.selected').attr('class', 'normal');
			$('#services a.selected').attr('class', 'normal');

			var list_id = $(this).attr('class', 'selected')
			                     .attr('list_id');

			$('#services')
				.attr('class', 'active')
				.find('ul:visible').hide().end()
				.find('ul[list_id="' + list_id + '"]').show();

			$('#selected-item')
				.attr('class', 'inactive')
				.find('form').hide();

			$('#main-content > div.corner').hide().show();

			return false;
		});

	this.find('#services a').click(function () {
			$('#services a.selected').attr('class', 'normal');

			var cur_obj = $(this).attr('class', 'selected');

			var prices = new Array();
			prices[24] = parseFloat(cur_obj.attr('price_24'));
			prices[48] = parseFloat(cur_obj.attr('price_48'));
			prices[72] = parseFloat(cur_obj.attr('price_72'));

			if (isNaN(prices[24]) || prices[18] < 0) {				prices[24] = 0;
			}
			if (isNaN(prices[48]) || prices[48] < 0) {
				prices[48] = 0;
			}
			if (isNaN(prices[72]) || prices[72] < 0) {
				prices[72] = 0;
			}

			var hours = $('#selected-item form select').attr('value');

			$('#selected-item').attr('class', 'active');
			$('#item').attr('value', cur_obj.attr('item_id'));
			$('#add-form').show()
				.find('h3 span.text').html(cur_obj.find('span.text').html()).end()
				.find('h3 span.price').html('$' + prices[hours].toFixed(2)).end()
				.find('input.page-count')
					.attr('price_24', prices[24])
					.attr('price_48', prices[48])
					.attr('price_72', prices[72])
					.keyup();

			$('#main-content > div.corner').hide().show();

			return false;
		});

	this.find('#add-form input:text').keyup(function () {        	var cur_obj = $(this);
        	var hours   = $('#add-form select').attr('value');

        	var price = parseFloat(cur_obj.attr('price_' + hours));
        	if (isNaN(price) || price < 0) {
				price = 0;
			}

        	var value = parseInt(cur_obj.attr('value'), 10);
        	if (isNaN(value) || value < 0) {
				value = 0;
			}

        	$('#total-sum span.price').html('$' + (price * value).toFixed(2));
		});

	this.find('#add-form select').change(function () {
        	var price = parseFloat($('#add-form input.page-count').attr('price_' + $(this).attr('value')));

        	if (isNaN(price) || price < 0) {
				price = 0;
			}

        	$('#add-form h3 span.price').html('$' + price.toFixed(2));
        	$('#add-form input.page-count').keyup();
		});

	this.find('#total-sum').show();
	this.find('#add-form h3 span.price').show();

	return this;
}