/*
	FUNCTIONS
*/
function createStatistic(id, type, action, base_url) {
	$.ajax({
	   type: 'POST',
	   url: base_url + '/index.php?cmd=statistic',
	   data: 'id=' + id + '&type=' + type + '&action=' + action
	 });
}



/*	check form
*
*	check if form fields are empty. alert message for each missing field
*
*	@param	(array)	fieldIdArray
*	@param	(array)	msgArray
*	@param	(string)	submit button
*	@param	(string)	"busy" label for submit button
*/
function checkForm(fieldIdArray, msgArray, submitButt, busyLabel) {
	//alert("checking fieldIdArray:\n" + fieldIdArray + "\n\nmsgArray:\n" + msgArray);

	var msg = "";

	for(var i = 0; i < fieldIdArray.length; i++) {
		var o = document.getElementById(fieldIdArray[i]);
		if(o.value == "") {
			//	missing value
			msg += "- " + msgArray[i] + "\n";
		}
	}

	if(msg != "") {
		//	missing values
		alert("Bitte folgende Eingaben prüfen:\n" + msg);
		return false;
	} else {
		//	ok, submit form
		var butt = document.getElementById(submitButt);
		butt.disabled = true;
		butt.value = busyLabel;

		return true;
	}
}



/*	open window
*/
function openWindow(url, win_name, options) {
	window.open(url, win_name, options);
}



/*	show help
*/
function showHelp(key) {
	openWindow('./contextHelp.php?key=' + key, 'contextHelp', 'width=300,height=300,resizable=yes,scrollbars=yes');
}



/*	show debug info
*/
function showDebugInfo(sNfo, rNfo) {
	openWindow('./extras/debug_info.php?sNfo=' + sNfo + '&rNfo=' + rNfo, 'debugInfo', 'width=500,height=500,resizable=yes');
}


/*	show PDF
*/
function showPDF(id) {
	openWindow('./extras/pdf/show.php?id=' + id, 'PDF', 'width=800,height=600,resizable=yes,scrollbars=yes');
	return false;
}

$(document).ready(function() {
	$('button').mouseover(function() {
		$(this).addClass('hover');
	});
	$('button').mouseout(function() {
		$(this).removeClass('hover');
	});
});

