/*
 * convertSliderQuestions
 * @param image path (needed for the handler)
 *
 */
function convertSliderQuestions(image_path) {
	/*
	 * iterate over all questions
	 */
	$$(".container-sliderQuestion .options").each(function(container) {
		
		// select all radio buttons
		var inputs				= container.select("input");
		
		// currently checked value
		var input_checked_value	= container.select("input:checked")[0].getValue();
		
		// remove radio buttons from the DOM
		container.select("input").invoke("remove");
		
		var question_id		= inputs[0].getAttribute("id").split("_")[2];
		var thesis_id		= inputs[0].getAttribute("id").split("_")[3];
		var uid_suffix		= question_id + "_" + thesis_id;
		
		// id's needed for custom slider
		var filler_id		= "filler_" + uid_suffix;
		var track_id		= "track_" + uid_suffix;
		var handle_id		= "handle_" + uid_suffix
				
		/*
		 * create hidden fields to keep track of selected value
		 */
		var input_hidden_id = "question_slider_" + question_id + "_" + thesis_id + "";
		container.up("form").insert({"bottom": new Element('input', {
			'type'	: 'hidden',
			'id'	: input_hidden_id,
			'name'	: "questions[slider][" + question_id + "][" + thesis_id + "]",
			'value'	: input_checked_value
			}
		)});
		
		/*
		 * create elements for custom slider, apply them to the DOM and initialize the slider
		 */
		var wrap		= new Element('div', { 'id': "wrap_" + uid_suffix, 'class': 'wrap'});
		var filler		= new Element('div', { 'id': filler_id, 'class': 'filler'});
		var track		= new Element('div', { 'id': track_id, 'class': 'track'});
		var handle		= new Element('div', { 'id': handle_id, 'class': 'handle'});
		var handle_img	= new Element('img', { 'src': image_path + 'slider-images-handle.png'});
		
		handle.insert(handle_img);
		track.insert(handle);
		filler.insert(track);
		wrap.insert(filler);
		container.insert(wrap);
				 
		new Control.Slider(handle_id, track_id, {
			range		: $R(0, inputs.length-1),
			values		: $R(0, inputs.length-1),
			sliderValue	: input_checked_value,
			startSpan	: filler_id,
			onChange	: function(v) {
               $(input_hidden_id).value = v;
           }
		});
	});
} // end convertSliderQuestions()