/***
*	javascript file 
*	(c) 2008 by Mirko Scharf
***/

function showDialog( type, txt, title, w, h, focusElement ) {
	document.mochaUI.newWindow({
		id: 'messageModal',
		title:  ( ( title != undefined) ? title : label_std_title ),
		content: '<img src="/images/ka/' + type + '.png" style="margin-top:40px; float:left;"><div id="msgDiv"><table border=0 width="100%" height="100%"><tr height="100%"><td height="100%" valign="middle">' + txt + '</td></tr></table><button id="messageCloserButton" style="width:100px; margin-left:45px" onclick="document.mochaUI.closeWindow($(\'messageModal\')); if( $( \'' + focusElement + '\' ) ) { $( \'' + focusElement + '\' ).focus(); }">' + label_close + '</button></div>',
		modal: true,
		width: ( ( w != undefined ) ? w : 300 ),
		height: ( ( h != undefined ) ? h : 150 )
	});
	$( 'messageCloserButton' ).focus();
}

function showMessage( txt, title, w, h, focusElement ) {
	showDialog( 'ok', txt, ( ( title != undefined) ? title : label_std_title ), w, h, focusElement );
}

function showWarning( txt, title, w, h, focusElement ) {
	showDialog( 'warning', txt, ( ( title != undefined) ? title : label_std_title_warning ), w, h, focusElement );
}

function showError( txt, title, w, h, focusElement ) {
	showDialog( 'error', txt, ( ( title != undefined) ? title : label_std_title_error ), w, h, focusElement );
}

function showWaiting( txt ) {
	document.mochaUI.newWindow({
		id: 'waitingModal',
		title: label_wait,
		content: '<img src="/images/ka/loader.gif" style="margin-top:40px; float:left;"><div id="msgDiv"><table border=0 width="100%" height="100%"><tr height="100%"><td height="100%" valign="middle">' + ( ( txt != undefined ) ? txt : label_wait_std_text ) + '</td></tr></table></div>',
		modal: true,
		closable: false,
		width: 300,
		height: 150
	});
}

function hideWaiting() {
	document.mochaUI.closeWindow($('waitingModal'));
}

function displayConfirmDialog( txt, funcOK, funcCancel ) {
	var myContent = '';
	myContent += '<div id="msgDiv" style="width:250px;"><table border=0 width="100%" height="100%"><tr height="100%"><td height="100%" valign="middle">' + txt + '</td></tr></table>',
	myContent += '<input type="button" id="messageYesButton" class="btn" value="' + label_yes + '" style="margin-left:21px;width:100px" onclick="document.mochaUI.closeWindow($(\'confirmModal\'));' + funcOK + '">';
	myContent += '<input type="button" id="messageNoButton" class="btn" value="' + label_no + '" style="margin-left:10px;width:100px" onclick="document.mochaUI.closeWindow($(\'confirmModal\'));' + funcCancel + '"></td>';
	myContent += '</div>';

	document.mochaUI.newWindow({
		id: 'confirmModal',
		title: '',
		content: myContent,
		modal: true,
		closable: false,
		width: 300,
		height: 150
	});
	$( 'messageNoButton' ).focus();
}

