/*	OKS - JavaScript-Funktionen für onlinekredit.de */

	function getElement(theID) {
		if(document.getElementById) {
	    	return document.getElementById(theID);
	    } else if(document.all) {
	    	return document.all[theID];
	    }	
	}

	function getFormElement(theName) {
		return document.forms[0].elements[theName + ''];	
	}
	
	function changeDisplay(theID, theValue) {
		if (theValue == 'none') {
			$("#" + theID).hide(300);
		} else {
			$("#" + theID).show(300);
		}
	}

	function checkDisplay(theID) {
		if (getElement("" + theID).style.display == 'none') {
			$("#" + theID).show(300);
		} else {
			$("#" + theID).hide(300);
		}
	}
	
	//	FAQ
	function checkDisplayFAQ(theID) {
		if (getElement("FAQ_answer_" + theID).style.display == 'none') {
			$("#FAQ_answer_" + theID).show(300);
			$("#FAQ_question_" + theID).addClass("active");
		} else {
			$("#FAQ_answer_" + theID).hide(300);
			if ($("#FAQ_question_" + theID).hasClass("active")) {
				$("#FAQ_question_" + theID).removeClass("active");	
			}
		}
	}

	function checkKreditsumme()
	{
		if($('#kreditsumme').val() < minKreditsumme || $('#kreditsumme').val() > maxKreditsumme) {
			$('#kreditsumme').val('20000');
			alert("Der Kreditbetrag muss zwischen " + minKreditsummeDisp + " und " + maxKreditsummeDisp + " liegen.");
		}
		$("#error").hide(100);
		calculateOffer();
	}
	
	function getRadioValue(theID)
	{
		if($('[name=' + theID + ']:checked').val()) {
			return $('[name=' + theID + ']:checked').val();
		} else {
			return '0';
		}
	}

	function applicationAction(theAction) {
		$('#ACTION').val(theAction);
		document.forms[0].submit();
	}
	
	function resetRatenpauseAnzahl() {
		getElement('ratenpauseAnzahl1').checked = false;
		getElement('ratenpauseAnzahl2').checked = false;
		getElement('ratenpauseAnzahl3').checked = false;
		calculateOffer();
	}
	
	function reloadCaptcha() {
		now = new Date();
		var capObj = document.getElementById('captchaimage');
		if (capObj) {
			capObj.src = capObj.src + (capObj.src.indexOf('?') > -1 ? '&amp;' : '?') + Math.ceil(Math.random()*(now.getTime()));
		}
	}