var x;
x=jQuery(document);
x.ready(initEvents);

function initEvents() {
	// Nivo Slider
    jQuery(window).load(function() {
        var numOfImg = $('#slider img').length;
        jQuery('#slider').nivoSlider({
            effect: 'fade', //Specify sets like: 'fold,fade,sliceDown'
            animSpeed: 500, //Slide transition speed
            pauseTime: (numOfImg > 1) ? 4000 : 999999999,
            startSlide: 0, //Set starting Slide (0 index)
            directionNav: false, //Next & Prev
            directionNavHide: false, //Only show on hover
            controlNav: (numOfImg > 1), //1,2,3...
            controlNavThumbs: false, //Use thumbnails for Control Nav
            controlNavThumbsFromRel: false, //Use image rel for thumbs
            controlNavThumbsSearch: '.jpg', //Replace this with...
            controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
            keyboardNav: false, //Use left & right arrows
            pauseOnHover: true, //Stop animation while hovering
            manualAdvance: false, //Force manual transitions
            captionOpacity: 0.7, //Universal caption opacity
            beforeChange: function() { },
            afterChange: function() { },
            slideshowEnd: function() { } //Triggers after all slides have been shown
        });
    });
	// END Nivo Slider
	
	jQuery("div#nav div.buttons").mouseenter(function() {
		id=jQuery(this).attr("id");
		idLength=id.length;
		id_box=id.slice(0,idLength-7);
		id_box="div#nav div#"+id_box;
		
		jQuery(id_box).stop().animate({
		    opacity: 0.97,
		    "bottom": "0px"
		}, 250, function() {
			// Animation complete.
		}).mouseleave(function() {
			
			jQuery(id_box).stop().animate({
				opacity: 1,
				"bottom": "-330px"
			}, 150, function() {
				// Animation complete.
			});
		});
	});
	
	jQuery("div#nav div.boxes, div#wrapper").mouseleave(function() {
		jQuery("div#nav div.boxes").stop().animate({
				opacity: 1,
				"bottom": "-330px"
			}, 150, function() {
				// Animation complete.
		});
	});
}
