$(document).ready(function(){

/* accordion */
if ( $('div.menu ul').length > 1 ) {
	$('div.menu ul').each(function()
	{
		$(this).data('height', $(this).height());
		$(this).data('padding-top', $(this).css('padding-top'));
		$(this).data('padding-bottom', $(this).css('padding-bottom'));
	});

$('div.menu h3').addClass('point');

	if($("div.menu").find("li").hasClass("sel"))
	{
		var met = $("div.menu ul").find("li.sel").parent("ul").index("ul")-1;
		//alert(met);
		}
		else
		{	
		var met = 0;			
			}

	//var met = 0;
$('div.menu ul:not(:eq(' + met + '))').animate({height: 0, 'padding-top': 0, 'padding-bottom': 0}, 500, function() { $(this).hide(); });

$('div.menu h3:eq(' + met + '), div.menu ul:eq(' + met + ')').addClass('active');

	
	$('div.menu h3').click(function()
	{
		$('div.menu h3').removeClass('active');
		$('div.menu ul:visible').animate({height: 0, 'padding-top': 0, 'padding-bottom': 0}, 500, function() { $(this).hide(); });
		
		$(this).addClass('active');
		box = $(this).next().addClass('active');
		$(box).animate(
		{
			height: $(box).data('height'), 
			'padding-top': $(box).data('padding-top'), 
			'padding-bottom': $(box).data('padding-bottom')
		}, 500).show();
	});
}
/* /accordion */


/* colorbox */
$("a[rel='example']").colorbox({opacity:"0.6", current:"{current} из {total}"});
/* /colorbox */

/* form */
if ( $('form').length > 0 ) {
$(function(){
$(".form-table input, .form-table textarea, .form-table select, .form-table button").uniform({fileDefaultText: 'Выберите файл', fileBtnText: 'Обзор'});
$(".search-page input").uniform();
});
}
/* /form */

/* main */
if ( $('#featured').length > 0 ) {
	 $("#featured").tabs({ fx: { opacity: "toggle"} }).tabs("rotate", 8000, true);
    //$("#featured").tabs("rotate", 9000, true);
    $("#fragment-1, #fragment-2, #fragment-3, #fragment-4").hover(
      function () {
          $("#featured").tabs("rotate", 0, true);
      },
      function () {
          $("#featured").tabs("rotate", 8000, true);
      });
}
/* /main */

/* chat */
$(function() {
		var offset = $("#chat").offset();
		var topPadding = 25;
		$(window).scroll(function() {
			if ($(window).scrollTop() > offset.top) {
				$("#chat").stop().animate({marginTop: $(window).scrollTop() - offset.top + topPadding});
			}
			else {$("#chat").stop().animate({marginTop:0});};});
	});
/* /chat */

/* more */
$("div.more").hide();
	$("h3 b").click(function(){
	$(this).parent().toggleClass("sel").next("div.more").slideToggle();
	return false;
	});
/* /more */

/* menu_top */
$('#menu_top li div').hide().addClass("show");
$('#menu_top li').hover(
        function() {
          //  $(this).addClass("hover");
            $(this).children('div').stop(true, true).slideDown();
        },
        function() {
           // $(this).removeClass("hover");
            $(this).find('div').hide();
        });
/* /menu_top */

});
