function ChangeAction(form_id,id_param)
{
	
	var arr_send_data = {};
	var ma_params = false;
	//inputy
	var $inputs = $('#' + form_id + ' input');
	$inputs.each(function() {
		var exploded_arr = this.id.split("_");
		if (exploded_arr[0]=="par" || exploded_arr[0]=="parhid") // pokud je to cast parametru
		{
			if((this.type=='radio' && this.checked) || (this.type=='text') || (this.type=='hidden'))
			{
				var id_parametru = exploded_arr[1];
				var id_hodnoty = exploded_arr[2];

				if (!isNaN(id_parametru) && !isNaN(id_hodnoty))
				{
					arr_send_data['param[' + id_parametru + ']'] = id_hodnoty;
					ma_params = true;
				}
			}
		}
    });
	//options
	var $selects = $('#' + form_id + ' option:selected');
	$selects.each(function() {
			var exploded_arr = this.id.split("_");
			if (exploded_arr[0]=="par") // pokud je to cast parametru
			{
				var id_parametru = exploded_arr[1];
				var id_hodnoty = exploded_arr[2];

				if (!isNaN(id_parametru) && !isNaN(id_hodnoty))
				{
					arr_send_data['param[' + id_parametru + ']'] = id_hodnoty;
					ma_params = true;
				}
			}		   
    });
	if(ma_params) //pokud ma nejaky parametr vybrany :)
	{
		//IDZ
		arr_send_data['IDZ'] = $("#" + form_id + " input[name='IDZ']").val();
		
		// id parametru ktery byl zmenen
		if(id_param != undefined)
		{
			var exploded_arr = id_param.split("_");
			if (exploded_arr[0]=="par")
				arr_send_data['param_change'] = exploded_arr[1];
		}
		
		$.ajax({
				type: "GET",
				url: web_root + 'scripts/params.php',
				data: arr_send_data,
				dataType: "xml",
				success: function(xml){
					$(xml).find('Params', xml).each(function(){
					
						// popisek k kombinaci
						var html = $(this).find('textHTML').text();
						
						// pokud je nejaky popis -> zobrazim .. pokud ne -> skryji
						if(html.length > 0)				
							$("#" + form_id + " .testdiv").css('display', 'block');
						else
							$("#" + form_id + " .testdiv").css('display', 'none');
							
						// doplneni html dle dotazu
						$("#" + form_id + " .testdiv").html(html);
						
						// zobrazeni obrazku parametru -> pokud je
						if($(this).find('ObrBig').length && $(this).find('ObrMedium').length)
						{
							$("#nahled_ajax img").attr('src', $(this).find('ObrMedium').text());
							$("#nahled_ajax img").attr('jqimg', $(this).find('ObrBig').text());
						}
						else
						{
							// nastaveni vychoziho obrazku -> pokud neni
							$("#nahled_ajax img").attr('src', $("#nahled_ajax img").attr('defsrc'));
							$("#nahled_ajax img").attr('jqimg', $("#nahled_ajax img").attr('defjqimg'));
						}
						
						//zobrazeni nezobrazeni tlacitka kosik
						if($(this).find('showCart').text()==1)
							$("#" + form_id + " .add_to_cart").css("visibility", "visible");
						else
							$("#" + form_id + " .add_to_cart").css("visibility", "hidden");
							
						if(arr_send_data['param_change'] != undefined) //pokud byl primo nejaky vybran
						{
							//odnastavime vse
							$(this).find('Availability').find('Option').each(function(){
								var id_option = $(this).text().split("_");
								$('#par_' + id_option[1] + ' option').each(function(){
									$(this).removeClass('stock');
									$(this).addClass('not_stock');
								});
							});
							// nastavime bravu tem co jsou ok
							$(this).find('Availability').find('Option').each(function(){
								$("#" + $(this).text()).removeClass('not_stock');
								$("#" + $(this).text()).addClass('stock');
							});
						}
					});
				}
				});
	}

}



$(document).ready(function() {
	$("select").change(function() {
		return ChangeAction(this.form.id,this.id);
	});
	
	$("input[type='radio']").click(function() {
		return ChangeAction(this.form.id,this.id);
	});
});


