$(document).ready( function (){

    $('#elements').jcarousel({
	scroll: 4,
	auto: 3,
	animation: 'slow',
	wrap: 'both'
    });
	
	$('a.images_view').fancybox();
	
	
	/* Внешние ссылки в новых окнах > */
	
	$('a[rel=external]').bind('click', function(){
		
		window.open($(this).attr('href'));
		return false;
		
	});
	
	
	/* отчистка и замена полей при вводе логина > */
	
  	  $('#id_username').bind("focus", function(){
  	  
  	  	$(this).val('');
		$(this).unbind('focus');
  	  	
  	  });
  	  
  	  $('#id_password').bind("focus", function(){
  	  
  	  	$(this).each(function(){

  			var name = $(this).attr('name');
  			var id = $(this).attr('id');
  			
  			var html = '<input type="password" name="'+name+'" id="' +id+ '" value="" class="textfield" />';
  			$(this).after(html).remove(); 
  			
		});
		
		$('#id_password').focus();
		$(this).unbind('focus');
  	  });

	
	/* ajax голосование */
	
	$('#opros-form').bind('submit', function(){

		$.ajax({ 
		  url: $('#opros-form').attr('action'),
		  type: "POST",
          data: ({
		  	
			choice : $('#opros-form > p > input:checked').val(),
		  	json : 1
		  
		  }),
		  dataType: "json",
		  success: function(data) {
    		
			if (data.error_msg != 'null') {
				$('#opros-inner').html(data.rendered_poll);
			}
  		  }		
		});
		
		return false;
	});

	$('#forum-index > tbody > tr:odd').css('background-color','#eee');
	$('#forum-detail > div.forum-post:odd').css('background-color','#f5f5f5');
}); 

