$(document).ready(function() {

	$('.voice_header span').removeClass('down');
	$('.voice_header span').addClass('right');
	$('.voice_block .content_inside_text').hide();
		$('.voice_block2 .content_inside_text').hide();
	
	$('.voice_block li .voice_header').click(function() {
	    id = $(this).parents().attr('id');
		head_class = $('#'+id+' .voice_header span').attr('class');
		if (head_class=="question down") {
			hideVoiceBox(id);
		}else {
			showVoiceBox(id);			
		}
	});
		$('.voice_block2 li .voice_header').click(function() {
	    id = $(this).parents().attr('id');
		head_class = $('#'+id+' .voice_header span').attr('class');
		if (head_class=="question down") {
			hideVoiceBox(id);
		}else {
			showVoiceBox(id);			
		}
	});
	
	firstid = $('.voice_block li').first().attr('id');
	showVoiceBox(firstid);
	firstid = $('.voice_block2 li').first().attr('id');
	showVoiceBox(firstid);

	

  $('form').submit(function() {
    id = $(this).attr('id');
    targetid = id.replace('form', '');	
	var options = { 
        target: '#'+targetid
    }; 
    $('#'+id).ajaxSubmit(options); 
    return false;
  });
  
  $('input:button').click(function() {
    id = $(this).attr('id');
	//alert(id);
    targetid = id.replace('result', '');
    $('#'+targetid+'form input[name*=vote]').val('false');	
	var options = { 
        target: '#'+targetid
    }; 
    $('#'+targetid+'form').ajaxSubmit(options); 
  });
  
  $('.vopros span').hide();
  
  $('.vopros').hover(function() {
    id = $(this).attr('id');
    $('#'+id+' span').show();
  
  }, function() {
    id = $(this).attr('id');
    $('#'+id+' span').hide();
  });


});

function showVoiceBox(id) {
	$('#'+id+' .voice_header span').removeClass('right');
	$('#'+id+' .voice_header span').addClass('down');
	$('#'+id+' .content_inside_text').show("slow");
}

function hideVoiceBox(id) {
	$('#'+id+' .voice_header span').removeClass('down');
	$('#'+id+' .voice_header span').addClass('right');
	$('#'+id+' .content_inside_text').hide(800);
}



