colors = ['#ffaa00', '#55cc00', '#00ddff']

$(function(){
	$('.select', '.listsoft').click(function(){
		$('.select', '.listsoft').css('background-color', '#fff')
		$('.select3', '.listsoft').css('background-color', '#fff')
		$('.select2', '.listsoft').css('background-color', '#eeeeee')
		//$(this).css('background-color', '#00ddff');
		$(this).css('background-color', colors[($(this).parent().prevAll('.c').length)])
		$(':radio', this).attr('checked', 'checked')
	})
	
	$('.select2', '.listsoft').click(function(){
		$('.select', '.listsoft').css('background-color', '#fff')
			$('.select3', '.listsoft').css('background-color', '#fff')
		$('.select2', '.listsoft').css('background-color', '#eeeeee')
		//$(this).css('background-color', '#00ddff');
		$(this).css('background-color', colors[($(this).parent().prevAll('.cc').length)])
		$(':radio', this).attr('checked', 'checked')
	})
	
	$('.select3', '.listsoft').click(function(){
		$('.select', '.listsoft').css('background-color', '#fff')
		$('.select3', '.listsoft').css('background-color', '#fff')
		$('.select2', '.listsoft').css('background-color', '#eeeeee')
		//$(this).css('background-color', '#00ddff');
		$(this).css('background-color', colors[($(this).parent().prevAll('.cc').length)])
		$(':radio', this).attr('checked', 'checked')
	})
	
	.mouseenter(function(){
		if($(':radio:checked', this).length == 0)
			$(this).css('background-color', '#eaeaea');
	})
	.mouseleave(function(){
		if($(':radio:checked', this).length == 0){
			$(this).css('background-color', '#fff');
		}
	});
});

$(document).ready( function () {

	$(".step_1 > button").click( function () {
		$(this).parent().parent().find('.step_1').fadeOut( function () {
			$(this).parent().parent().find('.step_2').fadeIn();
		});
		return false;
	});
	
	$(".back").click( function () {
		$(this).parent().parent().find('.step_2').fadeOut( function () {
			$(this).parent().parent().find('.step_1').fadeIn();
		});
		return false;
	});
	
	$(".back_2").live("click", function () {
		$(this).parent().parent().find('.step_3').fadeOut( function () {
			$(this).parent().parent().find('.step_2').fadeIn();
		});
		return false;
	});
	
	$(".order_send").click( function () {
		var button = $(this);
		$.ajax({
		   type: "POST",
		   url: "http://www.rafsoft.net/strona/www/order.php",
		   data: $(button).parent().parent().parent().serializeArray(),
		   success: function(msg){
				$(button).parent().parent().parent().find(".step_3").html(msg);
				$(button).parent().parent().parent().find('.step_2').fadeOut( function () {
						$(button).parent().parent().parent().find('.step_3').fadeIn();
				});
			}
		});
		return false;
	});

	$('.next').keypress(function(){
		if ($(this).attr('value').length == $(this).attr('maxlength')-1){
			$(this).next().focus().select();
		}
	});
			$('.tooltip_pyt').mouseover(function() {
				$(".tooltip").show();
			  }).mouseout(function(){
				$(".tooltip").hide();
			  });
});
