/*!
 * jQuery Cookie Plugin v1.3
 * https://github.com/carhartl/jquery-cookie
 *
 * Copyright 2011, Klaus Hartl
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.opensource.org/licenses/GPL-2.0
 */
 (function(e,h,j){function k(b){return b}function l(b){return decodeURIComponent(b.replace(m," "))}var m=/\+/g,d=e.cookie=function(b,c,a){if(c!==j){a=e.extend({},d.defaults,a);null===c&&(a.expires=-1);if("number"===typeof a.expires){var f=a.expires,g=a.expires=new Date;g.setDate(g.getDate()+f)}c=d.json?JSON.stringify(c):String(c);return h.cookie=[encodeURIComponent(b),"=",d.raw?c:encodeURIComponent(c),a.expires?"; expires="+a.expires.toUTCString():"",a.path?"; path="+a.path:"",a.domain?"; domain="+
a.domain:"",a.secure?"; secure":""].join("")}c=d.raw?k:l;a=h.cookie.split("; ");f=0;for(g=a.length;f<g;f++){var i=a[f].split("=");if(c(i.shift())===b)return b=c(i.join("=")),d.json?JSON.parse(b):b}return null};d.defaults={};e.removeCookie=function(b,c){return null!==e.cookie(b)?(e.cookie(b,null,c),!0):!1}})(jQuery,document);



$(document).ready(function()
{
	$("body").removeClass("noscript");
	
	

		$('.second-menu li .select-bg > a').click(function(ev){
			if ($(this).next().length){
				ev.preventDefault();
				$(this).parent().parent().toggleClass('selected');

			}
		});
	
	
	$('.content table tbody tr:odd td').addClass('even');
	
	
	
	function res(){
		var widt = $('#slides').width();
		$('.slides_container img').width(widt);
	}
	
	res();
	
	$(window).resize(function(){
		res();
	});
	
	
});

function SetPrintCSS(isPrint)
{
	var link;	
	if (document.getElementsByTagName)
		link = document.getElementsByTagName('link');
	else if (document.all)
		link = document.all.tags('link');
	else
		return;

	for (var index=0; index < link.length; index++)
	{
		if (!link[index].title || link[index].title != 'print')
			continue;

		if (isPrint)
		{
			link[index].disabled = false;
			link[index].rel = "stylesheet";
		}
		else
		{
			link[index].disabled = true;
			link[index].rel = "alternate stylesheet";
		}
	}
}

function AddToBookmark()
{
	var title = window.document.title;
	var url = window.document.location;

	if (window.sidebar)
	{
		window.sidebar.addPanel(title, url, "");
	}
	/*else if(window.opera)
	{
		var a = document.createElement("A");
		a.rel = "sidebar";
		a.target = "_search";
		a.title = title;
		a.href = url;
		a.click();
	}*/
	else if(document.all)
	{
		window.external.AddFavorite(url, title);
	}
	else
	{
		alert("Для добавления страницы в избранное нажмите Ctrl+D");
	}
	
	return false;
}

function BackToDesignMode()
{
	if (document.all)
		window.location.href = window.location.href.replace('#print','');
	else
		SetPrintCSS(false);

	return false;
}

if (document.location.hash == '#print')
	SetPrintCSS(true);

var $Menu = {
	init: function () {
		var _class = this;

		if (!document.createTouch) {
			$(document.documentElement).addClass('desktop');
		} else {
			$(document).on('touchstart', function (e) {
				var _parent = $(e.target).closest('.mainMenu');

				if (_parent.length) {
					var _list = $(e.target).closest('.mainMenuPodmenu');

					if (_list.length) {
						
					} else {
						e.preventDefault();
						var _item = $(e.target).closest('li');

						if (_item.length) {
							var _list = _item.find('.mainMenuPodmenu');

							if (_list.length) {
								if (!_item.hasClass('active')) {
									_item.addClass('active');
									if (_class.olditem) {
										_class.olditem.removeClass('active');
									}
									_class.olditem = _item;
								} else {
									_item.removeClass('active');
									_class.olditem = null;
								}
							}
						}
					}
				} else {
					if (_class.olditem) {
						_class.olditem.removeClass('active');
					}
				}
			});
		}
	}
};
$Menu.init();