// NICE EASING

jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	}

});

// EFFECT FUNCTIONS

$(document).ready(function(){

	// SETTINGS

	$("#statusbar #right").mouseover(function(){
	  $("#do_settings").toggle();
	  $("#settings").toggleClass("settings_active");
	});
	$("#statusbar #right").mouseout(function(){
	  $("#do_settings").toggle();
	  $("#settings").toggleClass("settings_active");
	});

	// LIBARY & INFOS

	var hoehe = $('#messeinfos').height();
	var messestand = 505;
	$("#messeinfos .headline_active").hide();
	
	$("#libary .objects").css({ height: messestand - hoehe - 20 /* höhe headline + objektnav */ });
	
	$("#libary_nav").mouseover(function(){
	  $("#libary_nav .libary_nav_items").toggle();
	  $("#libary .libary_headline").toggleClass("libary_active");
	});
	$("#libary_nav").mouseout(function(){
	  $("#libary_nav .libary_nav_items").toggle();
	  $("#libary .libary_headline").toggleClass("libary_active");
	});
	$("#messeinfos .headline").click(function(){
	  $("#hide_infos").slideToggle({ duration: 500, easing: 'easeInOutExpo' });
	  $(this).hide();
	  $("#messeinfos .headline_active").show();
	  $("#libary .objects").animate({
		height: messestand - 136 }, { duration: 500, easing: 'easeInOutExpo' });		
	});
	$("#messeinfos .headline_active").click(function(){
	  $("#hide_infos").slideToggle({ duration: 500, easing: 'easeInOutExpo' });
	  $(this).hide();
	  $("#messeinfos .headline").show();
	  $("#libary .objects").animate({
		height: messestand - hoehe - 20 }, { duration: 500, easing: 'easeInOutExpo' });		
	});
	
	$("#messeinfos .beschreibung").mouseover(function(){
		var inhalt = $(this).text();
		$(this).text($(this).text() == 'Show box' ? +inhalt : 'Show box');
	});	
	
	
	// HINTS MESSESTAND

	$(".hint").hide();

	$("#speichern").mouseover(function(){
	  $("#hint_speichern").fadeIn(250);
	});
	$("#speichern").mouseout(function(){
	  $("#hint_speichern").hide();
	});
	$("#bestellen").mouseover(function(){
	  $("#hint_bestellen").fadeIn(250);
	});
	$("#bestellen").mouseout(function(){
	  $("#hint_bestellen").hide();
	});
	
	// myMESSESTAND
		
	$("#legende .neu").click(function(){
		$("#mymessestand .details").effect("highlight");
	});

	// LOGIN

	$("#password").css('opacity', 0);

	$("#pwd_button").click(function(){
	  $("#password").animate({
		 marginTop: "150px", opacity: 1}, { duration: 500,  easing: 'easeInOutExpo'});
	  $(this).fadeOut(400);
	});
	$("#pwd_close").click(function(){
	  $("#password").animate({
		 marginTop: "", opacity: 0}, { duration: 500,  easing: 'easeInOutExpo'});
	  $("#pwd_button").fadeIn(400);
	});
	$("#loginform input").focus(function(){
	  $(this).addClass("hover");
	});
	$("#loginform input").blur(function(){
	  $(this).removeClass("hover");
	});
	$("#password input").focus(function(){
	  $(this).addClass("hover");
	});
	$("#password input").blur(function(){
	  $(this).removeClass("hover");
	});
	$("#pwd_lost").focus(function(){
	  $("#pwd_hint").fadeIn("fast");
	});
	$("#pwd_lost").blur(function(){
	  $("#pwd_hint").fadeOut("fast");
	});

});

// HELPCENTER LIGHTBOX

$(document).ready(function() {
	$("#helpcenter a").fancybox({ 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'frameWidth': 700, 'frameHeight': 500, 'overlayOpacity': 0.8, 'overlayColor': '#000', 'padding': 0 });
}); 
