function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;

//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += "    ";

if(typeof(arr) == 'object') { //Array/Hashes/Objects
 for(var item in arr) {
  var value = arr[item];
 
  if(typeof(value) == 'object') { //If it is an array,
   dumped_text += level_padding + "'" + item + "' ...\n";
   dumped_text += dump(value,level+1);
  } else {
   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
  }
 }
} else { //Stings/Chars/Numbers etc.
 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
return dumped_text;
} 



function pool_selector(pool_products_id)
{
	$(".pool_selector").removeClass("active");
	$(".pool_selector_" + pool_products_id).addClass("active");
	
	$("#form_pool_products_id").val(pool_products_id);	
	
	pool_winterzeil_calc(2);
}

function poolcover_selector(products_id)
{
	$(".poolcover_selector").removeClass("active");
	$(".poolcover_selector_" + products_id).addClass("active");
	
	$("#form_cover_products_id").val(products_id);
	$(".dummy_button_cover").attr("checked","");
	$("#dummy_button_cover_" + products_id).attr("checked",true);		
	
	pool_winterzeil_calc(4);
}

function poollocker_selector_old(products_id)
{
	$(".poolclocker_selector").removeClass("active");
	$("._" + products_id).addClass("active");
	
	$("#form_locker_products_id").val(products_id);			
	$(".dummy_button_locker").attr("checked","");
	$("#dummy_button_locker_" + products_id).attr("checked","checked");	
	
		
	pool_winterzeil_calc(5);
}

function poollocker_selector(lockers, msg)
{
	var total = 0;
	$(".locker_products_ids").each(function (i) {
		total += parseFloat($(this).val());
	});

	if (total == lockers) pool_winterzeil_calc(5);


}

function pool_winterzeil_calc(step)
{
	$("#step_load_" + step).html('<img src="images/txgn/loading.gif" />');

	products_id = $("#form_products_id").val();
	option_custom_length = $("#form_option_custom_length").val();
	option_custom_width = $("#form_option_custom_width").val();
		
	var post_data = new Array();
	$.each($("input"), function(){
		post_data += "&" + $(this).attr("name") +"="+ $(this).val();
	});
	$.each($("select"), function(){
		post_data += "&" + $(this).attr("name") +"="+ $(this).val();
	});
	if ($("#cover_categories_id").val() != undefined) post_data += "&cover_categories_id="+ $("#cover_categories_id").val();
	post_data += "&coupon="+ $("#coupon").val();

	$("#step_load_" + step).load("category_97.php?step=" + step + " #step_" + step, post_data, function(data){
		$.scrollTo(("#step_load_" + step), 800);
	 });
	
}



function pool_selector_181(pool_products_id)
{
	$(".pool_selector").removeClass("active");
	$(".pool_selector_" + pool_products_id).addClass("active");

	$("#form_pool_products_id").val(pool_products_id);

	pool_calc_181(2);
	pool_calc_181(3);
	pool_calc_181(4);	
}

function pool_calc_181(step, urladd)
{

	if ((step == 5) && ($("input#option_custom_d1").val() == "")) 
	{
	
	}
	else
	{

		$("#step_load_" + step).html('<img src="images/txgn/loading.gif" />');
	
		products_id = $("#form_products_id").val();
		option_custom_length = $("#form_option_custom_length").val();
		option_custom_width = $("#form_option_custom_width").val();
	
		var post_data = new Array();
		$.each($("input"), function(){
			post_data += "&" + $(this).attr("name") +"="+ $(this).val();
		});
		$.each($("option"), function(){
			post_data += "&" + $(this).attr("name") +"="+ $(this).val();
	
			 $('option', this).each(function() {
			 	alert($(this).val());
			} );
	
		});
		
		post_data += "&coupon="+ $("#coupon").val();
		if (urladd) post_data += "&" + urladd;
		
		$("#step_load_" + step).load("category_181.php?step=" + step + " #step_" + step, post_data, function(data){ });
	}

}

function pool_calc_181_steps_end()
{
	var d1 = parseFloat($(".option_custom_d1").val().replace(",", "."));

	var step_end_a = 0;
	$.each($("input.option_custom_ha"), function(){
		step_end_a += parseFloat($(this).val().replace(",", "."));
	});
 
	$(".step_height_end_a_field").val(d1-step_end_a);
	//$(".step_height_end_a").html(d1-step_end_a);
	
	var step_end_b = 0;
	$.each($("input.option_custom_hb"), function(){
		step_end_b += parseFloat($(this).val().replace(",", "."));
	});
	$(".step_height_end_b_field").val(d1-step_end_b);
	//$(".step_height_end_b").html(d1-step_end_b);
}

function poolliner_selector(products_id)
{
	$(".poolcliner_selector").removeClass("active");
	$("._" + products_id).addClass("active");
	
	$("#form_liner_products_id").val(products_id);			
	$(".dummy_button_liner").attr("checked","");
	$("#dummy_button_liner_" + products_id).attr("checked","checked");	
	pool_calc_181(6);	
}