
function switch_image_data()
{
    var imgid = this.id.replace('img','');
    for (img in imagedata)
    {
	if (imagedata[img].id == imgid)
	    {
		var image = $("#image");
		image.attr("src", imagedata[img].path);
		image.attr("alt", imagedata[img].alt);
		image.attr("title", imagedata[img].title);
		$("#text").html(imagedata[img].text);
	    }
    }
    $("#thumbnails>span").each(function(){
				   $(this).attr("class","");
			       });
    $(this).parent().attr("class","chosen");
}
function get_url()
{
    return window.location.href.split('?')[0];
}

function change_order_nr(event)
{
    var url = get_url();
    var id = this.id;
    $.get(url,
	  {
	      ajax: event.data.way,
	      id: id
	  },
	  function(data){
	      if (data.success){
		  $('#' + id + '_middle_nr').html(data.nr);
		  $('#' + id + '_right_nr').html(data.nr);
		  $('.items #' + id + '_price').html(data.price);
		  $('.items .total_price').each(function(){
							$(this).html(data.total_price);
						});
	      }

	  },
	  'json'
	 );
}

function kill_order()
{
    var url = get_url();
    var id = this.id;
    $.get(url,
	{
	    ajax: 'kill_suborder',
	    id: id
	},
	  function(data){
	      if (data.success){
		  $("." + id + "_suborder").each(function(){
							 $(this).remove();
						 });
		  $(".items .total_price").each(function(){
						    $(this).html(data.total_price);
						});
	      };
	  },
	  'json'
    );
}