function openHtmlPopupWn(strSource, windowName, width, height, xLocation, yLocation) {
	var addParam = '';
	//left location
	if ( isNaN(xLocation) ) {
		if ( xLocation == 'right' ) {
			xLocation = screen.width - width - 20;
			addParam += ',left=' + xLocation;
		}
	} else {
		addParam += ',left=' + xLocation;
	}
	// top location
	if ( isNaN(yLocation) ) {
		//further options can be added
	} else {
		addParam += ',top=' + yLocation;
	}

	htmlpopup = window.open(strSource,windowName,"width=" + width + ",height=" + height + ",location=0,menubar=0,status=0,toolbar=0,scrollbars=1,resizable=0"+addParam);
	htmlpopup.focus();
	return htmlpopup;
}


function subListFiller() {
	if (document.f1.category5Parent){
		if (typeof(document.f1.category5Parent) == 'object' && typeof(document.f1.category5Child) == 'object') {
			if (document.f1.category5Parent.options.selectedIndex != -1 && document.f1.category5Parent.options.selectedIndex != 0) {
				putChildren(document.f1.category5Parent, document.f1.category5Child);
			}
		} else {
			setTimeOut("subListFiller()",500);
		}
	}
}

function putChildren(parentListbox, childListbox){
	var myChildren = parentListbox.options[parentListbox.selectedIndex].value.split(String.fromCharCode(31));
	if (myChildren.length > 1) {
		childListbox.options.length = myChildren.length-1;
		childListbox.options[0].value = -1;
		childListbox.options[0].text = 'Bitte wählen...';
		for(var i=2;i<myChildren.length;i++){
			childListbox.options[i-1].value = myChildren[i];
			var myTmpDunno = myChildren[i].split(String.fromCharCode(7));
			childListbox.options[i-1].text = myTmpDunno[1];
		}
	}else{
		childListbox.options.length = 0;
	}
	return;
}

function doSubmit(popupUrl){
	if (document.f1) {
		if (document.f1.category1) {
			if (document.f1.category1.selectedIndex && document.f1.category1.options[document.f1.category1.selectedIndex].value != -1) {
				document.f.category1Title.value = document.f1.category1.options[document.f1.category1.selectedIndex].text;
				document.f.category1.value = document.f1.category1.options[document.f1.category1.selectedIndex].value;
			} else {
				document.f.category1Title.value = "";
				document.f.category1.value = "";
			}
			document.f.cat1Title.value = document.f1.cat1Title.value;
		}
		if (document.f1.category2) {
			if (document.f1.category2.selectedIndex && document.f1.category2.options[document.f1.category2.selectedIndex].value != -1) {
				document.f.category2Title.value = document.f1.category2.options[document.f1.category2.selectedIndex].text;
				document.f.category2.value = document.f1.category2.options[document.f1.category2.selectedIndex].value;
			} else {
				document.f.category2Title.value = "";
				document.f.category2.value = "";
			}
			document.f.cat2Title.value = document.f1.cat2Title.value;
		}
		if (document.f1.category3){
			if (document.f1.category3.selectedIndex && document.f1.category3.options[document.f1.category3.selectedIndex].value != -1) {
				document.f.category3Title.value = document.f1.category3.options[document.f1.category3.selectedIndex].text;
				document.f.category3.value = document.f1.category3.options[document.f1.category3.selectedIndex].value;
			} else {
				document.f.category3Title.value = "";
				document.f.category3.value = "";
			}
			document.f.cat3Title.value = document.f1.cat3Title.value;
		}
		if (document.f1.category4){
			if (document.f1.category4.selectedIndex && document.f1.category4.options[document.f1.category4.selectedIndex].value != -1) {
				document.f.category4Title.value = document.f1.category4.options[document.f1.category4.selectedIndex].text;
				document.f.category4.value = document.f1.category4.options[document.f1.category4.selectedIndex].value;
			} else {
				document.f.category4Title.value = "";
				document.f.category4.value = "";
			}
			document.f.cat4Title.value = document.f1.cat4Title.value;
		}
		if (document.f1.category5Parent) {
			if (document.f1.category5Parent.selectedIndex && document.f1.category5Parent.options[document.f1.category5Parent.selectedIndex].value != -1) {
				document.f.category5ParentTitle.value = document.f1.category5Parent.options[document.f1.category5Parent.selectedIndex].text;
				document.f.category5Parent.value = document.f1.category5Parent.options[document.f1.category5Parent.selectedIndex].value;
			} else {
				document.f.category5ParentTitle.value = "";
				document.f.category5Parent.value = "";
			}
			document.f.cat5ParentTitle.value = document.f1.cat5ParentTitle.value;
		}
		if (document.f1.category5Child) {
			if (document.f1.category5Child.selectedIndex != -1 && document.f1.category5Child.options[document.f1.category5Child.selectedIndex].value != -1) {
				document.f.category5ChildTitle.value = document.f1.category5Child.options[document.f1.category5Child.selectedIndex].text;
				document.f.category5Child.value = document.f1.category5Child.options[document.f1.category5Child.selectedIndex].value;
			} else {
				document.f.category5ChildTitle.value = "";
				document.f.category5Child.value = "";
			}
			document.f.cat5ChildTitle.value = document.f1.cat5ChildTitle.value;
		}
	}
	
	document.f.currentPage.value = 1;

	document.f.suchtext.value = document.f2.suchtext.value;
	if (document.f.suchtext.value == "Suchbegriff") {
		document.f.suchtext.value = "";
	}
	
	if (!resultPopup || (resultPopup && resultPopup.closed)) {
		resultPopup = null;
		resultPopup = openHtmlPopupWn(popupUrl, "dbWindow", '505', '800', 'right', '25');
	}else{
		resultPopup.focus();
	}
	
	recipePopupCaller();
	return false;
}

var resultPopup;

function recipePopupCaller(popupUrl) {
	if(resultPopup){
		document.f.target = "dbWindow";
		document.f.submit();
	}else{
		window.setTimeout('recipePopupCaller();', 500);
	}
	return;
}

function callByPageNumber(number) {
	document.f.currentPage.value = number;
	document.f.submit();
}

function openInOpener(url){
	top.opener.document.location.href = url;
	return false;
}

function newSearch(url) {
	top.opener.document.location.href = url;
	top.window.close();
}

