/***
 *
 *	OKS-JavaScript-Funktionen
 *
 ***/

/**	liefert ein HTML-Element aufgrund seiner ID
 */
function getElement(theID) {
	if(document.getElementById) {
    	return document.getElementById(theID);
    } else if(document.all) {
    	return document.all[theID];
    }	
}

/**	liefert ein Formelement anhand dessen Namen
 */
function getFormElement(theName) {
	return document.forms[0].elements['input_' + theName];	
}

/**	wenn vom Browser unterstützt Ebene einblenden
 */
function showLayer(theID)
{
	getElement(theID).style.display = "block";
}

/**	wenn vom Browser unterstützt Ebene ausblenden
 */
function hideLayer(theID)
{
	getElement(theID).style.display = "none";
}

function changeDisplay(theID) {
//	for(i = 1; i <= 20; i++) {
//		hideLayer("id" + i);
//	}
	if(getElement(theID).style.display == 'none') {
		showLayer(theID);
	} else {
		hideLayer(theID);
	}
}

/**	Befindet sich das land in der EU?
*
*	@param	theLand Name des zu prüfenden Staates
*	@param	array land_eu[] wird durch php aus einem Config-file generiert
*
*	return	0/1
*/
function checkLandEu(theLand)
{
	var myFound	= 0;
	var myIndex	= 0;

	while(myIndex<myListeEU.length && !myFound) {
		if(myListeEU[myIndex] == theLand) {
			myFound = 1;
		} else {
			myIndex++;
		}
	}

	return(myFound);
}

function reloadCaptcha() {
	now = new Date();
	var capObj = getElement('captchaimage');
	if (capObj) {
		capObj.src = capObj.src + (capObj.src.indexOf('?') > -1 ? '&amp;' : '?') + Math.ceil(Math.random()*(now.getTime()));
	}
}
