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

var Util = Class.create ({

	MAXLOGINATTEMPTS:3,
	MAXPASSWORDLENGTH:20,
	MINPASSWORDLENGTH:6,
	
	emailSent:false,
	
	//ACCOUNT ASSISTANT LABELS
	label_account_saved_message:$L("Palm profile saved"),
	//label_account_unchanged_message:$L("Palm profile unchanged"),

	//BACKUP-ASSISTANT LABELS
	label_backup_now : $L("Back up now"),
	label_backing_now : $L("Backing up..."),
	label_backupsuspended : $L("Backup suspended"),
	label_backupcomplete : $L("Backup complete"),
	label_backup_failed : $L("Backup failed"),
	label_display_message : $L("If you turn Backup off, your phone will no longer back up your data to your Palm Profile. Your data in your Palm Profile will also be erased."),
	label_opt_out : $L("Turn Backup off?"),
	label_optout_message : $L("Processing opt out"),
	label_preparing : $L("Preparing"),
	label_optingout : $L("Turning Backup off"),
	label_optoutFailed : $L('Opt out failed. Try later'),
	label_email_sent : $L('Sending password reset email'),
	
	label_noDataConnection : $L("You need an Internet connection to back up your data."),
	label_noDataConnectionForOutout : $L("You need an internet connection to turn off automatic backup."),
	label_noDataConnectionTitle : $L("No Internet connection"),
	
	label_noServerAvailable : $L("Your data will be backed up automatically when the server is available again."),
	label_noServerAvailableTitle : $L("Backup server unavailable"),
	
	label_dateSeperator:$L(" at  "),
	
	label_failureNotificationTitle:$L("Backup failure"),
	label_failureNotificationOK: "OK",
	label_backup_message_optOut_ON : $L("Your data is backed up automatically every day."),
	label_backup_message_optOut_OFF : $L("Turn Backup on to start backing up your data automatically."),

	//CHANGE PASSWORD ASSISTANT
	label_usrpwd_confirm_password_hintText : $L("confirm password..."),
	label_usrpwd_password_hintText : $L("enter password..."),
	label_usrpwd_confirm_message : $L("Password changed"),


	showConnectionError: function(sceneController) {
		Mojo.Log.info("----------------- show connection error ---------------------------");
		sceneController.showAlertDialog({
	    	onChoose: function(value) {
				if("help" == value) {
					this.launchHelp();
				}
			},
		    title: $L("No Internet Connection"),
		    message: $L("You must have an internet connection to continue."),
		    choices:[
				{label:$L('Help'), value:"help", type: 'color'},
	        	{label:$L('OK'), value:"ok", type: 'color'} 
		    ]
	  });
	},
	
	launchHelp: function(){
		var openParams = {  scene: 'page', url: "http://help.palm.com/palm_acct/index.html"};
		return new Mojo.Service.Request('palm://com.palm.applicationManager', {
        				method: 'open',
		      			parameters: { id: 'com.palm.app.browser',
						              params: openParams }
   		 });
	},
	
	filterSpace: function (value)
	{
		if (Mojo.Char.spaceBar === value)
			return false;
		return true;
	},
});

var ProfileUtil = new Util();