hwc-comms.js

1       /**
2        * Sybase Hybrid App version 2.3
3        * 
4        * API.js
5        * This file will not be regenerated, so it is possible to modify it, but it
6        * is not recommended.
7        *
8        * The template used to create this file was compiled on Thu Jun 07 14:57:11 EDT 2012
9        * 
10       * Copyright (c) 2012 Sybase Inc. All rights reserved.
11       */
12      
13      /** Holds all the Hybrib Web Container javascript
14      	@namespace 
15       */
16      hwc = (typeof hwc === "undefined" || !hwc) ? {} : hwc;      // SUP 'namespace'
17      
18      /**
19       * Global Legacy Mapping
20       * Needed because called by generated HTML or hardcoded in workflow.js or XBWUtil.java or in container callbacks.
21       */
22      
23      /**
24       * @deprecated Deprecated since version 2.2 - use hwc.guid()
25       */
26      function guid()               { return hwc.guid(); }
27      
28      /**
29       * @deprecated Deprecated since version 2.2 - use hwc.getXMLHTTPRequest()
30       */
31      function getXMLHTTPRequest()  { return hwc.getXMLHTTPRequest(); }
32      
33      /**
34       * @deprecated Deprecated since version 2.2 - use hwc.log(sMsg, eLevel, notifyUser)
35       */
36      function logToWorkflow(sMsg, eLevel, notifyUser) { return hwc.log(sMsg, eLevel, notifyUser); }
37      
38      /**
39       * @deprecated Deprecated since version 2.2 - use hwc.close()
40       */
41      function closeWorkflow()            { return hwc.close(); }
42      
43      /**
44       * @deprecated Deprecated since version 2.2 - use hwc.clearCacheItem( cachekey )
45       */
46      function clearCacheItem( cachekey ) { return hwc.clearCacheItem( cachekey ); }
47      
48      /**
49       * @deprecated Deprecated since version 2.2 - use hwc.clearCache()
50       */
51      function clearCache()               { return hwc.clearCache(); }
52      
53      /**
54       * @deprecated Deprecated since version 2.2 - use hwc.close()
55       */
56      function expireCredentials()        { return hwc.expireCredentials(); }
57      
58      /**
59       * @deprecated Deprecated since version 2.2 - use hwc.showCertificatePicker()
60       */
61      function showCertificatePicker()    { return hwc.showCertificatePicker(); }
62      
63      /**
64       * @deprecated Deprecated since version 2.2 - use hwc.saveLoginCertificate(certificate)
65       */
66      function saveLoginCertificate(certificate)         { return hwc.saveLoginCertificate(certificate); }
67      
68      /**
69       * @deprecated Deprecated since version 2.2 - use hwc.saveLoginCredentials(userName, password)
70       */
71      function saveLoginCredentials(userName, password)  { return hwc.saveLoginCredentials(userName, password); }
72      
73      /**
74       * @deprecated Deprecated since version 2.2 - use hwc.activationRequired()
75       */
76      function activationRequired()       { return hwc.activationRequired(); }
77      
78      /**
79       * @deprecated Deprecated since version 2.2 - use hwc.showUrlInBrowser(url)
80       */
81      function showUrlInBrowser(url)      { return hwc.showUrlInBrowser(url); }
82      
83      /**
84       * @deprecated Deprecated since version 2.2 - use hwc.markAsProcessed()
85       */
86      function markAsProcessed()      { return hwc.markAsProcessed(); }
87      
88      /**
89       * @deprecated Deprecated since version 2.2 - use hwc.markAsActivated()
90       */
91      function markAsActivated()      { return hwc.markAsActivated(); }
92      
93      /**
94       * Delegate for data message processing details.
95       * In the custom case, the user is expected to provide their own implemenation.
96       * In the default SUP HybridApp case, this updates values then sets the next screen to navigate to.
97       * @param {string} incomingDataMessageValue The XML formatted string for the incoming message
98       * @param {boolean} [noUI] true if this has no UI
99       * @param [loading]
100      * @param [fromActivationFlow]
101      * @param [dataType]
102      */
103     function processDataMessage(incomingDataMessageValue, noUI, loading, fromActivationFlow, dataType) {
104         if( typeof(hwc.processDataMessage) === 'function' ) {
105             return hwc.processDataMessage(incomingDataMessageValue, noUI, loading, fromActivationFlow, dataType);
106         }
107         else {
108             // get the users attention
109             hwc.log("Implementation required for hwc.processDataMessage", "ERROR", true);
110             throw new Error("Implementation required for either global processDataMessage or hwc.processDataMessage");
111         }
112     }
113     
114     /**
115      * @deprecated Deprecated since version 2.2 - use hwc.processDataMessage(incomingDataMessageValue, noUI, loading, fromActivationFlow, dataType)
116      */
117     function processWorkflowMessage(incomingDataMessageValue, noUI, loading, fromActivationFlow, dataType) {
118         return processDataMessage(incomingDataMessageValue, noUI, loading, fromActivationFlow, dataType);
119     }
120     
121     /**
122      * This function is invoked by the container when there is a native error to report.
123      * Use {@link hwc.setReportErrorFromNative} to set the callback funtion this function will call.
124      * This function is not intended to be called except by the container.
125      * @private
126      */
127     function reportErrorFromNative(errString) {
128        var reportErrorCallback = hwc.getReportErrorFromNativeCallback();
129        if( typeof reportErrorCallback === "function" )
130        {
131           reportErrorCallback( errString );
132        }
133     }
134     
135     /**
136      * Container API
137      */
138     (function(hwc, window, undefined) {
139         
140         /**
141          * A number representing the logging level.  The logging level must be an integer from the range [1..4]
142          * with the higher numbers being more verbose.
143          *
144          * @type {number}
145          */
146         var requestedLoggingLevel,
147         /**
148          * A callback function used when {@link hwc.log} is invoked with true for the notifyUser parameter.
149          * This callback should notify the user of the log message in an appropriate manner.
150          *
151          * @type {anonymous.alertDialogCallbackFunction}
152          */
153         requestedAlertDialogCallback,
154         /**
155          * A callback function used when there is a native error to report
156          *
157          * @type {anonymous.errorCallbackFunction}
158          */
159         reportErrorFromNativeCallback;
160         
161         /**
162          * This object contains constants representing the status of the hybrid app.
163          */
164         hwc.STATUS = {};
165         
166         /**
167          * A constant indicating the hybrid app has been closed.
168          * @constant
169          * @type {number}
170          * @member of hwc.STATUS
171          * @public
172          */
173         hwc.STATUS.CLOSED = 1;
174         
175         /**
176          * A constant indicating the hybrid app is running.
177          * @constant
178          * @type {number}
179          * @member of hwc.STATUS
180          * @public
181          */
182         hwc.STATUS.RUNNING = 2;
183         
184         /**
185          * A status representing the hybrid app, default is running.
186          *
187          * @type {number}
188          */
189         var status = hwc.STATUS.RUNNING;
190         
191         /**
192          * This function sets the callback used by hwc.log when it is required to notify the user of a log item.
193          *
194          * @param {anonymous.alertDialogCallbackFunction} newAlertDialogCallback The alert dialog to use.
195          *
196          * @example
197          * customLogAlert = function( message )
198          * {
199          *    alert( "New log message: " + message );
200          * }
201          * hwc.setLoggingAlertDialog( customLogAlert );
202          * @memberOf hwc
203          * @public
204          */
205         hwc.setLoggingAlertDialog = function( newAlertDialogCallback )
206         {
207             requestedAlertDialogCallback = newAlertDialogCallback;
208         };
209         
210         /**
211          * This function gets the callback used by hwc.log when it is required to notify the user of a log item.
212          *
213          * @return {anonymous.alertDialogCallbackFunction} The alert dialog callback function.
214          * @memberOf hwc
215          * @public
216          */
217         hwc.getLoggingAlertDialog = function()
218         {   
219             return requestedAlertDialogCallback;
220         };
221         
222         /**
223          * This function sets the logging level. The logging level set with this function only persists as long as this javascript context does.
224          * When the hybrid app is closed, the value set with this function is lost.
225          *
226          * @param {number} newLoggingLevel The number representing the new logging level.
227          * Must be an integer in the range [1..4].  The higher numbers represent more verbose logging levels
228          * from 1 for ERROR level logging up to 4 for DEBUG level logging.
229          * @memberOf hwc
230          * @public
231          * @example
232          * // Set the logging level to debug.
233          * hwc.setLoggingCurrentLevel( 4 );
234          */
235         hwc.setLoggingCurrentLevel = function( newLoggingLevel )
236         {
237             requestedLoggingLevel = newLoggingLevel;
238         };
239     
240         /**
241          * This function gets the logging level.
242          *
243          * @return {number} A number representing the logging level.  Will be an integer in the range [1..4].
244          * The higher numbers represent more verbose logging levels from 1 for ERROR level logging up to 4 for DEBUG level logging.
245          * @memberOf hwc
246          * @public
247          * @example
248          * // Get the logging level
249          * var loggingLevel = hwc.getLoggingCurrentLevel();
250          */
251         hwc.getLoggingCurrentLevel = function() {
252             var logLevel;
253             if (requestedLoggingLevel === undefined) {
254                 logLevel = hwc.getQueryVariable("loglevel");
255                 requestedLoggingLevel = logLevel ? parseInt(logLevel, 10) : 1;
256             }
257             return requestedLoggingLevel; 
258         };
259         
260         /**
261          * This function sets the callback function called when there is a native error reported.
262          * Calling this function will replace any callback that had been set previously.
263          * @memberOf hwc
264          * @public
265          * @example
266          * var errorCallback = function( errorString )
267          * {
268          *    alert( "There was a native error: " + errorString );
269          * }
270          * hwc.setReportErrorFromNativeCallback( errorCallback );
271          */
272         hwc.setReportErrorFromNativeCallback = function( callbackToSet )
273         {
274             reportErrorFromNativeCallback = callbackToSet;
275         };
276         
277         /**
278          * This function returns the callback function that will be called by {@link reportErrorFromNative}.
279          * This function is not intended to be called by any function but {@link reportErrorFromNative}.
280          * @private
281          */
282         hwc.getReportErrorFromNativeCallback = function()
283         {
284             return reportErrorFromNativeCallback;
285         };
286     
287         /**
288          * This function looks in the query string on the URL for the value corresponding to the given name.
289          *
290          * @param {string} variable The name of the variable in the URL to retrieve the value for.
291          * @memberOf hwc
292          * @public
293          * @example
294          * // Get the pageToShow variable from the URL query string
295          * var pageToShow = hwc.getQueryVariable( "pageToShow" );
296          */
297         hwc.getQueryVariable = function(variable) {
298             var query, vars, i, pair;
299             query = window.location.search.substring(1);
300             vars = query.split("&");
301             for (i = 0; i < vars.length; i++) {
302                 pair = vars[i].split("=");
303                 if (pair[0] === variable) {
304     				return unescape(pair[1]);
305                 }
306             }
307         };
308         
309     
310     /**
311      * This object contains constants representing the different types of public native error codes.
312      * Error codes larger than 500 are reserved for server communication errors which may occur as the result of online requests and/or attachment downloads
313      *
314      * @namespace
315      */
316     hwc.NativeErrorCodes = {};
317     /**
318      * A constant indicating there was an unknown error.
319      *
320      * @constant
321      *
322      * @type {number}
323      * @memberOf hwc.NativeErrorCodes
324      * @public
325      */
326     hwc.NativeErrorCodes.UNKNOWN_ERROR = 1;
327     /**
328      * A constant indicating the attachment has not been downloaded.
329      *
330      * @type {number}
331      * @memberOf hwc.NativeErrorCodes
332      * @public
333      */
334     hwc.NativeErrorCodes.ATTACHMENT_NOT_DOWNLOADED = 100;
335     /**
336      * A constant indicating there was an unkown MIME type.
337      *
338      * @type number
339      * @memberOf hwc.NativeErrorCodes
340      * @public
341      */
342     hwc.NativeErrorCodes.UNKNOWN_MIME_TYPE = 101;
343     /**
344      * A constant indicating there was a filename without an extension.
345      *
346      * @type {number}
347      * @memberOf hwc.NativeErrorCodes
348      * @public
349      */
350     hwc.NativeErrorCodes.FILENAME_NO_EXTENSION = 102;
351     /**
352      * A constant indicating a required parameter was not available.
353      *
354      * @type {number}
355      * @memberOf hwc.NativeErrorCodes
356      * @public
357      */
358     hwc.NativeErrorCodes.REQUIRED_PARAMETER_NOT_AVAILABLE = 103;
359     /**
360      * A constant indicating there was no certificate selected by the user.
361      *
362      * @type {number}
363      * @memberOf hwc.NativeErrorCodes
364      * @public
365      */
366     hwc.NativeErrorCodes.CERTIFICATE_NOT_SELECTED = 104;
367     /**
368      * A constant indicating the attachment type is not supported.
369      *
370      * @type {number}
371      * @memberOf hwc.NativeErrorCodes
372      * @public
373      */
374     hwc.NativeErrorCodes.UNSUPPORTED_ATTACHMENT_TYPE = 105;
375     /**
376      * A constant indicating there was an SSO certificate manager exception.
377      *
378      * @type {number}
379      * @memberOf hwc.NativeErrorCodes
380      * @public
381      */
382     hwc.NativeErrorCodes.SSOCERT_EXCEPTION = 106;
383     /**
384      * A constant indicating a failure to save a credential.
385      *
386      * @type {number}
387      * @memberOf hwc.NativeErrorCodes
388      * @public
389      */
390     hwc.NativeErrorCodes.FAIL_TO_SAVE_CREDENTIAL = 107;
391     /**
392      * A constant indicating a failure to save a certificate.
393      *
394      * @type {number}
395      * @memberOf hwc.NativeErrorCodes
396      * @public
397      */
398     hwc.NativeErrorCodes.FAIL_TO_SAVE_CERTIFICATE = 108;
399     /**
400      * A constant indicating the device is not connected.
401      *
402      * @type {number}
403      * @memberOf hwc.NativeErrorCodes
404      * @public
405      */
406     hwc.NativeErrorCodes.DEVICE_NOT_CONNECTED = 109;
407     /**
408      * A constant indicating the response it too large for a javascript variable.
409      *
410      * @type {number}
411      * @memberOf hwc.NativeErrorCodes
412      * @public
413      */
414     hwc.NativeErrorCodes.RESPONSE_TOO_LARGE = 110;
415     /**
416      * A constant indicating that opening the URL failed.
417      *
418      * @type {number}
419      * @memberOf hwc.NativeErrorCodes
420      * @public
421      */
422     hwc.NativeErrorCodes.NAVIGATION_ERROR = 111;
423     /**
424      * A constant indicating an invalid common name was passed while requesting a certificate from Afaria.
425      *
426      * @type {number}
427      * @memberOf hwc.NativeErrorCodes
428      * @public
429      */
430     hwc.NativeErrorCodes.INVALID_COMMON_NAME = 112;
431     
432     
433     
434     /**
435      * A utility function for use in generating a GUID
436      *
437      * @private
438      */
439     function S4() {
440         return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
441     }
442     
443     /**
444      * This function generates a GUID (globally unique identifier).
445      *
446      * @return {string} The generated GUID.
447      * @memberOf hwc
448      * @public
449      * @example
450      * var globallyUniqueName = hwc.guid();
451      */
452     hwc.guid = function() {
453         return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
454     };
455     
456     /**
457      * Reliably returns an XMLHttpRequest object regardless of what platform this code is being executed on.
458      *
459      * @return {object} An XMLHTTPRequest object.
460      * @memberOf hwc
461      * @public
462      * @example
463      * var request = hwc.getXMLHTTPRequest();
464      */
465     hwc.getXMLHTTPRequest = function getXMLHTTPRequest() {
466         // 
467     	/* 
468     	SMPONP-9439
469     	Avoid this endless loop:
470     		hwc.log()
471     		at hwc.traceEnteringMethod()
472     		at hwc.getXMLHTTPRequest()
473     		at hwc.postDataToContainer()
474     		at hwc.log()
475     	*/
476     	//hwc.traceEnteringMethod("hwc.getXMLHTTPRequest");
477     	try {
478     		var xmlHttpReq;
479     		if (window.XMLHttpRequest) {
480     			xmlHttpReq = new XMLHttpRequest();
481     		}
482     		else {// code for IE6, IE5
483     			xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
484     		}
485     		return xmlHttpReq;
486     	} finally {
487     		//hwc.traceLeavingMethod("hwc.getXMLHTTPRequest");
488     	}
489     };
490     
491     
492     /****************** Hybrid App NATIVE FUNCTIONS ************************/
493     
494     /**
495      * Sets the title of the screen.
496      *
497      * @param {string} screenTitle The screen title to use.
498      * @memberOf hwc
499      * @public
500      * @example
501      * hwc.setScreenTitle_CONT( "Custom Screen Title" );
502      */
503     hwc.setScreenTitle_CONT = function(screenTitle) {
504     	hwc.traceEnteringMethod("hwc.setScreenTitle_CONT");
505     	try {
506     		if (hwc.isWindows()) {
507     			document.title = screenTitle; 
508     		}      
509     		else {
510     			 if (hwc.isIOS() || hwc.isAndroid()) {
511     				 hwc.getDataFromContainer("setscreentitle", "&title=" + encodeURIComponent(screenTitle));
512     			  }
513     			  else {
514     				 hwc.postDataToContainer("setscreentitle", "&title=" + encodeURIComponent(screenTitle));
515     			  }
516     		}
517     	} finally {
518     		hwc.traceLeavingMethod("hwc.setScreenTitle_CONT");
519     	}
520     };
521     
522     /**
523      * This class represents a collection of menu items.
524      * @memberOf hwc
525      * @public
526      * @class
527      *
528      * @example
529      * // This is the function we'll use as a callback for the first menu item.
530      * var callback = function()
531      * {
532      *    alert( "You clicked the first menu item!" );
533      * }
534      * 
535      * // This is the function we'll use as a callback for the second menu item.
536      * var callback2 = function()
537      * {
538      *    alert( "You clicked the second menu item!" );
539      * }
540      *
541      * // This function creates and adds a menu item collection.
542      * var addMenuItems = function()
543      * {
544      *    var menuItemCollection = new hwc.MenuItemCollection();
545      *    menuItemCollection.addMenuItem("menu item 1", "callback()");
546      *    menuItemCollection.addMenuItem("menu item 2", "callback2()");
547      *    hwc.addMenuItemCollection( menuItemCollection );
548      * }
549      */
550     hwc.MenuItemCollection = function() {
551         this.menuItems = [];
552         this.subMenuName = null;
553         this.okAction = null;
554     };
555     
556     /**
557      * This function adds a menu item to the collection.
558      *
559      * @param {string} title The display text for the menu item.
560      * @param {anonymous.genericCallbackFunction} callback The function to call when the menu item is clicked.
561      * @param {boolean} [isDefault] Determines if the menu item is selected by default on BlackBerry.
562      * If more than one menu item is added to the same collection with true for this parameter, the
563      * last menu item added with true for this parameter will be selected by default on Blackberry.
564      * @memberOf hwc.MenuItemCollection
565      * @public
566      * @example
567      * var callbackFunctionName = function()
568      * {
569      *    alert( "Menu item clicked!" );
570      * }
571      * var menuItemCollection = new hwc.MenuItemCollection();
572      * menuItemCollection.addMenuItem("menu item name", "callbackFunctionName()", true);
573      * 
574      */
575     hwc.MenuItemCollection.prototype.addMenuItem = function(title, callback, isDefault) {
576     	hwc.traceEnteringMethod("hwc.MenuItemCollection.addMenuItem");
577     	try {
578     		this.menuItems.push( { "name" : title, "action" : callback, "default" : isDefault ? "true" : "false" } );
579     	} finally {
580     		hwc.traceLeavingMethod("hwc.MenuItemCollection.addMenuItem");
581     	}
582     };
583          
584     /**
585      * This function sets the sub menu name to use on Windows Mobile.
586      *
587      * @param {string} name The sub menu name to use.
588      * @memberOf hwc.MenuItemCollection
589      * @public
590      * @example
591      * var callbackFunctionName = function()
592      * {
593      *    alert( "Menu item clicked!" );
594      * }
595      * var menuItemCollection = new hwc.MenuItemCollection();
596      * menuItemCollection.setSubMenuName( "Custom Menu" );
597      * menuItemCollection.addMenuItem("menu item name", "callbackFunctionName()");
598      */
599     hwc.MenuItemCollection.prototype.setSubMenuName = function(name) {
600         this.subMenuName = name;
601     };
602         
603     /**
604      * This function sets the OK action to use on WM.
605      * @memberOf hwc.MenuItemCollection
606      * @public
607      * @param {anonymous.genericCallbackFunction} callback The function to call when the OK button is pressed.
608      *
609      * @example
610      * var callbackFunctionName = function()
611      * {
612      *    alert( "Menu item clicked!" );
613      * }
614      * var okActionFunction = function()
615      * {
616      *    alert( "A OKAY!" );
617      * }
618      * var menuItemCollection = new hwc.MenuItemCollection();
619      * menuItemCollection.setOKAction( "okActionFunction()" );
620      * menuItemCollection.addMenuItem("menu item name", "callbackFunctionName()");
621      */
622     hwc.MenuItemCollection.prototype.setOKAction = function(callback) {
623         this.okAction = callback;
624     };
625     
626     /**
627      * This function converts the menu item collection to a JSON string.  This function
628      * is used as a helper for {@link hwc.addMenuItemCollection}.
629      *
630      * @return {string} The JSON string representing this menu item collection.
631      * @memberOf hwc.MenuItemCollection
632      * @public
633      * @example
634      * var callbackFunctionName = function()
635      * {
636      *    alert( "Menu item clicked!" );
637      * }
638      * var menuItemCollection = new hwc.MenuItemCollection();
639      * var jsonMenuItemCollection = menuItemCollection.stringify();
640      */
641     hwc.MenuItemCollection.prototype.stringify = function()
642     {
643         return JSON.stringify({
644             "menuitems" : this.menuItems,
645             "submenuname" : this.subMenuName,
646             "OK" : this.okAction
647         }); 
648     };
649     
650     /**
651      * This function adds a menu item collection to the menu items for the screen.
652      *
653      * @param {@link hwc.MenuItemCollection} collection The collection of menu items to add to the screen.
654      * @memberOf hwc
655      * @public
656      * @example
657      * var callbackFunctionName = function()
658      * {
659      *    alert( "Menu item clicked!" );
660      * }
661      * var menuItemCollection = new hwc.MenuItemCollection();
662      * menuItemCollection.addMenuItem("menu item name", "callbackFunctionName()");
663      * hwc.addMenuItemCollection( menuItemCollection );
664      */
665     hwc.addMenuItemCollection = function(collection) {
666     	hwc.traceEnteringMethod("hwc.addMenuItemCollection");
667     	try {
668     		if (isBlackBerry() || isWindowsMobile() || isAndroid()) {
669     			var request = "menuitems=" + encodeURIComponent(collection.stringify());
670     			  hwc.postDataToContainer("addallmenuitems", request);
671     		}
672     	} finally {
673     		hwc.traceLeavingMethod("hwc.addMenuItemCollection");
674     	}
675     };
676     
677     /**
678      * Allows the user to add a menuitem with the specified name and with the specified
679      * callback, which will be invoked when the menuitem is clicked.  This function should
680      * only be used in hybrid apps generated with the Unwired Workspace designer.
681      *
682      * @private
683      *
684      * @param {string} menuItemName The specified menuitem name.
685      * @param {string} functionName The string representing the call to the {@link anonymous.genericCallbackFunction} callback function.
686      * @param {string} subMenuName The specific sub-menu name for Windows Mobile.
687      * @param {string} screenToShow The screen about to be shown.
688      * @param {string} [menuItemKey] The menuItem's key.
689      * @memberOf hwc
690      * @example
691      * var callbackFunction = function()
692      * {
693      *    alert( "Menu Item Clicked!" );
694      * }
695      * hwc.addMenuItem_CONT( "Custom Menu Item", "callbackFunction()", "Custom Sub Menu", "Start" );
696      */
697     hwc.addMenuItem_CONT = function(menuItemName, functionName, subMenuName, screenToShow, menuItemKey) {
698         var div, menuStr, idxOfMenuItemName, comma, request;
699     	hwc.traceEnteringMethod("hwc.addMenuItem_CONT");
700     	try {
701     		//first add the item to sup_menuitems
702     		div = document.getElementById(screenToShow + "ScreenDiv");
703     		menuStr = div.getAttribute("sup_menuitems");
704     		idxOfMenuItemName = menuStr.indexOf(menuItemName);
705     		if (idxOfMenuItemName !== -1) {
706     			return;
707     		}
708     		comma = (menuStr.length > 0) ? "," : "";
709     		menuStr = menuStr + comma + menuItemName + "," + menuItemKey;
710     		try {
711     			div.setAttribute("sup_menuitems", menuStr);  //has no affect on Windows Mobile
712     		}
713     		catch (e) {
714     		}
715     
716     		request = "menuitemname=" + encodeURIComponent(menuItemName);
717     		request += ("&onmenuclick=" + encodeURIComponent(functionName) + "()");
718     		if (hwc.isWindowsMobile()) {
719     			request += "&submenuname=";
720     			if (subMenuName) {
721     				request += encodeURIComponent(subMenuName);
722     			}
723     			else {
724     				if (resources) {
725     					request += encodeURIComponent(resources.getString("MENU"));
726     				}
727     				else {
728     					request += "Menu";
729     				}
730     			}
731     			  hwc.postDataToContainer("addMenuItem", request);
732     		}
733     		else if (hwc.isAndroid() || hwc.isBlackBerry()) {
734     			  hwc.postDataToContainer("addMenuItem", request);
735     		}    
736     	} finally {
737     		hwc.traceLeavingMethod("hwc.addMenuItem_CONT");
738     	}
739     };
740     
741     
742     /**
743      * This function removes all menu items that were added by the hybrid app.
744      * @memberOf hwc
745      * @public
746      * @example
747      * hwc.removeAllMenuItems();
748      */
749     hwc.removeAllMenuItems = function() {
750     	hwc.traceEnteringMethod("hwc.removeAllMenuItems");
751     	try {
752     		if (hwc.isAndroid() || hwc.isWindowsMobile() || hwc.isBlackBerry() ) {
753     			hwc.getDataFromContainer("removeallmenuitems");
754     		} 
755     	} finally {
756     		hwc.traceLeavingMethod("hwc.removeAllMenuItems");
757     	}
758     };
759     
760     /**
761      * This function sets the activation required state of this hybrid app to true.  After calling this
762      * function, the current hybrid app will need to be activated.
763      * @memberOf hwc
764      * @public
765      * @example
766      * hwc.activationRequired();
767      */
768     hwc.activationRequired = function() {
769     	hwc.traceEnteringMethod("hwc.activationRequired");
770     	try {
771     		hwc.getDataFromContainer("requiresactivation");      
772     	} finally {
773     		hwc.traceLeavingMethod("hwc.activationRequired");
774     	}
775     };
776     
777     /**
778      * This function sets the activation required state for the current hybrid app to false.  After calling this
779      * function, the current hybrid app will not need to be activated.
780      * @memberOf hwc
781      * @public
782      * @example
783      * hwc.markAsActivated();
784      */
785     hwc.markAsActivated = function() {
786     	hwc.traceEnteringMethod("hwc.markAsActivated");
787     	try {
788     		hwc.getDataFromContainer("markasactivated");     
789     	} finally {
790     		hwc.traceLeavingMethod("hwc.markAsActivated");
791     	}
792     };
793     
794     /**
795      * Allows the user to set the processed state to true for the current message.
796      * @memberOf hwc
797      * @public
798      * @example
799      * hwc.markAsProcessed()
800      */
801     hwc.markAsProcessed = function() {
802     	hwc.traceEnteringMethod("hwc.markAsProcessed");
803     	try {
804     		hwc.getDataFromContainer("markasprocessed");
805     	} finally {
806     		hwc.traceLeavingMethod("hwc.markAsProcessed");
807     	}
808     };
809     
810     /**
811      * Allows the user to set the credentials to the expired state for the current hybrid app.
812      * @memberOf hwc
813      * @public
814      * @example
815      * hwc.expireCredentials();
816      */
817     hwc.expireCredentials = function() {
818     	hwc.traceEnteringMethod("hwc.expireCredentials");
819     	try {
820     		hwc.getDataFromContainer("expirecredentials");   
821     	} finally {
822     		hwc.traceLeavingMethod("hwc.expireCredentials");
823     	}
824     };
825     
826     /**
827      * This function clears the contents of the on-device request result cache for the current hybrid app.
828      * @memberOf hwc
829      * @public
830      * @example
831      * hwc.clearCache();
832      */
833     hwc.clearCache = function() {
834     	hwc.traceEnteringMethod("hwc.clearCache");
835     	try {
836     		hwc.getDataFromContainer("clearrequestcache");
837     	} finally {
838     		hwc.traceLeavingMethod("hwc.clearCache");
839     	}
840     	
841     };
842     
843     /**
844      * This function clears an item from the contents of the on-device request result cache for the current hybrid app.
845      *
846      * @param {string} cachekey The key for the cache item to be removed.  This is the same key that was passed to hwc.doOnlineRequest.
847      * @memberOf hwc
848      * @public 
849      * @example
850      * // The cache key is set when calling hwc.doOnlineRequest_CONT
851      * hwc.doOnlineRequest( ., ., ., ., ., ., ., cacheKey, ., .);
852      * // At some later point if we want to clear the cache for the above request, we use the following code:
853      * hwc.clearCacheItem( cacheKey );
854      */
855     hwc.clearCacheItem = function( cachekey ) {
856         var request;
857     	hwc.traceEnteringMethod("hwc.clearCacheItem");
858     	try {
859     		request = "cachekey=" + encodeURIComponent(cachekey);
860     	   
861     		hwc.postDataToContainer("clearrequestcacheitem", request);
862     	} finally {
863     		hwc.traceLeavingMethod("hwc.clearCacheItem");
864     	}
865     };
866     
867     
868     /**
869      * Allows the user to log a message to the device trace log which can be remotely retrieved from the server. 
870      * Whether the message actually gets logged will depend on how the log level that the administrator has selected
871      * for this device user compares with the log level of this message.
872      * The logging level and alert dialog callback can be set with {@link hwc.setLoggingCurrentLevel} and {@link setLoggingAlertDialog}.
873      *  
874      * @param {string} sMsg The message to be logged.
875      * @param {string} eLevel The error level for this message.  This parameter must be one of: "ERROR", "WARN", "INFO" or "DEBUG".
876      * @param {boolean} notifyUser Whether the logging alert callback will be invoked.  This parameter is independent of the
877      * logging level (the logging alert callback will always be invoked if this is true, and never if this is false).
878      * @memberOf hwc
879      * @public
880      * @example
881      * var logAlert = function( message )
882      * {
883      *    alert( "New log message: " + message );
884      * }
885      * hwc.setLoggingAlertDialog( logAlert );
886      * hwc.setLoggingCurrentLevel( 3 );
887      * // The following will be logged, and the logging alert dialog will be invoked.
888      * hwc.log( "info message notify", "INFO", true );
889      * // The following will be logged, but the logging alert dialog will not be invoked.
890      * hwc.log( "info message", "INFO", false );
891      * // The following will not be logged, but the logging alert dialog will be invoked.
892      * hwc.log( "debug message notify", "DEBUG", true );
893      * // The following will not be logged, and the logging alert dialog will not be invoked.
894      * hwc.log( "debug message", "DEBUG", false );
895      * 
896      */
897     hwc.log = function log(sMsg, eLevel, notifyUser) {
898         var msgLogLevel;
899         if( !sMsg ) {
900             return; 
901         } 
902         if (notifyUser && hwc.getLoggingAlertDialog()) {
903             (hwc.getLoggingAlertDialog())(sMsg);
904         }
905         
906         switch (eLevel) {
907             case "ERROR":
908                 msgLogLevel = 1;
909                 break;
910             case "WARN":
911                 msgLogLevel = 2;
912                 break;
913             case "INFO":
914                 msgLogLevel = 3;
915                 break;
916             case "DEBUG":
917                 msgLogLevel = 4;
918                 break;
919             default:
920                 msgLogLevel = 1;
921         }
922         if((sMsg === "") || (msgLogLevel > hwc.getLoggingCurrentLevel()) || (hwc.isWindows())) {
923             return;
924         }
925     
926         if (hwc.isAndroid()) {
927             _HWC.log(sMsg, msgLogLevel);
928         } else {
929             hwc.postDataToContainer("logtoworkflow", "loglevel=" + msgLogLevel + "&logmessage=" + encodeURIComponent(sMsg));
930         }
931     
932     };
933     
934     /**
935      * This function opens a form on the device that allows the user to specify the credentials for the use of
936      * certificate-based authentication. If the user picks a certificate, then that certificate is saved in the
937      * credentials cache.
938      * @memberOf hwc
939      * @public
940      * @example
941      * hwc.showCertificatePicker();
942      */
943     hwc.showCertificatePicker = function() {
944     	hwc.traceEnteringMethod("hwc.showCertificatePicker");
945     	try {
946     		hwc.getDataFromContainer("showcertpicker");
947     	} finally {
948     		hwc.traceLeavingMethod("hwc.showCertificatePicker");
949     	}
950     };
951     
952     
953     /**
954      * This function saves login credentials from a certificate to the credential cache.
955      * The common name is used for the username and the signed certificate is used for the password.
956      *
957      * @param {hwc.Certificate} certificate The values certificate.subjectCN and certificate.signedCertificate must be defined.
958      * @memberOf hwc
959      * @public
960      * @example
961      * var certInfo = {};
962      * certInfo.subjectCN = "sampleCommonName";
963      * certInfo.signedCertificate = "samplePassword";
964      * hwc.saveLoginCertificate( certInfo );
965      */
966     hwc.saveLoginCertificate = function(certificate) {
967     	hwc.traceEnteringMethod("hwc.saveLoginCertificate");
968     	try {
969     		hwc.saveLoginCredentials(certificate.subjectCN, certificate.signedCertificate, true);
970     	} finally {
971     		hwc.traceLeavingMethod("hwc.saveLoginCertificate");
972     	}
973     };
974     
975     /**
976      * This function saves login credentials to the credential cache.
977      *
978      * @param {string} userName The user name to save
979      * @param {string} password The password to save
980      * @memberOf hwc
981      * @public
982      * @example
983      * hwc.saveLoginCredentials( "sampleUserName", "samplePassword" );
984      */
985     hwc.saveLoginCredentials = function(userName, password) {
986         var requestData;
987     	hwc.traceEnteringMethod("hwc.saveLoginCredentials");
988     	try {
989     		requestData = "supusername=" + encodeURIComponent(userName) + "&suppassword=" + encodeURIComponent(password);
990     
991     		if (hwc.isAndroid()) {
992     			_HWC.saveCredentials( userName, password );
993     		}  else {
994     			 hwc.postDataToContainer("savecredential", requestData);
995     		}
996     		
997     	} finally {
998     		hwc.traceLeavingMethod("hwc.saveLoginCredentials");
999     	}
1000    };
1001    
1002    /**
1003     * This function opens the supplied URL in a browser.  The browser opens on top of the hybrid app - the
1004     * context of the hybrid app is undisturbed.
1005     *
1006     * @param {string} url The URL to be shown in a browser.
1007     * @memberOf hwc
1008     * @public
1009     * @example
1010     * hwc.showUrlInBrowser( "http://www.google.com" );
1011     */
1012    hwc.showUrlInBrowser = function showUrlInBrowser(url)
1013    {
1014        var idxOfColon;
1015    	hwc.traceEnteringMethod("hwc.showUrlInBrowser");
1016    	try {
1017    		url = hwc.trimSpaces(url, true);
1018    		idxOfColon = url.indexOf(":");
1019    		if (idxOfColon === -1 || (idxOfColon > 7)) {
1020    			url = "http://" + url;
1021    		}
1022    		
1023    		if (hwc.isWindowsMobile() || hwc.isAndroid() || hwc.isIOS() || hwc.isBlackBerry()) {
1024    			hwc.getDataFromContainer("showInBrowser", "&url=" + encodeURIComponent(url));
1025    		} else {
1026    			window.open(url);
1027    		}
1028    	} finally {
1029    		hwc.traceLeavingMethod("hwc.showUrlInBrowser");
1030    	}
1031    };
1032    
1033    /**
1034     * Shows the given file contents in a content-appropriate way. The type of the content is
1035     * supplied by either the MIME type or the filename, at least one of which must be supplied.
1036     * The content itself should be presented as a base64-encoded string. Not all file types may
1037     * be supported on all platforms.
1038     *
1039     * @param {string} contents The base-64 encoded version of the binary content of the attachment to be displayed.
1040     * @param {string} mimeType The MIME type of the file.
1041     * @param {string} fileName The name of the file.
1042     * @param {anonymous.genericCallbackFunction} waitDialogCallbackString The callback function used to close a wait dialog once the attachment
1043     * is done opening.
1044     * @memberOf hwc
1045     * @public
1046     * @example
1047     * var openAttachmentBase64StringPng = function()
1048     * {
1049     *    // How you want get the base 64 encoding of the file is up to you. This string represents a small png image.
1050     *    var data = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAA0SURBVFhH7dAxEQAACAMx3CAT6eVQwZKh8/dSmc7n6jN+bQcIECBAgAABAgQIECBAgACBBb3SkJeQ67u1AAAAAElFTkSuQmCC";
1051     *    hwc.showProgressDialog();
1052     *    // Don't have to pass the filename because we are passing the MIME type.
1053     *    hwc.showAttachmentContents_CONT( data, "image/png", null, "hwc.hideProgressDialog()" );
1054     * }
1055     * 
1056     * @example
1057     * var openAttachmentBase64StringTxt = function()
1058     * {
1059     *    // How you want get the base 64 encoding of the file is up to you. This string represents a short text file.
1060     *    var data = "VGhpcyBpcyBwYXJ0IG9mIGEgaHlicmlkIGFwcC4=";
1061     *    // Don't have to pass the MIME type because we are passing the filename.
1062     *    hwc.showAttachmentContents_CONT( data, null, "attach.txt" );
1063     * }
1064     */
1065    hwc.showAttachmentContents_CONT = function(contents, mimeType, fileName, waitDialogCallbackString) {
1066        var request;
1067    	hwc.traceEnteringMethod("hwc.showAttachmentContents_CONT");
1068    	try {
1069    		request = "callback=" + waitDialogCallbackString;
1070    
1071    		if (hwc.isWindowsMobile()) {
1072    			contents = contents.replace(/=/g, "~");
1073    			request += "&Attachmentdata=" + contents;
1074    		} else {
1075    			request += "&Attachmentdata=" + encodeURIComponent(contents);
1076    		}
1077    		if (mimeType) {
1078    			request += "&mimetype=" + encodeURIComponent(mimeType);
1079    		}
1080    		if (fileName) {
1081    		   request += "&filename=" + encodeURIComponent(fileName);
1082    		}
1083    		 
1084    		hwc.postDataToContainer("showattachment", request);
1085    	} finally {
1086    		hwc.traceLeavingMethod("hwc.showAttachmentContents_CONT");
1087    	}
1088    };
1089    
1090    /**
1091     * Shows the given file contents in a content-appropriate way. The type of the content is
1092     * supplied by either the MIME type or the filename, at least one of which must be supplied.
1093     * The content itself will be a unique key supplied earlier to a call to doAttachmentDownload.
1094     * @param uniqueKey The unique key for the attachment.
1095     * @param mimeType The MIME type of the file.
1096     * @param fileName The name of the file.
1097     * @param waitDialogCallbackString string with the value for the 'callback=' parameter.
1098     * @memberOf hwc
1099     * @public 
1100     */
1101    hwc.showAttachmentFromCache_CONT = function(uniqueKey, mimeType, fileName, waitDialogCallbackString) {
1102        var request;
1103    	hwc.traceEnteringMethod("hwc.showAttachmentFromCache_CONT");
1104    	try {
1105    		request = "callback=" + waitDialogCallbackString;
1106    
1107    		request += "&uniquekey=" + encodeURIComponent(uniqueKey);
1108    		if (mimeType) {
1109    			request += "&mimetype=" + encodeURIComponent(mimeType);
1110    		}
1111    		if (fileName) {
1112    		   request += "&filename=" + encodeURIComponent(fileName);
1113    		}
1114    		 
1115    		hwc.postDataToContainer("showattachment", request);
1116    	} finally {
1117    		hwc.traceLeavingMethod("hwc.showAttachmentFromCache_CONT");
1118    	}
1119    };
1120    
1121    /**
1122     * Shows a local attachment.
1123     *
1124     * @param {string} key The key of the attachment.  This is the path to the file, with the root being the
1125     * folder that manifest.xml is located.
1126     * @memberOf hwc
1127     * @public
1128     * @example
1129     * hwc.showLocalAttachment( "html/images/samplePic.gif" );
1130     */
1131    hwc.showLocalAttachment = function showLocalAttachment(key) {
1132    	hwc.traceEnteringMethod("hwc.showLocalAttachment");
1133        try {
1134    		if (hwc.isWindowsMobile() || hwc.isAndroid() || hwc.isIOS()) { 
1135    			hwc.getDataFromContainer("showlocalattachment", "&key=" + encodeURIComponent(key));
1136    		} else if (hwc.isBlackBerry()) {
1137    			if (key.indexOf("file://") > -1){
1138    				window.location = key;
1139    			} else {
1140    				window.location = "http://localhost/" + key;
1141    			}
1142    		} else {
1143    			window.open(key);
1144    		}
1145    
1146    	} finally {
1147    		hwc.traceLeavingMethod("hwc.showLocalAttachment");
1148    	}
1149    };
1150    
1151    /**
1152     * Internal function to allow the user to cause an operation/object query to be invoked.  This function should probably
1153     * only be used by designer generated javascript.
1154     *
1155     * @private
1156     *
1157     * @param {string} credInfo Credential info in the format "supusername=usernameValue&suppassword=passwordValue"
1158     * @param {string} serializeDataMessageToSend The data message, already serialized.  This parameter should be obtained by calling serializeToString
1159     * on the result from hwc.getMessageValueCollectionForOnlineRequest.
1160     * @param {boolean} hasFileMessageValue Whether the data message to send has a file message value.  This parameter should be obtained by calling
1161     * getHasFileMessageValue on the result from hwc.getMessageValueCollectionForOnlineRequest.
1162     * @param {number} timeout Specifies the time, in seconds, to wait before giving up waiting for a response.
1163     * @param {string} cacheTimeout Specifies the time, in seconds, since the last invocation with the same input parameter values to use the same
1164     * response as previously retrieved without making a new call to the server.  If this parameter is NEVER, the cache content will never expire.
1165     * @param {string} errorMessage Specifies the string to display if an online request fails.
1166     * @param {anonymous.errorCallbackFunction} errorCallback Name of the function to be called if an online request fails. If  this parameter is null,
1167     * 'reportRMIError' will be used.
1168     * @param {string} cacheKey String used as the key for this request in the on-device request result cache.
1169     * @param {string} cachePolicy Specifies cache lookup policy used by container. If this parameter is 'serverfirst' (ignoring case) then the cache policy
1170     * used for this online request will be to check the server before the cache.  If this parameter is any other value then a cache first policy will be used.
1171     * If this parameter is absent and cache is enabled, the container uses default cache lookup policy to get data from cache if it is not expired.
1172     * @param {boolean} asynchronous Specifies whether container will make the request in synchronous or asynchronous mode.
1173     * If this parameter is absent, the container makes the request to the server in synchronous mode.
1174     * @memberOf hwc
1175     */
1176    hwc.doOnlineRequest_CONT = function( credInfo, 
1177            serializeDataMessageToSend,
1178            hasFileMessageValue,
1179            timeout, cacheTimeout, 
1180            errorMessage, errorCallback, 
1181            cacheKey, cachePolicy, 
1182            asynchronous) {
1183    		
1184    	hwc.traceEnteringMethod("hwc.doOnlineRequest_CONT");
1185        
1186    	try {
1187    		var request, xmlhttp, response, encodedMessage, url, funcCall, responseDataType;
1188    		request = "xmlWorkflowMessage=" + encodeURIComponent(serializeDataMessageToSend);
1189    		
1190    		if (credInfo) {
1191    			request += ("&" + credInfo);
1192    		}
1193    		request += ("&cachekey=" + encodeURIComponent(cacheKey));
1194    		if (timeout) {
1195    			request += ("&rmitimeout=" + timeout);
1196    		}
1197    		if (cacheTimeout) {
1198    			request += ("&RequestExpiry=" + cacheTimeout);
1199    		}
1200    		if (hasFileMessageValue) {
1201    			request += ("&parse=true");
1202    		}
1203    		if (errorMessage) {
1204    			if( hwc.isBlackBerry() ) {
1205    				encodedMessage = encodeURIComponent(escape(errorMessage));
1206    			} else {
1207    				// This is a temporary fix for a bug in the container that calls
1208    				// encodeURIComponent on the whole query string for Android.  See
1209    				// IR 676161-2.
1210    				encodedMessage = encodeURIComponent(errorMessage);
1211    			}
1212    			request += ("&onErrorMsg=" + encodedMessage);
1213    		}
1214    		if (!errorCallback) {
1215    			errorCallback = "hwc.reportRMIError";
1216    		}
1217    		if (cachePolicy) {
1218    			request += ("&cachePolicy=" + cachePolicy);
1219    		}
1220    		if (asynchronous) {
1221    			request += ("&asynchronous=" + asynchronous);
1222    		}
1223    		request += ("&onErrorCallback=" + errorCallback);
1224    
1225    		if (hwc.isWindowsMobile() || hwc.isWindows()) {
1226    			//make xmlhttp request to load the rmi response from server
1227    			xmlhttp = hwc.getXMLHTTPRequest();
1228    
1229    			if (hwc.isWindowsMobile()) {
1230    				xmlhttp.open("POST", "/sup.amp?querytype=rmi&" + hwc.versionURLParam, true );  
1231    		
1232    				xmlhttp.onreadystatechange = function() {
1233    					if (xmlhttp.readyState === 4) {
1234    						if (xmlhttp.status === 200 || xmlhttp.status === 0) {
1235    							response = xmlhttp.responseText;
1236    							var responseDataType = xmlhttp.getResponseHeader("OnlineRequest-Response-Data-Type");
1237    							processDataMessage(response, null, null, null, responseDataType);
1238    						 }
1239    					}
1240    				};
1241    
1242    				try {
1243    					xmlhttp.send(request);
1244    				}
1245    				catch (excep1) {
1246    					hwc.log("Error:  Unable to retrieve the message from the server", "ERROR", true);
1247    				}
1248    			}
1249    			else { // hwc.isWindows() 
1250    				xmlhttp.open("POST", "rmi.xml", false );
1251    				xmlhttp.send(request);
1252    		
1253    				//Win32 returns 200 for OK, WM returns 0 for OK
1254    				if (xmlhttp.status === 200 || xmlhttp.status === 0) {
1255    					response = xmlhttp.responseText;
1256    					processDataMessage(response);
1257    				}
1258    				else {
1259    					hwc.log("Error:  Unable to retrieve the message from the server", "ERROR", true);
1260    				}
1261    			}
1262    		}
1263    		
1264    		else if (hwc.isAndroid()) {
1265    			url = 'http://localhost/sup.amp?querytype=rmi&' + hwc.versionURLParam;
1266    			funcCall = "_HWC.postData('" + url + "', '" +  request + "')";
1267    			// method processDataMessage invoked by native container.
1268    			// funcCall = "processDataMessage(" + funcCall + ")";
1269    			setTimeout(funcCall, 5);
1270    		}  
1271    		else { //BB and iPhone
1272    			xmlhttp = hwc.getXMLHTTPRequest();   
1273    			xmlhttp.open("POST", "http://localhost/sup.amp?querytype=rmi&" + hwc.versionURLParam, true);            
1274    			
1275    			 if (hwc.isBlackBerry()) {
1276    				xmlhttp.onreadystatechange = function() {
1277    					if (xmlhttp.readyState === 4) {
1278    						if (xmlhttp.status === 200) {
1279    							response = xmlhttp.responseText;
1280    							responseDataType = xmlhttp.getResponseHeader("OnlineRequest-Response-Data-Type");
1281    							processDataMessage(response, null, null, null, responseDataType);
1282    						}
1283    					}
1284    				};
1285    			}
1286    			try {
1287    				xmlhttp.send(request);
1288    			}
1289    			catch (excep2) {
1290    				hwc.log("Error:  Unable to retrieve the message from the server", "ERROR", true);
1291    			}
1292    		}                           
1293    	} finally {
1294    		hwc.traceLeavingMethod("hwc.doOnlineRequest_CONT");
1295    	}
1296    };
1297    
1298    /**
1299     * Allows the user to cause an operation/object query to be invoked.  This function should probably only be used by
1300     * designer generated javascript.
1301     *
1302     * @private
1303     *
1304     * @param {string} credInfo Credential info in the format "supusername=usernameValue&suppassword=passwordValue"
1305     * @param {string} serializeDataMessageToSend The data message, already serialized.  This parameter should be obtained by calling serializeToString
1306     * on the result from hwc.getMessageValueCollectionForOnlineRequest.
1307     * @param {string} attachmentKey The specified key of the result will not be returned in the data message but will instead be stored on the
1308     * device for later access via {@link hwc.showAttachmentFromCache_CONT}.
1309     * @param {string} requestGUID Represents a unique key that can be used to store/access the cached key value from the request results.
1310     * @param {callback function} downloadCompleteCallback A function that will be invoked when the attachment has been downloaded to the device
1311     * and is ready to be accessed.
1312     * @memberOf hwc
1313     */
1314    hwc.doAttachmentDownload_CONT = function(credInfo, serializeDataMessageToSend, attachmentKey, requestGUID, downloadCompleteCallback) {
1315    	hwc.traceEnteringMethod("hwc.doAttachmentDownload_CONT");
1316    	try {
1317    		var request, xmlhttp;
1318    		request = "xmlWorkflowMessage=" + encodeURIComponent(serializeDataMessageToSend);
1319    		
1320    		if (credInfo) {
1321    			request += ("&" + credInfo);
1322    		}
1323    		request += ("&attachmentkey=" + attachmentKey);
1324    		request += ("&uniquekey="     + requestGUID);
1325    		request += ("&ondownloadcomplete=" + downloadCompleteCallback);
1326    		if (hwc.isWindowsMobile() || hwc.isWindows()) {
1327    			xmlhttp = hwc.getXMLHTTPRequest();
1328    			xmlhttp.open("POST", "/sup.amp?querytype=downloadattachment&" + hwc.versionURLParam, true );
1329    			xmlhttp.onreadystatechange = function() {
1330    				if (xmlhttp.readyState === 4) {
1331    					if (xmlhttp.status === 200) {
1332    						window[downloadCompleteCallback].call(this, decodeURIComponent(requestGUID), xmlhttp.responseText);
1333    					}
1334    				}
1335    			};
1336    			try {
1337    				xmlhttp.send(request);          
1338    			}
1339    			catch (e3) {}                                
1340    		}
1341    		else if (hwc.isAndroid()) {
1342    			hwc.postDataToContainer("downloadattachment", request);
1343    		}   
1344    		else {
1345    			xmlhttp = hwc.getXMLHTTPRequest();
1346    			xmlhttp.open("POST", "http://localhost/sup.amp?querytype=downloadattachment&" + hwc.versionURLParam, true);
1347    			if (hwc.isBlackBerry()) {
1348    				xmlhttp.onreadystatechange = function() {
1349    					if (xmlhttp.readyState === 4) {
1350    						if (xmlhttp.status === 200) {
1351    							window[downloadCompleteCallback].call(this, decodeURIComponent(requestGUID), xmlhttp.responseText);
1352    						}
1353    					}
1354    				};
1355    			}
1356    			try {
1357    				xmlhttp.send(request);
1358    			}
1359    			catch (e1) {}
1360    		}
1361    	} finally {
1362    		hwc.traceLeavingMethod("hwc.doAttachmentDownload_CONT");
1363    	}
1364    };
1365    
1366    /**
1367     * Allows the user to cause an operation/object query to be invoked. Will close the hybrid app application when finished.  This function should probably only be used by
1368     * designer generated javascript.
1369     *
1370     * @private
1371     *
1372     * @param {string} credInfo Credential info in the format "supusername=usernameValue&suppassword=passwordValue"
1373     * @param {string} serializeDataMessageToSend The data message, already serialized.  This parameter should be obtained by calling serializeToString
1374     * on the result from hwc.getMessageValueCollectionForOnlineRequest.
1375     * @param {boolean} hasFileMessageValue Whether the data message to send has a file message value.  This parameter should be obtained by calling
1376     * getHasFileMessageValue on the result from hwc.getMessageValueCollectionForOnlineRequest.
1377     * @memberOf hwc
1378     */
1379    hwc.doSubmitWorkflow_CONT = function(credInfo, serializeDataMessageToSend, hasFileMessageValue) {
1380    	hwc.traceEnteringMethod("hwc.doSubmitWorkflow_CONT");
1381    	try {
1382    		var request = "xmlWorkflowMessage=" + encodeURIComponent(serializeDataMessageToSend);
1383    		
1384    		if (credInfo) {
1385    			request += ("&" + credInfo);
1386    		}
1387    		if (hasFileMessageValue) {
1388    			request += ("&parse=true");
1389    		} 
1390    		 
1391    		 hwc.postDataToContainer("submit", request);
1392    	} finally {
1393    		hwc.traceLeavingMethod("hwc.doSubmitWorkflow_CONT");
1394    	}
1395    };
1396    
1397    /**
1398     * Internal function to allow the user to cause an operation/object query to be invoked.  This function should probably only be used by
1399     * designer generated javascript.
1400     *
1401     * @private
1402     *
1403     * @param {string} credInfo Credential info in the format "supusername=usernameValue&suppassword=passwordValue"
1404     * @param {string} serializeDataMessageToSend The data message, already serialized.  This parameter should be obtained by calling serializeToString
1405     * on the result from hwc.getMessageValueCollectionForOnlineRequest.
1406     * @memberOf hwc
1407     */
1408    hwc.doActivateWorkflow_CONT = function(credInfo, serializeDataMessageToSend ) {
1409        var request, xmlhttp;
1410    	hwc.traceEnteringMethod("hwc.doActivateWorkflow_CONT");
1411    	try {
1412    		request = "xmlWorkflowMessage=" + encodeURIComponent(serializeDataMessageToSend);
1413    
1414    		if (credInfo) {
1415    			request += ("&" + credInfo);
1416    		}
1417    		 
1418    		hwc.postDataToContainer("activate", request);
1419    	} finally {
1420    		hwc.traceLeavingMethod("hwc.doActivateWorkflow_CONT");
1421    	}
1422    };
1423    
1424    /**
1425     * This function should probably only be used by designer generated javascript.
1426     *
1427     * @private
1428     
1429     * @param {string} credInfo Credential info in the format "supusername=usernameValue&suppassword=passwordValue"
1430     * @param serializeDataMessageToSend The data message, already serialized.  This parameter should be obtained by calling serializeToString
1431     * on the result from hwc.getMessageValueCollectionForOnlineRequest.
1432     * @memberOf hwc
1433     */
1434    hwc.doCredentialsSubmit_CONT = function(credInfo, serializeDataMessageToSend ) {
1435    	hwc.traceEnteringMethod("hwc.doCredentialsSubmit_CONT");
1436    	try {
1437    		var request = "xmlWorkflowMessage=" + encodeURIComponent(serializeDataMessageToSend);
1438    
1439    		if (credInfo) {
1440    			request += ("&" + credInfo);
1441    		}
1442    
1443    		hwc.postDataToContainer("credentials", request);
1444    	} finally {
1445    		hwc.traceLeavingMethod("hwc.doCredentialsSubmit_CONT");
1446    	}
1447    };
1448    
1449    /**
1450     * This function shows a progress dialog with spinner.  The dialog created by this function will block all
1451     * user input until {@link hwc.hideProgressDialog} is called.  It is important to be sure that
1452     * {@link hwc.hideProgressDialog} will be called after a call to this function.
1453     *
1454     * @param {string} [message] The message to show on the progress dialog. This message is displayed on Android
1455     * platforms only - other platforms show only a spinner.
1456     * @memberOf hwc
1457     * @public
1458     * @example
1459     * var showProgress = function()
1460     * {
1461     *    hwc.showProgressDialog( "a message" );
1462     *    setTimeout( hideProgress, 10000 );
1463     * }
1464     * 
1465     * var hideProgress = function()
1466     * {
1467     *    hwc.hideProgressDialog();
1468     * }
1469     */
1470    hwc.showProgressDialog = function(message) {
1471    	hwc.traceEnteringMethod("hwc.showProgressDialog");
1472    	try {
1473    		hwc.getDataFromContainer("showprogressdialog",  "&message=" + message);
1474    	} finally {
1475    		hwc.traceLeavingMethod("hwc.showProgressDialog");
1476    	}
1477    };
1478    
1479    /**
1480     * This function hides the progress dialog displaying the  spinner.  This function should be used to hide
1481     * the progress dialog after a call to {@link hwc.showProgressDialog}.  If this function is called while there
1482     * is no progress dialog, then nothing will happen.
1483     * @memberOf hwc
1484     * @public
1485     * @example
1486     * var showProgress = function()
1487     * {
1488     *    hwc.showProgressDialog( "a message" );
1489     *    setTimeout( hideProgress, 10000 );
1490     * }
1491     * 
1492     * var hideProgress = function()
1493     * {
1494     *    hwc.hideProgressDialog();
1495     * }
1496     */
1497    hwc.hideProgressDialog = function() {
1498    	hwc.traceEnteringMethod("hwc.hideProgressDialog");
1499    	try {
1500    		hwc.getDataFromContainer("hideprogressdialog");
1501    	} finally {
1502    		hwc.traceLeavingMethod("hwc.hideProgressDialog");
1503    	}
1504    };
1505    
1506    
1507    /**
1508     * Displays an alert dialog to the user.  This function blocks until it receives a response from the user.
1509     *
1510     * @param {string} message The message to display
1511     * @param {string} [title] The title doesn't actually get displayed.
1512     * @memberOf hwc
1513     * @public
1514     * @example
1515     * hwc.showAlertDialog( "This is a fancy alert dialog", "With a Title" );
1516     */
1517    hwc.showAlertDialog = function(message, title) {
1518    	if(hwc.isIOS()){
1519            // For ios client, creating an IFRAME element for the alert message, so as to hide the
1520            // title bar in the alert box
1521    	    var iframe = document.createElement("IFRAME");
1522    	    iframe.setAttribute("src", 'data:text/plain');
1523    	    document.documentElement.appendChild(iframe);
1524    	    window.frames[window.frames.length-1].alert(message);
1525    	    iframe.parentNode.removeChild(iframe);
1526    	}
1527        else{
1528    		alert(message);
1529    	}
1530    };
1531    
1532    /**
1533     * Shows a confirm dialog to the user.  This function blocks until it receives a response from the user.
1534     *
1535     * @param {string} message The message to display in the dialog.
1536     * @param {string} [title] The title doesn't actualy get displayed.
1537     *
1538     * @return {boolean} The user's choice from the confirm dialog.
1539     * @memberOf hwc
1540     * @public
1541     * @example
1542     * var userConfirm = hwc.showConfirmDialog( "Are you sure you want to see an alert message?", "Confirm Alert" );
1543     * if( userConfirm )
1544     * {
1545     *    alert( "This is what you wanted." );
1546     * }
1547     */
1548    hwc.showConfirmDialog = function(message, title) {
1549        return confirm(message);
1550    };
1551    
1552    /**
1553     * This function closes the hybrid app.
1554     * @memberOf hwc
1555     * @public
1556     * @example
1557     * hwc.close();
1558     */
1559    hwc.close = function() {
1560        workflowMessage = "";
1561        hwc.supUserName = "";
1562    	hwc.traceEnteringMethod("hwc.close");
1563    	try {
1564    		if (hwc.isWindowsMobile()) {
1565    			if(typeof(hwc.setWindowBlankScreen) === 'function')
1566    			{
1567    				 hwc.setWindowBlankScreen();
1568    			}
1569    			  
1570    			  hwc.getDataFromContainer("close");
1571    		}
1572    		else if (hwc.isIOS()) {
1573    			  hwc.getDataFromContainer("close");
1574    		}
1575    		else if (hwc.isAndroid()) {
1576    			hwc.log("Closing Hybrid App" , "INFO");
1577    			_HWC.close();
1578    		}         
1579    		else {
1580    			window.close();
1581    		}
1582    		
1583    		status = hwc.STATUS.CLOSED; 
1584    	} finally {
1585    		hwc.traceLeavingMethod("hwc.close");
1586    	}
1587    };
1588    
1589    /**
1590     * This function checks if the hybrid app has been closed.
1591     * @return {boolean} true if hybrid app is closed, otherwise false.
1592     * @memberOf hwc
1593     * @public
1594     * @example 
1595     * hwc.isClosed();
1596     */
1597    hwc.isClosed = function() {
1598        return status === hwc.STATUS.CLOSED;
1599    };
1600    
1601    })(hwc, window);
1602     
1603    /**
1604     * A callback function invoked when {@link hwc.log} is invoked with true for the notifyUser parameter.
1605     * This callback should notify the user of the log message in an appropriate manner.
1606     *
1607     * @name anonymous.alertDialogCallbackFunction
1608     *
1609     * @param {string} message The message that the user should be notified of.
1610     *
1611     * @function
1612     */
1613     
1614    /**
1615     * A callback function invoked if there is an error.
1616     *
1617     * @name anonymous.errorCallbackFunction
1618     *
1619     * @param {string} errorMessage The message describing the error.
1620     *
1621     * @function
1622     */
1623     
1624    /**
1625     * A generic callback function that takes no parameters.  Used to execute code when a certain event occurs.
1626     *
1627     * @name anonymous.genericCallbackFunction
1628     *
1629     * @function
1630     */