var DOMViewerObj;
var DOMViewerName ='select';

function toggle_otherbusinesstype( select )
{
	// if the selected option is "Other business", enable/display the
	// text input field. If not, disabled/hide the sdam.e

	DOMViewerObj=select;
	//window.open("/domviewer");

	if ( select.value==0 )
	{
		select.form.otherbusinesstype.style.display='';
	}
	else
		select.form.otherbusinesstype.style.display='none';
}

function toggle_otherpaymentmethod( select )
{
        if ( select.value==0 )
        {
                select.form.otherpaymentmethod.style.display='';
        }
        else
                select.form.otherpaymentmethod.style.display='none';
}

function toggle_otherwhere( select )
{
        // if the selected option is "Other business", enable/display the
        // text input field. If not, disabled/hide the sdam.e

        DOMViewerObj=select;
        //window.open("/domviewer");

        if ( select.value==0 )
        {
                select.form.otherwhere.style.display='';
        }
        else
                select.form.otherwhere.style.display='none';
}

function toggle_proposal_data( f )
{
        // if the selected option is "Other business", enable/display the
        // text input field. If not, disabled/hide the same.

        DOMViewerObj=f;
        //window.open("/domviewer");

        tb=document.getElementById('proposal_required');

        if ( f.checked )
        {
                tb.style.display='';
        }
        else
                tb.style.display='none';

        return true;
}


function validate_form( fRef )
{
	var errors=0;

	resetError( fRef.discuss );
	if ( !(fRef.moreinfo.checked || fRef.proposal.checked || fRef.discuss.checked) )
	{
		setError( fRef.discuss, "Bitte mindestens einer der drei K&auml;stchen ankreuzen." );
		errors++;
	
		fRef.moreinfo.focus();
	}

	resetError( fRef.title );
	if ( fRef.title.value=="0" )
	{
		setError1( fRef.title, "Bitte w&auml;hlen.", errors );
                errors++;
	}

	resetError( fRef.name );
	match=fRef.name.value.match(/^ *([^ ].+[^ ]) *$/);
        if ( match==null )
	{
		setError1( fRef.name, "Bitte Ihre Name eingeben.", errors );
		errors++;
	}
	else fRef.name.value=match[1];

	resetError( fRef.country );	
	if ( fRef.country.value=="0" )
	{
		setError1( fRef.country, "Bitte w&auml;hlen.", errors );
		errors++;
	}

	resetError( fRef.email );
	// this could be a much more stringent check
	match=fRef.email.value.match(/^ *([^ ].+[^ ]) *$/);
        if ( match==null )
        {
                setError1( fRef.email, "Bitte Ihre Email-Adresse eingeben.", errors );
                errors++;
        }
        else fRef.email.value=match[1];

	resetError( fRef.language );
        if ( fRef.language.value=="0" )
        {
              setError1( fRef.language, "Bitte w&auml;hlen.", errors );
                errors++;
        }

	//resetError( fRef.bypost );
	//if ( !(fRef.download.checked || fRef.byemail.checked || fRef.bypost.checked) )
	//{
	//	setError1( fRef.bypost, "Bitte w&auml;hlen.", errors );
	//	errors++;
	//}

	//resetError( fRef.typeofbusiness );
	//if ( fRef.typeofbusiness.value==0 ) 
	//{
	//	match=fRef.otherbusinesstype.value.match(/^ *([^ ].+[^ ]) *$/);
	//	if ( match==null )
	//	{
	//		setError1( fRef.typeofbusiness, "Please specify which kind of business.", errors );
	//		errors++;
	//	}
	//}

        resetError( fRef.where );
        if ( fRef.where.value==0 )
        {
                match=fRef.otherwhere.value.match(/^ *([^ ].+[^ ]) *$/);
                if ( match==null )
                {
                        setError1( fRef.where, "Bitte w&auml;hlen.", errors );
                        errors++;
                }
        }


	//resetError( fRef.payment );
	//if ( fRef.payment.value==0 )
	//{
	//	match=fRef.otherpaymentmethod.value.match(/^ *([^ ].+[^ ]) *$/);
        //        if ( match==null )
        //        {
        //                setError1( fRef.payment, "Please specify which kind of payment method.", errors );
        //                errors++;
        //        }
        //}

	// if proposal is requested, the company information becomes required
	if ( fRef.proposal.checked )
	{
	//	resetError( fRef.typeofbusiness );
	//	if ( fRef.typeofbusiness.value==1 )
	//	{
	//		setError1( fRef.typeofbusiness, "In order to prepare a proposal we need to know your companys type of business.", errors );
	//		errors++;
	//	}
	//	else
	//	if ( fRef.typeofbusiness.value==0 )
        //	{
        //      	match=fRef.otherbusinesstype.value.match(/^ *([^ ].+[^ ]) *$/);
	//		if ( match==null )
	//		{
        //              setError1( fRef.typeofbusiness, "In order to prepare a proposal we need to know your companys type of business.", errors );
        //              errors++;
	//		}
	//	}

		resetError( fRef.numberofemployees );
		if ( fRef.numberofemployees.value==0 )
		{
			setError1( fRef.numberofemployees, "Bitte angeben.", errors );
			errors++;
		}

		resetError( fRef.numberofemailusers );
                if ( fRef.numberofemailusers.value==0 )
                {
                        setError1( fRef.numberofemailusers, "Bitte angeben.", errors );
                        errors++;
                }
	/*
		resetError( fRef.turnover );
                if ( fRef.turnover.value==0 )
                {
                        setError1( fRef.turnover, "Bitte angeben.", errors );
                        errors++;
                }

		resetError( fRef.payment );
                if ( fRef.payment.value==1 )
                {
                        setError1( fRef.payment, "Bitte angeben.", errors );
                        errors++;
                }
		else
		if ( fRef.payment.value==0)
		{
			match=fRef.otherpaymentmethod.value.match(/^ *([^ ].+[^ ]) *$/);
			if ( match==null )
	                {
                        setError1( fRef.payment, "Bitte angeben.", errors );
        		errors++;
	                }
		}
	*/
	}
	

	return errors==0;
}
