$(document).ready( function() {

//menu
$("#header-menu li.lvl-1").hover(
function() { $(this).addClass("hover").find("ul").slideDown("fast"); },
function() { $(this).removeClass("hover").find("ul").slideUp("fast"); }
);

$("#s-menu2 ul li a.lvl-1").click( function() {
	if ($(this).next().hasClass("active")) {
		$(this).parent().find("ul").slideUp("fast").removeClass("active");
	} else {
		$(this).parent().find("ul").slideDown("fast").addClass("active").animate({'padding-bottom': "10"}, 100).animate({'padding-bottom': "0"}, 200).animate({'margin-bottom': "-5"}, 100).animate({'margin-bottom': "0"}, 100);
	}
	return false;
});



// rotator
var slideTime = 5000; /* частота перехода */
var num = $("#rotator .box").length;
$("#rotator .box").css({'opacity': '0'});
$("#rotator .box.active").css({'opacity': '1'});
$("#rotator").append("<ul class='list'></ul>");
for (var i = 1; i <= num; i++) {
		$("#rotator ul").append("<li val="+i+"></li>");
		$("#rotator .box:eq(" + (i - 1) + ")").attr("val", ""+i +"");
	}
$("#rotator ul li:eq(0)").addClass("active");
	
function slidechange(current) {
	$("#rotator div.active").stop().animate({'opacity' : '0'}, 500).hide("fast").removeClass("active");
	$("#rotator ul li.active").stop().removeClass("active");
	$("#rotator .box:eq(" + (current) + ")").stop().animate({'opacity' : '1'}, 1200).show("slow").addClass("active");
	$("#rotator ul li:eq(" + (current) + ")").stop().addClass("active");
}
function fslider() {
	var current = $("#rotator .box:visible").attr("val");
	if ( current < num ) { 
		slidechange(current); 
	} else {
		slidechange(0);
	}
}
var repeat = setInterval(fslider, slideTime);
function repPause() {
	clearInterval(repeat);
	repeat = setInterval(fslider, slideTime);
}
$("#rotator-next").click( function() { 
	fslider();
	repPause();
});
$("#rotator-prev").click( function() { 
	var current = $("#rotator .box:visible").attr("val") - 2;
	if ( current < 0 ) { 
		slidechange(num - 1); 
	} else {
		slidechange(current);
	}		
	repPause();
});
$("#rotator ul li").click ( function() {
	var current = $(this).attr("val") - 1;
	slidechange(current);
	repPause();
});














});


function doClear(theText) { if (theText.value == theText.defaultValue) { theText.value = "" } }
function doDefault(theText) { if (theText.value == "") { theText.value = theText.defaultValue } }
		


