

function submitSearchForm(){
var bolSubmit=validateSearchForm();
if (bolSubmit==true){
document.searchform.submit()
}
}

function getBNDCCookie() {
	var cookieValue = getCookie(BNDCCookieName);
	if(cookieValue == null || typeof cookieValue == "object") {
		cookieValue = "";
	}
	return cookieValue;
}

function openPodcast(podcasturl) {
var podcast = window.open(podcasturl,'podcast','location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,width=735,height=730');
podcast.focus();
}

function addToDownloadCenter(fileName) {
	if(navigator.cookieEnabled == false) {
		alert(BNDCNoCookieErrorMsg);
	}
	var cookieValue = getBNDCCookie();
	if(cookieValue != "") {
		var entryList = new Array();
		if(cookieValue.indexOf(":") == -1) entryList[0] = cookieValue
		else entryList = cookieValue.split(":");
		var found = false;
		var imgCnt = 0;
		var txtCnt = 0;

		for(var i = 0; i < entryList.length; i += 1) {
			if(entryList[i] == (pageUniqueID + "|" + fileName)) found = true;
			if(entryList[i].indexOf("|images") >= 0 ) imgCnt++
			else txtCnt++;
		}
		if(found == true) {
			alert(BNDCExistsErrorMsg);
			return false;
		}
		if (txtCnt >= BNDCMaxTextFiles && fileName.indexOf("images") == -1) {
			alert(BNDCMaxTextErrorMsg);
			return false;
		}
		if (imgCnt >= BNDCMaxImageFiles && fileName.indexOf("images") != -1) {
			alert(BNDCMaxImageErrorMsg);
			return false;
		}
	}

	if(cookieValue != "") {
		cookieValue += ":";
	}
	cookieValue += pageUniqueID + "|" + fileName;
	var cookieCode=BNDCCookieName + "=" + cookieValue + "; path=/";
	document.cookie=cookieCode;
	refreshDownloadCenterInfo();
//	alert(cookieCode);
}

function getDownloadCenterFiles() {
	var cookieValue = getBNDCCookie();
	if(cookieValue != "") {
		var list = cookieValue.split(":");
	}
	return cookieValue;
}


function showDownloadCenterFiles() {
	var cookieValue = getBNDCCookie();
	var downloadCenterCode = "";
	if(cookieValue != "") {
		var list = cookieValue.split(":");
		for(var i=0; i < list.length(); i+=1) {
			downloadCenterCode = "";
		}
	}
	document.write(downloadCenterCode);
}



function refreshDownloadCenterInfo(additionalInfoText) {
//	if(typeof additionalInfoText == "undefined") additionalInfoText = ""
//	else additionalInfoText = additionalInfoText+"\n";
	var cookieValue = getBNDCCookie();
	var dcobj = document.getElementById(BNDCInfoId);
	if(cookieValue != "") {
		var entryList = new Array();
		if(cookieValue.indexOf(":") == -1) entryList[0] = cookieValue
		else entryList = cookieValue.split(":");
		if(dcobj) {
			dcobj.innerHTML = entryList.length;
		}
	} else {
		if(dcobj) {
			dcobj.innerHTML = "0";
		}
	}
//	alert(additionalInfoText+"Downloadcenter enthält " + entryList.length + " Downloads");
	return false;
}

function removeFromDownloadCenter(entryID, tagID) {
	var cookieValue = getBNDCCookie();
	if(cookieValue == "") {
		return false;
	}
	var entryList = new Array();
	if(cookieValue.indexOf(":") == -1) entryList[0] = cookieValue
	else entryList = cookieValue.split(":");

	var change = false;
	var newValue = new Array();
	var n = 0;
	for(var i = 0; i < entryList.length; i += 1) {
		if(entryList[i] == entryID) {
			change = true;
		} else {
			newValue[n] = entryList[i];
			n++;
		}
	}
	if(change == true) {
		cookieValue = newValue.join(":");
		var cookieCode=BNDCCookieName + "=" + cookieValue + "; path=/";
		document.cookie=cookieCode;
		document.getElementById(tagID).style.visibility = "hidden";
		document.getElementById(tagID).style.display = "none";
		if(newValue.length == 0) {
			var linkobj = document.getElementById("downloadZIPLink");
			if(linkobj) linkobj.style.display = "none";
			var emptyobj = document.getElementById("emptyDownloadCenter");
			if(emptyobj) emptyobj.style.display = "block";
		}
		refreshDownloadCenterInfo();
	}
//	alert(cookieCode);
}


function showElementWithId(boxId) {
	var obj = document.getElementById(boxId);
	var displayValue = (typeof showElementWithId.arguments[1] == "string")?showElementWithId.arguments[1]:"block";
	if(obj) obj.style.display = displayValue;
}

function hideElementWithId(boxId) {
	var obj = document.getElementById(boxId);
	if(obj) obj.style.display = "none";
}
