$(document).ready(function(){
//menu top  
	$("#topnav li").prepend("<span></span>"); //Throws an empty span tag right before the a tag

	$("#topnav li").each(function() { //For each list item...
		var linkText = $(this).find("a").html(); //Find the text inside of the <a> tag
		$(this).find("span").show().html(linkText); //Add the text in the <span> tag
	}); 

	$("#topnav li").hover(function() {	//On hover...
		$(this).find("span").stop().animate({
			marginTop: "-40" //Find the <span> tag and move it up 40 pixels
		}, 250);
	} , function() { //On hover out...
		$(this).find("span").stop().animate({
			marginTop: "0"  //Move the <span> back to its original state (0px)
		}, 250);
	});
//menu bottom
  var site = function() {
	this.navLi = $('#nav li').children('ul').hide().end();
	this.init();
};

site.prototype = {
 	
 	init : function() {
 		this.setMenu();
 	},
 	
 	// туткай ми дозволяєио слайд та включаємо підтримку осліка шостого
 	
	
 	setMenu : function() {
 	
 	$.each(this.navLi, function() {
 		if ( $(this).children('ul')[0] ) {
 			$(this)
 				.append('<span />')
 				.children('span')
 					.addClass('hasChildren')
 		}
 	});
 	
 		this.navLi.hover(function() {
 			// маусовер
			$(this).find('> ul').stop(true, true).slideDown('slow', 'easeOutBounce');
 		}, function() {
 			// маусаут
 			$(this).find('> ul').stop(true, true).hide(); 		
		});
 		
 	}
 
}
new site();



//Slideshow  
  $(function() {
      setInterval( "slideSwitch()", 7000 );
  });
  });
 
  
  function slideSwitch() {
	var $active = $('.slideshow div.active');
	if ( $active.length == 0 ) $active = $('.slideshow div:last');
	var $sibs  = $active.siblings();
	var rndNum = Math.floor(Math.random() * $sibs.length );
	var $next  = $( $sibs[ rndNum ] );
	$active.addClass('last-active');
	$next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 2000, function() {
			$active.removeClass('active last-active');
		});
  } 
