
$(document).ready(function(){
		blocks();
		$("#dataInputs").hide();
		$(".articles_of_avtor").hide();
			
			$("#nav-one li").hover(
				function() { $("ul", this).fadeIn("fast"); }, 
				function() { $("ul", this).fadeOut("fast"); } 
			);
	  	if (document.all) {
				$("#nav-one li").hoverClass ("sfHover");
			}
	  });
	  
		$.fn.hoverClass = function(c) {
			return this.each(function(){
				$(this).hover( 
					function() { $(this).addClass(c);  },
					function() { $(this).removeClass(c); }
				);
			});
		
	$("#loading").bind("ajaxSend", function(){
        $(this).show(); 
    }).bind("ajaxComplete", function(){
        $(this).hide(); 
    });
		}  

function openDateInputs() {
      var checkElement = $("#dataInputs");
      if(checkElement.is(':visible')) {
	  	$(checkElement).slideUp('fast');
        return false;
        }
      if(!checkElement.is(':visible')) {
        checkElement.slideDown('fast');
        return false;
        }
 }

 
 function openDiv() {
	 $('.blocklink').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('div')) && (checkElement.is(':visible'))) {
	  	$(checkElement).slideUp('normal');
        return false;
        }
      if((checkElement.is('div')) && (!checkElement.is(':visible'))) {
        //$('#accordion div:visible').slideUp('normal');
        checkElement.slideDown('normal');
        return false;
        }
      }
    );

 }
 
function showAllArticles(avID, number) {
	checkElement = '#all'+avID;
	closeElement = '#close'+avID;
	heightWin = parseInt(number) * 3.5 + 3;
	if (heightWin > 25) heightWin = 25;  
	heightWin = heightWin + 'em';  
	  if($(checkElement).is(':visible')) {
	  	$(checkElement).slideUp('normal');
	  	$(closeElement).hide();
        return false;
        }
      if(!$(checkElement).is(':visible')) {
		$(checkElement).load("/service/all_articles_of_author/", {avtor_id:avID});
		$(checkElement).css( "height", heightWin);
        $(checkElement).slideDown('normal');
	  	$(closeElement).show();
        return false;
        }

}

function onAjaxSuccess(avID, data)
{
//$(data).appendTo(div);
alert(data);
}
 
 function blocks() {
  $('#content-hp h2').click(
    function(event) {
      var checkElement = $(this).next();
      if((checkElement.is('div')) && (checkElement.is(':visible'))) {
	  	$(checkElement).slideUp('normal');
		$(this).css( "background-image", "url(/images/rusk/plus.gif)" );
        return false;
        }
      if((checkElement.is('div')) && (!checkElement.is(':visible'))) {
        //$('#accordion div:visible').slideUp('normal');
        checkElement.slideDown('normal');
		$(this).css( "background-image", "url(/images/rusk/minus.gif)" );
        return false;
        }
      }
    );
	$('#content-hp h2 a').click(
		function(event) {
			event.stopPropagation();
			return true;
		}
	);
  }
  
  
  function showDayArticles(razd, day, elem) {
	checkElement = elem;
	showElement = '#DayArticles';
	closeElement = '#NewsOfDay';
	
	$("#news-hplink a").attr('class', ''); 
	$(checkElement).attr('class', 'active');
	$("#news-hplink a:last[@class=active]").attr('class', 'active leftlink');
	$(closeElement).hide('normal');
	$(showElement).show('normal');
	$(showElement).html('<div id="loading">Идет загрузка...</div>');
	$(showElement).load("/service/articles_of_day/", {razd:razd, day:day});
      return false;
}
  
  function showArticlesOfDay(daypath, elem, template, razd, showElement, closeElement, limit, ball_min, ball_max, newsofday) {
	checkElement = elem;
	checkElements = razd+' a';
	checkElementLast = razd+' a:last[@class=active]';
	$(checkElements).attr('class', ''); 
	$(checkElement).attr('class', 'active');
	$(checkElementLast).attr('class', 'active leftlink');
	$(closeElement).hide('normal');
	$(showElement).show('normal');
	$(showElement).html('<div id="loading">Идет загрузка...</div>');
	$(showElement).load("/service/articles_of_day/", {daypath:daypath, template:template, limit:limit, ball_min:ball_min, ball_max:ball_max, newsofday:newsofday});
      return false;
}

function BlindUp() {
	$("#print_bar").hide();
	}


