$('.items label input:checkbox').live('change',function _select() {
	$_item = $(this);
	$_label = $_item.parent();
	_checked = $_item.attr('checked');
	_ID = $_item.attr('name');
	_info = $_item.attr('title');
	_info = _info.split(';');

	_item = _info[0];
	_money = _info[1];
	_money = _money * 1;

	if (_checked == true) {
		add_item(_ID,_item,_money);
		add_cash(_money);
		$_label.addClass('selected');
	};
	if (_checked == false) {
		remove_item(_ID);
		remove_cash(_money);
		$_label.removeClass('selected');
	};

});

function add_cash(money) {
	var cash = $('#price').text();
	cash = cash * 1;
	new_cash = cash + money;
	$('#price-tag').addClass('whito');
	$('#price').fadeOut(100, function() {
		$('#price-tag').removeClass('whito');
		$('#price').fadeIn(100);
	});
	$('#price').text(new_cash);
};

function remove_cash(money) {
	var cash = $('#price').text();
	cash = cash * 1;
	new_cash = cash - money;
	$('#price-tag').addClass('whito');
	$('#price').fadeOut(100, function() {
		$('#price-tag').removeClass('whito');
		$('#price').fadeIn(100);
	});
	$('#price').text(new_cash);
};

function add_item(ID,_item,money) {
	$('#inventory').append('<p id="' + ID + '" class="hidden">' + _item + '<span class="money item">' + money + '</span></p>');
	$('#' + ID).fadeIn('slow');
};

function remove_item(ID) {
	$('#' + ID).remove();
};

function reset_all() {
	$('#price').text('0');
	$('#inventory').empty();
	$('label').removeClass('selected');
	$('input').removeClass('fail');
};

function toggle() {
	$('.items label input:checkbox').each(function() {
		this.click();
	});
};

function sub_check() {
	username = $('#order-form input[name="user-name"]');
	username_value = username.attr('value');
	email = $('#order-form input[name="user-email"]');
	email_value = email.attr('value');
	nospam = $('#order-form input[name="nospam"]');
	nospam_value = nospam.attr('value');

	if (username_value == '') {
		username.focus();
		username.addClass('fail');
		return false;
	} else {
		username.removeClass('fail');
	};

	if (email_value == '') {
		email.focus();
		email.addClass('fail');
		return false;
	} else if (email_value.indexOf('@', 0) < 0) {
		email.focus();
		email.addClass('fail');
		return false;
	} else if (email_value.indexOf('.', 0) < 0) {
		email.focus();
		email.addClass('fail');
		return false;
	} else {
		email.removeClass('fail');
	};

	if (nospam_value != '609') {
		nospam.focus();
		nospam.addClass('fail');
		return false;
	} else {
		nospam.removeClass('fail');
	};

	return true;
};

function excl() {
	_checked = $('#design_checkbox').attr('checked');
	if (_checked == false) {
		add_item('wow-website-design','WoW-like Design',200);
		add_cash(200);
		$('#design_checkbox').attr('checked', true);
		$('#design_checkbox_label').addClass('selected');
	};
};

function xcl() {
	_checked = $('#layout_checkbox').attr('checked');
	if (_checked == true) {
		remove_item('wow-website-design-xhtml');
		remove_cash(200);
		$('#layout_checkbox').attr('checked', false);
		$('#layout_checkbox_label').removeClass('selected');
	};
};
