$(document).ready(function(){

  	$('.new_selector').click(function()
          	{
          	var id=$(this).attr('rel');
          	var url=$(this).attr('url');
          	location.hash = url;
           	$('img.nhs_borders').css('visibility','hidden');
           	$('img.nhs_borders').css('visibility','hidden');
           	$('li.news_header_sel').addClass('link');
           	$('li.news_header_sel').removeClass('news_header_sel');

            $('#nhsl_'+id).css('visibility','visible');
            $('#nhsr_'+id).css('visibility','visible');
            $(this).parent("li").removeClass('link');
            $(this).parent("li").addClass('news_header_sel');

			get_list_news(id,0);

			scroll($('h1.title'));

          	return false;
          		});





            if(location.hash)
            {
            var h =location.hash;
            var h = h.split('&');
            var type= h[0];
            type = type.substring(1);
            $('img.nhs_borders').css('visibility','hidden');
           	$('img.nhs_borders').css('visibility','hidden');
           	$('li.news_header_sel').addClass('link');
           	$('li.news_header_sel').removeClass('news_header_sel');

            $('#nhsl_'+type).css('visibility','visible');
            $('#nhsr_'+type).css('visibility','visible');
            $('#news_'+type).removeClass('link');
            $('#news_'+type).addClass('news_header_sel');

           scroll($('h1.title'));
           get_list_news(type,0);
            	}
            else
            {
            var type= 'all-news';
            $('img.nhs_borders').css('visibility','hidden');
           	$('img.nhs_borders').css('visibility','hidden');
           	$('li.news_header_sel').addClass('link');
           	$('li.news_header_sel').removeClass('news_header_sel');

            $('#nhsl_'+type).css('visibility','visible');
            $('#nhsr_'+type).css('visibility','visible');
            $('#news_'+type).removeClass('link');
            $('#news_'+type).addClass('news_header_sel');

            get_list_news('',0);            	}





});


	function news_datepicker(div)
	{
	$.datepicker.setDefaults($.extend({showMonthAfterYear: false}, $.datepicker.regional['ru']));

	$('.dpicker').slideUp();
	$("#"+div).slideToggle();
	var hdiv='datetill';
		if(div=='datepicker_from') hdiv='datefrom';

     $("#"+div).datepicker({
      	onSelect:function(dt)
      	{
				var date = $.datepicker.formatDate('dd.mm.yy', new Date(dt));
				$('#'+hdiv).html(date);
				$(this).slideUp();      		},
      	 dayNamesMin: ['пн', 'вт', 'ср', 'чт', 'пт', 'сб', 'вс'],
      	 monthNames: ['Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь']
     });



	return false;		}


  function get_list_news(type,pg)
   {
						 $.ajax({
                           	url:'/modules/news/ajax/list_news.php',
                           	dataType: 'html',
                           	data: 'type='+type+'&pg='+pg,
                           	type: 'POST',
                           	success: function(data,status)
                           	{
                             	$('#news_content').html(data);
                           	}
      					});

      					return false;
   	}


   	function showNews(id)
{
			if($('#ft_'+id))
			{
				$('#ft_'+id).slideToggle("slow");
				location.hash=id;
				}
			return false;

}