//<![CDATA[
function print() {
    var WinPrint = window.open('','','left=1,top=1,width=1000,height=1000,toolbar=1,scrollbars=1,status=1');
    var detailContent = document.getElementById('printableArea');

    WinPrint.document.write('<h1>Application Form Category 1</h1>');
    WinPrint.document.write('<style>table{font-family:Arial;font-size:12px;}td{padding-top:7px;}td.title{font-size:20px;}img{ display:none}</style>');
    WinPrint.document.write(detailContent.innerHTML);
    
    WinPrint.document.close();
    WinPrint.focus();
    WinPrint.print();
    WinPrint.close();
}

function isNumberKey(evt)
  {
	 var charCode = (evt.which) ? evt.which : event.keyCode
	 if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;

	 return true;
  }

function countIt(field,num) {
	var text = field.value;
	var word = text.split(/\s+/g);
	if(word.length>num)
	{
		alert('You have reached the maximum number of words allowed');
		field.value = text.substring(0,(text.length-2));
	}
}

function check_form()
{
	error = "";
	/**
	* Checks for part: 1. Applicant
	*/
	if (document.form.organization.value.length == 0)
	{
		error += "You did not enter any information in the field \'Name of the organization\'.\n";
	}
	if (document.form.address_applicant.value.length == 0)
	{
		error += "You did not enter any information in the field \'Address (street)\'.\n";
	}
	if (document.form.address_no_applicant.value.length == 0)
	{
		error += "You did not enter any information in the field \'No.\'.\n";
	}
	if (document.form.postal_code_applicant.value.length == 0)
	{
		error += "You did not enter any information in the field \'Postal Code; city or town\'.\n";
	}
	if (document.form.country_applicant.value.length == 0)
	{
		error += "You did not enter any information in the field \'Country\'.\n";
	}
	if (document.form.phone_applicant.value.length == 0)
	{
		error += "You did not enter any information in the field \'Phone number (incl. country and area code)\'.\n";
	}
	if (document.form.email_applicant.value.indexOf("@") == -1 || document.form.email_applicant.value.length == 0)
	{
		error += "No valid e-mail address entered in the field \'Email\'.\n";
	}
	else
	{
		if (document.form.email_applicant.value.indexOf(".") == -1)
		{
			error += "No valid e-mail address entered in the field \'Email\'.\n";
		}
	}
	if (document.form.cpo_applicant.value.length == 0)
	{
		error += "You did not enter any information in the field \'Managing Director or Chief Professional Officer\'.\n";
	}
//	if (document.form.accountant.value.length == 0)
//	{
//		error += "You did not enter any information in the field \'Accountant or bookkeeper of the organization\'.\n";
//	}
	/**
	* Checks for part: 2. Contact Person
	*/
	if (document.form.first_name_contact.value.length == 0)
	{
		error += "You did not enter any information in the field \'First Name\'.\n";
	}
	if (document.form.last_name_contact.value.length == 0)
	{
		error += "You did not enter any information in the field \'Family Name\'.\n";
	}
//	if (document.form.phone_contact.value.length == 0)
//	{
//		error += "You did not enter any information in the field \'Direct Phone number (incl. country and area code)\'.\n";
//	}
	if (document.form.email_contact.value.indexOf("@") == -1 || document.form.email_contact.value.length == 0)
	{
		error += "No valid e-mail address entered for the contact person\n";
	}
	else
	{
		if (document.form.email_contact.value.indexOf(".") == -1)
		{
			error += "No valid e-mail address entered for the contact person\n";
		}
	}
	/**
	* Checks for part: 3. Mission and Activities
	*/
	if (document.form.description_applicant.value.length == 0)
	{
		error += "You did not enter any information in the field \'Description of your organization and its mission\'.\n";
	}
	if (document.form.activities_past_applicant.value.length == 0)
	{
		error += "You did not enter any information in the field \'Description of organization's activities and/or projects over the past three years\'.\n";
	}
	/**
	* Checks for part: 4. Total costs of the project
	*/
	if (document.form.project.value.length == 0)
	{
		error += "You did not enter any information in the field \'Name of the project\'.\n";
	}
	if (document.form.project_costs.value.length == 0)
	{
		error += "You did not enter any information in the field \'Total costs for the project\'.\n";
	}
	if (document.form.funding_requested.value.length == 0)
	{
		error += "You did not enter any information in the field \'Payment requested from the JHF\'.\n";
	}
	if (document.form.funding_requested.value > 8000)
	{
		error += "The maximum amount is 8000 Euro for the field \'Payment requested from the JHF\'.\n";
	}
	if (document.form.project_start_day.selectedIndex == 0)
	{
		error += "Day field for \'Date of commencement\' is not selected\n"; 
	}
	if (document.form.project_start_month.selectedIndex == 0)
	{
		error += "Month field for \'Date of commencement\' is not selected\n";
	}
	if (document.form.project_start_year.selectedIndex == 0)
	{
		error += "Year field for \'Date of commencement\' is not selected\n";
	}
	if (document.form.project_end_day.selectedIndex == 0)
	{
		error += "Day field for \'Date of completion\' is not selected\n"; 
	}
	if (document.form.project_end_month.selectedIndex == 0)
	{
		error += "Month field for \'Date of completion\' is not selected\n";
	}
	if (document.form.project_end_year.selectedIndex == 0)
	{
		error += "Year field for \'Date of completion\' is not selected\n";
	}
	if (document.form.project_location.value.length == 0)
	{
		error += "You did not enter any information in the field \'Place where the project will be carried out\'.\n";
	}
	if (document.form.jhf_cofund.value.length == 0)
	{
		error += "You did not enter any information in the field \'Amount requested from the JHF\'.\n";
	}
	if (document.form.own_cofund.value.length == 0)
	{
		error += "You did not enter any information in the field \'Contribution from your own organization\'.\n";
	}
	/**
	* Checks for part: 5. Short Description of your project
	*/
	if (document.form.project_description.value.length == 0)
	{
		error += "You did not enter any information in the field \'Project description\'.\n";
	}
	if (document.form.targetgroup_project.value.length == 0)
	{
		error += "You did not enter any information in the field \'Description of the target group\'.\n";
	}
	if (document.form.project_objective.value.length == 0)
	{
		error += "You did not enter any information in the field \'Project objectives\'.\n";
	}
	if (document.form.project_objective_explanation.value.length == 0)
	{
		error += "You did not enter any information in the field \'Project evaluation success\'.\n";
	}
	/**
	* Checks for part: 7. Details of Bank-account
	*/
	if (document.form.bank_bic.value.length == 0)
	{
		error += "You did not enter any information in the field \'BIC beneficiary bank (SWIFT)\'.\n";
	}
	if (document.form.bank_iban.value.length == 0)
	{
		error += "You did not enter any information in the field \'IBAN or account number of beneficiary\'.\n";
	}
	if (document.form.name_beneficiary.value.length == 0)
	{
		error += "You did not enter any information in the field \'Exact name of beneficiary\'.\n";
	}
	if (document.form.postalcode_beneficiary.value.length == 0)
	{
		error += "You did not enter any information in the field \'Postal code of beneficiary\'.\n";
	}
	if (document.form.place_beneficiary.value.length == 0)
	{
		error += "You did not enter any information in the field \'City of beneficiary\'.\n";
	}
	if (document.form.country_beneficiary.value.length == 0)
	{
		error += "You did not enter any information in the field \'Country of beneficiary\'.\n";
	}
	if (document.form.bank_beneficiary.value.length == 0)
	{
		error += "You did not enter any information in the field \'Name of bank of beneficiary\'.\n";
	}
	/**
	* Checks for part: 10. Sign &amp; Submit
	*/
	if (!document.form.agree.checked)
	{
		error += "You did not 'sign' the form\n";
	}
	if (document.form.place_signed.value.length == 0)
	{
		error += "You did not enter a city name in the sign part of the form\n";
	}
	if (error == "")
	{
		return true;
	}
	else
	{
		alert(error);
		return false;
	}
}
  
//]]>
