var wpTestTimerInt;
var wpTestMaxTime;
jQuery(document).ready(function(){
	jQuery('.wp_test_custom_question_form').each(function(i,f){
		jQuery('.wp_test_custom_answer',jQuery(f)).click(function(){
			jQuery(f).submit();
			});
		});
	jQuery('.wp_test_custom_timer').each(function(i,t){
		wpTestMaxTime = jQuery(t).attr('rel');
		if (!wpTestMaxTime) return;
		jQuery(t).append('<div></div>');
		jQuery(t).append('<span>' + wpTestMaxTime + '</span>');
		var d = jQuery('.wp_test_custom_timer div');
		var p = function(){
			var s = jQuery('.wp_test_custom_timer span').text();
			if (s>0) jQuery('.wp_test_custom_timer span').text(s-1);
			else clearInterval(wpTestTimerInt);
			};
		wpTestTimerInt = setInterval(p, 1000);
		d.animate({'left': 0}, wpTestMaxTime * 1000, 'linear', function(){
			jQuery('.wp_test_custom_question_form').submit();
			});
		});
	});

