function getSummary(cform)
{
var daysinmonth = new Array(31,29,31,30,31,30,31,31,30,31,30,31);

	if ( cform.day_enable.value == 'false' )
	{
                cform.value_from.value =
                cform.prefix.value +
                cform.year.value + "/" +
                cform.month.value;

                cform.value_to.value = cform.value_from.value;

	        cform.date.value =      cform.month.value + '.' +
                                        cform.year.value
	}
	else
	{
                if ( cform.day.value == "" ||
        	     cform.day.value == " " ||
        	     cform.day.value == "  " )
        	{
                        cform.value_from.value =
                        cform.prefix.value +
                        cform.year.value + "/" +
                        cform.month.value + "/01";

                        cform.value_to.value =
                        cform.prefix.value +
                        cform.year.value + "/" +
                        cform.month.value + "/" +
                        daysinmonth[cform.month.value-1];


        	        cform.date.value =      cform.month.value + '.' +
                                                cform.year.value
        	}
        	else
        	{
                        cform.value_from.value =
                        cform.prefix.value +
                        cform.year.value + "/" +
                        cform.month.value + "/" +
                        (new Number(cform.day.value)<10?"0":"") +
                        (new Number(cform.day.value)).toString();

                        cform.value_to.value = cform.value_from.value;

        	        cform.date.value = cform.day.value + '.' +
                                                cform.month.value + '.' +
                                                cform.year.value
        	}
         }
}


function getNewRange(cform)
{
        getSummary(cform);
        return ScheduleValidate(cform);
}

function ScheduleValidate(cform)
{
        if( Valid_Date(cform, cform.date.value ) == false )
        {
                alert( "Недопустимая дата: " + cform.date.value );
                return false;
        }

        return true;
}


function Valid_Date(cform, datein)
{

        var indate=datein;
        var rc = true;

        var sdate = indate.split(".")

        if(  cform.dayRequired.value == "yes"  || cform.day.value != ""  &&  cform.day.value != " " &&
	     cform.day.value != "  ")
        {
	                var chkDate=new Date(Date.parse(sdate[1]+"/"+sdate[0]+"/"+sdate[2]));
	                var cmpDate=(chkDate.getMonth()+1)+"/"+(chkDate.getDate())+"/"+(chkDate.getFullYear())
	                var indate2=(Math.abs(sdate[1]))+"/"+(Math.abs(sdate[0]))+"/"+(Math.abs(sdate[2]))

	                if ( indate2 != cmpDate )
	                {
		                rc = false;
	                }
        }
        return (rc);
}


