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

var SystemService = Class.create({ 
	initialize: function() { 
	}
});


SystemService.identifier = 'palm://com.palm.systemmanager';
SystemService.sysserviceidentifier = 'palm://com.palm.systemservice';

SystemService.setSystemlockValue = function(mode,value,callback) {
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'setDevicePasscode',
			parameters: {passCode:value, lockMode: mode}, 
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}

SystemService.matchDevicePasscode = function(value,callback) {
	
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'matchDevicePasscode',
			parameters: {passCode:value}, 
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}

SystemService.getSystemlockMode = function(callback) {
	
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'getDeviceLockMode',
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}

SystemService.getSystemlockTimeout = function(callback) {
	
	var request = new Mojo.Service.Request(SystemService.sysserviceidentifier, {
			method: 'getPreferences',
			parameters: {keys: ["lockTimeout"]},
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}

SystemService.setSystemlockTimeout = function(value) {
	
	var request = new Mojo.Service.Request(SystemService.sysserviceidentifier, {
			method: 'setPreferences',
			parameters: {lockTimeout:value}
		});
	return request;
}

SystemService.getSecurityPolicy = function(callback) {
	
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'getSecurityPolicy',
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}

SystemService.getShowAlertWhenLocked = function(callback) {
	var request = new Mojo.Service.Request(SystemService.sysserviceidentifier, {
			method: 'getPreferences',
			parameters: {keys:["showAlertsWhenLocked","sysUiEnableNextPrevGestures","BlinkNotifications","onDeviceDemoRunning"]},
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}

SystemService.setShowAlertWhenLocked = function(value) {
	var request = new Mojo.Service.Request(SystemService.sysserviceidentifier, {
			method: 'setPreferences',
			parameters: {showAlertsWhenLocked:value}			
		});
	return request;
}

SystemService.setLEDThrobber = function(value) {
	var request = new Mojo.Service.Request(SystemService.sysserviceidentifier, {
			method: 'setPreferences',
			parameters: {BlinkNotifications:value}			
		});
	return request;
}

SystemService.getSwitchAppSettings = function(callback) {
	var request = new Mojo.Service.Request(SystemService.sysserviceidentifier, {
			method: 'getPreferences',
			parameters: {keys:["sysUiEnableNextPrevGestures"]},
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}

SystemService.setSwitchAppSettings = function(value) {
	var request = new Mojo.Service.Request(SystemService.sysserviceidentifier, {
			method: 'setPreferences',
			parameters: {sysUiEnableNextPrevGestures:value}			
		});
	return request;
}

SystemService.numberToWord = function(number){
	var word=[$L('Zero'),$L('One'),$L('Two'), $L('Three'),$L('Four'),$L('Five'),$L('Six'),$L('Seven'),$L('Eight'),$L('Nine')];
	return word[number];
}
