var requiredFields=new Array();
var requiredFieldsName=new Array();
var requiredSelect=new Array();
var requiredSelectName=new Array();
var checkBoxField=new Array();
var checkBoxName=new Array();
var emailFields=new Array();


function validateGeneralForm(formname){
	var error="";
	var error1;
	for(var i=0;i<requiredFields.length;i++){
		if(eval("document."+formname+"."+requiredFields[i]+".value") == ""){
			if(error==""){
				eval("document."+formname+"."+requiredFields[i]+".focus()");
			}
			error=error+"\n   - "+requiredFieldsName[i];
		}
	}
	
	for(var i=0;i<requiredSelect.length;i++){
		if(eval("document."+formname+"."+requiredSelect[i]+".selectedIndex") == "0"){
			if(error==""){
				eval("document."+formname+"."+requiredSelect[i]+".focus()");
			}
			error=error+"\n   - "+requiredSelectName[i];
		}
	}
	
	
		for(var i=0;i<checkBoxField.length;i++){
			if(eval("document."+formname+"."+checkBoxField[i]+".checked") == ""){
				if(error==""){
					eval("document."+formname+"."+checkBoxField[i]+".focus()");
				}//end if
				error=error+"\n   - "+checkBoxName[i];
			}//end if
		}//end for
	
	for(var i=0;i<emailFields.length;i++){
		if(eval("document."+formname+"."+emailFields[i]+".value") != ""){
			if(!emailCheckMultiple(formname,emailFields[i])){
				error1=1;
				eval("document."+formname+"."+emailFields[i]+".focus()");
			}
		}
	}
	
	if(error){
		alert(alert_title+":"+error);
		return false;
	}else{
		if(error1){
			alert(alert_email);
			return false;
		}else{
			return true;
		}
	}
}

function emailCheckMultiple(formname,emailfield)
{
	var formname;
	var emailfield;
	  var email_list=eval("document."+formname+"."+emailfield+".value");
      var pl=email_list.split(",");
      for(var j=0;j<pl.length;j++){
		var item = pl[j];
	   
        var returnVal = false
        checkVal = 0
        period = 0
        count1 = 0
        count2 = 0
        
        for (var i=0; i < item.length; i++)
        {
                if (item.substring(i,i+1) == '@')
                {
                        checkVal = checkVal + 1
                        count1 = count1 + 1
                }
                if (item.substring(i,i+1) == '!')
                {
                        checkVal = checkVal + 2
                        count2 = count2 + 1
                }
                if (item.substring(i,i+1) == '.')
                {
                        if (period != 1)
                        {
                           checkVal = checkVal + 4
                           period = 1
                        }
                }
                if (item.substring(i,i+1) == ' ')
                {
                        checkVal = 8
                }
                if (item.substring(i,i+1) == ',')
                {
                        checkVal = 8
                }
                if (item.substring(i,i+1) == '"')
                {
                        checkVal = 8
                }
                if (item.substring(i,i+1) == '\'')
                {
                        checkVal = 8
                }
        }
        if (checkVal == 5 || checkVal == 6)
        {
               var p=item.split("@");
               var r=p[1].split(".");
               var lungime=(r.length-1);
		        if(p[0].length<1){
		        	var ret=1;
		        	fout="1";
		        }
		        
		        if(r[0].length<1){
		        	var ret=1;
		        	fout="1";
		        }
		        if(r[lungime].length<2){
		        	var ret=1;
		        	fout="1";
		        }
		        if(r[lungime].length>4){
		        	var ret=1;
		        	fout="1";
		        }
		        if(ret==1){
		        	returnVal=false;
		        }else{
		        	returnVal = true
		        }
               
               
                
        }
        else

        if (checkVal == 0) fout = '1'
        if (checkVal == 1) fout = '1'
        if (checkVal == 2) fout = '1'
        if (checkVal == 3) fout = '1'
        if (checkVal == 4) fout = '1'
        if (checkVal == 7) fout = '1'
        if (checkVal > 7)  fout = '1'

        if (count1 > 1) fout =    '1'
        if (count2 > 1) fout =    '1'
        
        
	}
        return returnVal
}
function emailCheck(formname,emailfield)
{
	var formname;
	var emailfield;
	if (eval("document."+formname+"."+emailfield+".value") == "")
	 { alert("Bitte tragen Sie Ihre Email-Adresse ein!");
	   
	   return false;}
      
		var item = eval("document."+formname+"."+emailfield+".value");
	   
        var returnVal = false
        checkVal = 0
        period = 0
        count1 = 0
        count2 = 0
        
        for (var i=0; i < item.length; i++)
        {
                if (item.substring(i,i+1) == '@')
                {
                        checkVal = checkVal + 1
                        count1 = count1 + 1
                }
                if (item.substring(i,i+1) == '!')
                {
                        checkVal = checkVal + 2
                        count2 = count2 + 1
                }
                if (item.substring(i,i+1) == '.')
                {
                        if (period != 1)
                        {
                           checkVal = checkVal + 4
                           period = 1
                        }
                }
                if (item.substring(i,i+1) == ' ')
                {
                        checkVal = 8
                }
                if (item.substring(i,i+1) == ',')
                {
                        checkVal = 8
                }
                if (item.substring(i,i+1) == '"')
                {
                        checkVal = 8
                }
                if (item.substring(i,i+1) == '\'')
                {
                        checkVal = 8
                }
        }
        if (checkVal == 5 || checkVal == 6)
        {
               var p=item.split("@");
               var r=p[1].split(".");
               var lungime=(r.length-1);
		        if(p[0].length<1){
		        	var ret=1;
		        	fout="Vor dem @ muss mindestens ein Zeichen stehen!";
		        }
		        
		        if(r[0].length<1){
		        	var ret=1;
		        	fout="Vor dem . muss mindestens ein Zeichen stehen!";
		        }
		        if(r[lungime].length<2){
		        	var ret=1;
		        	fout="Nach dem . müssen mindestens zwei Zeichen stehen!";
		        }
		        if(r[lungime].length>3){
		        	var ret=1;
		        	fout="Nach dem . dürfen höchstens drei Zeichen stehen!";
		        }
		        if(ret==1){
		        	returnVal=false;
		        }else{
		        	returnVal = true
		        }
               
               
                
        }
        else

        if (checkVal == 0) fout = 'Die Email-Adresse ist unvollstaendig !'
        if (checkVal == 1) fout = 'In der Email-Adresse fehlt der Punkt !'
        if (checkVal == 2) fout = 'In der Email-Adresse fehlt der Punkt !'
        if (checkVal == 3) fout = '-@- und -!- sind nicht gleichzeitig erlaubt in der Email-Adresse !'
        if (checkVal == 4) fout = 'In der Email-Adresse fehlt das -@- !'
        if (checkVal == 7) fout = '-@- und -!- sind nicht gleichzeitig erlaubt in der Email-Adresse !'
        if (checkVal > 7)  fout = 'In the email addres it is a space or comma or quote !'

        if (count1 > 1) fout =    'In der Email-Adresse sind mehrere -@- Zeichen !'
        if (count2 > 1) fout =    'In der Email-Adresse sind mehrere -@- Zeichen !'
        
        if (returnVal == false)
        {
                alert('Ihre Email-Adresse ist nicht korrekt.\nBitte ueberpruefen Sie Ihre Eingabe.\n\nFehler:\n' + fout)
   			   

        }else{
        	if(p[0].substring(0,4)=='www.'){
		        	return confirm("Eine Email-Adresse beginnt normalerweise nicht mit www. \nSind Sie sicher dass Ihre EMail-Adresse lautet:"+item+" ?");
		        	
		        	
		        }
        }
        return returnVal
}

function openWin(url, w, h)
{
	var thisWindow;
	thisWindow = window.open(url, "newWin", "width=" + w + ", height=" + h + ",scrollbars=no,screenX=0,screenY=0");
	thisWindow.moveTo((screen.width-w)/2,(screen.height-h)/2);
 	thisWindow.window.focus();
}

function window_picture( newsitem, x, y, title )
{
	var thisWindow;
	thisWindow = window.open(newsitem,title,"width="+x+",height="+y+",scrollbars=auto,screenX=0,screenY=0,toolbar=no,location=no,menubar=no");
	thisWindow.moveTo((screen.width-x)/2,(screen.height-y)/3);
 	thisWindow.window.focus();
}

function window_picture3( newsitem, x, y, title )
{
	var thisWindow;
	thisWindow = window.open(newsitem,title,"width="+x+",height="+y+",scrollbars=yes,screenX=0,screenY=0,toolbar=no,location=no,menubar=no");
	thisWindow.moveTo((screen.width-x)/2,(screen.height-y)/3);
 	thisWindow.window.focus();
}


function window_picture1( newsitem, x, y, title )
{
	var thisWindow;
	thisWindow = window.open(newsitem,title,"width="+x+",height="+y+",scrollbars=yes,screenX=0,screenY=0,toolbar=no,location=no,resizable=yes,menubar=no");
	thisWindow.moveTo((screen.width-x)/2,(screen.height-y)/3);
 	thisWindow.window.focus();
}

function window_picture_max( newsitem, title )
{
	var thisWindow;
	var x=(screen.width-20);
	var y=(screen.height-80);
	thisWindow = window.open(newsitem,title,"width="+x+",height="+y+",scrollbars=yes,screenX=0,screenY=0,toolbar=no,location=no,resizable=yes,menubar=no");
	thisWindow.moveTo((screen.width-x)/2,(screen.height-y)/4);
 	thisWindow.window.focus();
}

function stopErrors() {
	return true;
}
//window.onerror = stopErrors;

