// General JavaScripts routines
//
// Created: 24.04.2008
// Updated: 18.06.2008  Function 'fncCheckForm' added
//          20.05.2008  Function 'pop_print_parameters' added
//
// Version 1.1.0





function MandatoryText( msg,len ){
    tF=testField;
	return ( 	tF.value.length > len  ) ? true: msg ;
}

//loop through all formfield and validate them.

//make globals;
var errors		='';
var testField	='';

function fncCheckForm( f,prefix ){

	//clear values
	var errors		='';
	var firstFocus  ='';

		for ( i=0; i<f.length ; i++ ){
			// prepare some vars from Form-Data
			fe		=f.elements[i];
			f_cmd 	=fe.name.substring(0,9);
			f_aim 	=fe.name.substring(9);
			f_test  =fe.value;

			// if Command is Validate then doValidate and add Error to stack
			if ( f_cmd == 'validate_' ){
				testField=f.elements[ f_aim ]; /* global testValue */

				if ( (msg=eval( f_test )) !=true  ) {
					errors+=msg +'\n';
					// put focus on first and only first wrong field
					if (firstFocus=='' ) { firstFocus='set'; testField.focus(); }
		}
		}

            // Test for mandatory single checkbox
            if (fe.name == 'CheckboxSingleMandatory') {
               if (fe.checked != true) {
                    msg = fe.value;
            		errors += msg + '\n';
               }
            }


	}


	if ( errors!='') {
		alert( prefix + '\n\n' + errors );
    return false;
  }

  return true;
	//alert( 'ok' );
	//return false; // later return true, means accept submit
}

function fncReset(objForm) {
    // this allows images to be used as reset "buttons"
	objForm.reset();
	return false;
}

// PLZ finder
function pop_print_parameters(f,file,w,h,titleofpage,lang)
	{
		self.name = "opener";
		if (f=="")
		{
			zip ='';
		}
		else
		{
			zip = f.zip.value;
		}
		titleofpage = escape(titleofpage);
		addedurl = "/php/frameset.php?src="+file+"&lang="+lang+"&zip="+zip+"&title="+titleofpage;
		ref = window.open(addedurl, Math.round(Math.random()*50000), "status=no,scrollbars=no,scrolling=0,resizable=no,width="+w+",height="+h+",top=10,left=10,locationbar=no");
	}
