function chkFormular()
{
	form = document.easyform;
	tests = new Array();
	tests[0] = new Array(form.tb_search , "checkEntry" , "Geben Sie einen Suchbegriff ein",1,100,1);			
	if(makeTests(tests))
	{
		var isPerson = "0";
		for(i=0;i<form.op_search.options.length;i++)
		{
			if(form.op_search.options[i].selected == true)
			{
				 isPerson = form.op_search.options[i].value;
			}
		}
		if(isPerson == "-1")
		{
			//popup("http://www.easymonitoring.ch/publikationen_partner.aspx?n="+escape(form.tb_search.value).replace(/\+/,"%2B")+"&x="+isPerson+"&p="+form.hi_pid.value,500,700,"popup_partner");		
			window.open("http://www.easymonitoring.ch/publikationen_partner.aspx?n="+escape(form.tb_search.value).replace(/\+/,"%2B")+"&x="+isPerson+"&p="+form.hi_pid.value);
		}
		else
		{
			var p = "http://www.easymonitoring.ch/publikationen_partner.aspx?s="+escape(form.tb_search.value).replace(/\+/,"%2B")+"&x="+isPerson+"&p="+form.hi_pid.value;
			//popup(p,800,700,"popup_partner");
			window.open(p);
		}
	}
	return false;
}
function SetValue()
{
	form = document.easyform;
	var isPerson = "0";
	var textValue = form.tb_search.value;
	for(i=0;i<form.op_search.options.length;i++)
	{
		if(form.op_search.options[i].selected == true)
		{
			 isPerson = form.op_search.options[i].value;
		}
	}
	if(isPerson == "-1" && (textValue == '' || textValue == "Vorname Nachname" || textValue == "Firmenname" || textValue == "Stichwort")) form.tb_search.value = "Firmenname";
	else if(isPerson == "0" && (textValue == '' || textValue == "Vorname Nachname" || textValue == "Firmenname" || textValue == "Stichwort")) form.tb_search.value = "Stichwort";	
	else if(isPerson == "1" && (textValue == '' || textValue == "Vorname Nachname" || textValue == "Firmenname" || textValue == "Stichwort")) form.tb_search.value = "Vorname Nachname";	
}

function popup(url,x,y,name) 
{
	var str = "toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+x+" ,height="+y;
	window.open(url, name,str);
}
function makeTests(tests)
{
	messages = "";
	focusfield = null;
	for(t=0; t<tests.length; t++)
	{
		result = check(tests[t]);
		if(result==false)
		{
			messages = messages + "\n - " + tests[t][2];
			if(focusfield==null)
			{
				focusfield = tests[t][0];
			}
		}
	}
	if(messages != "")
	{
		alert("Bitte korrigieren Sie die folgenden Fehler:\n"+messages);
		if(focusfield.type == "text" || focusfield.type == "textarea")
		  focusfield.focus();
		return false;
	}
	return true;
}
function check(test)
{
	field = test[0];
	checkname = test[1];
	code = checkname+"(field";
	for(p=3;p<test.length;p++)
	{
		code = code + ",'"+test[p]+"'";
	}
	code = code + ")";
	result = eval(code);
	return result;
}
function checkEmpty(field)
{
	if(field.value.replace(/\s*/,"").length == 0) return true;
	return false;	
}
function checkLength(field,minLength,maxLength)
{
	if(minLength>-1 && field.value.replace(/\s*/,"").length<minLength) return false;
	if(maxLength>-1 && field.value.replace(/\s*/,"").length>maxLength) return false;
	return true;
}
function checkEntry(field,minLength,maxLength,isRequired)
{
	if(isRequired == 1)
		return (!checkEmpty(field) && checkLength(field,minLength,maxLength));
	else
	{
		if(!checkEmpty(field))
		{
			return checkLength(field,minLength,maxLength);
		}
	}
	return true;
}
