function getIntValue(value) {
	value = parseInt(value);
	if(isNaN(value) || value <= 0 ) {
		value = 1;
	}
	return value;
}

function getFloatValue(value) {
	value = value.replace("," , ".");
	value = parseFloat(value);
	if(isNaN(value) || value <= 0) {
		value = 1.0;
	}
	return value;
}

function getSelectedRadioValue(radioButtons) {
	for(var i=0; i<radioButtons.length; i++) {
		if(radioButtons[i].checked) {
			return radioButtons[i].value;
		}
	}
}

function setSelectedRadioValue(htmlname, value) {
	var radioButtons = document.getElementsByName(htmlname);
	for(i=0;i<radioButtons.length;i++) {
		if(radioButtons[i].value == value) {
			radioButtons[i].checked = true;
		}
	}
}

function checkAnswerRadio(targetID) {
	document.getElementById(targetID).checked = "true";
}

function round(value) {
	return Math.round(value);
}

function showQuestionsExpert() {
	var questionsExpert = document.getElementById("questionsExpert");
	var alternateVersion = false;
	var searchRegExp = /MSIE\s(\d)/;
	searchRegExp.exec(navigator.userAgent);
	if(navigator.appName.indexOf("Internet Explorer") != -1 && parseInt(RegExp.$1) < 8) {
		alternateVersion = true;
	}
	if(alternateVersion) {
		if(questionsExpert.style.display == 'none') {
			questionsExpert.style.display = 'block';
		}
		else {
			questionsExpert.style.display = 'none';
		}
		document.getElementById("questionsExpertIcon").src = '/fileadmin/_img/ico/' + (questionsExpert.style.display != 'block' ? "ico_qct_expert-11x11.png" : "ico_qct_expert-close-11x11.png");
	}
	else {
		if(questionsExpert.style.height != 'auto') {
			questionsExpert.style.height = "auto";
			questionsExpert.style.overflow = "visible";
		}
		else {
			questionsExpert.style.height = "0";
			questionsExpert.style.overflow = "hidden";
		}
		document.getElementById("questionsExpertIcon").src = '/fileadmin/_img/ico/' + (questionsExpert.style.height != 'auto' ? "ico_qct_expert-11x11.png" : "ico_qct_expert-close-11x11.png");
	}
}

function showLoadingDiv() {
	var loadingDiv = document.getElementById("loadingDiv");
	var questionDiv = document.getElementById("questionDiv");
	loadingDiv.style.height = (parseInt(questionDiv.clientHeight) + 27) + "px";
	loadingDiv.style.top = (parseInt(questionDiv.offsetTop) - 27) + "px";
	loadingDiv.style.display = "block";
}

function hideLoadingDiv() {
	var loadingDiv = document.getElementById("loadingDiv");
	loadingDiv.style.display = "none";
}

function saveUserEntryAction(section, question, value) {
	tx_dscdenaqctajaxSaveUserEntryAction(section, question, value);
}

var funcParams = new Array();
var timeoutDate;

function checkForTimeout(funcName) {
	var now = new Date();
	timeoutDate = now + ":" + now.getMilliseconds();
	var lastDate = timeoutDate;
	window.setTimeout("my_timeout('" + lastDate + "', \"" + funcName + "\")", 500);
}

function my_timeout(lastDate, funcName) {
	if(timeoutDate == lastDate) {
		eval(funcName);
	}	
}

function saveEntries(currentPageID) {
	return GB_showCenter('Speichern', '/index.php?id=' + currentPageID + '&type=20091229', 280, 395);
}

function resetEntries() {
	if(confirm("ACHTUNG! Alle Eingaben werden auf den Anfangszustand zurückgesetzt!")) {
		tx_dscdenaqctajaxResetEntriesAction();
	}
}

function jumpToStartPage(pageID) {
	window.location.href = "/?id=" + pageID;
}

function printResults() {
	self.print();
}



