function SetDaysForDateSelector(objYear, objMonth, objDay, DaySelected){
    DaysInMonth=30;
    if(objMonth.value==1||objMonth.value==3||objMonth.value==5||objMonth.value==7||objMonth.value==8||objMonth.value==10||objMonth.value==12)DaysInMonth=31;
    
    if(objMonth.value==2){
        DaysInMonth=28;
        if(objYear.value%4==0)DaysInMonth=29;
	}
	
    objDay.options.length = 0;
    //OptionHTML='';
	for(DayCounter=1;DayCounter<=DaysInMonth;DayCounter++){
		var ThisOption = document.createElement("OPTION");
		
		ThisOption.text = DayCounter;
		ThisOption.value = DayCounter;
		if(DayCounter==DaySelected)ThisOption.selected=true;
		
		objDay.options.add(ThisOption);
	}
}

function SetDateSelectorValueToSCW(objSCW, DateSelectorBaseID, DateSeperator){
	MonthNameShort='Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec';
	MonthNameShort=MonthNameShort.split(',');

	objSCW.value=''+document.getElementById(DateSelectorBaseID+'_Day').value+DateSeperator+MonthNameShort[document.getElementById(DateSelectorBaseID+'_Month').value-1]+DateSeperator+document.getElementById(DateSelectorBaseID+'_Year').value+'';
}

function SetSCWValueToDateSelector(objSCW, DateSelectorBaseID, DateSeperator){
	MonthNameShort='Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec';
	MonthNameShort=MonthNameShort.split(',');

	DatePart=objSCW.value.split(DateSeperator);
	if(DatePart[0].substring(0, 1)==0)DatePart[0]=DatePart[0].substring(1, 2)

	document.getElementById(DateSelectorBaseID+'_Year').value=DatePart[2];
	
	for(MonthCounter=0; MonthCounter<12; MonthCounter++)if(MonthNameShort[MonthCounter]==DatePart[1])break;
	if(MonthCounter<12)document.getElementById(DateSelectorBaseID+'_Month').value=MonthCounter+1;
	
	SetDaysForDateSelector(document.getElementById(DateSelectorBaseID+'_Year'), document.getElementById(DateSelectorBaseID+'_Month'), document.getElementById(DateSelectorBaseID+'_Day'), DatePart[0]);
}

function ToggleDateSelector(DateSelectorBaseID, Enabled){
	document.getElementById(DateSelectorBaseID+'_Year').disabled=!Enabled
	document.getElementById(DateSelectorBaseID+'_Month').disabled=!Enabled
	document.getElementById(DateSelectorBaseID+'_Day').disabled=!Enabled
	document.getElementById(DateSelectorBaseID+'IconCalendar').disabled=!Enabled
}
