function get_form_params(form)
{
	var form_params={};	
	$('input, textarea', form).each(function() {
			if($(this).attr('name'))
			{
				var value = $(this).attr('value');
				if($("input[name='"+$(this).attr('name')+"']", form).is(':radio')) 
				{ 
					value = $("input[name='"+$(this).attr('name')+"']:checked", form).val();
				}
				form_params[$(this).attr('name')] = value;
			}
		})
	form_params['rnd'] = Math.random();
	form_params['utf8'] = 1;		
	return form_params;
}
function show_basket_info()
{
	if($('.cartheader').length) 
	{
		$.post("/cgi-bin/dsp.pl", { cl: "order", event: "show_basket_info", rnd: Math.random(), utf8: 1 }, 
		function(data) {
			$('.cartheader').html(data);
		});	
	}
}
$(document).ready(function(){

	  $("a.price1").click(
      function () {
		$(this).parent().next().children("font.price2, font.price3, font.price4, font.price5").css("display","none");
		$(this).parent().next().children("font.price1").css("display","block");
		$(this).parent().children("a.price2, a.price3, a.price4, a.price5").css("background","none");
		$(this).parent().next().children(".popupback").children("a.pprice2, a.pprice3, a.pprice4, a.pprice5").css("font-weight","normal");
		$(this).parent().next().children(".popupbackunit").children("a.pprice2, a.pprice3, a.pprice4, a.pprice5").css("color","#b7b7b7");
		$(this).parent().children("a.price1").css("background","#ffc800");
		$(this).parent().next().children(".popupback").children("a.pprice1").css("font-weight","bold");
		$(this).parent().next().children(".popupbackunit").children("a.pprice1").css("color","#000");
		var price_id = $("a.price1").attr("price_id");
		$("#price_id").val(price_id);
      });

	  $("a.price2").click(
      function () {
		$(this).parent().next().children("font.price1, font.price3, font.price4, font.price5").css("display","none");
		$(this).parent().next().children("font.price2").css("display","block");
		$(this).parent().children("a.price1, a.price3, a.price4, a.price5").css("background","none");
		$(this).parent().next().children(".popupback").children("a.pprice1, a.pprice3, a.pprice4, a.pprice5").css("font-weight","normal");
		$(this).parent().next().children(".popupbackunit").children("a.pprice1, a.pprice3, a.pprice4, a.pprice5").css("color","#b7b7b7");
		$(this).parent().children("a.price2").css("background","#ffc800");
		$(this).parent().next().children(".popupback").children("a.pprice2").css("font-weight","bold");
		$(this).parent().next().children(".popupbackunit").children("a.pprice2").css("color","#000");
		var price_id = $("a.price2").attr("price_id");
		$("#price_id").val(price_id);
      });

	  $("a.price3").click(
      function () {
		$(this).parent().next().children("font.price1, font.price2, font.price4, font.price5").css("display","none");
		$(this).parent().next().children("font.price3").css("display","block");
		$(this).parent().children("a.price1, a.price2, a.price4, a.price5").css("background","none");
		$(this).parent().next().children(".popupback").children("a.pprice1, a.pprice2, a.pprice4, a.pprice5").css("font-weight","normal");
		$(this).parent().next().children(".popupbackunit").children("a.pprice1, a.pprice2, a.pprice4, a.pprice5").css("color","#b7b7b7");
		$(this).parent().children("a.price3").css("background","#ffc800");
		$(this).parent().next().children(".popupback").children("a.pprice3").css("font-weight","bold");
		$(this).parent().next().children(".popupbackunit").children("a.pprice3").css("color","#000");
		var price_id = $("a.price3").attr("price_id");
		$("#price_id").val(price_id);
      });

	  $("a.price4").click(
      function () {
		$(this).parent().next().children("font.price1, font.price2, font.price3, font.price5").css("display","none");
		$(this).parent().next().children("font.price4").css("display","block");
		$(this).parent().children("a.price1, a.price2, a.price3, a.price5").css("background","none");
		$(this).parent().next().children(".popupback").children("a.pprice1, a.pprice2, a.pprice3, a.pprice5").css("font-weight","normal");
		$(this).parent().next().children(".popupbackunit").children("a.pprice1, a.pprice2, a.pprice3, a.pprice5").css("color","#b7b7b7");
		$(this).parent().children("a.price4").css("background","#ffc800");
		$(this).parent().next().children(".popupback").children("a.pprice4").css("font-weight","bold");
		$(this).parent().next().children(".popupbackunit").children("a.pprice4").css("color","#000");
		var price_id = $("a.price4").attr("price_id");
		$("#price_id").val(price_id);
      });

	  $("a.price5").click(
      function () {
		$(this).parent().next().children("font.price1, font.price2, font.price3, font.price4").css("display","none");
		$(this).parent().next().children("font.price5").css("display","block");
		$(this).parent().children("a.price1, a.price2, a.price3, a.price4").css("background","none");
		$(this).parent().next().children(".popupback").children("a.pprice1, a.pprice2, a.pprice3, a.pprice4").css("font-weight","normal");
		$(this).parent().next().children(".popupbackunit").children("a.pprice1, a.pprice2, a.pprice3, a.pprice4").css("color","#b7b7b7");
		$(this).parent().children("a.price5").css("background","#ffc800");
		$(this).parent().next().children(".popupback").children("a.pprice5").css("font-weight","bold");
		$(this).parent().next().children(".popupbackunit").children("a.pprice5").css("color","#000");
		var price_id = $("a.price5").attr("price_id");
		$("#price_id").val(price_id);
      });

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	  $("a.pprice1").click(
      function () {
		$(this).parent().parent().children("font.price2, font.price3, font.price4, font.price5").css("display","none");
		$(this).parent().parent().children("font.price1").css("display","block");
		$(this).parent().parent().prev().children("a.price2, a.price3, a.price4, a.price5").css("background","none");
		$(this).parent().children("a.pprice2, a.pprice3, a.pprice4, a.pprice5").css("font-weight","normal");
		$(this).parent(".popupbackunit").children("a.pprice2, a.pprice3, a.pprice4, a.pprice5").css("color","#b7b7b7");
		$(this).parent().parent().prev().children("a.price1").css("background","#ffc800");
		$(this).parent().children("a.pprice1").css("font-weight","bold");
		$(this).parent(".popupbackunit").children("a.pprice1").css("color","#000");
		$(this).parent(".popupbackunit").children("a.pprice1").css("font-weight","normal");
		var price_id = $("a.pprice1").attr("price_id");
		$("#price_id").val(price_id);
      });

	  $("a.pprice2").click(
      function () {
		$(this).parent().parent().children("font.price1, font.price3, font.price4, font.price5").css("display","none");
		$(this).parent().parent().children("font.price2").css("display","block");
		$(this).parent().parent().prev().children("a.price1, a.price3, a.price4, a.price5").css("background","none");
		$(this).parent().children("a.pprice1, a.pprice3, a.pprice4, a.pprice5").css("font-weight","normal");
		$(this).parent(".popupbackunit").children("a.pprice1, a.pprice3, a.pprice4, a.pprice5").css("color","#b7b7b7");
		$(this).parent().parent().prev().children("a.price2").css("background","#ffc800");
		$(this).parent().children("a.pprice2").css("font-weight","bold");
		$(this).parent(".popupbackunit").children("a.pprice2").css("color","#000");
		$(this).parent(".popupbackunit").children("a.pprice2").css("font-weight","normal");
		var price_id = $("a.pprice2").attr("price_id");
		$("#price_id").val(price_id);
      });

	  $("a.pprice3").click(
      function () {
		$(this).parent().parent().children("font.price1, font.price2, font.price4, font.price5").css("display","none");
		$(this).parent().parent().children("font.price3").css("display","block");
		$(this).parent().parent().prev().children("a.price1, a.price2, a.price4, a.price5").css("background","none");
		$(this).parent().children("a.pprice1, a.pprice2, a.pprice4, a.pprice5").css("font-weight","normal");
		$(this).parent(".popupbackunit").children("a.pprice1, a.pprice2, a.pprice4, a.pprice5").css("color","#b7b7b7");
		$(this).parent().parent().prev().children("a.price3").css("background","#ffc800");
		$(this).parent().children("a.pprice3").css("font-weight","bold");
		$(this).parent(".popupbackunit").children("a.pprice3").css("color","#000");
		$(this).parent(".popupbackunit").children("a.pprice3").css("font-weight","normal");
		var price_id = $("a.pprice3").attr("price_id");
		$("#price_id").val(price_id);
      });

	  $("a.pprice4").click(
      function () {
		$(this).parent().parent().children("font.price1, font.price2, font.price3, font.price5").css("display","none");
		$(this).parent().parent().children("font.price4").css("display","block");
		$(this).parent().parent().prev().children("a.price1, a.price2, a.price3, a.price5").css("background","none");
		$(this).parent().children("a.pprice1, a.pprice2, a.pprice3, a.pprice5").css("font-weight","normal");
		$(this).parent(".popupbackunit").children("a.pprice1, a.pprice2, a.pprice3, a.pprice5").css("color","#b7b7b7");
		$(this).parent().parent().prev().children("a.price4").css("background","#ffc800");
		$(this).parent().children("a.pprice4").css("font-weight","bold");
		$(this).parent(".popupbackunit").children("a.pprice4").css("color","#000");
		$(this).parent(".popupbackunit").children("a.pprice4").css("font-weight","normal");
		var price_id = $("a.pprice4").attr("price_id");
		$("#price_id").val(price_id);
      });

	  $("a.pprice5").click(
      function () {
		$(this).parent().parent().children("font.price1, font.price2, font.price3, font.price4").css("display","none");
		$(this).parent().parent().children("font.price5").css("display","block");
		$(this).parent().parent().prev().children("a.price1, a.price2, a.price3, a.price4").css("background","none");
		$(this).parent().children("a.pprice1, a.pprice2, a.pprice3, a.pprice4").css("font-weight","normal");
		$(this).parent(".popupbackunit").children("a.pprice1, a.pprice2, a.pprice3, a.pprice4").css("color","#b7b7b7");
		$(this).parent().parent().prev().children("a.price5").css("background","#ffc800");
		$(this).parent().children("a.pprice5").css("font-weight","bold");
		$(this).parent(".popupbackunit").children("a.pprice5").css("color","#000");
		$(this).parent(".popupbackunit").children("a.pprice5").css("font-weight","normal");
		var price_id = $("a.pprice5").attr("price_id");
		$("#price_id").val(price_id);
      });

		show_basket_info();
	  $("a.qwa").click(
      function () {
		$(this).parent().next().children("div.popupback").toggleClass("yesshow");
      });
			


	  $(".cartpopup").click(
		
      function () {
		var this_form = $(this).closest('form'); 
		var form_params=get_form_params(this_form);
		form_params['event']="add_to_basket_short";
		$.post("/cgi-bin/dsp.pl", form_params, 
					function(data) {	
						show_basket_info();
					}
		);
		$(this).next("div.cartbackpopup").addClass("yesshow");
		return false;
	});

	  $(".cartbackpopupclose").click(
      function () {
		$(this).parent().parent("div.cartbackpopup").removeClass("yesshow");
      });	  
		$(".close_dop_price").click(
      function () {
		$(this).parent().parent("div.popupback").removeClass("yesshow");
      });

});
