/*
	Small controller class used for the dialog sample.

Copyright 2009 Palm, Inc.  All rights reserved.

*/
var RecurrenceWarning = Class.create({
	
	initialize: function(sceneAssistant,id) {
		this.sceneAssistant = sceneAssistant;
		this.parentid =id;
	},
	
	setup : function(widget) {
		this.widget = widget;
		this.sceneAssistant.controller.get('Series').addEventListener(Mojo.Event.tap, this.handleSeries.bindAsEventListener(this));
		this.sceneAssistant.controller.get('Single').addEventListener(Mojo.Event.tap, this.handleSingle.bindAsEventListener(this));
		this.sceneAssistant.controller.get('Cancel').addEventListener(Mojo.Event.tap, this.handleCancel.bindAsEventListener(this));
		
	},
	handleCommand:function(event){
		if(event.type == Mojo.Event.back){
			this.handleCancel(event);
		}
	},
	
	handleSeries: function(event) {
		Mojo.Log.info("in handle series");
		this.widget.mojo.close();
		Event.stop(event);
		this.sceneAssistant.saveEvent(null);
		
		
	},
	handleSingle: function(event) {
		//Mojo.Log.info("************handling single");
		this.widget.mojo.close();		
		Event.stop(event);
	   this.sceneAssistant.saveEvent(this.parentid);
		
		
	},
	handleCancel:function(event){
		//Mojo.Log.info("**********************cancel called");
		this.widget.mojo.close();
		//we do this to discard the changes done in this scene
		this.sceneAssistant.recurrenceCancel();
		
		Event.stop(event);
	},
		
	
});