$(document).ready(function() { 
	$("#menu ul li a").css("opacity","0.6");
	$("#menu ul li a").hover(
		function () {
			$(this).fadeTo(200, 0.8);
		}, 
		function () {
			$(this).fadeTo(300, 0.6);
		}
	);	
	$("#header .right").css("opacity","0.8");
	$("#header .right").hover(
		function () {
			$(this).fadeTo(200, 1);
		}, 
		function () {
			$(this).fadeTo(300, 0.8);
		}
	);	
	$(".rightinner input").css("opacity","0.4");
	$(".rightinner input").hover(
		function () {
			$(this).fadeTo(200, 0.8);
		}, 
		function () {
			$(this).fadeTo(300, 0.4);
		}
	);	
	$(".soft").css("opacity","0.7");
	$(".soft").hover(
		function () {
			$(this).fadeTo(200, 1);
		}, 
		function () {
			$(this).fadeTo(300, 0.7);
		}
	);	
	$('.neww').click(function() {
		fenster = window.open($(this).attr("href"));
		return false;
	});
	$(".showt:input").tooltip({ 
		position: "center right", 
		offset: [-2, 8], 
		opacity: 0.7,
		tip: '.ohnet'
	});
	$(".slider").click(function () {
		$("#"+$(this).attr("href")).slideToggle(400);
		var expa = "toggle-expand.png\")"; var expa2 = "toggle.png\")";
		var akt1 = $(this).parent().css("background-image").substr(-1*(expa.length));
		var akt2 = $(this).parent().css("background-image").substr(-1*(expa2.length));
		if(akt1 == expa) {
			$(this).parent().css("background-image","url(\"webicons/"+expa2)
		} else {
			if(akt2 == expa2) {
				$(this).parent().css("background-image","url(\"webicons/"+expa)
			}	
		}
		return false;
	});
	$(".showtip").tooltip({ 
		position: "bottom center", 
		offset: [-20, 12], 
		opacity: 0.85
	});
	$(".showtip3[title]").tooltip('.ohnet'); 
	$(".showtip4").tooltip({ 
		position: "bottom center", 
		offset: [0, 12], 
		opacity: 0.85
	});
	$(".showtip2").tooltip({ 
		position: "bottom center", 
		offset: [2, 50], 
		opacity: 0.85
	});
	
	function split( val ) {
		return val.split( /,\s*/ );
	}
	function extractLast( term ) {
		return split( term ).pop();
	}

	
	
	$("#pn_user")
			.bind( "keydown", function( event ) {
				if ( event.keyCode === $.ui.keyCode.TAB &&
						$( this ).data( "autocomplete" ).menu.active ) {
					event.preventDefault();
				}
			})

	
			.autocomplete({
				source: function( request, response ) {
				$.getJSON( "core_system/ajax/users.php", {
					term: extractLast( request.term )
				}, response );
			},
			search: function() {
				// custom minLength
				var term = extractLast( this.value );
				if ( term.length < 2 ) {
					return false;
				}
			},
			focus: function() {
				// prevent value inserted on focus
				return false;
			},
			select: function( event, ui ) {
				var terms = split( this.value );
				// remove the current input
				terms.pop();
				// add the selected item
				terms.push( ui.item.value );
				// add placeholder to get the comma-and-space at the end
				terms.push( "" );
				this.value = terms.join( ", " );
				return false;
			}


	}
	
	
	);		
});
