/*
Nikolay Gromov
Author URI: http://nicothin.ru
*/
$(document).ready(function() {

$('#nav-one li').hover(
	function(){ 
		$('ul', this).fadeIn(50); 
	}, 
	function(){ 
		$('ul', this).hide(); 
	} 
);
$('#nav-one li').hoverClass('sfHover');

theRotator();

$('#nav-one li.current-page').parent('ul').parent('li').addClass('current-page');

});

$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c); },
			function() { $(this).removeClass(c); }
		);
	});
};
function theRotator() {
	$('#topadv div.topadvblock').css({opacity: 0.0});
	$('#topadv div.topadvblock:eq(0)').css({opacity: 1.0,display:'block'});
	setInterval('rotate()',7000);
}
function rotate() {	
	var current = ($('#topadv div.topadvblock.show')?  $('#topadv div.topadvblock.show') : $('#topadv div.topadvblock:first'));
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('#topadv div.topadvblock:first') :current.next()) : $('#topadv div.topadvblock:eq(0)'));	
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
};
