
function DoRefSearch(act) {
	var loc = location.pathname;
	if (act=='none') {
		location.href = loc+"?filtergroup=alle";
	} else {
		location.href = loc+"?filtergroup="+document.getElementById("filtergroup").value+"&filterword="+document.getElementById("filterword").value;
	}
}

function PostRefSearch() {
	if (event.keyCode == 13) {
		event.cancelBubble = true;
		event.returnValue = false;
		var button = document.getElementById("RefButton");
		if (button != null) {
			button.click();
		}
	}
}

function NewsSubscribe(r, act, o) {
	var isValid = true;
	var oe = o.elements;
	HideError("1");
	HideError("2");
	HideError("3");
	var sList = GetSelectedCHKvalues("chkList", o);
	if (oe["1"].value=="") {ShowError("1");isValid = false;}
	if (!isValidEmail(oe["2"].value)) {ShowError("2");isValid = false;}
	if (sList=="" && act=="subscribe") {ShowError("3");isValid = false;}
	if (isValid) {
		//alert("/Forms/newsletter.aspx?1="+oe["1"].value+"&2="+oe["2"].value+"&3="+oe["3"].value+"&4="+oe["4"].value+"&sli="+sList+"&act="+act+"&r="+r);
		location.href = "/Forms/newsletter.aspx?1="+oe["1"].value+"&2="+oe["2"].value+"&3="+oe["3"].value+"&4="+oe["4"].value+"&sli="+sList+"&act="+act+"&r="+r;
		return true;
	}
	return false;
}
/*
function ContactRequest(r,o) {
	var isValid = true;
	var oe = o.elements;
	HideError("1");
	HideError("2");
	HideError("3");
	HideError("4");
	HideError("5");
	if (oe["subject"].value=="") {ShowError("1");isValid = false;}
	if (oe["firstname"].value=="") {ShowError("2");isValid = false;}
	if (oe["lastname"].value=="") {ShowError("3");isValid = false;}
	if (oe["email"].value=="" && oe["phone"].value=="") {
		ShowError("4");
		ShowError("5");
		isValid = false;
	}
	if (!oe["email"].value=="" && !isValidEmail(oe["email"].value)) {
		ShowError("4");
		isValid = false;
	}
	if (isValid) {
		o.action = "/Forms/ContactPost.aspx";
		o.submit();
		return true;
	}
	return false;
}
*/
function ContactRequest(r,o) {
	var isValid = true;
	/*var oe = o.elements;
	HideError("1");
	HideError("2");
	HideError("3");
	HideError("4");
	HideError("5");
	if (oe["subject"].value=="") {ShowError("1");isValid = false;}
	if (oe["firstname"].value=="") {ShowError("2");isValid = false;}
	if (oe["lastname"].value=="") {ShowError("3");isValid = false;}
	if (oe["email"].value=="" && oe["phone"].value=="") {
		ShowError("4");
		ShowError("5");
		isValid = false;
	}
	if (!oe["email"].value=="" && !isValidEmail(oe["email"].value)) {
		ShowError("4");
		isValid = false;
	}*/
	if (isValid) {
		o.action = "/Forms/ContactPost.aspx";
		o.submit();
		return true;
	}
	return false;
}

function ShowError(oID) {
	document.getElementById("error"+oID).style.display = "inline";
}

function HideError(oID) {
	document.getElementById("error"+oID).style.display = "none";
}

function isValidEmail(emailAddress) {
	var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
	return re.test(emailAddress);
}


function DoSearch(itemid) {
	location.href = "/?path="+itemid+"&search="+document.getElementById("searchfield").value;
}

function PostSearch(buttonName) {    
	if (event.keyCode == 13) {
		event.cancelBubble = true;
		event.returnValue = false;
		var button = document.getElementById(buttonName);
		if (button != null) {
			button.click(); 
		}
	}
}

function DontPost(buttonName) {    
	if (event.keyCode == 13) {
		event.cancelBubble = true;
		event.returnValue = false;
	}
}

function DoPrint() {
	var loc = location.href;
	var pri = "?print=1";
	if (loc.indexOf("?")>0) {
		pri = "&print=1";
	}
	window.open(loc+pri, "", "toolbar=1,location=0,directories=0,status=0,menubar=yes,scrollbars=yes,resizable=yes,width=769,height=400");
}

function PrepPrint() {
	for (i=0; i<document.body.all.tags("A").length; i++) {
		document.body.all.tags("A")[i].href = 'JavaScript:void(0)';
		document.body.all.tags("A")[i].target = '';
	}
	for (i=0; i<document.body.all.length; i++) {
		document.body.all[i].setAttribute('onclick','');
	}
	window.print();
}


function GetSelectedCHKvalues(n, f) {
	var oe = f.elements;
	var sReturn = "";
	var i = 0;
	for (i=0; i<oe.length; i++) {
		if (oe[i].name.indexOf(n)==0) {
			if (oe[i].checked) {
				sReturn += oe[i].value+",";
			}
		}
	}
	i = sReturn.length;
	if (i>0) {
		sReturn = sReturn.substring(0, i-1);
	}
	//alert(sReturn);
	return sReturn;
}
