﻿try {
var $j = jQuery.noConflict();

$j(document).ready(function() {
		$j("#topnav li.page_item").append("<br/><span></span>"); //Throws an empty span tag right before the a tag
		$j("#topnav li.page_item").each(function() { //For each list item...
			if ($j(this).attr("class").indexOf("current_page_item") >= 0) {
				$j(this).removeClass("page_item");					// фикс активного элемента
				if (navigator.userAgent.indexOf("Opera") != -1) {
					var w = $j(this).innerWidth() - (parseInt($j(this).css('padding-right')) || 0) - ( parseInt($j(this).css('padding-left')) || 0)
					var s = w+24+"";
					$j(this).css("width", s);
				} else {
					$j(this).width($j(this).width()+24);
				}
			} else {
				if ($j(this).attr("class").indexOf("current_page_parent") >= 0) {
					$j(this).removeClass("page_item");
					if (navigator.userAgent.indexOf("Opera") != -1) {
						var w = $j(this).innerWidth() - (parseInt($j(this).css('padding-right')) || 0) - ( parseInt($j(this).css('padding-left')) || 0)
						var s = w+24+"";
						$j(this).css("width", s);
					} else {
						$j(this).width($j(this).width()+24);
					};
				} else {
					var linkText = $j(this).find("a").html(); //Find the text inside of the a tag
					$j(this).find("span").show().html(linkText); //Add the text in the span tag
				}
			};
		});
		$j("#topnav li.page_item").hover (function() {
			$j(this).animate({marginTop: "0"}, 350);
		}, function() {
			$j(this).animate({marginTop: "-44",}, 350)
		});
		$j("#toTop").click(function () {
			$j('body,html').animate({
				scrollTop: 0
			}, 800);
		});
		
		$j("a[rel='external']").attr('target', '_blank');
	
		$j("a._link").fancybox({'autoScale' : false, 'transitionIn' : 'none', 'transitionOut' : 'none', 'type' : 'iframe', 'width' : 750, 'height' : 512 });
		$j("a.__link").fancybox({'autoScale' : false, 'transitionIn' : 'none', 'transitionOut' : 'none', 'type' : 'iframe', 'width' : 800, 'height' : 592 });
		$j("a.inline-fancy-mi8").fancybox({'width' : 100, 'height' : 100, 'autoScale' : true, 'transitionIn' : 'none', 'transitionOut' : 'none' });
		$j("a[rel='fancy-video']").fancybox({'transitionIn' : 'none', 'transitionOut' : 'none', 'type' : 'iframe', 'width' : 930, 'height': 523});
		$j("a[rel='fancybox']").fancybox({'transitionIn' : 'none', 'transitionOut' : 'none', 'type' : 'iframe', 'width' : 800, 'height' : 592, 'showNavArrows' : false});
		$j("a[rel='fancy_photo_mi8']").fancybox({'transitionIn' : 'none', 'transitionOut' : 'none', 'width' : 800, 'height' : 550, 'showNavArrows' : true, 'autoScale': false});
		$j("a[rel='fancy_photo_ka32']").fancybox({'transitionIn' : 'none', 'transitionOut' : 'none', 'width' : 800, 'height' : 550, 'showNavArrows' : true, 'autoScale': false});
		
		$j('#post_line').cycle({
			fx:    'scrollUp',
		});
	
		var w = $j(window).width();
		if (w <= 1024) {
			$j("div.spisok").attr("style", "position: relative; float: left; margin-left: 42px;");
		} else {
			$j("div.spisok").attr("style", "position: relative; float: left; margin-left: 89px;");
		};
});
$j(function() {
	$j("#tabs").tabs();
});

	window.addEvent('domready', function(){
		var slideshow = new BarackSlideshow('menu', 'pictures', 'loading', { transition: 'fade', auto: true});
	});
} catch (e) {}
	
