/* Copyright 2009 Palm, Inc.  All rights reserved. */

var LocationIntroAssistant = Class.create({
	
	initialize: function(){
		FirstUseUtil.addDashboardSmall($('target'));
		saveCurrentState("location-intro");
	},
	
	setup: function(){
		$('target').addEventListener(Mojo.Event.tap, FirstUseUtil.tapHandler.bindAsEventListener(this));
		// Listen to ## key presses
		this.controller.listen(this.controller.sceneElement, Mojo.Event.keydown, FirstUseUtil.handleKeyPressEvent.bind(this));
				
		this.buttonAttr = {
			disabledProperty: 'disabled'
		};
		
		this.buttonModel = {
			disabled: false,
			buttonLabel : $L('Next'),
			buttonClass: 'palm-button'
		};
		
		this.controller.setupWidget('showTermsOfUse', this.buttonAttr, this.buttonModel);
		Mojo.listen(this.controller.get('showTermsOfUse'), Mojo.Event.tap, this.showTermsOfUse.bindAsEventListener(this));
	},
	
	handleCommand: function(event) {
		if (event.type == Mojo.Event.back) {
			event.preventDefault();
			event.stopPropagation();
		}	
	},
	
	showTermsOfUse: function (event) {
		this.buttonModel.disabled = true;
		this.controller.modelChanged(this.buttonModel);
		Mojo.Controller.stageController.pushScene('location-terms');
	},
	
	deactivate: function () {
		this.buttonModel.disabled = false;
		this.controller.modelChanged(this.buttonModel);
	}
		
}); 

