
			//Date.prototype.json = function() { return dojo.date.stamp.toISOString(this/*, {selector: 'date'}*/); };
		
	        // subclass DateTextBox to allow the initial value to be specified
	        // as MM/dd/y instead of yyyy-MM-dd in the markup
	        dojo.addOnLoad(function(){	
	        	Date.prototype.json = function() { return dojo.date.stamp.toISOString(this/*, {selector: 'date'}*/); };
	        	
	            dojo.declare("qatraq.projects.form.CheckedMultiSelect", dojox.form.CheckedMultiSelect, {
	                    serialize: function(value, constraints, a) {
	                            // overrides to send the date to the server with a format of constraints.datePattern
	                            // instead of calling dojo.date.stamp.toISOString
	            				//alert(value);
	            				//if (value instanceof Date) {
	            					//return dojo.date.locale.format(value, constraints);
	            					//return dojo.date.stamp.toISOString(value, {selector: 'date'});
	            				//}
	                	
	                	alert(value);
	                	alert(constraints);
	                	alert(a);
	            				
	            				return [2];
	                    }
	            });	  
	                
	            dojo.declare("qatraq.projects.form.DateTextBox", dijit.form.DateTextBox, {
	                        /*serialize: function(value, constraints) {
	                                // overrides to send the date to the server with a format of constraints.datePattern
	                                // instead of calling dojo.date.stamp.toISOString
	                				//alert(value);
	                				//if (value instanceof Date) {
	                					//return dojo.date.locale.format(value, constraints);
	                					//return dojo.date.stamp.toISOString(value, {selector: 'date'});
	                				//}
	                				
	                				return '2009-05-01';
	                        }
	                		postMixInProperties: function(){
	                			//dijit.form.RangeBoundTextBox.prototype.postMixInProperties.apply(this, arguments);
	                			this.inherited(arguments);
	                			if(!this.value || this.value.toString() == dijit.form._DateTimeTextBox.prototype.value.toString()){
	                				this.value = null;
	                			}
	                			var constraints = this.constraints;
	                			constraints.selector = this._selector;
	                			constraints.fullYear = true; // see #5465 - always format with 4-digit years
	                			var fromISO = dojo.date.stamp.fromISOString;
	                			if(typeof constraints.min == "string"){ constraints.min = fromISO(constraints.min); }
	                 			if(typeof constraints.max == "string"){ constraints.max = fromISO(constraints.max); }
	                		}//,	                        
	                        postMixInProperties: function(){
	                                this.inherited(arguments);
	                                
	                                //this.constraints.datePattern = "MM/dd/y";
	                                if(this.srcNodeRef){
	                                        // reparse the value attribute using constraints.datePattern
	                                        // instead of calling dojo.date.stamp.fromISOString
	                                        var item = this.srcNodeRef.attributes.getNamedItem('value');
	                                        if(item){
	                                                this.value = dojo.date.locale.parse(item.value, this.constraints);
	                                        }
	                                }
	                                
	                        }*/
	            });
	        });
	        
function doSubmitProjectForm(form, url) {// alert(dojo.byId('project[Description]').value);
	// var oEditor = FCKeditorAPI.GetInstance('project[Description]');
	// //alert(oEditor.GetXHTML());
	// var data = form.getValues();
	// alert(data['project[Name]']);
	// data['project[Description]'] = oEditor.GetXHTML();
	// alert(dojo.toJson(data));
	
	//dijit.byId('project-progress').domNode.style.display = 'block';
	//dijit.byId('project-progress').update({indeterminate: true});
	//dijit.byId('project-progress-dialog').show();
	
	//dijit.byId('projects-dialog').containerNode.innerHTML = "<span class='dijitContentPaneLoading'>Saving...</span>" + dijit.byId('projects-dialog').containerNode.innerHTML;
	//alert(dojo.toJson(dijit.byId('project-form').attr('value')));return;
	
	var formWidget = dijit.byId('project-form');
	var formSubmit = dijit.byId('submit');

	var node = new Image(); 
	node.src = 'images/pixel.gif'; 
	dojo.attr(node, "id", formSubmit.id+"_icon"); 
	dojo.addClass(node, "dojoxBusyButtonIcon"); 
	formSubmit.containerNode.appendChild(node);
	formSubmit.setDisabled(true);	

	//var data = dijit.byId('project-form').attr('value');
	//var data = formWidget.attr('value');
	//alert(dojo.toJson(data));
	//alert(data['project[StartDate]']);
	//if (data['project[StartDate]'] instanceof Date) data['project[StartDate]'] = dojo.date.stamp.toISOString(data['project[StartDate]'], {selector: 'date'});
	//if (data['project[DueDate]'] instanceof Date) data['project[DueDate]'] = dojo.date.stamp.toISOString(data['project[DueDate]'], {selector: 'date'});
	
	
	//data['project[StartDate]'] = dojo.date.stamp.toISOString(data['project[StartDate]'], {selector: 'date'});
	//data['project[DueDate]'] = dojo.date.stamp.toISOString(data['project[DueDate]'], {selector: 'date'});
	//data.project[StartDate] = dojo.date.locale.format(data.project['StartDate'], {datePattern: "y-MM-dd"});
	//alert(dojo.toJson(data));
	//return;
	
	var kw = {
		url: url,// "<?php echo $this->url(array('controller' => 'project' ,
					// 'action' => 'modify' , 'id' => $this->project->ID))?>",
		
		content: {}, // data,
		//content: data,//dijit.byId('project-form').attr('value'),
		form: 'project-form',
		
		load: function(data) {
			// dojo.byId('myBox').value = data;
			//dijit.byId('project-progress').domNode.style.display = 'none';
			//alert(data);
			dijit.byId('projects-dialog').setContent(data);
			// alert(dojo.toJson(dijit.byId('projectForm').attr('value')));
			//dijit.byId('project-progress-dialog').hide();
		},
		
		error: function(data) {
			alert("An error occurred: " + data);
		},
		
		timeout: 60000
		// form: "myForm"
	};

	var d = dojo.xhrPost(kw);
	/*
    d.addCallback(function() {
	    // Stop the indeterminate bar
	    dijit.byId("project-progress").update({indeterminate: false});
	    avgTime = new Date() - timeStart;
	    //Now you can estimate the time for 10 calls
	    avgTime10 = avgTime * 10;
	    dijit.byId("project-progress").update({maximum: avgTime10});
	});
	*/
}

function doDeleteProjectForm(form, url) {

	var formWidget = dijit.byId('project-form');
	var formSubmit = dijit.byId('delete');

	var node = new Image(); 
	node.src = 'images/pixel.gif'; 
	dojo.attr(node, "id", formSubmit.id+"_icon"); 
	dojo.addClass(node, "dojoxBusyButtonIcon"); 
	formSubmit.containerNode.appendChild(node);
	formSubmit.setDisabled(true);	
	
	var data = formWidget.attr('value');

	var kw = {
		url: url,// "<?php echo $this->url(array('controller' => 'project' ,
					// 'action' => 'modify' , 'id' => $this->project->ID))?>",
		
		//content: {}, // data,
		content: data,//dijit.byId('project-form').attr('value'),
		//form: 'project-form',
		
		load: function(data) {
			// dojo.byId('myBox').value = data;
			//dijit.byId('project-progress').domNode.style.display = 'none';
			//alert(data);
			dijit.byId('projects-dialog').setContent(data);
			// alert(dojo.toJson(dijit.byId('projectForm').attr('value')));
			//dijit.byId('project-progress-dialog').hide();
		},
		
		error: function(data) {
			alert("An error occurred: " + data);
		},
		
		timeout: 60000
		// form: "myForm"
	};

	var d = dojo.xhrPost(kw);
}

function Zend_ProgressBar_Update(data)
{
	var text = data.text;
	var percent = Math.round(data.percent); ;
	
	//if (console && console.log) console.log(percent);
	
    //document.getElementById('pg-percent').style.width = percent + '%';

    //document.getElementById('pg-text-1').innerHTML = data.text;
    //document.getElementById('pg-text-2').innerHTML = data.text;
    
	if (text) {
		dijit.byId('project-import-progress-table').setContent(text);
	}
    dijit.byId('project-import-progress').update({progress: percent});
}

function Zend_ProgressBar_Finish()
{
    //document.getElementById('pg-percent').style.width = '100%';

    //document.getElementById('pg-text-1').innerHTML = 'Demo done';
    //document.getElementById('pg-text-2').innerHTML = 'Demo done';
	dijit.byId('project-import-progress').domNode.style.display = 'none';
	dijit.byId('project-import-progress-table').domNode.style.display = 'none';
	
	dojo.byId('success-container').style.display = 'block';
}

function Zend_ProgressBar_Finish_Success()
{
    dojo.byId('success-container').style.display = 'block';
}

function Zend_ProgressBar_Finish_Error(data)
{
	dijit.byId('project-import-progress').domNode.style.display = 'none';
	dijit.byId('project-import-progress-table').domNode.style.display = 'none';
	
    dijit.byId('message-pane-error-message').label = data.text;
   
    dojo.byId('error-container').style.display = 'block';
}

