﻿// JScript File
var libraryName = 'js/RU.js';
document.write( '<script type="text/javascript" src="'+libraryName+'"></script>' );

function Save()
{
    if( !CheckForm() ) return false;
    uniform.pg_mode.value = (uniform.pg_mode.value == 'create' ) ? 'append' : 'update';
    try{ AfterSave(); } catch( e ) {}
    uniform.submit();
}

function	CheckForm()
{
	try
	{
		var res = CustomCheck();
		if( res != null )
		{
			ShowError( res );
			return false;
		}
	} 
	catch( e ) {}
	
	var checkline = '';
	for( var i=0;i<FormFields.length; i++ )
	{
	    if( !FormFields[i] ) continue;
		name = FormFields[i].id.substring( 3, FormFields[i].id.length );
		chkfld = $( 'checkline' + name);
		if( chkfld ) checkline += chkfld.value;
	}
	return CheckFieldSet( checkline );
}

//Валидация группы полей
function	CheckFieldSet( checkline )
{
	var chk = new DataChecker( DataCheckerLanguage ); 
	chk.bild( uniform, checkline );
	if( ! chk.check() )
	{	
		ShowError( chk.message(",\n") );
		if( chk.element(0).disabled	== false && chk.element(0).type != "hidden" )
		{
			try{ chk.element(0).focus(); } catch( e ) {}
		}
		return false; 
 	}
 	return true;
}