var ErrorInstance = '';
var ErrorFlashVar = 0;
var OtherDocId = 0;
var ErrorString = '';
var ShowHint	= '';

var CyrillicArray = new Array('А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ж', 'З', 'И', 'Й', 'К',//upper case range 1 
			                          'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х',//upper case range 2
									              'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь', 'Э', 'Ю', 'Я', 'Ё',//upper case range 3
										            'а', 'б', 'в', 'г', 'д', 'е', 'ж', 'з', 'и', 'й', 'к',//lower case range 1
																'л', 'м', 'н', 'о', 'п', 'р', 'с', 'т', 'у', 'ф', 'х',//lower case range 2
																'ц', 'ч', 'ш', 'щ', 'ъ', 'ы', 'ь', 'э', 'ю', 'я', 'ё', '№','-'//lower case range 3	  
									  );

var one_day=1000*60*60*24
var one_month=1000*60*60*24*30
var one_year=1000*60*60*24*30*12


function ConfirmExit(Url)
{
	document.getElementById('NextUrl').value = Url;
	openWindow('application_warning.html',215,155);	
}


function CheckSelectedOption(Id)
{
	SelectBox = document.getElementById(Id);
	
	if (SelectBox.selectedIndex != 0)
	{
		SetAsNormal(Id);
	}
}

function SetAsNormalRadio(Id)
{
  if (!document.getElementById(Id)) { alert("Null exception in SetAsNormalRadio('"+Id+"')"); return false;}
        document.getElementById(Id).style.border = '2px solid #FFF';
        return false;
}

function displayage(yr, mon, day, unit, decimal, round){

	today=new Date()
	var pastdate=new Date(yr, mon-1, day)
	
	var countunit=unit
	var decimals=decimal
	var rounding=round
	
	finalunit=(countunit=="days")? one_day : (countunit=="months")? one_month : one_year
	decimals=(decimals<=0)? 1 : decimals*10
	
	if (unit!="years") {
	
		if (rounding=="rounddown")
			document.write(Math.floor((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals+" "+countunit)
		else
			document.write(Math.ceil((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals+" "+countunit)
	}
	
	else {
		yearspast=today.getFullYear()-yr-1
		tail=(today.getMonth()>mon-1 || today.getMonth()==mon-1 && today.getDate()>=day)? 1 : 0
		pastdate.setFullYear(today.getFullYear())
		pastdate2=new Date(today.getFullYear()-1, mon-1, day)
		tail=(tail==1)? tail+Math.floor((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals : Math.floor((today.getTime()-pastdate2.getTime())/(finalunit)*decimals)/decimals
		//document.write(yearspast+tail+" "+countunit)
		
		return yearspast;
	}
	
}

function CheckDOB()
{
	Year  = 0;
	Month = 0;
	Day   = 0;
	
	if (document.getElementById('dob_year').selectedIndex != 0 && document.getElementById('dob_month').selectedIndex != 0 && document.getElementById('dob_day').selectedIndex !=0)
	{
		Year  = document.getElementById('dob_year').options[document.getElementById('dob_year').selectedIndex].value;
		Month = document.getElementById('dob_month').options[document.getElementById('dob_month').selectedIndex].value;
		Day   = document.getElementById('dob_day').options[document.getElementById('dob_day').selectedIndex].value;
		 
		Age   = displayage(Year, Month, Day, 'years', 0, 'rounddown');

		if (Age < 21 || Age > 55)
		{			
			ShowErrorPrompt('dob_day', 'Ваш возраст должен быть 21-55 лет.');
		}
		else if (ErrorInstance == 'dob_day')
		{
			HideErrorPrompt('dob_day');
		}
	}
	
}

function CheckEmail(Id, Text)
{
	//document.getElementById('prompt2').style.display = 'none';
	SetAsNormal(Id);
	var Text = Text || "Адрес электронной почты введен неверно. Пожалуйста, исправьте.";
	if (document.getElementById(Id).value != '' &&
		!document.getElementById(Id).value.match(/^.+@.+\..+$/) &&			
		(ErrorInstance == Id || ErrorInstance == '')
		)
	{	
		ShowErrorPrompt(Id, Text);  
		return false;
	}	
	else if (ErrorInstance == Id)
	{	
		HideErrorPrompt(Id); 
	}	
	else if (ShowHint == Id)
	{   
		HideHint();
	}		
	return true;
}


/*function CheckEmail(Id)
{
	//document.getElementById('prompt').style.display = 'none';
		
	if (document.getElementById('email').value != '' &&
//		!document.getElementById('email').value.match(/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/) &&
		!document.getElementById('email').value.match(/^\s*[a-zA-Z0-9_][\w\.-]*[a-zA-Z0-9_]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]\s*$/) &&
		(ErrorInstance == 'email' || ErrorInstance == '')
		)
	{			
		ShowErrorPrompt('email', "Адрес электронной почты введен неверно. Пожалуйста, исправьте.");
	}	
	else if (ErrorInstance == 'email')
	{		
		HideErrorPrompt('email');
	}	
	else if (ShowHint == 'email')
	{
		HideHint();
	}		
}
*/

function CheckStrict(Id)
{
	//document.getElementById('prompt').style.display = 'none';
	
	Length 	  = document.getElementById(Id).value.length
	MaxLength = document.getElementById(Id).getAttribute('maxlength');

	if (Length != 0)
	{
		if (Length != MaxLength && (ErrorInstance == Id || ErrorInstance == ''))
		{
			ShowErrorPrompt(Id, "Количество цифр должно быть\n\nравно " +MaxLength+ ". Вы указали " +Length+". Пожалуйста, исправьте.");
			return false;
		} 

		else if (ErrorInstance == Id)
		{
			HideErrorPrompt(Id);			
		}
		
		else if (ShowHint == Id)
		{
			HideHint();
		}	
	
	}
		
	return true;	
}

function CheckStrictDocument(Id)
{
	if (CheckStrict(Id))
	{
		IsInteger(Id);	
	}
}

function CheckLoanAmount()
{

	if (IsInteger('LoanAmmount'))
	{

		if ((parseInt(document.getElementById('LoanAmmount').value.replace(/\s+/g, '')) > 300000 || parseInt(document.getElementById('LoanAmmount').value.replace(/\s+/g, '')) < 12000) && (ErrorInstance == 'LoanAmmount' || ErrorInstance == ''))
		{
			ShowErrorPrompt('LoanAmmount', 'Сумма кредита может быть только в пределах 12 000 - 300 000 руб.');
		}		
		else if (ErrorInstance == 'LoanAmmount')
		{
			HideErrorPrompt('LoanAmmount');
		}		
		else if (ShowHint == 'LoanAmmount')
		{
			HideHint();
		}	
	}
	
}

function DisplayGender(Id)
{
	if (Id == 'sex-male')
	{
		document.getElementById('AssistantHolder').className 	 = 'assistant';
		document.getElementById('AssistantHolder2').className 	 = 'assistant';
		document.getElementById('fam-stat-male').style.display 	 = 'block';
		document.getElementById('fam-stat-female').style.display = 'none';
	}
	else
	{
		document.getElementById('AssistantHolder').className 	 = 'assistant2';
		document.getElementById('AssistantHolder2').className 	 = 'assistant2';
		document.getElementById('fam-stat-male').style.display 	 = 'none';
		document.getElementById('fam-stat-female').style.display = 'block';	
	}
}

function DisplayOtherDocLayer()
{
	OtherDocSelectBox = document.getElementById('type_of_other_doc');
	
	if (OtherDocSelectBox.selectedIndex == 0)
	{
		if (OtherDocId != 0)
		{
			document.getElementById(OtherDocId).style.display = 'none';
		}		
	}
	else
	{
		if (OtherDocId != 0)
		{
			document.getElementById(OtherDocId).style.display = 'none';
		}
		
		OtherDocId = OtherDocSelectBox.options[OtherDocSelectBox.selectedIndex].value;
		document.getElementById(OtherDocId).style.display = 'block';
	}
}

function ErrorFlash(Id)
{
	if (ErrorFlashVar != 0)
	{
		clearTimeout(ErrorFlashVar);
	}
		
	if (document.getElementById(Id).style.border == '#ff0000 2px solid')
	{
		if (document.getElementById(Id).type != 'text')
		{
			if (document.getElementById(Id).tagName != 'textarea')
			{
				document.getElementById(Id).style.border = 0;
			}
		}
		else
		{
			document.getElementById(Id).style.border = '2px solid #CCCCCC';
		}
	}
	else
	{
		document.getElementById(Id).style.border = '2px solid #FF0000';
	}
	
	ErrorFlashVar = setTimeout('ErrorFlash(\''+Id+'\')', 700);
}

function StopErrorFlash(Id)
{

	clearTimeout(ErrorFlashVar);
	
	if (document.getElementById(Id).type != 'text')
	{
		if (document.getElementById(Id).tagName != 'textarea')
		{
			document.getElementById(Id).style.border = 0;
		}
	}
	else
	{
		document.getElementById(Id).style.border = '2px solid #CCCCCC';
	}
}

function HideHint()
{
	ShowHint = '';
	document.getElementById('prompt2').style.display = 'none';
}

function ShowHintPrompt(Id, Hint)
{
	
			
	if (ErrorInstance == '')
	{
		ShowHint	= Id;
		ErrorPrompt = document.getElementById('ErrorMsg');
		Prompt      = document.getElementById('prompt2');
		ParentNode  = document.getElementById(Id).parentNode;
		
		if (ErrorPrompt.childNodes.length != 0)
		{
			ErrorPrompt.removeChild(ErrorPrompt.firstChild);
		}
		
		ErrorPrompt.appendChild(document.createTextNode(Hint));
		ErrorPrompt.style.color = '#555555';
		Prompt.style.display = 'block';	

		if (Id == 'LoanAmmount')
		{
			Prompt.style.top = '80px';
		}		
		else
		{
			Prompt.style.top = '';
		}
	
		ParentNode.appendChild(Prompt);
	}
}

function ShowErrorPrompt(Id, ErrorMsg)
{	
	document.getElementById('FormSubmitError').style.display = 'none';
	
	ErrorInstance = Id;
	
	ErrorPrompt = document.getElementById('ErrorMsg');
	Prompt      = document.getElementById('prompt2');
	ParentNode  = document.getElementById(Id).parentNode;
	
	if (ErrorPrompt.childNodes.length != 0)
	{
		ErrorPrompt.removeChild(ErrorPrompt.firstChild);
	}
	
	ErrorPrompt.appendChild(document.createTextNode(ErrorMsg));
	ErrorPrompt.style.color = '#FF0000';
	Prompt.style.display = 'block';
	
	ParentNode.appendChild(Prompt);
	
	SetAsWrong(Id);
	
	if (document.getElementById(Id).type == 'text' || document.getElementById(Id).tagName == 'textarea')
	{
		setTimeout('document.getElementById(\''+Id+'\').focus();', 20);
	}
	
	/*	
	ErrorFlash(Id);
	*/
}

function HideErrorPrompt(Id)
{
	ErrorInstance = '';
	
	ErrorPrompt   = document.getElementById('ErrorMsg');
	
	if (ErrorPrompt.childNodes.length > 1)
	{
		ErrorPrompt.removeChild(ErrorPrompt.firstChild);
	}
	
	document.getElementById('prompt2').style.display = 'none';
	
	SetAsNormal(Id);
	//StopErrorFlash(Id);	
}

function IsCity(Id)
{
	//document.getElementById('prompt').style.display = 'none';
	
	if (document.getElementById(Id).value != '')
	{
		if (document.getElementById(Id).value.length < 3 && !document.getElementById(Id).value.match(/^\d/) && (ErrorInstance == Id || ErrorInstance == ''))
		{
			ShowErrorPrompt(Id, 'Название не может быть меньше 3 букв. Пожалуйста, исправьте.');	
		}
		else if (document.getElementById(Id).value.match(/^\d/) && (ErrorInstance == Id || ErrorInstance == ''))
		{
			ShowErrorPrompt(Id, 'Первым символом должна быть буква. Пожалуйста, исправьте.');
		}
		else 
		{
			CheckCyrillic(Id, true);	
		}
	}
}

function PensionNumber(Id)
{
	 NextFieldNumber = parseInt(Id.match(/\d$/))+1;
	 Length 		 = document.getElementById(Id).value.length;
	 MaxLength 		 = parseInt(document.getElementById(Id).getAttribute('maxlength'));
	 
	 if (Length == MaxLength && NextFieldNumber != 5)
	 {
		 document.getElementById('pension_number_' + NextFieldNumber).focus();
	 } 
	 
}

function CheckPhoneNumber(PrefixId)
{
	AreaCode      	= document.getElementById(PrefixId + '_area').value;
	PhoneNumber   	= document.getElementById(PrefixId + '_number').value;
	FullPhoneNumber = 0;
	SetAsNormal(PrefixId);
	if (IsInteger(PrefixId + '_area') && IsInteger(PrefixId + '_number'))
	{	
		if (AreaCode != '' && PhoneNumber != '')
		{
			FullPhoneNumber = AreaCode.length + PhoneNumber.length;
			
			if ((FullPhoneNumber != 10) && (ErrorInstance == PrefixId || ErrorInstance == ''))
			{
				ShowErrorPrompt(PrefixId, "Номер телефона (вместе с кодом) должен содержать 10 цифр. Пожалуйста, исправьте.");
				return false;
			}
			else if (ErrorInstance == PrefixId)
			{
				HideErrorPrompt(PrefixId);
				SetAsNormalRadio(PrefixId);
				return true;
			}
			
		} else
		if (ErrorInstance == PrefixId)
		{
			HideErrorPrompt(PrefixId);
			SetAsNormalRadio(PrefixId);
			return true;
		}
	} else
	{
	  return false;
  	}
  return true;
}


/*function CheckPhoneNumber(PrefixId)
{
	AreaCode      	= document.getElementById(PrefixId + '_area').value;
	PhoneNumber   	= document.getElementById(PrefixId + '_number').value;
	FullPhoneNumber = 0;

  if (ErrorInstance == PrefixId)
  {
		SetAsNormalRadio(PrefixId);
		ErrorInstance = "";
	}
	
	if (IsInteger(PrefixId + '_area') && IsInteger(PrefixId + '_number'))
	{	
		if (AreaCode != '' && PhoneNumber != '')
		{
			FullPhoneNumber = AreaCode.length + PhoneNumber.length;
			
			if (FullPhoneNumber != 10 && (ErrorInstance == PrefixId || ErrorInstance == ''))
			{
				ShowErrorPrompt(PrefixId, "Номер телефона (вместе с кодом) может содержать только 10 цифр. Пожалуйста, исправьте.");
			}
			else if (ErrorInstance == PrefixId)
			{
				SetAsNormalRadio(PrefixId);
				ErrorInstance = "";
			}
		}
		else if (ErrorInstance == PrefixId)
		{
  		SetAsNormalRadio(PrefixId);
	  	ErrorInstance = "";
		}
	}
}
*/
function CheckDriverLicenceSeries()
{
	//document.getElementById('prompt').style.display = 'none';
	
	Word 		= document.getElementById('DriverLicSeries').value;
	NumCyrillic = 0;
	NumNumber   = 0;
	NumberArray = new Array(0,1,2,3,4,5,6,7,8,9);
	
	if (CheckStrict('DriverLicSeries'))
	{
		for (i = 0; i < Word.length; i++)
		{																	
				for (j = 0; j < CyrillicArray.length; j++)					
				{												
					if (Word.substring(i,i+1) == CyrillicArray[j])
					{							
						NumCyrillic++;
					}							
				}
					
				for (j = 0; j < NumberArray.length; j++)					
				{												
					if (Word.substring(i,i+1) == NumberArray[j])
					{							
						NumNumber++;
					}							
				}
				
		}		
	
		if (NumCyrillic != 2 && NumNumber != 2 && Word != '' && (ErrorInstance == 'DriverLicSeries' || ErrorInstance == ''))
		{   
			ShowErrorPrompt('DriverLicSeries', "Серия водительского удостоверения должна состоять из 2 русских букв и 2 цифр.");
		}
		else if (ErrorInstance == 'DriverLicSeries' && ((NumCyrillic == 2 && NumNumber == 2) || Word == ''))
		{
			HideErrorPrompt('DriverLicSeries');
		}
		else if (ShowHint == Id)
		{
			HideHint();				
		}
	}
}
 
function CheckCyrillic(Id, AcceptExtended)
{						
	//document.getElementById('prompt').style.display = 'none';
			
	ExtendedArray= new Array('a', 'b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
							 'A', 'B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
							 0,1,2,3,4,5,6,7,8,9,'.', ',','№'
							);
	
	
	// Andys added this to allow extra characters in Job Position fields
	if( 'PositionName' == Id || 'PrevEmploymPosition' == Id)
	{
      ExtendedArray  = new Array('"', '+');
      AcceptExtended = true;
	}

   // Andy added this to allow forward slash in house number fields
   if( 'RegistrAddressHouse' == Id || 'WorkPlaceHouse' == Id || 'ActAddrHomeAddress' == Id)
   {
      ExtendedArray[ExtendedArray.length] = '/';
   }

	
	Word         = document.getElementById(Id).value;
									 												 
	IsCyrillic   = true;			
	CyrillicChar = false;
	NotNumber	 = false;
	Character	 = new String();
		
	if (Word == '')		
	{
		IsCyrillic = false;
	}
	else {
	
		for (i = 0; i < Word.length; i++)
		{
			Character = Word.substring(i,i+1); 
			
			if (Character != ' ')  
			{
								
				CyrillicChar = false;
		
				for (j = 0; j < CyrillicArray.length; j++)					
				{												
					if (Word.substring(i,i+1) == CyrillicArray[j])
					{							
						CyrillicChar = true;
					}
							
				}
	
				if (AcceptExtended && !CyrillicChar)
				{	
					for (j = 0; j < ExtendedArray.length; j++)					
					{												
						if (Word.substring(i,i+1) == ExtendedArray[j])
						{							
							CyrillicChar = true;
						}							
					}
														
					if (!CyrillicChar)
					{
						IsCyrillic = false;
						break;
					}
				}
											
				if (!CyrillicChar && !AcceptExtended)
				{
					IsCyrillic = false;
					break;
				}
				
			}
		}
	}
	
	SetAsNormal(Id);
	
	if (!IsCyrillic && !AcceptExtended && Word != '' && (ErrorInstance == Id || ErrorInstance == ''))
	{		
		//Make sure you translate this and mentioning that the word may NOT contain numbers
		ShowErrorPrompt(Id, 'Вы можете использовать только русские буквы.');
		return false;		
	}
	else if (!IsCyrillic && AcceptExtended && Word != '' && (ErrorInstance == Id || ErrorInstance == ''))
	{	
		//This string may contain numbers	
		ShowErrorPrompt(Id, 'Вы можете использовать только русские буквы.');		
		return false;
	}
	else if ((IsCyrillic || Word == '') && ErrorInstance == Id)
	{
		HideErrorPrompt(Id);
	}
	else if (ShowHint == Id)
	{
		HideHint();				
	}

	
	return true;
}

function IsFloat(Id)
{  
	//document.getElementById('prompt').style.display = 'none';
	SetAsNormal(Id);
	
	if(!document.getElementById(Id).value.match(/^(\s+|\d+)*$/) && document.getElementById(Id).value != '' && (ErrorInstance == Id || ErrorInstance == ''))
	{
		ShowErrorPrompt(Id, 'Поле заполнено неверно. Пожалуйста, исправьте ошибку.');
		return false;		
	}
	else if (ErrorInstance == Id && (document.getElementById(Id).value.match(/^(\s+|\d+)*$/) || document.getElementById(Id).value == ''))
	{
		HideErrorPrompt(Id);
	}
	else if (ShowHint == Id)
	{
		HideHint();				
	}
	
	return true;
}

function IsInteger(Id)
{  
	//document.getElementById('prompt').style.display = 'none';
	SetAsNormal(Id);
	
	if(!document.getElementById(Id).value.match(/^(\s+|\d+)*$/) && document.getElementById(Id).value != '' && (ErrorInstance == Id || ErrorInstance == ''))
	{
		ShowErrorPrompt(Id, 'Поле заполнено неверно. Пожалуйста, исправьте ошибку.');		
		return false;
	}
	else if (ErrorInstance == Id && (document.getElementById(Id).value.match(/^\d+$/) || document.getElementById(Id).value == ''))
	{
		HideErrorPrompt(Id);
	}
	else if (ShowHint == Id)
	{
		HideHint();				
	}
	
	return true;
}

function SetAsWrong(Id)
{ 
	if (!document.getElementById(Id)) { /*alert("Null exception in SetAsWrong('"+Id+"')"); */return false;}
		$('#'+Id).addClass('wrong');
	
	ErrorString += Id +"\n";
	return false;		
}
		
function SetAsNormal(Id)
{
	if (!document.getElementById(Id)) { /*alert("Null exception in SetAsNormal('"+Id+"')"); */return false;}
		$('#'+Id).removeClass('wrong');

	return false;
}


/*		
function SetAsWrong(Id)
{
	switch (document.getElementById(Id).nodeName)
	{
		case "SELECT":
			document.getElementById(Id).style.backgroundColor = '#FF0000';
			document.getElementById(Id).style.color = '#FFFFFF';
		break;
				
		default: 
			document.getElementById(Id).style.border = '2px solid #FF0000';
	}
	
	ErrorString += Id +"\n";
	return false;		
}
		
function SetAsNormal(Id)
{
	//alert(document.getElementById(Id).nodeName);

	switch (document.getElementById(Id).nodeName)
	{
		case "SELECT":
			document.getElementById(Id).style.backgroundColor = '';
			document.getElementById(Id).style.color = '';
		break;
						
		default: 
//			document.getElementById(Id).style.border = '1px solid #CCCCCC';
			document.getElementById(Id).style.border = '2px inset';
	}

	return false;
}
*/
function ValidateGPApplication()
{
	SumErrors = 0;

	//SetAsNormal('WhereDidULearnAboutGPLoanLayer');
	SetAsNormal('LoanPeriod');		
	SetAsNormal('dob_day');
	SetAsNormal('dob_month');
	SetAsNormal('dob_year');
	SetAsNormal('date_of_pass_issue_day');
	SetAsNormal('date_of_pass_issue_month');
	SetAsNormal('date_of_pass_issue_year');
	SetAsNormal('type_of_other_doc');
	SetAsNormal('DataOfTaxReg_year');
	SetAsNormal('DataOfTaxReg_month');
	SetAsNormal('DataOfTaxReg_day');	
	SetAsNormal('DateForeignPassIssued_year');
	SetAsNormal('DateForeignPassIssued_month');
	SetAsNormal('DateForeignPassIssued_day');
	SetAsNormal('DateDrivLicIssued_year');
	SetAsNormal('DateDrivLicIssued_month');
	SetAsNormal('DateDrivLicIssued_day');
	SetAsNormal('TypeOfInhabEntityRegAddress');
	SetAsNormal('LoanAmmount');
	SetAsNormal('name');
	SetAsNormal('surname');
	SetAsNormal('middle_name');
	SetAsNormal('ChangedFirstName');
	SetAsNormal('ChangedSurName');
	SetAsNormal('ChangedMiddleName');
	SetAsNormal('place_of_birth');
	SetAsNormal('education');
	SetAsNormal('email');
	SetAsNormal('passport_series');
	SetAsNormal('passport_number');
	SetAsNormal('place_of_passport_issue');
	SetAsNormal('pension_number_1');
	SetAsNormal('pension_number_2');
	SetAsNormal('pension_number_3');
	SetAsNormal('pension_number_4');
	SetAsNormal('OMSpolicySeries');
	SetAsNormal('OMSpolicyNumber');
	SetAsNormal('TaxNumber');
	SetAsNormal('WhoIssuedTaxNumber');
	SetAsNormal('ForeignPassSeries');
	SetAsNormal('ForeignPassNumber');
	SetAsNormal('WhereForeignPassIssued');
	SetAsNormal('DriverLicSeries');
	SetAsNormal('DriverLicNumber');
	SetAsNormal('WhoIssuedDrivLicense');
	SetAsNormal('reg-reg');
	SetAsNormal('NameInhabEntityRegistrAddress');
	SetAsNormal('RegistrAddressStreet');
	SetAsNormal('RegistrAddressHouse');
	SetAsNormal('ActAddrTypeofInhabEntity');
	SetAsNormal('reg-liveing');
	SetAsNormal('ActAddrPlaceName');
	SetAsNormal('ActAddrStreet');
	SetAsNormal('ActAddrHomeAddress');
	SetAsNormal('ActAddrTypeOFProperty');
	SetAsNormal('ActAddrLivePeriod_years');
	SetAsNormal('ActAddrLivePeriod_months');
	SetAsNormal('RegAddrPhone_number');
	SetAsNormal('RegAddrPhone_area');
	SetAsNormal('ContactPersSurname');
	SetAsNormal('ContactPersName');
	SetAsNormal('ContactPersMiddleName');
	SetAsNormal('ContactPersPhone_area');
	SetAsNormal('ContactPersPhone_number');
	SetAsNormal('CorrespondAddress');
	SetAsNormal('delivery');
	SetAsNormal('income_source');
	SetAsNormal('main_incometype');
	SetAsNormal('MonthIncome');
	SetAsNormal('add_income_source');
	SetAsNormal('add_income_amount');
	SetAsNormal('AutoMake');
	SetAsNormal('AutoRegNumber');
	SetAsNormal('AutoYear');
	SetAsNormal('RealEstateOwnershipType');
	SetAsNormal('CompanyName');
	SetAsNormal('Industry');
	SetAsNormal('PositionType');
	SetAsNormal('PositionName');
	SetAsNormal('FullOrPartTime');
	SetAsNormal('WorkPeriod_years');
	SetAsNormal('WorkPeriod_months');
	SetAsNormal('reg-work');
	SetAsNormal('WorkPlacetypeOfInhabitEnt');
	SetAsNormal('WorkPlaceNameOfInhabEnt');
	SetAsNormal('WorkPlaceStreet');
	SetAsNormal('WorkPlaceHouse');
	SetAsNormal('sex-male');
	SetAsNormal('sex-female');
	SetAsNormal('WorkPhone_area');
	SetAsNormal('WorkPhone_number');
	SetAsNormal('SecureWord');
	SetAsNormal('HomePhone_area');
	SetAsNormal('HomePhone_number');
	SetAsNormal('AdditIncome-yes');
	SetAsNormal('AdditIncome-no');
	SetAsNormal('Auto_RemainingAmount');
	SetAsNormal('Auto_MonthlyPayment');
	SetAsNormal('Auto_Bank');
	SetAsNormal('Mortgage_RemainingAmount');
	SetAsNormal('Mortgage_MonthlyPayment');
	SetAsNormal('Mortgage_Bank');
	SetAsNormal('GP_RemainingAmount');
	SetAsNormal('GP_MonthlyPayment');
	SetAsNormal('GP_Bank'); 
	SetAsNormal('CreditCard_RemainingAmount');
	SetAsNormal('CreditCard_MonthlyPayment');
	SetAsNormal('CreditCard_Bank');		
	SetAsNormal('Other_RemainingAmount');
	SetAsNormal('Other_MonthlyPayment');
	SetAsNormal('Other_Bank');				
	SetAsNormal('Other_Name');

	if (document.getElementById('OtherBank_Other').checked &&
		document.getElementById('Other_Name').value == ''
		)
	{
		SetAsWrong('Other_Name');
		SumErrors++;
	}
	
	if (document.getElementById('OtherBank_Other').checked &&
		document.getElementById('Other_RemainingAmount').value == ''
		)
	{
		SetAsWrong('Other_RemainingAmount');
		SumErrors++;
	}
	
	if (document.getElementById('OtherBank_Other').checked &&
		document.getElementById('Other_MonthlyPayment').value == ''
		)
	{
		SetAsWrong('Other_MonthlyPayment');
		SumErrors++;
	}
	
	if (document.getElementById('OtherBank_Other').checked &&
		document.getElementById('Other_Bank').value == ''
		)
	{
		SetAsWrong('Other_Bank');
		SumErrors++;
	}
	
	if (document.getElementById('OtherBank_CreditCard').checked &&
		document.getElementById('CreditCard_RemainingAmount').value == ''
		)
	{
		SetAsWrong('CreditCard_RemainingAmount');
		SumErrors++;
	}
	
	if (document.getElementById('OtherBank_CreditCard').checked &&
		document.getElementById('CreditCard_MonthlyPayment').value == ''
		)
	{
		SetAsWrong('CreditCard_MonthlyPayment');
		SumErrors++;
	}
	
	if (document.getElementById('OtherBank_CreditCard').checked &&
		document.getElementById('CreditCard_Bank').value == ''
		)
	{
		SetAsWrong('CreditCard_Bank');
		SumErrors++;
	}

	if (document.getElementById('OtherBank_Auto').checked &&
		document.getElementById('Auto_RemainingAmount').value == ''
		)
	{
		SetAsWrong('Auto_RemainingAmount');
		SumErrors++;
	}
	
	if (document.getElementById('OtherBank_Auto').checked &&
		document.getElementById('Auto_MonthlyPayment').value == ''
		)
	{
		SetAsWrong('Auto_MonthlyPayment');
		SumErrors++;
	}
	
	if (document.getElementById('OtherBank_Auto').checked &&
		document.getElementById('Auto_Bank').value == ''
		)
	{
		SetAsWrong('Auto_Bank');
		SumErrors++;
	}
	
	if (document.getElementById('OtherBank_Mortgage').checked &&
		document.getElementById('Mortgage_RemainingAmount').value == ''
		)
	{
		SetAsWrong('Mortgage_RemainingAmount');
		SumErrors++;
	}
	
	if (document.getElementById('OtherBank_Mortgage').checked &&
		document.getElementById('Mortgage_MonthlyPayment').value == ''
		)
	{
		SetAsWrong('Mortgage_MonthlyPayment');
		SumErrors++;
	}
	
	if (document.getElementById('OtherBank_Mortgage').checked &&
		document.getElementById('Mortgage_Bank').value == ''
		)
	{
		SetAsWrong('Mortgage_Bank');
		SumErrors++;
	}

	if (document.getElementById('OtherBank_GP').checked &&
		document.getElementById('GP_RemainingAmount').value == ''
		)
	{
		SetAsWrong('GP_RemainingAmount');
		SumErrors++;
	}
	
	if (document.getElementById('OtherBank_GP').checked &&
		document.getElementById('GP_MonthlyPayment').value == ''
		)
	{
		SetAsWrong('GP_MonthlyPayment');
		SumErrors++;
	}
	
	if (document.getElementById('OtherBank_GP').checked &&
		document.getElementById('GP_Bank').value == ''
		)
	{
		SetAsWrong('GP_Bank');
		SumErrors++;
	}
	
	
	
	if (document.getElementById('SecureWord').value == '')
	{
		SetAsWrong('SecureWord');
		SumErrors++;
	}
		
	if (document.getElementById('HomePhone_number').value == '')
	{
		SetAsWrong('HomePhone_number');
		SumErrors++;
	}
	
	if (document.getElementById('HomePhone_area').value == '')
	{
		SetAsWrong('HomePhone_area');
		SumErrors++;
	}
		
	if (document.getElementById('WorkPhone_number').value == '')
	{
		SetAsWrong('WorkPhone_number');
		SumErrors++;
	}
	
	if (document.getElementById('WorkPhone_area').value == '')
	{
		SetAsWrong('WorkPhone_area');
		SumErrors++;
	}
	
	if (document.getElementById('WorkPlaceHouse').value == '')
	{
		SetAsWrong('WorkPlaceHouse');
		SumErrors++;
	}
	
	if (document.getElementById('WorkPlaceStreet').value == '')
	{
		SetAsWrong('WorkPlaceStreet');
		SumErrors++;
	}
	
	if (document.getElementById('WorkPlaceNameOfInhabEnt').value == '')
	{
		SetAsWrong('WorkPlaceNameOfInhabEnt');
		SumErrors++;
	}
	
	if (document.getElementById('WorkPlacetypeOfInhabitEnt').selectedIndex == 0)
	{
		SetAsWrong('WorkPlacetypeOfInhabitEnt');
		SumErrors++;
	}
	
	if (document.getElementById('reg-work').selectedIndex == 0)
	{
		SetAsWrong('reg-work');
		SumErrors++;
	}
		
	if (document.getElementById('WorkPeriod_months').selectedIndex == 0)
	{
		SetAsWrong('WorkPeriod_months');
		SumErrors++;
	}
	
	if (document.getElementById('WorkPeriod_years').selectedIndex == 0)
	{
		SetAsWrong('WorkPeriod_years');
		SumErrors++;
	}
	
	if (document.getElementById('FullOrPartTime').selectedIndex == 0)
	{
		SetAsWrong('FullOrPartTime');
		SumErrors++;
	}
	
	if (document.getElementById('PositionName').value == '')
	{
		SetAsWrong('PositionName');
		SumErrors++;
	}
	
	if (document.getElementById('PositionType').selectedIndex == 0)
	{
		SetAsWrong('PositionType');
		SumErrors++;
	}
	
	if (document.getElementById('Industry').selectedIndex == 0)
	{
		SetAsWrong('Industry');
		SumErrors++;
	}
	
	if (document.getElementById('CompanyName').value == '')
	{
		SetAsWrong('CompanyName');
		SumErrors++;
	}

	if (document.getElementById('RealEstate').checked && 
		document.getElementById('RealEstateOwnershipType').selectedIndex == 0
		)
	{
		SetAsWrong('RealEstateOwnershipType');
		SumErrors++;
	}
			
	if (document.getElementById('Auto').checked && 
		document.getElementById('AutoRegNumber') == ''
		)
	{
		SetAsWrong('AutoRegNumber');
		SumErrors++;
	}
	
	if (document.getElementById('Auto').checked && 
		document.getElementById('AutoYear') == ''
		)
	{
		SetAsWrong('AutoYear');
		SumErrors++;
	}

	if (!document.getElementById('sex-female').checked && 
		!document.getElementById('sex-male').checked)
	{
		SetAsWrong('sex-female');
		SetAsWrong('sex-male');
		SumErrors++;
	}

	if (document.getElementById('Auto').checked && 
		document.getElementById('AutoMake') == ''
		)
	{
		SetAsWrong('AutoMake');
		SumErrors++;
	}
	
	if (document.getElementById('AdditIncome-yes').checked && 
		document.getElementById('add_income_amount') == ''
		)
	{
		SetAsWrong('add_income_amount');
		SumErrors++;
	}
	
	if (!document.getElementById('AdditIncome-yes').checked && !document.getElementById('AdditIncome-no').checked)
	{
		SetAsWrong('AdditIncome-yes');
		SetAsWrong('AdditIncome-no');
		SumErrors++;
	}
	
	if (document.getElementById('AdditIncome-yes').checked && 
		document.getElementById('add_income_source').selectedIndex == 0
		)
	{
		SetAsWrong('add_income_source');
		SumErrors++;
	}

	if (document.getElementById('MonthIncome').value == '')
	{
		SetAsWrong('MonthIncome');
		SumErrors++;
	}
	
	if (document.getElementById('main_incometype').selectedIndex == 0)
	{
		SetAsWrong('main_incometype');
		SumErrors++;
	}


	if (document.getElementById('income_source').selectedIndex == 0)
	{
		SetAsWrong('income_source');
		SumErrors++;
	}

	if (!document.getElementById('delivery-m').checked && !document.getElementById('delivery-n').checked)
	{
		SetAsWrong('delivery');
		SumErrors++;
	}

	if (document.getElementById('delivery-m').checked && document.getElementById('CorrespondAddress').selectedIndex == 0)
	{
		SetAsWrong('CorrespondAddress');
		SumErrors++;
	}
	
	if (document.getElementById('ContactPersPhone_area').value == '')
	{
		SetAsWrong('ContactPersPhone_area');
		SumErrors++;
	}
	
	if (document.getElementById('ContactPersPhone_number').value == '')
	{
		SetAsWrong('ContactPersPhone_number');
		SumErrors++;
	}

	if (document.getElementById('ContactPersMiddleName').value == '')
	{
		SetAsWrong('ContactPersMiddleName');
		SumErrors++;
	}
	
	if (document.getElementById('ContactPersName').value == '')
	{
		SetAsWrong('ContactPersName');
		SumErrors++;
	}
	
	if (document.getElementById('ContactPersSurname').value == '')
	{
		SetAsWrong('ContactPersSurname');
		SumErrors++;
	}
			
	if (!document.getElementById('RegAddrPhone').checked && 
		document.getElementById('RegAddrPhone_number').value == ''
		)
	{
		SetAsWrong('RegAddrPhone_number');
		SumErrors++;
	}
	
	if (!document.getElementById('RegAddrPhone').checked && 
		document.getElementById('RegAddrPhone_area').value == ''
		)
	{
		SetAsWrong('RegAddrPhone_area');
		SumErrors++;
	}
			
	if (document.getElementById('ActAddrLivePeriod_months').selectedIndex == 0
		)
	{
		SetAsWrong('ActAddrLivePeriod_months');
		SumErrors++;
	}
	
	if (document.getElementById('ActAddrLivePeriod_years').selectedIndex == 0
		)
	{
		SetAsWrong('ActAddrLivePeriod_years');
		SumErrors++;
	}
	
	if (document.getElementById('ActAddrTypeOFProperty').selectedIndex == 0
		)
	{
		SetAsWrong('ActAddrTypeOFProperty');
		SumErrors++;
	}
	
	if (!document.getElementById('RegistrAddressIsTheSameFactualAddr').checked && 
		document.getElementById('ActAddrHomeAddress').value == ''
		)
	{
		SetAsWrong('ActAddrHomeAddress');
		SumErrors++;
	}
	
	if (!document.getElementById('RegistrAddressIsTheSameFactualAddr').checked && 
		document.getElementById('ActAddrStreet').value == ''
		)
	{
		SetAsWrong('ActAddrStreet');
		SumErrors++;
	}
	
	if (!document.getElementById('RegistrAddressIsTheSameFactualAddr').checked && 
		document.getElementById('ActAddrPlaceName').value == ''
		)
	{
		SetAsWrong('ActAddrPlaceName');
		SumErrors++;
	}
	
	if (!document.getElementById('RegistrAddressIsTheSameFactualAddr').checked && 
		document.getElementById('reg-liveing').selectedIndex == 0
		)
	{
		SetAsWrong('reg-liveing');
		SumErrors++;
	}
	
	if (!document.getElementById('RegistrAddressIsTheSameFactualAddr').checked && 
		document.getElementById('ActAddrTypeofInhabEntity').selectedIndex == 0
		)
	{
		SetAsWrong('ActAddrTypeofInhabEntity');
		SumErrors++;
	}
	
	if (document.getElementById('NameInhabEntityRegistrAddress').value == '')
	{
		SetAsWrong('NameInhabEntityRegistrAddress');
		SumErrors++;
	}
	
	if (document.getElementById('RegistrAddressStreet').value == '')
	{
		SetAsWrong('RegistrAddressStreet');
		SumErrors++;
	}
	
	if (document.getElementById('RegistrAddressHouse').value == '')
	{
		SetAsWrong('RegistrAddressHouse');
		SumErrors++;
	}
	
	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 4
		&& document.getElementById('WhoIssuedDrivLicense').value == ''
		)
	{
		SetAsWrong('WhoIssuedDrivLicense');
		SumErrors++;
	}

	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 4
		&& document.getElementById('DateDrivLicIssued_year').selectedIndex == 0)
	{
		SetAsWrong('DateDrivLicIssued_year');
		SumErrors++;
	}
	
	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 4
		&& document.getElementById('DateDrivLicIssued_month').selectedIndex == 0)
	{
		SetAsWrong('DateDrivLicIssued_month');
		SumErrors++;
	}
	
	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 4
		&& document.getElementById('DateDrivLicIssued_day').selectedIndex == 0)
	{
		SetAsWrong('DateDrivLicIssued_day');
		SumErrors++;
	}

	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 4
		&& document.getElementById('DriverLicSeries').value == ''
		)
	{
		SetAsWrong('DriverLicSeries');
		SumErrors++;
	}
	
	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 4
		&& document.getElementById('DriverLicNumber').value == '')

	{
		SetAsWrong('DriverLicNumber');
		SumErrors++;
	}

	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 2
		&& document.getElementById('WhereForeignPassIssued').value == '')

	{
		SetAsWrong('WhereForeignPassIssued');
		SumErrors++;
	}
	
	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 2
		&& document.getElementById('ForeignPassSeries').value == '')

	{
		SetAsWrong('ForeignPassSeries');
		SumErrors++;
	}
	
	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 2
		&& document.getElementById('ForeignPassNumber').value == '')

	{
		SetAsWrong('ForeignPassNumber');
		SumErrors++;
	}
	
	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 2
		&& document.getElementById('DateForeignPassIssued_month').selectedIndex == 0)
	{
		SetAsWrong('DateForeignPassIssued_month');
		SumErrors++;
	}
	
	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 2
		&& document.getElementById('DateForeignPassIssued_day').selectedIndex == 0)
	{
		SetAsWrong('DateForeignPassIssued_day');
		SumErrors++;
	}

	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 2
		&& document.getElementById('DateForeignPassIssued_year').selectedIndex == 0)
	{
		SetAsWrong('DateForeignPassIssued_year');
		SumErrors++;
	}

	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 5
		&& document.getElementById('WhoIssuedTaxNumber').value == '')

	{
		SetAsWrong('WhoIssuedTaxNumber');
		SumErrors++;
	}
	
	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 5
		&& document.getElementById('TaxNumber').value == '')

	{
		SetAsWrong('TaxNumber');
		SumErrors++;
	}
	
	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 5
		&& document.getElementById('DataOfTaxReg_day').selectedIndex == 0)
	{
		SetAsWrong('DataOfTaxReg_day');
		SumErrors++;
	}

	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 5
		&& document.getElementById('DataOfTaxReg_month').selectedIndex == 0)
	{
		SetAsWrong('DataOfTaxReg_month');
		SumErrors++;
	}
	
	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 5
		&& document.getElementById('DataOfTaxReg_year').selectedIndex == 0)
	{
		SetAsWrong('DataOfTaxReg_year');
		SumErrors++;
	}

	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 7
		&& document.getElementById('OMSpolicySeries').value == '')

	{
		SetAsWrong('OMSpolicySeries');
		SumErrors++;
	}
	
	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 7
		&& document.getElementById('OMSpolicyNumber').value == '')

	{
		SetAsWrong('OMSpolicyNumber');
		SumErrors++;
	}



	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 3
		&& document.getElementById('pension_number_1').value == '')

	{
		SetAsWrong('pension_number_1');
		SumErrors++;
	}
	
	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 3
		&& document.getElementById('pension_number_2').value == '')

	{
		SetAsWrong('pension_number_2');
		SumErrors++;
	}
	
	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 3
		&& document.getElementById('pension_number_3').value == '')

	{
		SetAsWrong('pension_number_3');
		SumErrors++;
	}
	
	if (document.getElementById('type_of_other_doc').options[document.getElementById('type_of_other_doc').selectedIndex].value == 3
		&& document.getElementById('pension_number_4').value == '')

	{
		SetAsWrong('pension_number_4');
		SumErrors++;
	}
	
	if (document.getElementById('place_of_passport_issue').value == '')
	{
		SetAsWrong('place_of_passport_issue');
		SumErrors++;
	}

	if (document.getElementById('passport_series').value == '')
	{
		SetAsWrong('passport_series');
		SumErrors++;
	}

	if (document.getElementById('passport_number').value == '')
	{
		SetAsWrong('passport_number');
		SumErrors++;
	}
	
	if (document.getElementById('delivery-n').checked && document.getElementById('email').value == '')
	{
		SetAsWrong('email');
		SumErrors++;
	}
	
	if (document.getElementById('place_of_birth').value == '')
	{
		SetAsWrong('place_of_birth');
		SumErrors++;
	}
	
	if (document.getElementById('ChangedFirstName').value == '' && document.getElementById('ChangedName').checked)
	{
		SetAsWrong('ChangedFirstName');
		SumErrors++;
	}
	
	if (document.getElementById('ChangedSurName').value == '' && document.getElementById('ChangedName').checked)
	{
		SetAsWrong('ChangedSurName');
		SumErrors++;
	}
	
	if (document.getElementById('ChangedMiddleName').value == '' && document.getElementById('ChangedName').checked)
	{
		SetAsWrong('ChangedMiddleName');
		SumErrors++;
	}
	
	if (document.getElementById('name').value == '')
	{
		SetAsWrong('name');
		SumErrors++;
	}

	if (document.getElementById('surname').value == '')
	{
		SetAsWrong('surname');
		SumErrors++;
	}
	
	if (document.getElementById('middle_name').value == '')
	{
		SetAsWrong('middle_name');
		SumErrors++;
	}
	
	/*if (document.getElementById('WhereDidULearnAboutGPLoan').selectedIndex == 0)
	{
		SetAsWrong('WhereDidULearnAboutGPLoanLayer');
		SumErrors++;
	}*/
	
	if (document.getElementById('LoanPeriod').selectedIndex == 0)
	{
		SetAsWrong('LoanPeriod');	
		SumErrors++;
	}
	
	if (!document.getElementById('sex-male').checked && !document.getElementById('sex-female').checked)
	{
		SetAsWrong('sex-male');
		SetAsWrong('sex-female');
		SumErrors++;
	}
	
	if (document.getElementById('dob_day').selectedIndex == 0)
	{
		SetAsWrong('dob_day');
		SumErrors++;
	}
	
	if (document.getElementById('dob_month').selectedIndex == 0)
	{
		SetAsWrong('dob_month');
		SumErrors++;
	}

	if (document.getElementById('dob_year').selectedIndex == 0)
	{
		SetAsWrong('dob_year');
		SumErrors++;
	}
	
	if (document.getElementById('reg-reg').selectedIndex == 0)
	{
		SetAsWrong('reg-reg');
		SumErrors++;
	}

	if (document.getElementById('date_of_pass_issue_day').selectedIndex == 0)
	{
		SetAsWrong('date_of_pass_issue_day');
		SumErrors++;
	}
	
	if (document.getElementById('date_of_pass_issue_month').selectedIndex == 0)
	{
		SetAsWrong('date_of_pass_issue_month');
		SumErrors++;
	}

	if (document.getElementById('date_of_pass_issue_year').selectedIndex == 0)
	{
		SetAsWrong('date_of_pass_issue_year');
		SumErrors++;
	}

	if (document.getElementById('type_of_other_doc').selectedIndex == 0)
	{
		SetAsWrong('type_of_other_doc');
		SumErrors++;
	}
					
	if (document.getElementById('TypeOfInhabEntityRegAddress').selectedIndex == 0)
	{
		SetAsWrong('TypeOfInhabEntityRegAddress');
		SumErrors++;
	}
	
	if (document.getElementById('education').selectedIndex == 0)
	{
		SetAsWrong('education');
		SumErrors++;
	}
	
	if (document.getElementById('LoanAmmount').value == '')
	{
		SetAsWrong('LoanAmmount');
		SumErrors++;
	}
	
	//return true;
	if (SumErrors > 0)
	{
		document.getElementById('FormSubmitError').style.display = 'block'; //alert(ErrorString); ErrorString = '';
		return false;
	}
	else
	{	
		document.getElementById('FormSubmitError').style.display = 'none';
		return true;
	}
	
}

