
jQuery.noConflict();
var currentimg;
var currentnumber;

jQuery(document).ready(

		function() {

			/* menu effects */
			jQuery("ul#menu li a").click(
					function() {

						var child = jQuery(this).parent().find("ul");

						// if there is any next level
						if (child.size() > 0) {
							// var siblings =
							// jQuery(this).parent().siblings().children("ul:visible[class!=active]").slideUp();

							if (jQuery(this).hasClass("rollup")) {
								jQuery(this).removeClass("rollup");
							} else {
								jQuery(this).addClass("rollup");

								var siblings = jQuery(this).parent().siblings()
										.children("ul:visible");
								siblings.slideUp(300);
								siblings.prev().removeClass("rollup");
							}

							child.eq(0).slideToggle(300);
							setTimeout(updateIntroWrapperHeight, 350);

							return false;
						} else
							return true;
					});

			/* search link activation */
			jQuery("a#search-link").click(function() {
				jQuery(this).parent().submit();

			});

			colorTableRows();

			/* table highlight effect */
			jQuery("tr").mouseover(function() {
				jQuery(this).addClass("mouseover");
			});

			jQuery("tr").mouseout(function() {
				jQuery(this).removeClass("mouseover");
			});

			/* pictures slideshow in top right of page */
			currentimg = jQuery("img.picture-show");
			currentnumber = 1;

			setTimeout(function() {
				changePicture();
				setInterval(changePicture, 5000);
			}, 4000);

		});

function colorTableRows() {

	/* table odd rows color */
	if (jQuery("table.specialists").size() == 0) {
		jQuery("tr:visible").removeClass("odd");
		jQuery("tr:visible:even").addClass("odd");
	}
}

function changePicture() {

	var newnumber;
	// files begin counting from 1, preventing of repetition
	while ((newnumber = Math.floor(Math.random() * 27) + 1) == currentnumber) {
	}
	var newsrc = "pictures/picture_" + newnumber + ".jpg";
	var newimg = jQuery("<img />").attr("class", "picture-show")
			.attr("alt", "").attr("src", newsrc);

	jQuery(newimg).insertBefore(currentimg);

	setTimeout(function() {
		currentimg.fadeOut(1000);
		setTimeout(function() {
			currentimg.remove();
			currentimg = newimg;
			currentnumber = newnumber;
		}, 1000);
	}, 1000);
}

function updateIntroWrapperHeight() {

	hg = jQuery("div#left-side").height();
	jQuery("div#intro-wrapper").css("height", hg - 55);

}

