
Ext.onReady(function() {


var tdih_date = new Ext.form.DateField({
	name: 'tdih',
	width:90,
	allowBlank:false,
	format:'d-m'
});

tdih_date.setValue(new Date());

tdih_date.applyTo('mydate');


Ext.get('gobutton').on('click', function(){

		if(tdih_date.getValue()){
			var t = new Date(tdih_date.getValue());
			var m = t.getMonth()+1;
			var d = t.getDate();
	
			Ext.get("maincontent").load({
			        url: "/cgi-script/csDynamic/csDynamic.cgi",
			        scripts:true,
			        params: "command=view&cid=1&m="+m+"&d="+d,
			        text: "Loading Date..."
  			});
  		}	
  		else{
  			Ext.MessageBox.alert('Errors', 'Please select a date.');
  		}
  		

});



Ext.get("maincontent").load({
			        url: "/cgi-script/csDynamic/csDynamic.cgi",
			        scripts:true,
			        params: "command=view&cid=1",
			        text: "Loading Date..."
  			});
  			

//var form_date = new Ext.form.Form({
//	labelAlign: 'right',
//	labelWidth: 100,
//	buttonAlign: 'center'
//	});
//
//
//var tdih_date = new Ext.form.DateField({
//	fieldLabel: 'Pick a Day',
//	name: 'tdih',
//	width:90,
//	allowBlank:false,
//	format:'d-m-Y'
//});
//
//
//form_date.add(tdih_date);
//    
//
//
//form_date.addButton('Go', function(){
//	if (form_date.isValid()) {
//		//Ext.MessageBox.alert('Success', 'You have filled out the form correctly.' + tdih_date.getValue());
//		
//		var t = new Date(tdih_date.getValue());
//		var m = t.getMonth()+1;
//		var d = t.getDate();
//
//		Ext.get("maincontent").load({
//		        url: "/cgi-script/csDynamic/csDynamic.cgi",
//		        scripts:true,
//		        params: "command=view&cid=1&m="+m+"&d="+d,
//		        text: "Loading Date..."
 //  		});
 //  
//	}else{
//		Ext.MessageBox.alert('Errors', 'Please select a date.');
//	}
//}, form_date);
//
//form_date.render('form1');




});

