$(window).load(function() {
	
	// Reflection
	
	$.include('jquery/jquery.reflection.js', function() {$("img.reflect").reflect({height: 0.2, opacity: 0.3})});
	
});

$(document).ready(function() {
	
	// allgemeine Togglebox
	
	if ($("[class*=togglebox-v]").length > 0) {
		$.include('jquery/jquery.togglebox.js', function() {
			$("[class*=togglebox-v]").toggleBox();
		});
	}
	
	$.ajax({url: '/site/javascript/jquery/jquery.tooltip.js', dataType: 'script', async: false, cache: true});
	$.ajax({url: '/site/javascript/jquery/jquery.bgiframe.js', dataType: 'script', async: false, cache: true});
	$.include('/site/css/screen/jquery.tooltip.css');
	
	// IE 7 Reflection Overflow Fix
	
	if ($.browser.msie) $("img.reflect").css("overflow", "hidden");
	
	// Loginbox

	var _yabDefaultUser = $("#yabLoginForm").find("#yabLoginBox-user").attr("title") ? $("#yabLoginForm").find("#yabLoginBox-user").attr("title") : '';
	var _yabDefaultPwd = "xxxxxxxx";
	
	$("#yabLoginForm").find("#yabLoginBox-user").val(_yabDefaultUser).focus(function() {
		if ($(this).val() == _yabDefaultUser) $(this).val("");
	});
	
	$("#yabLoginForm").find("#yabLoginBox-pass").val(_yabDefaultPwd).focus(function() {
		if ($(this).val() == _yabDefaultPwd) $(this).val("");
	});
	
	$("#yabLoginForm").submit(function(event) {
		
		// das wird beim keyCode == 13 in den Formularen noch abgefragt, so wird das absenden dessen Formulars unterbunden
		keysubmit = false;
		
		if ($(this).find("#yabLoginBox-login").is("input")) {
			if ($(this).find("#yabLoginBox-user").val() == _yabDefaultUser || $.trim($(this).find("#yabLoginBox-user").val()) == "") {
				$(this).find("#yabLoginBox-user").val("").addClass("marker").focus();
				return false;
			} else {
				$(this).find("#yabLoginBox-user").removeClass("marker");
			}
			
			if ($(this).find("#yabLoginBox-pass").val() == _yabDefaultPwd || $.trim($(this).find("#yabLoginBox-pass").val()) == "") {
				$(this).find("#yabLoginBox-pass").val("").addClass("marker").focus();
				return false;
			} else {
				$(this).find("#yabLoginBox-pass").removeClass("marker");
			}
		}
		
		$("#yabLoginBox-error").hide();
		$("#yabLoginBox-login").hide();
		$("#yabLoginBox-logout").hide();
		$("#yabLoginBox-wait").show().css("z-index", "100");

	});
	
	// Script fuer forceLoginBox einbinden
	
	if ($(".forceLoginBox").hasClass("forceLoginBox")) $.include('forceloginbox-jquery.js');

	// Tooltip
	
	$("#yabLoginBox-description").tooltip({delay: 0, track: false, showURL: false, fixPNG: true});
	
	// Cluetip
	
	$.include('jquery/jquery.cluetip.js', function() {
		$.include('/site/css/screen/jquery.cluetip.css');
		$("#yabLoginForm a.cluetip").cluetip({
			onActivate: function(e) {
				$('#cluetip-waitimage').addClass("yabLoginBox-cluetip-waitimage");
				return true;
			},
			attribute: 'href', dropShadow: true, sticky: true, arrows: true,
		    activation: 'click', width: 450,
		    dropShadowSteps:  7,
		    closePosition: 'title',
		    closeText: '<img src="/site/css/images/cluetip/cross.gif" alt="close" title="close" width="16" height="16" />',
		    ajaxSettings: {data: '_ajaxRequest=true', type: "POST", dataType: 'html'},
		    ajaxCache: true,
		    fx: {open: 'slideDown', hide: 'slideUp'}
		});
	});
		
});