/////////////////////////////////////////////////////////////////////////////////////////////

function select_value_get( cID ) {
	var oSelect = document.getElementById( cID );
	return ( oSelect.selectedIndex >= 0 ?
		oSelect.options[ oSelect.selectedIndex ].value :
		null 
	);
}

function select_value_set( cID, cValue ) {
	var oSelect = document.getElementById( cID ), nIndex, oOpt;
	if (cValue == null) nIndex = -1;
	else {
		oOpt = oSelect.options;
		for ( nIndex = 0; nIndex < oOpt.length; nIndex ++ ) 
			if ( oOpt[ nIndex ].value == cValue ) break;
		if ( nIndex >= oOpt.length ) nIndex = -1;
	};
	oSelect.selectedIndex = nIndex;
}

function select_date_get( cIdY, cIdM, cIdD ) {
	var oD;
	try {
		oD = new Date(
			select_value_get( cIdY ),
			select_value_get( cIdM ),
			select_value_get( cIdD )
		);
	} catch( e ) {
		oD = null;
	};
	return oD;
};

function select_date_set( cIdY, cIdM, cIdD, oD ) {
	select_value_set( cIdD, oD.getDate());
	select_value_set( cIdM, oD.getMonth());
	select_value_set( cIdY, oD.getFullYear());
}

function select_date_group_set( cIdPfx, oD ) {
	select_date_set( cIdPfx + "YearSELECT", cIdPfx + "MonthSELECT", cIdPfx + "DaySELECT", oD );
}

function select_date_group_get( cIdPfx ) {
	return select_date_get( cIdPfx + "YearSELECT", cIdPfx + "MonthSELECT", cIdPfx + "DaySELECT" );
}


Date.prototype.midnight = function() {
	var oD = new Date( this );
	oD.setHours( 0 ); oD.setMinutes( 0 ); oD.setSeconds( 0 );
	return oD;
}

Date.prototype.toDDMMYYYYString = function() {
	return this.getDate() + "." + ( this.getMonth() + 1 ) + "." + this.getFullYear();

}

Date.prototype.toLongString = function() {
	return this.getDate() + " " + aMonths[ this.getMonth() ] + " " + this.getFullYear();
}

Array.prototype.add = function( item ) {
	this[ this.length ] = item;
	return this;
}

/////////////////////////////////////////////////////////////////////////////////////////////

var aMonths = new Array();

aMonths.add( "Января" );
aMonths.add( "Февраля" );
aMonths.add( "Марта" );
aMonths.add( "Апреля" );
aMonths.add( "Мая" );
aMonths.add( "Июня" );
aMonths.add( "Июля" );
aMonths.add( "Августа" );
aMonths.add( "Сентября" );
aMonths.add( "Октября" );
aMonths.add( "Ноября" );
aMonths.add( "Декабря" );

/////////////////////////////////////////////////////////////////////////////////////////////
