<?xml version="1.0" encoding="utf-8"?>
<!--
////////////////////////////////////////////////////////////////////////////////
// ADOBE SYSTEMS INCORPORATED
// Copyright 2007 Adobe Systems Incorporated
// All Rights Reserved.
//
// NOTICE:  Adobe permits you to use, modify, and distribute this file in accordance with the 
// terms of the Adobe license agreement accompanying it.  If you have received this file from a 
// source other than Adobe, then your use, modification, or distribution of it requires the prior 
// written permission of Adobe.
////////////////////////////////////////////////////////////////////////////////
-->
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"
   	xmlns:custom="components.*"
    creationComplete="init()">
    <mx:Script>
    	<![CDATA[
    		import mx.events.ListEvent;
    		//create bindable variables to share with components
	      	[Bindable]
	     	private var days:Array;

      		[Bindable]
      		private var years:Array = new Array();         		
      		
      		private function init():void{
      			this.monthsCB.addEventListener(ListEvent.CHANGE,monthsHandler);
      			//get current date
      			var now:Date = new Date();
      			
      			//populate days and year
      			setDays(now.getMonth());
				setYears(now.getFullYear());        		
        		
        		//select the display values for the combo boxes based on the current date
        		this.daysCB.selectedIndex = 0;
        		this.yearsCB.selectedIndex = years.indexOf(now.getFullYear());     		
        		
      		}
      		
      		private function monthsHandler(event:ListEvent):void{
      			setDays(event.currentTarget.selectedIndex);
      			this.daysCB.selectedIndex = 0;
      		}
      		
      		private function setDays(month:int):void{
      			this.days = new Array();	
      			var i:int;
      			
      			if (month == 0 || month == 2 || month == 4 || month == 6 || month == 7 || month == 9 || month == 11){      			
        			for(i=1; i<=31; i++)      			
          			this.days.push(i);
          			
        		}else if (month == 3 || month == 5 || month == 8 || month == 10){
        			for(i=1; i<=30; i++)
          			this.days.push(i);
          			
        		}else if (month == 1){
        			if (yearsCB.selectedIndex % 4 == 0){        				
	        			for(i=1; i<=29; i++)
	          			this.days.push(i);
        			}else{
        				for(i=1; i<=28; i++)
	          			this.days.push(i);
        			}          			
        		}
	      	}
	      	
	      	private function setYears(year:int):void{
	      		var j:int;	      		
       			for(j=1950; j<=year; j++){
          			this.years.push(j);          
        		}	      		
	      	}
     ]]>
  </mx:Script>
  
  <custom:ComboBoxMonths id="monthsCB"/>
  <mx:ComboBox id="daysCB" dataProvider="{this.days}" width="50"/>
  <mx:ComboBox id="yearsCB" dataProvider="{this.years}" width="70"/>
</mx:HBox>
