function getBrowserInfo() {
	var t,v = undefined;
	if (window.opera) t = 'Opera';
	else if (document.all) {
		t = 'IE';
		var nv = navigator.appVersion;
		var s = nv.indexOf('MSIE')+5;
		v = nv.substring(s,s+1);
	} else if (navigator.appName) t = 'Netscape';
	return {type:t,version:v};
};

function bookmark(a){
	var url = window.document.location;
	var title = window.document.title;
	var b = getBrowserInfo();
	if (b.type == 'IE' && 7 > b.version && b.version >= 4) window.external.AddFavorite(url,title);
	else if (b.type == 'Opera') {
		a.href = url;
		a.rel = "sidebar";
		a.title = url+','+title;
		return true;
	}
	else if (b.type == "Netscape") window.sidebar.addPanel(title,url,"");
	else alert("Нажмите CTRL-D, чтобы добавить страницу в закладки.");
	return false;
};

function get_date(){
	if (!document.all && !document.getElementById) return
	var Elm = (document.getElementById) ? document.getElementById("datetime_div") : document.all.datetime_div;
	var dat = new Date();
	var month = dat.getMonth();
	var year = dat.getFullYear();
	var day = dat.getDate();
	switch(month){
		case 0: mon = 'Января'; break;
		case 1: mon = 'Февраля'; break;
		case 2: mon = 'Марта'; break;
		case 3: mon = 'Апреля'; break;
		case 4: mon = 'Мая'; break;
		case 5: mon = 'Июня'; break;
		case 6: mon = 'Июля'; break;
		case 7: mon = 'Августа'; break;
		case 8: mon = 'Сентября'; break;
		case 9: mon = 'Октября'; break;
		case 10: mon = 'Ноября'; break;
		case 11: mon = 'Декабря'; break;
	}
	var hours = dat.getHours();
	var minutes = dat.getMinutes();
	var seconds = dat.getSeconds();
	if (minutes<=9) minutes = "0"+minutes
	if (seconds<=9) seconds = "0"+seconds
	var time = day+" "+mon+" "+year+" "+hours+":"+minutes+":"+seconds;
	Elm.innerHTML = ""+time+""
	setTimeout("get_date()",1000)
}
window.onload = get_date;

function mycarousel_initCallback(carousel) {
	carousel.buttonNext.bind('click', function() {
		carousel.startAuto(0);
	});
	carousel.buttonPrev.bind('click', function() {
		carousel.startAuto(0);
	});
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
};

jQuery(document).ready(function() {
	jQuery('#mycarousel').jcarousel({
		auto: 2,
		wrap: 'circular',
		initCallback: mycarousel_initCallback
	});
});

$(document).ready(function() {
	$('ul#down_menu ul').each(function(i) {
		if ($.cookie('submenuMark-' + i)) {
			$(this).show().prev().removeClass('collapsed').addClass('expanded');
		}else {
			$(this).hide().prev().removeClass('expanded').addClass('collapsed');
		}
		$(this).prev().addClass('collapsible').click(function() {
			var this_i = $('ul#down_menu ul').index($(this).next());
			if ($(this).next().css('display') == 'none') {
				$(this).parent('li').parent('ul').find('ul').each(function(j) {
					if (j != this_i) {
						$(this).slideUp(200, function () {
							$(this).prev().removeClass('expanded').addClass('collapsed');
							cookieDel($('ul#down_menu ul').index($(this)));
						});
					}
				});
				$(this).next().slideDown(200, function () {
					$(this).prev().removeClass('collapsed').addClass('expanded');
					cookieSet(this_i);
				});
			}else {
				$(this).next().slideUp(200, function () {
					$(this).prev().removeClass('expanded').addClass('collapsed');
					cookieDel(this_i);
					$(this).find('ul').each(function() {
						$(this).hide(0, cookieDel($('ul#down_menu ul').index($(this)))).prev().removeClass('expanded').addClass('collapsed');
					});
				});
			}
		//return false;
		});
	});
});

function cookieSet(index) {
	$.cookie('submenuMark-' + index, 'opened', {expires: null, path: '/'});
}
function cookieDel(index) {
	$.cookie('submenuMark-' + index, null, {expires: null, path: '/'});
}

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') {
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString();
        }
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else {
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};






