	var ie = $.browser.msie;
	var ie8 = $.browser.msie && /MSIE (8).+Win/.test(navigator.userAgent) ;
	var ie7 = $.browser.msie && /MSIE (7).+Win/.test(navigator.userAgent) && !/MSIE (8).+Win/.test(navigator.userAgent) ;
	var ie6 = $.browser.msie && /MSIE (6).+Win/.test(navigator.userAgent) && !/MSIE (7|8).+Win/.test(navigator.userAgent);

jQuery.fn.horoscope = function () {
	$('.horo select').change(function () {
		$('.horo select option:selected').each(function () {
				str = $(this).text();
				id = $(this).attr('id').split("_")[1]/1;
			});
		$('.horo-znak').attr('id', 'zn_' + id);
		if (!ie6) { $('.horo .horo-ann p').fadeOut('fast'); } else { $('.horo .horo-ann p').hide(); }
		if (!ie6) { $('.horo .horo-ann #ann_' + id).fadeIn('fast'); } else { $('.horo .horo-ann #ann_' + id).show(); }
		//console.log($('.horo .horo-ann #ann_' + id).text());
		})
		.change();
}

//Декорация для Зоны отдыха
jQuery.fn.zoneo = function () {
		$('.zentry .inf a').append('<i class="hover"></i>');
		$('.zentry .inf a').hover(function(){
			//console.log($('i',this).next().html());
			$('i',this).stop().animate({ 
				'opacity': 0.5,
				'borderWidth': '5px',
				'width':'170',
				'height':'100'
				}, 100, 'easeInExpo')
		}, function() {
			$('i',this).stop().animate({ 
				'opacity': 0.25,
				'borderWidth': '1px',
				'width':'178',
				'height':'108'
				}, 100, 'easeOutExpo')
		});

}

// Флеш-баннеры
// Синтаксис:
// <div class="adv b" rel="banner.swf|160|105|http://ya.ru|_self"><a href="http://ya.ru"><img src="banner.gif" width="160" height="105" /></a></div> 
jQuery.fn.bnx = function () {
	$('div.adv.flash').flash(
		null, null,
		function(htmlOptions) {
			var $this = $(this);
			var params = $this.attr('rel').split('|');
			htmlOptions.src = params[0]; //путь
			htmlOptions.width = params[1]; //ширина
			htmlOptions.height = params[2]; //высота 
			htmlOptions.flashvars.link1=params[3]; //урл
			htmlOptions.flashvars.trg1=params[4]; //открывать в новом или текущем окне
			htmlOptions.wmode = 'opaque';
			htmlOptions.version = 7;
			htmlOptions.expressInstall = true;
			this.innerHTML = '';
			$this.prepend($.fn.flash.transform(htmlOptions));
		});
	}


// Хинты для input
jQuery.fn.hint = function (blurClass) {
	if (!blurClass) { blurClass = 'blur'; }
	return this.each(function () {
	// get jQuery version of 'this'
	var $input = $(this),

	// capture the rest of the variable to allow for reuse
	title = $input.attr('title'),
	$form = $(this.form),
	$win = $(window);

	function remove() {
		if ($input.val() === title && $input.hasClass(blurClass)) {
			$input.val('').removeClass(blurClass);
		}
	}

	// only apply logic if the element has the attribute
    if (title) { 
      // on blur, set value to title attr if text is blank
      $input.blur(function () {
        if (this.value === '') {
          $input.val(title).addClass(blurClass);
        }
      }).focus(remove).blur(); // now change all inputs to title
      
      // clear the pre-defined text when form is submitted
      $form.submit(remove);
      $win.unload(remove); // handles Firefox's autocomplete
    }
  });
}



jQuery.fn.pnav= function () {
	$('li.share').find('a').click(function(){
		var t = $(this).html();
		$.prettyPhoto.open(
			['#share'],
			[t],
			['bashvest.ru']
		);
		return false;
		});
}

//Версия для печати
jQuery.fn.print = function () {
	$('<div class="print printcopy">' 
		+ $('#footer .copyright').html() 
		+ '</div>')
		.appendTo('body');
	$('<div class="ph">' 
		+ $('.meta.photo').html() 
		+ '</div>')
		.appendTo('.article-gallery-scroll');

	$('.printv').click(function(){
		$('#styles').attr({
			href:'/.static/css/print.css'
			});
		window.print();
		return false;
		});
	$('.evclose').click(function(){
		$('#styles').attr({
			href:'/.static/css/master.css'
			}); 
		return false;
		});
	$('.evprint').click(function(){
		window.print();
		return false;
		});
};

//Постраничная навигация по ctrl+клик 
jQuery.fn.pagination = function () {
	var linkPrev = $("#nav_prev").attr("href");
	var linkNext = $("#nav_next").attr("href");

	$(".pagination span").find("b").show();
	$(document).bind('keydown', 'ctrl+left', function(){ if (linkPrev) {location.href = linkPrev;} });
	$(document).bind('keydown', 'ctrl+right', function(){ if (linkNext) {location.href = linkNext;} });
	$(document).bind('keydown', 'ctrl+down', function(){ if (linkNext) {location.href = linkNext;} });
	$(document).bind('keydown', 'ctrl+up', function(){ if (linkPrev) {location.href = linkPrev;} });
}

//Скролл-галерея в статьях + полноэкранный просмотр фото
jQuery.fn.galleryscroll = function (s) {
		//var s = '.article-gallery-scroll';
		n = $('.items li').length;
		//console.log(n);
		t = '1/' + n;
		$('#nn').text(t);
		var s = $(s);
		//s.show();
		s.hover(function(){
				$(this).find('.loupe').fadeIn();
			},
			function(){
				$(this).find('.loupe').fadeOut();
			});
		
		s.scrollable({  
			size: 1,
				next:'#next',
				prev:'#prev',
			speed:200,
				items:'ul.items',
			onSeek: function() {
					var position = (this.getIndex()+1).toString();
					var size = this.getItems().size();
					$('#nn').text(position + ' / ' + size);
					//alert(position + ' / ' + size);
				}
				});

		s.find('a[rel^="prettyPhoto"]').prettyPhoto({
			animationSpeed:'fast',
			theme: 'facebook',
			slideshow:2500
			});
	}

//Слоты (известный голос)
jQuery.fn.slots = function (th) {
	//var i = Math.floor(Math.random() * $(th).find("li").length)
	//$(th).find("li, div").removeClass("here");
	//$(th).find("li:eq(" + i + "), .slot-item:eq(" + i + ")").addClass("here");
	
	$(th).find("li").hoverIntent({
		sensitivity: 5,
		interval: 50,
		over: function(){
			if($(this).hasClass("here")){}
			else {
				$(th).find("li").removeClass("here");
				$(this).addClass("here");
				tid = $(this).attr("id");
				//console.log(tid);
				if ($.browser.msie && 6 >= parseInt($.browser.version)) { 
					$(th).find(".slot-item:visible").removeClass("here");
					$(th).find("#slot"+tid).addClass("here");
					}
				else { 
					$(th).find(".slot-item:visible").fadeOut(200).removeClass("here");
					$(th).find("#slot"+tid).fadeIn(200).addClass("here");
					}
			}
		},
		timeout: 50,
		out: function(){}
	});
}


jQuery.fn.fading = function (s,time) {
	var time=(!time?($.browser.safari?300:200):null);

	// Basic hover functions, fading stuff
	$(s)
	.each(function() {$(this).prepend('<i class="fade"></i>')})
	.hover(function() { 
		$('.fade',this).stop().animate({ 
			'opacity': 1
			}, time);
	}, function() {
		$('.fade',this).stop().animate({ 
			'opacity': 0
			}, time)
			//console.log(time);
			})
	.find('.fade').css('opacity', 0);
}

jQuery.fn.fade2 = function (s, o) {
		if (!o) o = '0.3';
		if (!s) s = '.counters img';
		$(s)
			.each(function() {
				$(s).css('opacity', o);
				$(s).mouseover(function(eventObject) { 
						$(this).stop().animate({ opacity: 1 }, 200); 
					}).mouseout(function(eventObject) { 
						$(this).stop().animate({ opacity: o }, 200); 
					});
			});
	}

jQuery.fn.fixedblock = function (s) {
		var s = $('.article-gallery');
		var offset = s.offset();
		var poss = s.position();
		//console.log();
        actualtop = offset.top;
        $(window).scroll(function() {
            //horizontal position
            current = $(this).scrollTop();
            winw = $(window).width();
            if(current<actualtop){
                toscroll = 0;
                    if(winw<1000){leftt = 0;}
                    else{leftt = 30+ (winw-1000)/2;}
                    leftt = poss.left;
                    s.css('position', 'absolute').css('right', 'auto').css('left', leftt+'px');   
                }
            else{
                if(winw<1000){leftt = 0;}
                else{leftt = 30+ (winw-1000)/2;}
                toscroll = current-actualtop+10; s.css('position', 'fixed').css('right', 'auto').css('left', leftt+'px');
                }
                //hiding vertical
                if(current>(actualtop-200+$('.content').height())){
                    s.hide();
                }
                else{
                    s.show();
                }
        });

	}




$(function(){

/*
	$("ul").each(function(i) {
		var ul = $(this);
		ul.find("li:first").addClass("first").end().find("li:last").addClass("last");
		ul.find("li").each(function(x) {
			if (x % 2 == 0) { $(this).addClass("even"); }
			if (x % 2 == 1) { $(this).addClass("odd"); }
			if (x % 4 == 3) { $(this).addClass("xdoubleEven"); }	
			})
	})
*/
	$.fn.slots('.content-topslots');
	$.fn.slots('.vox');
	$.fn.bnx();

	if(!ie6) {
		$.fn.fading('.cats li a');
		}


	$.fn.fade2('.counters img', 0.25);

	$('.voteresults').click(function(){
			var t = $('form').hasClass('showresults');
			$('.poll form').toggleClass('showresults');
			$('.voteresults').html(t ? 'Результаты' : 'Проголосовать');
			return false;
		});

	//$.fn.print();
	$.fn.pnav();
	if (!ie6) { $.fn.zoneo(); }
	$.fn.horoscope();
	$.fn.print();

	$('input[title!=""], textarea[title!=""]').hint();
	$("input[type='submit'], input[type='reset']").each(function(i) {
		$(this).addClass("btn");
	})




});



$(document).bind('keydown', 'ctrl+up', function(){
		//openFeedback();
		});
$(document).bind('copy', function(e){ alert($('#footer .copyright').text()) })