function addOption(selectId, txt, val) {
    obj = document.getElementById(selectId);
	if (!document.all) {
		var objOption = new Option(txt, val);
		obj.options[document.getElementById(selectId).length] = objOption;
    } else {
		var objOption = document.createElement("option");
		obj.options.add(objOption);
		objOption.innerText = txt;
		objOption.value = val;
    }
}

function selOption(selectId, val) {
    obj = document.getElementById(selectId);
	if (!document.all) {
		for (i=0;i<document.getElementById(selectId).length;i++) {
			if (obj.options[i].value == val) {
				obj.options[i].selected=true;
			}
		}
    } else {
    	for (i=0;i<document.getElementById(selectId).length;i++) {
    		if (obj.options[i].value == val) {
				obj.options[i].selected=true;
			}
		}
    }
}

function clearList(selectId) {
   	document.getElementById(selectId).length = 0;
}

function searchFormCheck(oForm) {
	if (oForm!=null && typeof oForm!="undefined") {
		var error = false;
		var errorMsg = "Ihre Eingaben waren Fehlerhaft:\n\n";
		var matches = null;
		
		if (typeof oForm.sg_arrival != "undefined") {
			if (oForm.sg_arrival.value=="TT.MM.YYYY") {
				oForm.sg_arrival.value = "";
			} else if (oForm.sg_arrival.value != "") {
				var regExp = new RegExp("^\s*([0-3]?[0-9]\.[0-3]?[0-9]\.)([0-9]{2})([0-9]{2}|)\s*$","ig");
				if (!(matches = regExp.exec(oForm.sg_arrival.value))) {
					error = true;
					errorMsg += "- Bitte geben Sie ein gültiges Datum an.\n";
				} else if (matches[3]=="") {
					oForm.sg_arrival.value = matches[1]+"20"+matches[2];
				}	
			}
		}
		
		if (error) {
			alert(errorMsg);
			return false;
		}
		return true;
	} else {
		return false;
	}
}

function switchImages(big,thumb) {
	if (big && thumb) {
		var bigsrc = big.src;
		big.src = thumb.src.replace("&width=54&height=54&resizemode=fill","&width=240");
		thumb.src = bigsrc.replace("&width=240","&width=54&height=54&resizemode=fill");
	}
}

function map_popup(id,type) {
	window.open('/tourtipp/snippets/map.php?id='+id+'&type='+type,'map'+type,'width=800,height=600,scrollbars=no,statusbar=no,resizeable=yes');
}