jQuery.noConflict();


jQuery(document).ready(function() 
{

	jQuery("#poll_tabs a").click(function(){displayPoll(this);return false;})
	//jQuery("#poll_tabs").mouseover(function(){alert('ok');})

	/*prepinanie zaloziek v ankete*/
	

	poll_active = 'poll';
	
	function displayPoll(sourceElement)
	{
		jQuery('#poll_tabs .active').attr('class','');
		jQuery('#'+poll_active).hide();
		
		poll_active = jQuery(sourceElement).attr('class');
		jQuery('#'+poll_active).show();
		jQuery(sourceElement).parent().attr('class','active');	
	}
	
	//kalkulacka
	jQuery('#direction').val('eur');
	//clear();
	
	jQuery("#eur").keyup(function(){result();})
	jQuery("#skk").keyup(function(){result();})
	jQuery('#eur').focus(function(){setDirection('eur');clear();});
	jQuery('#skk').focus(function(){setDirection('skk');clear();});
	
	function setDirection(direction)
	{
		jQuery('#direction').val(direction);
		
		if('eur' == direction)
		{
			jQuery('#skk').css('border','1px solid #9F8523');
			jQuery('#eur').css('border','2px solid #9F8523');
		}
		else
		{
			jQuery('#eur').css('border','1px solid #9F8523');
			jQuery('#skk').css('border','2px solid #9F8523');
		}
	}

	function result()
	{
		directio = jQuery('#direction').val();
		
		if('eur' == directio)
		{
			string_val = jQuery('#eur').val();
			
			current_val = parseFloat(string_val.replace(",", "."));
			skk_value = current_val*30.126;
			jQuery('#skk').val(skk_value.toFixed(4));
		}
		else
		{
			string_val = jQuery('#skk').val();
			current_val = parseFloat(string_val.replace(",", "."));
			eur_value = current_val/30.126;
			jQuery('#eur').val(eur_value.toFixed(4));
		}
	
	}
	
	function clear()
	{
		jQuery('#eur').val('');
		jQuery('#skk').val('');
	}
	
	jQuery("#poll_form").submit(function(){vote();return false;})
	function vote()
	{
		jQuery.ajax({
				   type: "POST",
				   url: '/components/poll/vote.php',
				   data: 'answer_id='+jQuery('#poll_id').val()+'&'+jQuery("#poll_form input:checked").serialize()+'&poll_list_id='+jQuery('#poll_list_id').val(), 
				   success: function(msg)
				   {
						jQuery("#poll").html(msg);
					 	jQuery("#poll_form").unbind();
					 	jQuery("#poll_form").submit(function(){vote();return false;});
				   },
				   error: function()
				   {
						
				   }
			   });	
			  jQuery("#poll").html('Odosiela sa hlasovanie<br />');
	}
	
	//fotogaleria - lightbox
	jQuery('a[@rel*=lightbox[fotoshow]').lightBox();
	jQuery('a[@rel*=lightbox[rel-]').lightBox();
	jQuery('a[@rel*=lightbox[gal-]').lightBox();
	//jQuery('a[@rel*=lightbox[gal]').lightBox();
	
	//alert(jQuery("actual_slider").css('height'));
	
	
	/*jQuery("#actual_slider").animate(
			{
				top: '90px'
			}, 1000, 'linear', function()
				{
				}
		);*/
		
		
		
});

setInterval("jQuery.fn.animateAktual()", 3 * 1200);


jQuery.fn.animateAktual = function()
		{

  		var current_frame = jQuery("#current_frame");
		var next_frame = jQuery("#current_frame").next();

		if(null == next_frame.html())
		{
			all_frames = jQuery("#current_frame").parent().children();
			next_frame = jQuery(all_frames[0]);
		}
		
		next_frame.css('top','0');

		current_frame.animate(
			{
				top: '-100px'
			}, 500, 'linear', function()
				{
					next_frame.fadeIn(400);
					current_frame.attr('id','');
					current_frame.hide();
					next_frame.attr('id','current_frame');
				}
		);
};

