$(document).ready(function() 
{
	//taby vpravo
	
	$('#tabs a').click(function(){showTab(this);return false;});
	var current_tab = $('#tabs li a:first').attr('id');
	
	function showTab(elem)
	{
		clicked_tab_name = $(elem).attr('id');
		
		$('#'+current_tab).attr('class','');
		$(elem).attr('class','active');
		
		//zobrazenie obsahu
		$('.'+current_tab).hide();
		$('.'+clicked_tab_name).show();
		
		current_tab = clicked_tab_name;
	}
	
	
	var form_data = $('#poll_form').serializeArray();
	
	//abecedny zoznam firiem
    $('#comp_letter a').click(function(){getCompanyByLetter(this);return false;});
	
	function getCompanyByLetter(elem)
	{
        $.ajax({
            type: "GET",
            url: "/getCompany.php?letter="+$(elem).text(),
            success: function(msg)
            {
                $('#comp_letter_result').html(msg);
            }
        });
    }
    
    //anketa
    $('.poll_vote').click(function(){pollVote(this);return false});
	
	function pollVote(elem)
	{
		var form_data = $('#poll_form').serializeArray();
		$.ajax({
			   type: "GET",
			   url: "/anketa/vote.php",
			   url: $(elem).attr('href'),
			   success: function(msg)
			   {
					$('#poll_form').html(msg);
					$('.poll_vote').unbind();
					$('.poll_vote').click(function(){pollVote(this);return false});
			   }
		   });	
	}
	
	
    
});