(function($){
	$(document).ready(function() {
		$('div.survey-slider').livequery(function(){
			$(this).each(function() {
				var inputValue = parseInt($(this).nextAll('input.survey-slider').val(),10);
				var startValue = inputValue ? inputValue : 0;
				$(this).slider({
					range:'min',
					min:0,
					max:100,
					step:1,
					value: startValue,
					disabled: $(this).nextAll('input.survey-slider').is(':disabled'),
					slide: function(event, ui) {
						$(this).nextAll('input.survey-slider').val(ui.value);
					},
					start: function(event, ui) {
						$(this).nextAll('input.survey-slider').val(ui.value);
					}
				});
			});
		});
		
		$('input.radio-text[type="radio"]').livequery(function(){
			$(this).click(function(){
				if ($(this).val() == '0') {
					$(this).parent().nextAll('input[type="text"]:first,textarea:first').attr('disabled', 'disabled');
				} else {
					$(this).parent().nextAll('input[type="text"]:first,textarea:first').removeAttr('disabled');
				}
			});
		});
		$('h1.survey').livequery(function(){
			$(this).find('#form-select').change(function() {
				$('input[name="nextForm"]' ,'.survey-block form').val($(this).attr('disabled', 'disabled').val());
				$('.survey-block .eview-block-content form').submit();
			});
		});
	});
})(jQuery);
