/**
 * Projekt:	Beppo_Website
 *
 * Create:	29.05.2009
 * Copyright 2009 by Kirchnerei
 *			http://www.kirchnerei.de
 *			mailto:infos@kirchnerei.de
 *
 * Veröffentlichung:
 * Version:	2.0 (Build: 28)
 * Datum:	13.08.2009
 * Vendor:	Kirchnerei
 *
 * Subversion:
 * Author:	$LastChangedBy: sarah $
 * Date:	$LastChangedDate: 2009-07-24 22:46:02 +0200 (Fr, 24 Jul 2009) $
 * Version:	$LastChangedRevision: 64 $
 */


var BACKGROUND_COLOR = '#444444';
var DIALOG_BACKGROUND = '#F9F3E3';
var WAIT_MESSAGE = '<h1 class="waiting"><img src="assets/busy.gif" alt="Warten"/> <span>Bitte warten</span></h1>';

/**
 * Zeitspanne bis der Notify ausgeblendet wird
 */
var NOITFY_DELAY_MS = 10000;

/**
 * TOOLTIP_DELAY_MS definiert die Millisekunden, bis ein Tooltip angezeigt wird.
 */
var TOOLTIP_DELAY_MS = 200;

var TOOLTIP_PARAM = {
	delay: 200,
	track: false,
	showBody: '##',
	showURL: false
};

/**
 * doShowWaitung() blockiert die Anwendung wegen Wartezeit
 */
function doShowWaiting() {
	$.blockUI({
		message: WAIT_MESSAGE,
		css: {
			border: '3px solid #999999',
			backgroundColor: DIALOG_BACKGROUND
		},
		overlayCSS: {
			backgroundColor: BACKGROUND_COLOR,
			opacity: 0.7
		},
		fadeIn: 400,
		fadeOut: 100
	});	// end if blockUI
}

function doBlockElement(id) {
	$(id).block({
		message: WAIT_MESSAGE,
		css: {
			border: '3px solid #999999',
			backgroundColor: DIALOG_BACKGROUND
		},
		overlayCSS: {
			backgroundColor: BACKGROUND_COLOR,
			opacity: 0.7
		},
		fadeIn: 400,
		fadeOut: 100		
	});
}

/**
 * doShowLogDialog() blockiert die Anwendung mit einem Login- oder Logout-Dialog.
 * 
 * @param data ist der Html Code
 */
function doShowLogDialog(data) {
	$.blockUI({
		message: data,
		css: {
			border: 'none',
			backgroundColor: DIALOG_BACKGROUND,
			left: '',
			top: '60px', 
			right: '20px',
			width: '400px',
			cursor: 'default'
		},
		overlayCSS: {
			backgroundColor: BACKGROUND_COLOR,
			opacity: 0.7
		},
		fadeIn: 400,
		fadeOut: 400
	}); // end of blockUI()
	$('a.closeLink').tooltip(TOOLTIP_PARAM);
}

/**
 * doShowCenterDialog() blockiert die Anwendung mit einem Eingabeformular
 * 
 * @param data ist der Html Code
 */
function doShowCenterDialog(data) {
	$.blockUI({
		message: data,
		css: {
			border: 'none',
			backgroundColor: '',
			width: '100%',
			left: '',
			right: '',
			top: '90px',
			cursor: 'default'
		},
		overlayCSS: {
			backgroundColor: BACKGROUND_COLOR,
			opacity: 0.7
		},
		fadeIn: 400,
		fadeOut: 400
	}); // end of blockUI()
	$('a.closeLink').tooltip(TOOLTIP_PARAM);
}

/**
 * doShowTopDialog() blockiert die Anwendung mit einem Eingabeformular
 * 
 * @param data ist der Html Code
 */
function doShowTopDialog(data) {
	$.blockUI({
		message: data,
		css: {
			border: 'none',
			backgroundColor: '',
			width: '100%',
			left: '',
			right: '',
			top: '0px',
			cursor: 'default'
		},
		overlayCSS: {
			backgroundColor: BACKGROUND_COLOR,
			opacity: 0.7
		},
		fadeIn: 400,
		fadeOut: 400
	}); // end of blockUI()
	$('a.closeLink').tooltip(TOOLTIP_PARAM);
}

 /**
  * doDialogClose() schließt einen modalen Dialog
  */
function doDialogClose() {
	$.unblockUI({fadeOut: 400});
}

function doDialogSubmit(id) {
	$(id).click();
}


function decode_Link(link) {
    var n = 0;
    var r = "";
    for( var i = 0; i < link.length; i++)
    {
        n = link.charCodeAt( i );
        if( n >= 8364 )
        {
            n = 128;
        }
        r += String.fromCharCode( n - 1 );
    }
	
    document.location.href = r;
}

