$(document).ready(function () {
	$("#topmenu a").mouseover( function () {
		if ( !$(this).parent().parent().hasClass("select") ) {
			$(this).parent().css("background","url(/res/topmenu_hover_rig.png) no-repeat right");
			$(this).parent().parent().css("background","url(/res/topmenu_hover_lef.png) no-repeat left");
		}
	});

	$("#topmenu a").mouseout( function () {
		if ( !$(this).parent().parent().hasClass("select") ) {
			$(this).parent().css("background","none");
			$(this).parent().parent().css("background","none");
		}
	});

	$("input").focus ( function () {
		$(this).prev().filter("label").hide();
	});

	$("input").blur ( function () {
		if ( $(this).val() == '' ) {
			$(this).prev().filter("label").show();
		}
	});

	$("input").each ( function () {
		if ( $(this).val() != '' ) {
			$(this).prev().filter("label").hide();
		}
	});

	$("ul.items h3").mouseover ( function () {
		$(this).parent().children().filter("p.cover").addClass("selected");
	});

	$("ul.items h3").mouseout ( function () {
		$(this).parent().children().filter("p.cover").removeClass("selected");
	});

	$("#sideLeft ul.menu li").mouseover ( function () {
		$(this).addClass("hover");
	});

	$("#sideLeft ul.menu li").mouseout ( function () {
		$(this).removeClass("hover");
	});

	$(".imageflow img").mouseover ( function () {
		$(this).addClass("hover");
	});

	$(".imageflow img").mouseout ( function () {
		$(this).removeClass("hover");
	});

	$(".imageflow *").tooltip({
			track: true,
			delay: 0,
			circular: true,
			showURL: false,
			showBody: " - ",
			fade: 250
		});

	var offset = 0;

	var width = $(".imageflow ul").attr("scrollWidth");
	var scrolls = parseInt( width / 515 ) + parseInt( ( width % 515 ) ? 1:0 );

	if ( scrolls > 1 ) {
		$(".imageflow .next").show();
	}

	$(".imageflow .prev").live( "click", function () {
		offset--;
		var indent = -offset * 515;
		$(".imageflow ul").animate ( {
			textIndent: indent
		});

		if ( !offset ) $(".imageflow .prev").hide ();
		$(".imageflow .next").show ();
		return false;
	});

	$(".imageflow .next").live( "click", function () {
		offset++;
		var indent = -offset * 515;
		$(".imageflow ul").animate ( {
			textIndent: indent
		});

		if ( offset == scrolls - 1 ) $(".imageflow .next").hide ();
		$(".imageflow .prev").show ();
		return false;
	});

});
