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

var ParentMessages = Class.create ({
	
	initialize: function() {
		
		// blocked/unknown caller id
		this.blockedNumber = $L("Blocked number");
		this.unknownNumber = $L("Unknown number");
	
		// no contact in addressbook
		this.unknownCaller =  $L("Unknown caller");
		
		// call log version
		this.defaultErrorIndex =  0;
	
		// common service errors
		this.serviceErrors = {
			"-1": $L("TelephonyService not connected to radio."),
			0: $L("Operation failed."),
			1: $L("Phone is off."),
			99: $L("Operation failed."),
			100: $L("Operation failed."),
			101: $L("Operation failed."),
			102: $L("Network failure."),
			103: $L("Not supported on this network."),
			104: $L("Authorization failed."),
			105: $L("SIM card phonebook unavailable. Try again later."),
			106: $L("Your SIM card is not working."),
			107: $L("The network did not respond."),
			108: $L("Fixed-dialing restricted.")
		};
		
		this.phoneLabel = {
			'0': $L('Home'),
			'1': $L('Work'),
			'2': $L('Other'),
			'3': $L('Mobile'),
			'4': $L('Pager'),
			'5': $L('Fax'),
			'6': $L('Fax'),
			'7': $L('Main'),
			'8': ' ',
			'-1': ' ' // prophylactic -- sometimes during EAS sync we see this
		};
		this.phoneLabelShort = {
			'0': $L('H'), // Home
			'1': $L('W'), // Work
			'2': $L('O'), // Other
			'3': $L('M'), // Mobile
			'4': $L('P'), // Pager
			'5': $L('F'), // Fax
			'6': $L('F'), // Fax
			'7': $L('M'), // Main
			'8': ' ',
			'-1': ' ' // prophylactic -- sometimes during EAS sync we see this
		};
		// WORKAROUND: our call log database stores labels by both localized string and
		// numeric key. If we need to get a short label from a label, we also
		// need to add the string keys
		var key;
		for ( key in this.phoneLabel ) {
			if ( this.phoneLabel.hasOwnProperty(key) ) {
				var value = this.phoneLabel[key];
				this.phoneLabelShort[value] = this.phoneLabelShort[key];
			}
		}
	
		// call failure messages
		this.callFailErrorMessageDefault = $L("Call failed.");
	
		this.callFailErrorMessage = {
			0: $L("Call failed."),
			1: $L("Airplane mode is on."),
			2: $L("Phone is locked."),
			3: $L("No service."),
			4: $L("Number not on fixed dialing list."),
			5: $L("Emergency calls only."),
			6: $L("No free lines."),
			7: $L("PIN required."),
			8: $L("Call service provider for PUK code."),
			10: $L("The number you are trying to call cannot be tried again until you restart your phone."),
			4242: $L("The network is unavailable.")
		};

		// call dropped messages (for abnormal disconnects)
		this.disconnectErrorMessageDefault = $L("Call dropped");
	
		this.disconnectErrorMessageCdma = {
			0: $L("Call dropped"),
			//22: $L("Call faded: out of range."),
			21: $L("Call failed: no service"),
			22: $L("Call dropped: signal faded"),
			24: $L("Call failed: network busy"),
			26: $L("Call failed"),
			36: $L("Call failed: network busy"),
			6969: $L("Call dropped")
		};
	
		this.disconnectErrorMessageGsm = {
			0: $L("Call dropped"),
			17: $L("Line is busy"),
			4242: $L("Call dropped: out-of-range"),
			6969: $L("Call dropped")
		};
	
		this.answerError = {
			0: $L("Answer failed."),
			2: $L("Answer failed: invalid call id")
		};
	
		this.conferenceError = {
			0: $L("Conference failed."),
			2: $L("Conference failed: need at least 2 calls.")
		};
	 
		this.extractError = {
			0: $L("Extract failed."),
			2: $L("Extract failed: no conference."),
			3: $L("Extract failed: no free lines.")
		};
	
		this.akeyError = {
			0: $L("Akey set failed."),
			2: $L("Akey and checksum are not correct.")
		};
	
		this.enablePinError =  {
			0: $L("Unable to change PIN status."),
			2: $L("Unable to change PIN status: bad format."),
			3: $L("Unable to change PIN status: PUK locked."),
			4: $L("Unable to change PIN status: SIM locked.")	
		};
	
		this.pinChangeError =  {
			0: $L("Unable to change PIN."),
			2: $L("Unable to change PIN: bad format."),
			3: $L("Unable to change PIN: PUK locked."),
			4: $L("Unable to change PIN: SIM locked."),	
			5: $L("Unable to change PIN: enable PIN first."),
			6: $L("Unable to change PIN: PINs don't match.")
		};
	
		this.pukUnlockError = {
			0: $L("Unable to unlock PUK."),
			2: $L("Unable to unlock PUK: bad or incorrect PUK."),
			3: $L("Unable to unlock PUK: new PIN not valid."),
			4: $L("Unable to unlock PUK: SIM locked."),	
			5: $L("Unable to unlock PUK: PINs don't match.")
		};
	
		this.bearers = {
			"defaultbearer": $L("all basic services"),
			"default": $L("all basic services"),
			"voice": $L("voice"),
			"data": $L("data"),
			"fax":$L("fax"),
			"sms":$L("SMS"),
			"datacircuitsync":$L("synchronous circuit data"),
			"datacircuitasync":$L("asynchronous circuit data"),
			"packetaccess":$L("packet access"),
			"padaccess":$L("PAD access"),
			"allsyncservices":$L("all synchronous services"),
			"allasyncservices":$L("all asynchronous services"),
			"auxiliarytelephony":$L("auxiliary telephony"),
			"alldataCDSServices":$L("synchronous circuit data switch"),
			"alldataCDAServices":$L("asynchronous circuit data switch")
		};
	
		//OTASP Status Notification
		this.otaspNotifications = {
			"initialprogrammingrequired": $L("Initial programming required"),
			"programminginprogress": $L("Programming in progress"),
			"splunlocked": $L("SPL unlocked"),
			"prldownloaded": $L("PRL downloaded"),
			"commitsucceeded": $L("Commit succeeded"),
			"programmingsucceeded": $L("Programming succeeded"),
			"namdownloaded": $L("NAM downloaded"),
			"mdndownloaded": $L("MDN downloaded"),
			"programmingfailed": $L("Programming unsuccessful. Call customer service.")
		};
	
		// translations for displaying the above otasp notification as a banner message,
		// format: <message>: [<banner title>, <banner message>]
		// default: [Messages.otaspMessageTitle, <notification message>]
		this.otaspNotificationsDashboardTranslations = {
			"programmingfailed": [$L("Programming unsuccessful"), $L("Call customer service")]
		};
	
		this.otaspFailureBanner = $L("Programming unsuccessful.  Call #{value}");
		this.otaspFailureWithInfoBody = $L("Call #{value}"); 
	
		this.fwdActivated = $L("(activated)");
		this.fwdNotActivated = $L("(not activated)");
	
		// dashboard message titles
		this.serviceMessageNew = $L("New network message");
		this.serviceMessageTitle = $L("Network message");
		this.basebandDebugMessageTitle = $L("Modem error");
		this.otaspMessageTitle = $L("Network update");
		this.missedMessage = $L("Missed call at #{timeStamp}");
		this.voicemailTitle = $L("Voicemail");
		this.voicemailMessage = $L("1#1 message #{high}|255#New message #{high}|1>##{count} messages #{high}");
		this.voicemailHigh = $L("- URGENT");
		this.newVoicemailUnknownCount = $L("NEW");
		this.missedCallLabel = $L("Missed call ");
		this.callEndedBanner = $L("Call with #{contact} ended");
		this.callEndedNoNameBanner = $L("Call ended");
		this.conferenceEndedBanner = $L("Conference call ended");
		this.callIgnoredBanner = $L("Ignored call from #{contact}");
		this.callMissedBanner = $L("Missed call from #{contact}");
		this.contactWithLabel = $L("#{contact} - #{label}");
	
	
		// active call labels
		this.waitDigitsLabel = $L("Dial #{digits}");
		this.voicemailContact = $L("Voicemail");
		this.emergencyCallContact = $L("Emergency call");
		this.returnToDialpadButton = $L("Done");
	
		// contact labels
		this.addContact = $L("Add to contacts");
		this.viewContact =  $L("View contact");
	
		// dialpad hint text
		this.dialpadHint = $L("Enter number...");
		this.dialpadHintAutoLookup = $L("Enter name or number...");
	
		// dialpad messages
		this.voicemailNumberNotFound = $L("Unable to find voicemail number.");
		this.messageDialogOk = $L("OK");
		this.dialOnPowerPending = $L("Connecting to network to dial...");
		this.dialOnPowerFail = $L("Unable to complete call.");
	
		// mmi-related
		this.mmiPending = $L("Sending your request...");
		this.mmiTimeout = $L("Request failed to complete before timeout.");
		this.noServiceError = $L("No service.");
		this.ussdSuccess = $L("USSD request successful");
		this.ussdError = $L("USSD request failed. ");
	
		// cdma activation
		this.activationQuery = $L("Getting activation info...");
		this.activationDoneLabel = $L("Done");
		this.activationSuccess = $L("Success");
	
		this.mslPrompt = $L("Enter MSL then tap Done.");
		this.mslDone = $L("Done");
		this.mslEmptyError = $L("Error = MSL value is empty.");
		this.mslVerify = $L("Verifying MSL...");
		this.mslVerifyError = $L("Invalid MSL");	
		this.cdmaProgrammingInProgress = $L("Programming...");
		this.cdmaProgrammingUnknownError = $L("Unknown error.");
		
		this.akeySuccess = $L("Success");
		this.prevSuccess = $L("Success");
		this.omadmSuccess = $L("Success");
		
		this.voicePrivacyOn = $L("Voice privacy enabled.");
		this.voicePrivacyOff = $L("Voice privacy disabled.");
	
		// call formatting
		this.unknownNumber = $L("Unknown number"); // should NOT have a period at the end
		this.conferenceCall = $L("Conference call");
		this.callStateDialing = $L("Connecting");
		this.callStateEnding = $L("Ending");
		this.callStateEnded = $L("Ended");
		this.callStateHold = $L("On hold");
	
		// call banner
		this.callBannerTwoCalls = $L("2 calls");
	
		// emergency mode
		this.emergencyModeDialFailure = $L("Emergency call failed.");
	
		// call log
		this.logIncoming = $L("Incoming call");
		this.logMissed = $L("Missed call");
		this.logOutgoing = $L("Placed call");
	
		// low-level errors =
		this.noTelephonyServiceError = $L("No telephony server");
		this.noPalmbusServiceError = $L("Failed to register for TelephonyService status.");
		this.generalServiceError = $L("Error occurred.");
		// vestigial
		this.pin1RetryError = $L("Failure. Tries left = ");
		this.pin1GeneralError = $L("Failure. ");

		// audio route
		this.audioRouteNormal = $L("Normal");
		this.audioRouteBluetooth = $L("Bluetooth");
		this.audioRouteSpeaker = $L("Speaker");
		this.audioRouteWiredHeadset = $L("Wired headset");
		this.audioRouteTTY = $L("TTY/TDD");
		this.audioRouteMenu = $L("Audio");
	
		// active call buttons
		this.unlock = $L("Unlock");
	}	
});

var Messages = new ParentMessages();
