// Generated by Construct 2, the HTML5 game and app creator :: http://www.scirra.com
//////////////////////////////////////
// COCOONJS.JS                      //
//////////////////////////////////////

(function()
{
	// There should not be a CocoonJS object when this code is executed.
	// if (typeof window.CocoonJS !== 'undefined') throw("This is strange, a CocoonJS object already exists when trying to create it.");

    /**
    * The basic object for all the CocoonJS related specific APIs === extensions.
    * @namespace
    */
    CocoonJS = window.CocoonJS ? window.CocoonJS : {};

	CocoonJS.nativeExtensionObjectAvailable = typeof window.ext !== 'undefined';

	/**
	* This type represents a 2D size structure with horizontal and vertical values.
	* @namespace
	*/
	CocoonJS.Size = {
		/**
		* The horizontal size value.
		*/
		width : 0,

		/**
		* The vertical size value.
		*/
		height : 0
	};

	/**
	* This utility function allows to create an object oriented like hierarchy between two functions using their prototypes.
	* This function adds a "superclass" and a "__super" attributes to the subclass and it's functions to reference the super class.
	* @param {function} subc The subclass function.
	* @param {function} superc The superclass function.
	*/
	CocoonJS.extend = function(subc, superc) {
	    var subcp = subc.prototype;

	    // Class pattern.
	    var CocoonJSExtendHierarchyChainClass = function() {};
	    CocoonJSExtendHierarchyChainClass.prototype = superc.prototype;

	    subc.prototype = new CocoonJSExtendHierarchyChainClass();       // chain prototypes.
	    subc.superclass = superc.prototype;
	    subc.prototype.constructor = subc;

	    // Reset constructor. See Object Oriented Javascript for an in-depth explanation of this.
	    if (superc.prototype.constructor === Object.prototype.constructor) {
	        superc.prototype.constructor = superc;
	    }

	    // Check all the elements in the subclass prototype and add them to the chain object's prototype.
	    for (var method in subcp) {
	        if (subcp.hasOwnProperty(method)) {
	            subc.prototype[method] = subcp[method];

	            // // tenemos en super un metodo con igual nombre.
	            // if ( superc.prototype[method]) 
	            // {
	            //     subc.prototype[method]= (function(fn, fnsuper) 
	            //     {
	            //         return function() 
	            //         {
	            //             var prevMethod= this.__super;

	            //             this.__super= fnsuper;

	            //             var retValue= fn.apply(
	            //                     this,
	            //                     Array.prototype.slice.call(arguments) );

	            //             this.__super= prevMethod;

	            //             return retValue;
	            //         };
	            //     })(subc.prototype[method], superc.prototype[method]);
	            // }
	        }
	    }
	}

	/**
	* IMPORTANT: This function should only be used by Ludei.
	* This function allows a call to the native extension object function reusing the same arguments object.
	* Why is interesting to use this function instead of calling the native object's function directly?
	* As the CocoonJS object functions expicitly receive parameters, if they are not present and the native call is direcly mapped,
	* undefined arguments are passed to the native side. Some native functions do not check the parameters validation
	* correctly (just check the number of parameters passed).
	* Another solution instead of using this function call is to correctly check if the parameters are valid (not undefined) to make the
	* call, but it takes more work than using this approach.
	* @static
	* @param {string} nativeExtensionObjectName The name of the native extension object name. The object that is a member of the 'ext' object.
	* @param {string} nativeFunctionName The name of the function to be called inside the native extension object.
	* @param {object} arguments The arguments object of the CocoonJS extension object function. It contains all the arguments passed to the CocoonJS extension object function and these are the ones that will be passed to the native call too.
	* @param {boolean} [async] A flag to indicate if the makeCall (false or undefined) or the makeCallAsync function should be used to perform the native call.
	* @returns Whatever the native function call returns.
	*/
	CocoonJS.makeNativeExtensionObjectFunctionCall = function(nativeExtensionObjectName, nativeFunctionName, args, async) {
		if (CocoonJS.nativeExtensionObjectAvailable) {
			var argumentsArray = Array.prototype.slice.call(args);
			argumentsArray.unshift(nativeFunctionName);
			var nativeExtensionObject = ext[nativeExtensionObjectName];
			var makeCallFunction = async ? nativeExtensionObject.makeCallAsync : nativeExtensionObject.makeCall;
			var ret = makeCallFunction.apply(nativeExtensionObject, argumentsArray);
			var finalRet = ret;
			if (typeof ret === "string") {
				try	{
					finalRet = JSON.parse(ret);
				}
				catch(error) {
				}
			}
			return finalRet;
		}
	};

	/**
	* Returns an object retrieved from a path specified by a dot specified text path starting from a given base object.
	* It could be useful to find the reference of an object from a defined base object. For example the base object could be window and the
	* path could be "CocoonJS.App" or "document.body".
	* @param {Object} baseObject The object to start from to find the object using the given text path.
	* @param {string} objectPath The path in the form of a text using the dot notation. i.e. "document.body"
	* For example:
	* var body = getObjectFromPath(window, "document.body");
	*/
	CocoonJS.getObjectFromPath = function(baseObject, objectPath) {
    	var parts = objectPath.split('.');
    	var obj = baseObject;
        for (var i = 0, len = parts.length; i < len; ++i) 
        {
            obj[parts[i]] = obj[parts[i]] || undefined;
    		obj = obj[parts[i]];
    	}
    	return obj;
 	};

 	/**
 	* Returns the key for a value in a dictionary. It looks for an specific value inside a dictionary and returns the corresponding key.
 	* @param {Object} dictionary The dictionary to look for the value in and get the corresponding key.
 	* @param {Object} value The value to look for inside the dictionary and return it's corresponding key.
 	* @return The key that corresponds to the given value it is has been found or null.
 	*/
 	CocoonJS.getKeyForValueInDictionary = function(dictionary, value) {
        var finalKey = null;
        for (var key in dictionary) {
            if (dictionary[key] === value)            {
                finalKey = key;
                break;
            }
        }
        return finalKey;
 	}

 	/**
 	* Finds a string inside a given array of strings by looking for a given substring. It can also
 	* specify if the search must be performed taking care or not of the case sensitivity.
 	* @param {Array} stringArray The array of strings in which to to look for the string.
 	* @param {string} subString The substring to look for inside all the strings of the array.
 	* @param {boolean} caseSensitive A flag to indicate if the search must be performed taking case of the 
 	* case sensitiveness (true) or not (false).
 	* @return {string} The string that has been found or null if the substring is not inside any of the string of the array.
 	*/
 	CocoonJS.findStringInStringArrayThatIsIndexOf = function(stringArray, subString, caseSensitive) {
 		var foundString = null;
 		subString = caseSensitive ? subString : subString.toUpperCase();
 		for (var i = 0; foundString == null && i < stringArray.length; i++)	{
 			foundString = caseSensitive ? stringArray[i] : stringArray[i].toUpperCase();
 			foundString = foundString.indexOf(subString) >= 0 ? stringArray[i] : null; 
 		}
 		return foundString;
 	};

	/**
	* A class that represents objects to handle events. Event handlers have always the same structure:
	* Mainly they provide the addEventListener and removeEventListener functions.
	* Both functions receive a callback function that will be added or removed. All the added callback
	* functions will be called when the event takes place.
	* Additionally they also allow the addEventListenerOnce and notifyEventListeners functions.
	* @constructor
	* @param {string} nativeExtensionObjectName The name of the native extension object (inside the ext object) to be used.
	* @param {string} cocoonJSExtensionObjectName The name of the sugarized extension object.
	* @param {string} nativeEventName The name of the native event inside the ext object.
	* @param {number} [chainFunction] An optional function used to preprocess the listener callbacks. This function, if provided,
	* will be called before any of the other listeners.
	*/
	CocoonJS.EventHandler = function(nativeExtensionObjectName, cocoonJSExtensionObjectName, nativeEventName, chainFunction) {
		this.listeners = [];
		this.listenersOnce = [];
		this.chainFunction = chainFunction;

		/**
		* Adds a callback function so it can be called when the event takes place.
		* @param {function} listener The callback function to be added to the event handler object. See the referenced Listener function documentation for more detail in each event handler object's documentation.
		*/
		this.addEventListener = function(listener) {
			if (chainFunction) {
				var f = function() {
					chainFunction.call(this, arguments.callee.sourceListener, Array.prototype.slice.call(arguments)); 
				};
				listener.CocoonJSEventHandlerChainFunction = f;
				f.sourceListener = listener;
				listener = f;
			}

			var cocoonJSExtensionObject = CocoonJS.getObjectFromPath(CocoonJS, cocoonJSExtensionObjectName);
            if (cocoonJSExtensionObject && cocoonJSExtensionObject.nativeExtensionObjectAvailable) {
                ext[nativeExtensionObjectName].addEventListener(nativeEventName, listener);
            }
            else {
                var indexOfListener = this.listeners.indexOf(listener);
                if (indexOfListener < 0) {
                	this.listeners.push(listener);
                }
            }
		};

        this.addEventListenerOnce = function(listener)
		{
			if (chainFunction) {
				var f = function() { chainFunction(arguments.callee.sourceListener,Array.prototype.slice.call(arguments)); };
				f.sourceListener = listener;
				listener = f;
			}

			var cocoonJSExtensionObject = CocoonJS.getObjectFromPath(CocoonJS, cocoonJSExtensionObjectName);
            if (cocoonJSExtensionObject.nativeExtensionObjectAvailable) {
                ext[nativeExtensionObjectName].addEventListenerOnce(nativeEventName, listener);
            }
            else
            {
                var indexOfListener = this.listeners.indexOf(listener);
                if (indexOfListener < 0)
                {
                	this.listenersOnce.push(listener);
                }
            }
		};

        /**
         * Removes a callback function that was added to the event handler so it won't be called when the event takes place.
         * @param {function} listener The callback function to be removed from the event handler object. See the referenced Listener function documentation for more detail in each event handler object's documentation.
         */
        this.removeEventListener = function (listener) {

        	if (chainFunction) {
        		listener = listener.CocoonJSEventHandlerChainFunction;
        		delete listener.CocoonJSEventHandlerChainFunction;
        	}

			var cocoonJSExtensionObject = CocoonJS.getObjectFromPath(CocoonJS, cocoonJSExtensionObjectName);
            if (cocoonJSExtensionObject.nativeExtensionObjectAvailable) {
                ext[nativeExtensionObjectName].removeEventListener(nativeEventName, listener);
            }
            else {
                var indexOfListener = this.listeners.indexOf(listener);
                if (indexOfListener >= 0) {
                    this.listeners.splice(indexOfListener, 1);
                }
            }
        };

		this.notifyEventListeners = function() {
			var cocoonJSExtensionObject = CocoonJS.getObjectFromPath(CocoonJS, cocoonJSExtensionObjectName);
            if (cocoonJSExtensionObject && cocoonJSExtensionObject.nativeExtensionObjectAvailable) {
                ext[nativeExtensionObjectName].notifyEventListeners(nativeEventName);
            } else {

                var argumentsArray= Array.prototype.slice.call(arguments);
                var listeners =     Array.prototype.slice.call(this.listeners);
                var listenersOnce = Array.prototype.slice.call(this.listenersOnce);
                var _this = this;
                // Notify listeners after a while ;) === do not block this thread.
                setTimeout(function() {
                    for (var i = 0; i < listeners.length; i++) {
                        listeners[i].apply(_this, argumentsArray);
                    }
                    for (var i = 0; i < listenersOnce.length; i++) {
                        listenersOnce[i].apply(_this, argumentsArray);
                    }
                }, 0);

                _this.listenersOnce= [];
            }
		};
		return this;
	};

	/**
	* A simple timer class. Update it every loop iteration and get values from accumulated time to elapsed time in seconds or milliseconds.
	*/
	CocoonJS.Timer = function() {
		this.reset();
		return this;
	};

	CocoonJS.Timer.prototype = {
		currentTimeInMillis : 0,
		lastTimeInMillis : 0,
		elapsedTimeInMillis : 0,
		elapsedTimeInSeconds : 0,
		accumTimeInMillis : 0,

		/**
		Resets the timer to 0.
		*/
		reset : function() {
			this.currentTimeInMillis = this.lastTimeInMillis = new Date().getTime();
			this.accumTimeInMillis = this.elapsedTimeInMillis = this.elapsedTimeInSeconds = 0;
		},

		/**
		Updates the timer calculating the elapsed time between update calls.
		*/
		update : function() {
			this.currentTimeInMillis = new Date().getTime();
			this.elapsedTimeInMillis = this.currentTimeInMillis - this.lastTimeInMillis;
			this.elapsedTimeInSeconds = this.elapsedTimeInMillis / 1000.0;
			this.lastTimeInMillis = this.currentTimeInMillis;
			this.accumTimeInMillis += this.elapsedTimeInMillis;
		}
	};

	// CocoonJS.FindAllNativeBindingsInCocoonJSExtensionObject = function(cocoonJSExtensionObject, nativeFunctionBindingCallback, nativeEventBindingCallback)
	// {
	// 	for (var cocoonJSExtensionObjectAttributeName in cocoonJSExtensionObject)
	// 	{
	// 		var cocoonJSExtensionObjectAttribute = cocoonJSExtensionObject[cocoonJSExtensionObjectAttributeName];

	// 		// Function
	// 		if (typeof cocoonJSExtensionObjectAttribute === 'function' && typeof cocoonJSExtensionObjectAttribute.nativeFunctionName !== 'undefined')
	// 		{
	// 			var nativeFunctionName = cocoonJSExtensionObjectAttribute.nativeFunctionName;
	// 			nativeFunctionBindingCallback(cocoonJSExtensionObjectAttributeName, nativeFunctionName);
	// 		}
	// 		// Event object
	// 		else if (typeof cocoonJSExtensionObjectAttribute === 'object' && cocoonJSExtensionObjectAttribute !== null && typeof cocoonJSExtensionObjectAttribute.nativeEventName !== 'undefined')
	// 		{
	// 			var nativeEventName = cocoonJSExtensionObjectAttribute.nativeEventName;
	// 			nativeEventBindingCallback(cocoonJSExtensionObjectAttributeName, nativeEventName);
	// 		}
	// 	}
	// }

	/**
	This function looks for a CocoonJS extension object that is bound to the given native ext object name.
	@returns The CocoonJS extension object that corresponds to the give native extension object name or null if it cannot be found.
	*/
	// CocoonJS.GetCocoonJSExtensionObjectForNativeExtensionObjectName = function(nativeExtensionObjectName)
	// {
	// 	var cocoonJSExtensionObject = null;
	// 	// Look in the CocoonJS object and for every object that is a CocoonJS.Extension check if it's nativeExtensionObjectName matches to the one passed as argument. If so, create an object that will represent it's documentation for the native ext object.
	// 	for (var cocoonJSAttributeName in CocoonJS)
	// 	{
	// 		var cocoonJSAttribute = CocoonJS[cocoonJSAttributeName];
	// 		if (typeof cocoonJSAttribute === 'object' && cocoonJSAttribute instanceof CocoonJS.Extension && cocoonJSAttribute.nativeExtensionObjectName === nativeExtensionObjectName)
	// 		{
	// 			// We have found the CocoonJS object that represents the native ext extension object name. 
	// 			cocoonJSExtensionObject = cocoonJSAttribute;
	// 			break;
	// 		}
	// 	}
	// 	return cocoonJSExtensionObject;
	// };

	/**
	This function adds functions to a CocoonJS extension object in order to bind them to the native makeCall function calls of the ext object.

	@param extensionObject The reference to the CocoonJS extension object where to add the new functions bound to the ext object makeCall functions calls.

	@param nativeFunctionsConfiguration An array of objects with the following structure:

		{ nativeFunctionName : "" [, functionName : "", isAsync : true/false] }

		- nativeFunctionName: Specifies the name of the function inside the ext object makeCall function call that will be bound.
		- functionName: An optional attribute that allows to specify the name of the function to be added to the CocoonJS extension object. If is not present, the name of the function will be the same
		as the nativeFunctionName.
		- isAsync: An optional attribute that allows to specify if the call should be performed using makeCall (false or missing) or makeCallAsync (true).
		- alternativeFunction: An optional attribute that allows to specify an alternative function that will be called internally when this function is called. This attribute
		allows for adding new functionalities like for example adding methods 

	@returns The CocoonJS extension object.
	*/
	// CocoonJS.AddNativeFunctionBindingsToExtensionObject = function(extensionObject, nativeFunctionsConfiguration)
	// {
	// 	if (typeof extensionObject === 'undefined' || extensionObject === null) throw("The passed extension object be a valid object.");
	// 	if (typeof nativeFunctionsConfiguration === 'undefined' || nativeFunctionsConfiguration === null) throw("The passed native functions configuration array must be a valid object.");

	// 	for (var i = 0; i < nativeFunctionsConfiguration.length; i++)
	// 	{
	// 		if (typeof nativeFunctionsConfiguration[i].nativeFunctionName === 'undefined') throw("The 'nativeFunctionName' attribute in the native function configuration object at index '" + i + "' in the native function configuration array cannot be undefined.");
	// 		var nativeFunctionName = nativeFunctionsConfiguration[i].nativeFunctionName;
	// 		var functionName = typeof nativeFunctionsConfiguration[i].functionName !== 'undefined' ? nativeFunctionsConfiguration[i].functionName : nativeFunctionName;
	// 		var makeCallFunction = null;
	// 		makeCallFunction = typeof nativeFunctionsConfiguration[i].isAsync !== 'undefined' && nativeFunctionsConfiguration[i].isAsync ? extensionObject.nativeExtensionObject.makeCallAsync : extensionObject.nativeExtensionObject.makeCall;
	// 		// Add the new function to the CocoonJS extension object
	// 		extensionObject[functionName] = function()
	// 		{
	// 			// Convert the arguments object to an array
	// 			var arguments = Array.prototype.slice.call(arguments);
	// 			// Add the native function name as the first parameter
	// 			arguments.unshift(nativeFunctionName);
	// 			// Make the native ext object call
	// 			var result = makeCallFunction.apply(extensionObject.nativeExtensionObject, arguments);
	// 			return result;
	// 		}
	// 		// Add a property to the newly added function to store the name of the original function.
	// 		extensionObject[functionName].nativeFunctionName = nativeFunctionName;
	// 	}
	// 	return extensionObject;
	// };

	/**
	This function adds objects to a CocoonJS extension object to allow event listener handling (add and remove) bound to the native ext object event listener handling.

	@param extensionObject The reference to the CocoonJS extension object where to add the new objects bound to the ext object event listener handling.

	@param nativeEventsConfiguration An array of objects with the following structure:

		{ nativeEventName : "" [, eventObjectName : ""] }

		- nativeEventName: Specifies the event in the native ext object to be bound.
		- eventObjectName: An optional attribute that allows to specify the name of the object to be added to the CocoonJS extension object. If is not present, the name of the function will be the same
		as the nativeEventName.
		- alternativeAddEventListenerFunction:
		- alternativeRemoveEventListenerFunction:

	@returns The CocoonJS extension object.
	*/
	// CocoonJS.AddNativeEventBindingsToExtensionObject = function(extensionObject, nativeEventsConfiguration)
	// {
	// 	if (typeof extensionObject === 'undefined' || extensionObject === null) throw("The passed extension object be a valid object.");
	// 	if (typeof nativeEventsConfiguration === 'undefined' || nativeEventsConfiguration === null) throw("The passed native events configuration array must be a valid object.");

	// 	for (var i = 0; i < nativeEventsConfiguration.length; i++)
	// 	{
	// 		if (typeof nativeEventsConfiguration[i].nativeEventName === 'undefined') throw("The 'nativeEventName' attribute in the native event configuration object at index '" + i + "' in the native event configuration array cannot be undefined.");
	// 		var nativeEventName = nativeEventsConfiguration[i].nativeEventName;
	// 		var eventObjectName = typeof nativeEventsConfiguration[i].eventObjectName !== 'undefined' ? nativeEventsConfiguration[i].eventObjectName : nativeEventName;
	// 		// Anonymous function call so each variable in the loop is used in the event listener handling function bindings.
	// 		(function(nativeEventName, eventObjectName)
	// 		{
	//     		extensionObject[eventObjectName] =
	//     		{
	//     			// Store the native event name
	//     			nativeEventName : nativeEventName,
	//     			// Create the event listener management functions bound to the native counterparts
	//     			addEventListener : function(callback)
	// 	    		{
	// 	    			extensionObject.nativeExtensionObject.addEventListener(nativeEventName, callback);
	//     			},
	//     			removeEventListener : function(callback)
	//     			{
	// 	    			extensionObject.nativeExtensionObject.removeEventListener(nativeEventName, callback);
	//     			}
	//     			// ,
	//     			// removeAllEventListeners : function()
	//     			// {

	//     			// }
	//     		};
	// 		})(nativeEventName, eventObjectName);
	// 	}
	// 	return extensionObject;
	// };

	/**
	The function object constructor function all the CocoonJS extensions can use to instantiate the CocoonJS extension object and add all the functionality needed bound to the native ext object.

	@param nativeExtensionObject The reference to the ext object extension object.

	@param nativeFunctionsConfiguration See CocoonJS.AddNativeFunctionBindingsToExtensionObject function's documentation for more details.

	@param nativeEventsConfiguration See CocoonJS.AddNativeEventBindingsToExtensionObject function's documentation for more details.

	@returns The new CocoonJS extension object.
	*/
	// CocoonJS.Extension = function(nativeExtensionObjectName, nativeFunctionsConfiguration, nativeEventsConfiguration)
	// {
	// 	if (typeof nativeExtensionObjectName === 'undefined' || nativeExtensionObjectName === null) throw("The native extension object name cannot be null");

	// 	if (window.ext[nativeExtensionObjectName] === 'undefined') throw("The given native extension object name '" + nativeExtensionObjectName + "' is incorrect or the native extension object is undefined.");

	// 	var nativeExtensionObject = window.ext[nativeExtensionObjectName];

	// 	// Store a reference to the native extension object and to it's name
	// 	this.nativeExtensionObject = nativeExtensionObject;
	// 	this.nativeExtensionObjectName = nativeExtensionObjectName;

	// 	// If native function configuration is passed, use it to add some functions to the new extension object.
	// 	if (typeof nativeFunctionsConfiguration !== 'undefined')
	// 	{
	// 		CocoonJS.AddNativeFunctionBindingsToExtensionObject(this, nativeFunctionsConfiguration);
	// 	}

	// 	// If native event configuration is passed, use it to add some event objects to the new extension object.
	// 	if (typeof nativeEventsConfiguration !== 'undefined')
	// 	{
	// 		CocoonJS.AddNativeEventBindingsToExtensionObject(this, nativeEventsConfiguration);
	// 	}

	// 	return this;
	// };   

})();

//////////////////////////////////////
// COCOONJS_APP.JS                  //
//////////////////////////////////////

(function () {
    // The CocoonJS must exist before creating the extension.
    if (typeof window.CocoonJS === 'undefined' || window.CocoonJS === null) throw("The CocoonJS object must exist and be valid before creating any extension object.");

    /**
     * This namespace represents all the basic functionalities available in the CocoonJS extension API.
     * @namespace
     */
    CocoonJS.App = CocoonJS.App ? CocoonJS.App : {};

    CocoonJS.App.nativeExtensionObjectAvailable = CocoonJS.nativeExtensionObjectAvailable && typeof window.ext.IDTK_APP !== 'undefined';

    /**
     * The predefined possible layouts for the FPS overlay.
     * @namespace
     */
    CocoonJS.App.FPSLayout = {
        TOP_LEFT:'top-left',
        TOP_RIGHT:'top-right',
        BOTTOM_LEFT:'bottom-left',
        BOTTOM_RIGHT:'bottom-right'
    };

    /**
     * Contains all the possible values to specify the input keyboard type to be used when introducing text.
     * @namespace
     */
    CocoonJS.App.KeyboardType = {
        /**
         * Represents a generic text input keyboard.
         */
        TEXT:"text",

        /**
         * Represents a number like input keyboard.
         */
        NUMBER:"num",

        /**
         * Represents a phone like input keyboard.
         */
        PHONE:"phone",

        /**
         * Represents an email like input keyboard.
         */
        EMAIL:"email",

        /**
         * Represents an URL like input keyboard.
         */
        URL:"url"
    };

    /**
     * The storage types to be used with file system related operations.
     * @namespace
     */
    CocoonJS.App.StorageType = {
        /**
         * Represents the application storage. The application storage is the place where all the resources that come with the application are stored.
         */
        APP_STORAGE:"APP_STORAGE",

        /**
         * Represents the internal storage. The internal storage is a different storage space that the application storage and only the data that the application has stored
         * in it will be in this storage. It is internal to the platform/device.
         */
        INTERNAL_STORAGE:"INTERNAL_STORAGE",

        /**
         * Represents an external storage. The external storage is similar to the internal storage in the sense that it only contains information that the application has written
         * in it but it represents an external storage device like a SD-CARD. If there is no exrernal storage, it will represent the same as the internal storage.
         */
        EXTERNAL_STORAGE:"EXTERNAL_STORAGE",

        /**
         * Represents the temporal storage. Same as the internal and external storage spaces in the sense that it only contains information that the application has written
         * in it but the main difference is that the information in this storage may dissapear without notice.
         */
        TEMPORARY_STORAGE:"TEMPORARY_STORAGE"
    };

    /**
     * The capture types to capture screenshots using CocoonJS native capabilities.
     * @namespace
     */
    CocoonJS.App.CaptureType = {
        /**
         Captures everything, both the CocoonJS GL hardware accelerated surface and the system views (like the WebView).
         */
        EVERYTHING:0,

        /**
         * Captures just the CocoonJS GL hardware accelerated surface.
         */
        JUST_COCOONJS_GL_SURFACE:1,

        /**
         * Captures just the sustem views (like the webview)
         */
        JUST_SYSTEM_VIEWS:2
    };

    /**
     * Makes a forward call of some javascript code to be executed in a different environment (i.e. from CocoonJS to the WebView and viceversa).
     * It waits until the code is executed and the result of it is returned === synchronous.
     * @function
     * @param {string} javaScriptCode Some JavaScript code in a string to be forwarded and executed in a different JavaScript environment (i.e. from CocoonJS to the WebView and viceversa).
     * @return {string} The result of the execution of the passed JavaScript code in the different JavaScript environment.
     */
    CocoonJS.App.forward = function (javaScriptCode) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "forward", arguments);
        }
        else if (!navigator.isCocoonJS) {
            if (window.name == 'CocoonJS_App_ForCocoonJS_WebViewIFrame') {
                return window.parent.eval(javaScriptCode);
            }
            else {
                //return window.parent.frames['CocoonJS_App_ForCocoonJS_WebViewIFrame'].window.eval(javaScriptCode);
                return window.frames['CocoonJS_App_ForCocoonJS_WebViewIFrame'].window.eval(javaScriptCode);
            }
        }
    };

    /**
     * Makes a forward call of some javascript code to be executed in a different environment (i.e. from CocoonJS to the WebView and viceversa).
     * It is asyncrhonous so it does not wait until the code is executed and the result of it is returned. Instead, it calls a callback function when the execution has finished to pass the result.
     * @function
     * @param {string} javaScriptCode Some JavaScript code in a string to be forwarded and executed in a different JavaScript environment (i.e. from CocoonJS to the WebView and viceversa).
     * @param {function} [returnCallback] A function callback that will be called when the passed JavaScript code is executed in a different thread to pass the result of the execution in the different JavaScript environment.
     */
    CocoonJS.App.forwardAsync = function (javaScriptCode, returnCallback) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            if (typeof returnCallback !== 'undefined') {
                return ext.IDTK_APP.makeCallAsync("forward", javaScriptCode, returnCallback);
            }
            else {
                return ext.IDTK_APP.makeCallAsync("forward", javaScriptCode);
            }
        }
        else if (!navigator.isCocoonJS) {
            if (window.name == 'CocoonJS_App_ForCocoonJS_WebViewIFrame') {
                return window.parent.eval(javaScriptCode);
            }
            else {
                return window.parent.frames['CocoonJS_App_ForCocoonJS_WebViewIFrame'].window.eval(javaScriptCode);
                // window.frames['CocoonJS_App_ForCocoonJS_WebViewIFrame'].window.eval(javaScriptCode);
            }
        }
    };

    /**
     * Pops up a text dialog so the user can introduce some text and the application can get it back. It is the first approach CocoonJS has taken to be able to introduce
     * text input in a easy way. The dialog execution events are passed to the application through the {@link CocoonJS.App.onTextDialogFinished} and the {@link CocoonJS.App.onTextDialogCancelled} event objects.
     * @function
     * @param {string} [title] Default value is "". The title to be displayed in the dialog.
     * @param {string} [message] Default value is "". The message to be displayed in the dialog, next to the text input field.
     * @param {string} [text] Default value is "". The initial text to be introduced in the text input field.
     * @param {CocoonJS.App.KeyboardType} [keyboardType] Default value is {@link CocoonJS.App.KeyboardType.TEXT}. The keyboard type to be used when the text has to be introduced.
     * @param {string} [cancelButtonText] Default value is "". The text to be displayed in the cancel button of the dialog.
     * @param {string} [okButtonText] Default value is "". The text to be displayed in the ok button of the dialog.
     * @see CocoonJS.App.onTextDialogFinished
     * @see CocoonJS.App.onTextDialogCancelled
     */
    CocoonJS.App.showTextDialog = function (title, message, text, keyboardType, cancelButtonText, okButtonText) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "showTextDialog", arguments, true);
        }
        else if (!navigator.isCocoonJS) {
            if (!message) {
                message = "";
            }
            if (!text) {
                text = "";
            }
            var result = prompt(message, text);
            var eventObject = result ? CocoonJS.App.onTextDialogFinished : CocoonJS.App.onTextDialogCancelled;
            eventObject.notifyEventListeners(result);
        }
    };

    /**
     * Pops up a message dialog so the user can decide between a yes or no like confirmation. The message box execution events are passed to the application through the {@link CocoonJS.App.onMessageBoxConfirmed} and the {@link CocoonJS.App.onMessageBoxDenied} event objects.
     * @function
     * @param {string} [title] Default value is "". The title to be displayed in the dialog.
     * @param {string} [message] Default value is "". The message to be displayed in the dialog, next to the text input field.
     * @param {string} [confirmButtonText] Default value is "Yes". The text to be displayed for the confirm button.
     * @param {string} [denyButtonText] Default value is "No". The text to be displayed for the deny button.
     * @see CocoonJS.App.onMessageBoxConfirmed
     * @see CocoonJS.App.onMessageBoxDenied
     */
    CocoonJS.App.showMessageBox = function (title, message, confirmButtonText, denyButtonText) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "showMessageBox", arguments, true);
        }
        else if (!navigator.isCocoonJS) {
            if (!message) {
                message = "";
            }
            var result = confirm(message);
            var eventObject = result ? CocoonJS.App.onMessageBoxConfirmed : CocoonJS.App.onMessageBoxDenied;
            eventObject.notifyEventListeners();
        }
    };

    /**
     * It allows to load a new JavaScript/HTML5 resource that can be loaded either locally (inside the platform/device storage) or using a remote URL.
     * @function
     * @param {string} path A path to a resource stored in the platform or in a URL to a remote resource.
     * @param {CocoonJS.App.StorageType} [storageType] If the path argument represents a locally stored resource, the developer can specify the storage where it is stored. If no value is passes, the {@link CocoonJS.App.StorageType.APP_STORAGE} value is used by default.
     */
    CocoonJS.App.load = function (path, storageType) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "loadPath", arguments);
        }
        else if (!navigator.isCocoonJS) {
            var xhr = new XMLHttpRequest();

            xhr.onreadystatechange = function (event) {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        // TODO: As window load event is not being called (WHY???), I have decided to call the listeners directly
                        // var callback= function(event){
                        //     window.removeEventListener("load", callback);
                        var jsCode;
                        // If there is no webview, it means we are in the webview, so notify the CocoonJS environment
                        if (!CocoonJS.App.EmulatedWebViewIFrame) {
                            jsCode = "window.CocoonJS && window.CocoonJS.App.onLoadInTheWebViewSucceed.notifyEventListeners('" + path + "');";
                        }
                        // If there is a webview, it means we are in CocoonJS, so notify the webview environment
                        else {
                            jsCode = "window.CocoonJS && window.CocoonJS.App.onLoadInCocoonJSSucceed.notifyEventListeners('" + path + "');";
                        }
                        CocoonJS.App.forwardAsync(jsCode);
                        // };
                        // window.addEventListener("load", callback);
                        window.location.href = path;
                    }
                    else if (xhr.status === 404) {
                        this.onreadystatechange = null;
                        var jsCode;
                        // If there is no webview, it means we are in the webview, so notify the CocoonJS environment
                        if (!CocoonJS.App.EmulatedWebViewIFrame) {
                            jsCode = "CocoonJS && CocoonJS.App.onLoadInTheWebViewFailed.notifyEventListeners('" + path + "');";
                        }
                        // If there is a webview, it means we are in CocoonJS, so notify the webview environment
                        else {
                            jsCode = "CocoonJS && CocoonJS.App.onLoadInCocoonJSFailed.notifyEventListeners('" + path + "');";
                        }
                        CocoonJS.App.forwardAsync(jsCode);
                    }
                }
            };
            xhr.open("GET", path, true);
            xhr.send();
        }
    };

    /**
     * Reloads the last loaded path in the current context.
     * @function
     */
    CocoonJS.App.reload = function () {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "reload", arguments);
        }
        else if (!navigator.isCocoonJS) {
            if (window.name == 'CocoonJS_App_ForCocoonJS_WebViewIFrame') {
                return window.parent.location.reload();
            }
            else {
                return window.parent.frames['CocoonJS_App_ForCocoonJS_WebViewIFrame'].window.location.reload();
            }
        }
    };

    /**
     * Opens a given URL using a system service that is able to open it. For example, open a HTTP URL using the system WebBrowser.+
     * @function
     * @param {string} url The URL to be opened by a system service.
     */
    CocoonJS.App.openURL = function (url) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "openURL", arguments, true);
        }
        else if (!navigator.isCocoonJS) {
            window.open(url, '_blank');
        }
    }

    /**
     * Forces the app to be finished.
     * @function
     */
    CocoonJS.App.forceToFinish = function () {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "forceToFinish", arguments);
        }
        else if (!navigator.isCocoonJS) {
            window.close();
        }
    }

    /**
     * Enables or disables the auto lock to control if the screen keeps on after an inactivity period.
     * When the auto lock is enabled and the application has no user input for a short period, the system puts the device into a "sleepâ€ state where the screen dims or turns off.
     * When the auto lock is disabled the screen keeps on even when there is no user input for long times.
     * @param enabled A boolean value that controls whether to enable or disable the auto lock.
     */
    CocoonJS.App.setAutoLockEnabled = function (enabled) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "setAutoLockEnabled", arguments);
        }
    }

    /**
     * Creates a canvas element that is automatically resized to the screen size. When the app is being executed
     * inside CocoonJS. This canvas is optimized for rendering so it is higly recommended to use it if it fits
     * your app needs. If your app uses one canvas as the main canvas where all other canvases and images are displayed, Ludei recommends to
     * call this function in order to create this main canvas. A usual 2x performance gain is achieved by doing so
     * depending on the device and the graphics card driver.
     * @function
     * @return {object} The canvas object that should be used as the main canvas and that is resized to the screen resolution.
     */
    CocoonJS.App.createScreenCanvas = function () {
        var screenCanvas;
        if (navigator.isCocoonJS) {
            screenCanvas = document.createElement("screencanvas");
        }
        else if (!navigator.isCocoonJS) {
            screenCanvas = document.createElement("canvas");
            screenCanvas.width = window.innerWidth;
            screenCanvas.height = window.innerHeight;
        }
        return screenCanvas;
    };

    /**
     * Disables the touch events in the CocoonJS environment.
     * @function
     */
    CocoonJS.App.disableTouchInCocoonJS = function () {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            window.ext.IDTK_APP.makeCall("disableTouchLayer", "CocoonJSView");
        }
    };

    /**
     * Enables the touch events in the CocoonJS environment.
     * @function
     */
    CocoonJS.App.enableTouchInCocoonJS = function () {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            window.ext.IDTK_APP.makeCall("enableTouchLayer", "CocoonJSView");
        }
    };

    /**
     * Disables the touch events in the WebView environment.
     * @function
     */
    CocoonJS.App.disableTouchInTheWebView = function () {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            window.ext.IDTK_APP.makeCall("disableTouchLayer", "WebView");
        }
    };

    /**
     * Enables the touch events in the WebView environment.
     * @function
     */
    CocoonJS.App.enableTouchInTheWebView = function () {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            window.ext.IDTK_APP.makeCall("enableTouchLayer", "WebView");
        }
    };

    /**
     * Setups the update interval in seconds (1 second / X frames) to receive the accelerometer updates.
     * It defines the rate at which the devicemotion events are updated.
     * @function
     * @param {number} updateIntervalInSeconds The update interval in seconds to be set.
     */
    CocoonJS.App.setAccelerometerUpdateIntervalInSeconds = function (updateIntervalInSeconds) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return window.ext.IDTK_APP.makeCall("setAccelerometerUpdateIntervalInSeconds", updateIntervalInSeconds);
        }
    };

    /**
     * Returns the update interval in seconds that is currently set for accelerometer related events.
     * @function
     * @return {number} The update interval in seconds that is currently set for accelerometer related events.
     */
    CocoonJS.App.getAccelerometerUpdateIntervalInSeconds = function () {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return window.ext.IDTK_APP.makeCall("getAccelerometerUpdateIntervalInSeconds");
        }
    };

    /**
     * Setups the update interval in seconds (1 second / X frames) to receive the gyroscope updates.
     * It defines the rate at which the devicemotion and deviceorientation events are updated.
     * @function
     * @param {number} updateIntervalInSeconds The update interval in seconds to be set.
     */
    CocoonJS.App.setGyroscopeUpdateIntervalInSeconds = function (updateIntervalInSeconds) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return window.ext.IDTK_APP.makeCall("setGyroscopeUpdateIntervalInSeconds", updateIntervalInSeconds);
        }
    };

    /**
     * Returns the update interval in seconds that is currently set for gyroscope related events.
     * @function
     * @return {number} The update interval in seconds that is currently set for gyroscope related events.
     */
    CocoonJS.App.getGyroscopeUpdateIntervalInSeconds = function () {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            window.ext.IDTK_APP.makeCall("getGyroscopeUpdateIntervalInSeconds");
        }
    };


    /**
     * Setups a origin proxy for a given typeName. What this means is that after calling this function the environment that makes this call will suddenly
     * have a way of creating instances of the given typeName and those instances will act as a transparent proxy to counterpart instances in the destination environment.
     * Manipulating attributes, calling funcitions or handling events will all be performed in the destination environment but the developer will think they will be
     * happening in the origin environment.
     * IMPORTANT NOTE: These proxies only work with types that use attributes and function parameters and return types that are primitive like numbers, strings or arrays.
     * @param {string} typeName The name of the type to be proxified.
     * @param {array} [attributeNames] A list of the names of the attributes to be proxified.
     * @param {array} [functionNames] A list of the names of the functions to be proxified.
     * @param {array} [eventHandlerNames] A list of the names of the event handlers to be proxified (onXXXX like attributes that represent callbacks).
     * A valid typeName and at least one valid array for attribute, function or event handler names is mandatory.
     */
    CocoonJS.App.setupOriginProxyType = function (typeName, attributeNames, functionNames, eventHandlerNames) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            // Control the parameters.
            if (!typeName) throw "The given typeName must be valid.";
            if (!attributeNames && !functionNames && !eventHandlerNames) throw "There is no point on setting up a proxy for no attributes, functions nor eventHandlers.";
            attributeNames = attributeNames ? attributeNames : [];
            functionNames = functionNames ? functionNames : [];
            eventHandlerNames = eventHandlerNames ? eventHandlerNames : [];

            // The parent object will be the window. It could be another object but careful, the destination side should know about this.
            // TODO: Specify the parentObject as a parameter, obtain it's path from the window object and pass it to the destination environment so it knows about it.
            var parentObject = window;

            // Setup the destination side too.
            var jsCode = "CocoonJS.App.setupDestinationProxyType(" + JSON.stringify(typeName) + ", " + JSON.stringify(eventHandlerNames) + ");";
            CocoonJS.App.forward(jsCode);

            var originalType = parentObject[typeName];

            // Constructor. This will be the new proxified type in the origin environment. Instances of this type will be created by the developer without knowing that they are
            // internally calling to their counterparts in the destination environment.
            parentObject[typeName] = function () {
                var _this = this;

                // Each proxy object will have a origin object inside with all the necessary information to be a proxy to the destination.
                this._cocoonjs_proxy_object_data = {};
                // The id is obtained calling to the destination side to create an instance of the type.
                var jsCode = "CocoonJS.App.newDestinationProxyObject(" + JSON.stringify(typeName) + ");";
                this._cocoonjs_proxy_object_data.id = CocoonJS.App.forward(jsCode);
                // The eventHandlers dictionary contains objects of the type { eventHandlerName : string, eventHandler : function } to be able to make the callbacks when the 
                // webview makes the corresponding calls.
                this._cocoonjs_proxy_object_data.eventHandlers = {};
                // Also store the typename inside each instance.
                this._cocoonjs_proxy_object_data.typeName = typeName;
                // A dictionary to store the event handlers
                this._cocoonjs_proxy_object_data.eventListeners = {};

                // TODO: eventHandlers and eventListeners should be in the same list ;)

                // Store all the proxy instances in a list that belongs to the type itself.
                parentObject[typeName]._cocoonjs_proxy_type_data.proxyObjects[this._cocoonjs_proxy_object_data.id] = this;

                // Create a setter and a getter for all the attribute names that have been specified. When the attributes are accessed (set or get) a call to the destination counterpart will be performed.
                for (var i = 0; i < attributeNames.length; i++) {
                    (function (attributeName) {
                        _this.__defineSetter__(attributeName, function (value) {
                            var jsCode = "CocoonJS.App.setDestinationProxyObjectAttribute(" + JSON.stringify(typeName) + ", " + _this._cocoonjs_proxy_object_data.id + ", " + JSON.stringify(attributeName) + ", " + JSON.stringify(value) + ");";
                            return CocoonJS.App.forwardAsync(jsCode);
                        });
                        _this.__defineGetter__(attributeName, function () {
                            var jsCode = "CocoonJS.App.getDestinationProxyObjectAttribute(" + JSON.stringify(typeName) + ", " + _this._cocoonjs_proxy_object_data.id + ", " + JSON.stringify(attributeName) + ");";
                            return CocoonJS.App.forwardAsync(jsCode);
                        });
                    })(attributeNames[i]);
                }

                // Create a function that performs a call to the destination environment counterpart for all the function names that have been specified.
                for (var i = 0; i < functionNames.length; i++) {
                    (function (functionName) {
                        _this[functionName] = function () {
                            // Get the arguments as an array and add the typeName, the proxy id and the functionName before all the other arguments before making the call to the destination counterpart.
                            var argumentsArray = Array.prototype.slice.call(arguments);
                            argumentsArray.unshift(functionName);
                            argumentsArray.unshift(this._cocoonjs_proxy_object_data.id);
                            argumentsArray.unshift(typeName);
                            // Use the array to create the correct function call.
                            var jsCode = "CocoonJS.App.callDestinationProxyObjectFunction(";
                            for (var i = 0; i < argumentsArray.length; i++) {
                                // The second argument (the id) should not be stringified
                                jsCode += (i !== 1 ? JSON.stringify(argumentsArray[i]) : argumentsArray[i]) + (i < argumentsArray.length - 1 ? ", " : "");
                            }
                            jsCode += ");";
                            // TODO: This next call should be synchronous but it seems that some customers are experiencing some crash issues. Making it async solves these crashes.
                            // Another possible solution could be to be able to specify which calls could be async and which sync in the proxification array.
                            var ret = CocoonJS.App.forwardAsync(jsCode);
                            return ret;
                        };
                    })(functionNames[i]);
                }

                // Create a setter and getter for all the event handler names that have been specified. When the event handlers are accessed, store them inside the corresponding position on the eventHandlers
                // array so they can be called when the destination environment makes the corresponding callback call.
                for (var i = 0; i < eventHandlerNames.length; i++) {
                    (function (eventHandlerName) {
                        _this.__defineSetter__(eventHandlerName, function (value) {
                            _this._cocoonjs_proxy_object_data.eventHandlers[eventHandlerName] = value;
                        });
                        _this.__defineGetter__(eventHandlerName, function () {
                            return _this._cocoonjs_proxy_object_data.eventHandlers[eventHandlerName];
                        });
                    })(eventHandlerNames[i]);
                }

                // Setup the add and remove event listeners in the proxy object
                _this.addEventListener = function (eventTypeName, eventCallback) {
                    var addEventCallback = true;
                    // Check for the eventListeners
                    var eventListeners = _this._cocoonjs_proxy_object_data.eventListeners[eventTypeName];
                    if (eventListeners) {
                        // As the eventListeners were already added, check that the same callback has not been added.
                        addEventCallback = eventListeners.indexOf(eventCallback) < 0;
                    }
                    else {
                        // There are no event listeners, so add the one and add the listeners array for the specific event type name
                        eventListeners = [];
                        _this._cocoonjs_proxy_object_data.eventListeners[eventTypeName] = eventListeners;

                        // Forward the call so the other end registers a event listener (only one is needed).
                        var jsCode = "CocoonJS.App.addDestinationProxyObjectEventListener(" + JSON.stringify(_this._cocoonjs_proxy_object_data.typeName) + ", " + _this._cocoonjs_proxy_object_data.id + ", " + JSON.stringify(eventTypeName) + ");";
                        CocoonJS.App.forwardAsync(jsCode);
                    }
                    // Only if the alforithm above specify so, add the eventcallback and notify the destination environment to do the same
                    if (addEventCallback) {
                        eventListeners.push(eventCallback);
                    }
                };

                _this.removeEventListener = function (eventTypeName, eventCallback) {
                    // Check for the eventListeners
                    var eventListeners = _this._cocoonjs_proxy_object_data.eventListeners[eventTypeName];
                    if (eventListeners) {
                        var eventCallbackIndex = eventListeners.indexOf(eventCallback);
                        if (eventCallbackIndex >= 0) {
                            eventListeners.splice(eventCallbackIndex, 1);
                        }
                    }
                };

                // Return the proxy instance.
                return this;
            };

            // The type will contain a proxy data structure to store all the instances that are created so they are available when the destination environment calls back. 
            parentObject[typeName]._cocoonjs_proxy_type_data =
            {
                originalType:originalType,
                proxyObjects:[]
            };

            /**
             * Deletes a proxy instance from both the CocoonJS environment structures and also deleting it's webview environment counterpart.
             * This function should be manually called whenever a proxy instance won't be accessed anymore.
             * @param {object} object The proxy object to be deleted.
             */
            parentObject[typeName]._cocoonjs_proxy_type_data.deleteProxyObject = function (object) {
                var proxyObjectKey = CocoonJS.getKeyForValueInDictionary(this.proxyObjects, object);
                if (proxyObjectKey) {
                    var jsCode = "CocoonJS.App.deleteDestinationProxyObject(" + JSON.stringify(typeName) + ", " + object._cocoonjs_proxy_object_data.id + ");";
                    CocoonJS.App.forwardAsync(jsCode);
                    object._cocoonjs_proxy_object_data = null;
                    delete this.proxyObjects[proxyObjectKey];
                }
            };

            /**
             * Calls a event handler for the given proxy object id and eventHandlerName.
             * @param {number} id The id to be used to look for the proxy object for which to make the call to it's event handler.
             * @param {string} eventHandlerName The name of the handler to be called.
             * NOTE: Events are a complex thing in the HTML specification. This function just performs a call but at least provides a
             * structure to the event passing the target (the proxy object).
             * TODO: The destination should serialize the event object as far as it can so many parameters can be passed to the origin
             * side. Using JSON.stringify in the destination side and parse in origin side maybe? Still must add the target to the event structure though.
             */
            parentObject[typeName]._cocoonjs_proxy_type_data.callProxyObjectEventHandler = function (id, eventHandlerName) {
                var object = this.proxyObjects[id];
                var eventHandler = object._cocoonjs_proxy_object_data.eventHandlers[eventHandlerName];
                if (eventHandler) {
                    eventHandler({ target:object });
                }
            };

            parentObject[typeName]._cocoonjs_proxy_type_data.callProxyObjectEventListeners = function (id, eventTypeName) {
                var object = this.proxyObjects[id];
                var eventListeners = object._cocoonjs_proxy_object_data.eventListeners[eventTypeName].slice();
                for (var i = 0; i < eventListeners.length; i++) {
                    eventListeners[i]({ target:object });
                }
            };
        }
    };

    /**
     * Takes down the proxification of a type and restores it to it's original type. Do not worry if you pass a type name that is not proxified yet. The
     * function will handle it correctly for compativility reasons.
     * @param {string} typeName The name of the type to be deproxified (take down the proxification and restore the type to it's original state)
     */
    CocoonJS.App.takedownOriginProxyType = function (typeName) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            if (parentObject[typeName] && parentObject[typeName]._cocoonjs_proxy_type_data) {
                parentObject[typeName] = parentObject[typeName]._cocoonjs_proxy_type_data.originalType;
            }
        }
    };

    /**
     * Deletes everything related to a proxy object in both environments. Do not worry of you do not pass a proxified object to the
     * function. For compatibility reasons, you can still have calls to this function even when no poxification of a type has been done.
     * @param {object} object The proxified object to be deleted.
     */
    CocoonJS.App.deleteOriginProxyObject = function (object) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            if (object && object._cocoonjs_proxy_object_data) {
                parentObject[object._cocoonjs_proxy_object_data.typeName]._cocoonjs_proxy_type_data.deleteProxyObject(object);
            }
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the destination environment whenever it is needed to work with proxy objects.
     * It calls the origin proxy object when an event handler need to be updated/called from the destination environment.
     * @param {string} typeName The type name of the proxified type.
     * @param {number} id The id of the proxy object.
     * @param {string} eventHandlerName The name of the event handler to be called.
     */
    CocoonJS.App.callOriginProxyObjectEventHandler = function (typeName, id, eventHandlerName) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            parentObject[typeName]._cocoonjs_proxy_type_data.callProxyObjectEventHandler(id, eventHandlerName);
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the destination environment whenever it is needed to work with proxy objects.
     * It calls the origin proxy object when all the event listeners related to a specific event need to be updated/called from the destination environment.
     * @param {string} typeName The type name of the proxified type.
     * @param {number} id The id of the proxy object.
     * @param {string} eventTypeName The name of the event type to call the listeners related to it.
     */
    CocoonJS.App.callOriginProxyObjectEventListeners = function (typeName, id, eventTypeName) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            parentObject[typeName]._cocoonjs_proxy_type_data.callProxyObjectEventListeners(id, eventTypeName);
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the origin environment whenever it is needed to work with proxy objects.
     * Setups all the structures that are needed to proxify a destination type to an origin type.
     * @param {string} typeName The name of the type to be proxified.
     * @param {array} eventHandlerNames An array with al the event handlers to be proxified. Needed in order to be able to create callbacks for all the event handlers
     * and call to the CocoonJS counterparts accordingly.
     */
    CocoonJS.App.setupDestinationProxyType = function (typeName, eventHandlerNames) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;

            // Add a cocoonjs structure to the destination proxified type to store some useful information like all the proxy instances that are created, plus the id counter 
            // and the names of all the event handlers and some utility functions.
            parentObject[typeName]._cocoonjs_proxy_type_data =
            {
                nextId:0,
                proxyObjects:{},
                eventHandlerNames:eventHandlerNames
            }
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the origin environment whenever it is needed to work with proxy objects.
     * Takes down the proxy type at the destination environment. Just removes the data structure related to proxies that was added to the type when proxification tool place.
     * @param {string} typeName The name of the type to take the proxification down.
     */
    CocoonJS.App.takedownDestinationProxyType = function (typeName) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            if (parent[typeName] && parentObject[typeName]._cocoonjs_proxy_type_data) {
                delete parentObject[typeName]._cocoonjs_proxy_type_data;
            }
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the original environment whenever it is needed to work with proxy objects.
     * Creates a new destination object instance and generates a id to reference it from the original environment.
     * @param {string} typeName The name of the type to be proxified and to generate an instance.
     * @return The id to be used from the original environment to identify the corresponding destination object instance.
     */
    CocoonJS.App.newDestinationProxyObject = function (typeName) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;

            var proxyObject = new parentObject[typeName]();
            // Also store some additional information in the proxy object
            proxyObject._cocoonjs_proxy_object_data = {};
            // Like the type name, that could be useful late ;)
            proxyObject._cocoonjs_proxy_object_data.typeName = typeName;
            // Caculate the id for the object. It will be returned to the origin environment so this object can be referenced later
            var proxyObjectId = parentObject[typeName]._cocoonjs_proxy_type_data.nextId;
            // Store the created object in the structure defined in the setup of proxification with an id associated to it
            parentObject[typeName]._cocoonjs_proxy_type_data.proxyObjects[proxyObjectId] = proxyObject;
            // Also store the id inside the proxy object itself
            proxyObject._cocoonjs_proxy_object_data.id = proxyObjectId;
            // Calculate a new id for the next object.
            parentObject[typeName]._cocoonjs_proxy_type_data.nextId++;

            // Setup all the event handlers.
            for (var i = 0; i < parentObject[typeName]._cocoonjs_proxy_type_data.eventHandlerNames.length; i++) {
                (function (eventHandlerName) {
                    proxyObject[eventHandlerName] = function (event) {
                        var proxyObject = this; // event.target;
                        // var eventHandlerName = CocoonJS.getKeyForValueInDictionary(proxyObject, this); // Avoid closures ;)
                        var jsCode = "CocoonJS.App.callOriginProxyObjectEventHandler(" + JSON.stringify(proxyObject._cocoonjs_proxy_object_data.typeName) + ", " + proxyObject._cocoonjs_proxy_object_data.id + ", " + JSON.stringify(eventHandlerName) + ");";
                        CocoonJS.App.forwardAsync(jsCode);
                    };
                })(parentObject[typeName]._cocoonjs_proxy_type_data.eventHandlerNames[i]);
            }

            // Add the dictionary where the event listeners (callbacks) will be added.
            proxyObject._cocoonjs_proxy_object_data.eventListeners = {};

            return proxyObjectId;
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the origin environement whenever it is needed to work with proxy objects.
     * Calls a function of a destination object idetified by it's typeName and id.
     * @param {string} typeName The name of the type of the proxy.
     * @param {number} id The id of the proxy object.
     * @param {string} functionName The name of the function to be called.
     * @return Whatever the function call returns.
     */
    CocoonJS.App.callDestinationProxyObjectFunction = function (typeName, id, functionName) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            var argumentsArray = Array.prototype.slice.call(arguments);
            argumentsArray.splice(0, 3);
            var proxyObject = parentObject[typeName]._cocoonjs_proxy_type_data.proxyObjects[id];
            var result = proxyObject[functionName].apply(proxyObject, argumentsArray);
            return result;
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the original environment whenever it is needed to work with proxy objects.
     * Sets a value to the corresponding attributeName of a proxy object represented by it's typeName and id.
     * @param {string} typeName The name of the type of the proxy.
     * @param {number} id The id of the proxy object.
     * @param {string} attributeName The name of the attribute to be set.
     * @param {unknown} attributeValue The value to be set to the attribute.
     */
    CocoonJS.App.setDestinationProxyObjectAttribute = function (typeName, id, attributeName, attributeValue) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            var proxyObject = parentObject[typeName]._cocoonjs_proxy_type_data.proxyObjects[id];
            proxyObject[attributeName] = attributeValue;
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the original environment whenever it is needed to work with proxy objects.
     * Retrieves the value of the corresponding attributeName of a proxy object represented by it's typeName and id.
     * @param {string} typeName The name of the type of the proxy.
     * @param {number} id The id of the proxy object.
     * @param {string} attributeName The name of the attribute to be retrieved.
     */
    CocoonJS.App.getDestinationProxyObjectAttribute = function (typeName, id, attributeName) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            var proxyObject = parentObject[typeName]._cocoonjs_proxy_type_data.proxyObjects[id];
            return proxyObject[attributeName];
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the original environment whenever it is needed to work with proxy objects.
     * Deletes a proxy object identifying it using it's typeName and id. Deleting a proxy object mainly means to remove the instance from the global structure
     * that hold all the instances.
     * @param {string} typeName The name of the type of the proxy.
     * @param {number} id The id of the proxy object.
     */
    CocoonJS.App.deleteDestinationProxyObject = function (typeName, id) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            delete parentObject[typeName]._cocoonjs_proxy_type_data.proxyObjects[id];
        }
    };

    /**
     * NOTE: This function should never be directly called. It will be called from the original environment whenever it is needed to work with proxy objects.
     */
    CocoonJS.App.addDestinationProxyObjectEventListener = function (typeName, id, eventTypeName) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            var parentObject = window;
            // Look for the proxy object
            var proxyObject = parentObject[typeName]._cocoonjs_proxy_type_data.proxyObjects[id];

            var callback = function (event) {
                var proxyObject = this; // event.target;
                // var eventTypeName = CocoonJS.getKeyForValueInDictionary(proxyObject._cocoonjs_proxy_object_data.eventListeners, this); // Avoid closures ;)
                // TODO: Is there a way to retrieve the callbackId without a closure?
                var jsCode = "CocoonJS.App.callOriginProxyObjectEventListeners(" + JSON.stringify(proxyObject._cocoonjs_proxy_object_data.typeName) + ", " + proxyObject._cocoonjs_proxy_object_data.id + ", " + JSON.stringify(eventTypeName) + ");";
                CocoonJS.App.forwardAsync(jsCode);
            };

            proxyObject._cocoonjs_proxy_object_data.eventListeners[eventTypeName] = callback;

            // Finally add the event listener callback to the proxy object
            proxyObject.addEventListener(eventTypeName, callback);
        }
    };

    // TODO: We could add a removeDestinationProxyObjectEventListener although it seems that is not completely necessary.

    /**
     * Proxifies the XMLHttpRequest type for the environment where this call is made. After calling this function, all the new objects
     * of XMLHttpRequest that are instantiated, will be proxified objects that will make calls to the counterparts in the other environment (CocoonJS <-> WebView viceversa).
     * IMPORTANT NOTE: Remember to take down the proxification once you are done or to delete proxy objects whenever they are not needed anymore or memory leaks may occur.
     */
    CocoonJS.App.proxifyXHR = function () {
        var ATTRIBUTE_NAMES =
            [
                "timeout",
                "withCredentials",
                "upload",
                "status",
                "statusText",
                "responseType",
                "response",
                "responseText",
                "responseXML",
                "readyState"
            ];
        var FUNCTION_NAMES =
            [
                "open",
                "setRequestHeader",
                "send",
                "abort",
                "getResponseHeader",
                "getAllResponseHeaders",
                "overrideMimeType"
            ];
        var EVENT_HANDLER_NAMES =
            [
                "onloadstart",
                "onprogress",
                "onabort",
                "onerror",
                "onload",
                "ontimeout",
                "onloadend",
                "onreadystatechange"
            ];
        CocoonJS.App.setupOriginProxyType("XMLHttpRequest", ATTRIBUTE_NAMES, FUNCTION_NAMES, EVENT_HANDLER_NAMES);
    };

    /**
     * Proxifies the Audio type for the environment where this call is made. After calling this function, all the new objects
     * of Audio that are instantiated, will be proxified objects that will make calls to the counterparts in the other environment (CocoonJS <-> WebView viceversa).
     * IMPORTANT NOTE: Remember to take down the proxification once you are done or to delete proxy objects whenever they are not needed anymore or memory leaks may occur.
     */
    CocoonJS.App.proxifyAudio = function () {
        var ATTRIBUTE_NAMES =
            [
                "src",
                "loop",
                "volume",
                "preload"
            ];
        var FUNCTION_NAMES =
            [
                "play",
                "pause",
                "load",
                "canPlayType"
            ];
        var EVENT_HANDLER_NAMES =
            [
                "onended",
                "oncanplay",
                "oncanplaythrough",
                "onerror"
            ];
        CocoonJS.App.setupOriginProxyType("Audio", ATTRIBUTE_NAMES, FUNCTION_NAMES, EVENT_HANDLER_NAMES);
    };

    /**
     * Captures a image of the screen synchronously and saves it to a file. Sync mode allows to capture the screen in the middle of a frame rendering.
     * @param {string} fileName Desired file name and format (png or jpg). If no value is passed, "capture.png" value is used by default
     * @param {CocoonJS.App.StorageType} storageType The developer can specify the storage where it is stored. If no value is passed, the {@link CocoonJS.App.StorageType.TMP_STORAGE} value is used by default.
     * @param {CocoonJS.App.CaptureType} captureType. Optional value to choose capture type. [0: captures everything, 1: only captures cocoonjs surface 2: only captures system views]. @see CocoonJS.App.CaptureType
     * @return The URL of the saved file.
     * @throws exception if the image fails to be stored or there is another error.
     * @see CocoonJS.App.onCaptureScreenSucceeded
     * @see CocoonJS.App.onCaptureScreenFailed
     */
    CocoonJS.App.captureScreen = function (fileName, storageType, captureType) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return window.ext.IDTK_APP.makeCall("captureScreen", fileName, storageType, captureType);
        }
    };

    /**
     * Captures a image of the screen asynchronously and saves it to a file.
     * Async mode captures a final frame as soon as possible.
     * @param {string} Desired file name and format (png or jpg). If no value is passed, "capture.png" value is used by default
     * @param {CocoonJS.App.StorageType} [storageType] The developer can specify the storage where it is stored. If no value is passed, the {@link CocoonJS.App.StorageType.TMP_STORAGE} value is used by default.
     * @param {CocoonJS.App.CaptureType} captureType. Optional value to choose capture type. [0: captures everything, 1: only captures cocoonjs surface, 2: only captures system views]. @see CocoonJS.App.CaptureType
     * @param {function} callback. Response callback, check the error property to monitor errors. Check the 'url' property to get the URL of the saved Image
     */
    CocoonJS.App.captureScreenAsync = function (fileName, storageType, captureType, callback) {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            window.ext.IDTK_APP.makeCallAsync("captureScreen", fileName, storageType, captureType, callback);
        }
    };

    /**
     * Returns the device UUID
     * @return {string} The device UUID
     */
    CocoonJS.App.getDeviceId = function() {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return window.ext.IDTK_APP.makeCall("getDeviceId");
        }
    };

    /**
     * Structure that defines the getDeviceInfo returned information
     */
    CocoonJS.App.DeviceInfo = {

        /**
        * The operating system name (ios, android,...)
        * @type string
        */
        os: null,

        /**
        * The operating system version (4.2.2, 5.0,...)
        * @type string
        */
        version: null,

        /**
        * The operating system screen density in dpi
        * @type string
        */
        dpi: null,

        /**
        * The device manufacturer (apple, samsung, lg,...)
        * @type string
        */
        brand: null,

        /**
        * The device model (iPhone 4S, SAMSUNG-SGH-I997, SAMSUNG-SGH-I997R, etc)
        * @type string
        */
        model: null,

        /**
        * The phone IMEI
        * Android: The phone IMEI is returned or null if the device has not telepohny
        * iOS: null is returned as we cannot get the IMEI in iOS, no public API available for that yet.
        * @type string
        */
        imei: null,

        /**
        * The platform Id
        * Android: The ANDROID_ID is used.
        * iOS: The OpenUDID is used as there is no Android ANDROID_ID equivalent in iOS
        * @type string
        */
        platformId: null,

        /**
        * The Odin generated id https://code.google.com/p/odinmobile/
        * @type string
        */
        odin: null,

        /**
        * The OpenUDID generated Id https://github.com/ylechelle/OpenUDID
        * @type string
        */
        openudid: null
    };

    /**
     * Returns the device Info
     * @return {CocoonJS.App.DeviceInfo} The device Info
     */
    CocoonJS.App.getDeviceInfo = function() {
        if (CocoonJS.App.nativeExtensionObjectAvailable) {
            return window.ext.IDTK_APP.makeCall("getDeviceInfo");
        }
    };    

    /**
     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.App.onTextDialogFinished} event calls.
     * @name OnTextDialogFinishedListener
     * @function
     * @static
     * @memberOf CocoonJS.App
     * @param {string} text The text that was introduced in the text dialog when it was finished.
     */
    /**
     * This {@link CocoonJS.EventHandler} object allows listening to events called when the text dialog is finished by accepting it's content.
     * The callback function's documentation is represented by {@link CocoonJS.App.OnTextDialogFinishedListener}
     * @event
     * @static
     * @memberOf CocoonJS.App
     */
    CocoonJS.App.onTextDialogFinished = new CocoonJS.EventHandler("IDTK_APP", "App", "ontextdialogfinish");

    /**
     * This {@link CocoonJS.EventHandler} object allows listening to events called when the text dialog is finished by dismissing it's content.
     * The callback function does not receive any parameter.
     * @event
     * @static
     * @memberOf CocoonJS.App
     */
    CocoonJS.App.onTextDialogCancelled = new CocoonJS.EventHandler("IDTK_APP", "App", "ontextdialogcancel");

    /**
     * This {@link CocoonJS.EventHandler} object allows listening to events called when the text dialog is finished by accepting it's content.
     * The callback function does not receive any parameter.
     * @event
     * @static
     * @memberOf CocoonJS.App
     */
    CocoonJS.App.onMessageBoxConfirmed = new CocoonJS.EventHandler("IDTK_APP", "App", "onmessageboxconfirmed");

    /**
     * This {@link CocoonJS.EventHandler} object allows listening to events called when the text dialog is finished by dismissing it's content.
     * The callback function does not receive any parameter.
     * @event
     * @static
     * @memberOf CocoonJS.App
     */
    CocoonJS.App.onMessageBoxDenied = new CocoonJS.EventHandler("IDTK_APP", "App", "onmessageboxdenied");

    /**
     * This {@link CocoonJS.EventHandler} object allows listening to events called when the application is suspended.
     * The callback function does not receive any parameter.
     * @event
     * @static
     * @memberOf CocoonJS.App
     */
    CocoonJS.App.onSuspended = new CocoonJS.EventHandler("IDTK_APP", "App", "onsuspended");

    /**
     * This {@link CocoonJS.EventHandler} object allows listening to events called when the application is activated.
     * The callback function does not receive any parameter.
     * @event
     * @static
     * @memberOf CocoonJS.App
     */
    CocoonJS.App.onActivated = new CocoonJS.EventHandler("IDTK_APP", "App", "onactivated");

})();

//////////////////////////////////////
// COCOONJS_APP_FORCOCOONJS.JS		//
//////////////////////////////////////

(function()
{
    if (typeof window.CocoonJS === 'undefined' || window.CocoonJS === null) throw("The CocoonJS object must exist and be valid before adding more functionalities to an extension.");
    if (typeof window.CocoonJS.App === 'undefined' || window.CocoonJS.App === null) throw("The CocoonJS.App object must exist and be valid before adding more functionalities to it.");

    /**
    * This namespace represents all the basic functionalities available in the CocoonJS extension API.
    * @namespace
    */
    CocoonJS.App = CocoonJS.App ? CocoonJS.App : {};

    if (!CocoonJS.App.nativeExtensionObjectAvailable)
    {
        (function createWebView() { 
            CocoonJS.App.EmulatedWebView = document.createElement('div'); 
            CocoonJS.App.EmulatedWebView.setAttribute('id', 'CocoonJS_App_ForCocoonJS_WebViewDiv'); 
            CocoonJS.App.EmulatedWebView.style.width = 0; 
            CocoonJS.App.EmulatedWebView.style.height = 0; 
            CocoonJS.App.EmulatedWebView.style.position = "absolute"; 
            CocoonJS.App.EmulatedWebView.style.left = 0; 
            CocoonJS.App.EmulatedWebView.style.top = 0;
            CocoonJS.App.EmulatedWebView.style.backgroundColor = 'transparent';
            CocoonJS.App.EmulatedWebView.style.border = "0px solid #000"; 
            CocoonJS.App.EmulatedWebViewIFrame = document.createElement("IFRAME"); 
            CocoonJS.App.EmulatedWebViewIFrame.setAttribute('id', 'CocoonJS_App_ForCocoonJS_WebViewIFrame');
            CocoonJS.App.EmulatedWebViewIFrame.setAttribute('name', 'CocoonJS_App_ForCocoonJS_WebViewIFrame');
            CocoonJS.App.EmulatedWebViewIFrame.style.width = 0; 
            CocoonJS.App.EmulatedWebViewIFrame.style.height = 0; 
            CocoonJS.App.EmulatedWebViewIFrame.frameBorder = 0;
            CocoonJS.App.EmulatedWebViewIFrame.allowtransparency = true;
            CocoonJS.App.EmulatedWebView.appendChild(CocoonJS.App.EmulatedWebViewIFrame);
            if(!document.body)
            document.body = document.createElement("body");
            document.body.appendChild(CocoonJS.App.EmulatedWebView);
        })(); 
    }

    /**
    * Pauses the CocoonJS JavaScript execution loop.
    * @function
    * @augments CocoonJS.App
    */
    CocoonJS.App.pause = function()
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "pause", arguments);
        }
    };

    /**
    * Resumes the CocoonJS JavaScript execution loop.
    * @static
    * @function
    */
    CocoonJS.App.resume = function()
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "resume", arguments);
        }
    };

    /**
    * Loads a resource in the WebView environment from the CocoonJS environment.
    * @function
    * @param {string} path The path to the resource. It can be a remote URL or a path to a local file.
    * @param {CocoonJS.App.StorageType} [storageType] An optional parameter to specify at which storage in the device the file path is stored. By default, APP_STORAGE is used.
    * @see CocoonJS.App.load
    * @see CocoonJS.App.onLoadInTheWebViewSucceed
    * @see CocoonJS.App.onLoadInTheWebViewFailed
    */
    CocoonJS.App.loadInTheWebView = function(path, storageType)
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
            // TODO: All this code should be changed to a simple call makeNativeExtensionObjectFunctionCall when the native argument control is improved.
            var javaScriptCodeToForward = "ext.IDTK_APP.makeCall('loadPath'";
            if (typeof path !== 'undefined')
            {
                javaScriptCodeToForward += ", '" + path + "'";
                if (typeof storageType !== 'undefined')
                {
                    javaScriptCodeToForward += ", '" + storageType + "'";
                }
            }
            javaScriptCodeToForward += ");";

            return CocoonJS.App.forwardAsync(javaScriptCodeToForward);
        }
        else if (!navigator.isCocoonJS)
        {
            var xhr = new XMLHttpRequest();

            xhr.onreadystatechange = function(event) {
                if (xhr.readyState === 4)
                {
                    if (xhr.status === 200)
                    {
                        var callback= function(event){
                            CocoonJS.App.onLoadInTheWebViewSucceed.notifyEventListeners(path);
                            CocoonJS.App.EmulatedWebViewIFrame.removeEventListener("load", callback);
                        };

                        CocoonJS.App.EmulatedWebViewIFrame.addEventListener(
                            "load", 
                            callback
                        );
                        CocoonJS.App.EmulatedWebViewIFrame.contentWindow.location.href= path;
                    }
                    else if (xhr.status === 404)
                    {
                        this.onreadystatechange = null;
                        CocoonJS.App.onLoadInTheWebViewFailed.notifyEventListeners(path);
                    }
                }
            };
            xhr.open("GET", path, true);
            xhr.send();
        }
    };

    /**
     * Reloads the last loaded path in the WebView context.
     * @function
     */
    CocoonJS.App.reloadWebView = function()
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
            return CocoonJS.App.forwardAsync("ext.IDTK_APP.makeCall('reload');");
        }
        else if (!navigator.isCocoonJS)
        {
            CocoonJS.App.EmulatedWebViewIFrame.contentWindow.location.reload();
        }
    };

    /**
    * Shows the webview.
    * @function
    * @param {int} x The top lef x coordinate of the rectangle where the webview will be shown.
    * @param {int} y The top lef y coordinate of the rectangle where the webview will be shown.
    * @param {width} y The width of the rectangle where the webview will be shown.
    * @param {height} y The height of the rectangle where the webview will be shown.
    */
    CocoonJS.App.showTheWebView = function(x, y, width, height)
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
            var javaScriptCodeToForward = "ext.IDTK_APP.makeCall('show'";
            if (typeof x !== 'undefined' && typeof y !== 'undefined' && typeof width !== 'undefined' && typeof height !== 'undefined')
            {
                javaScriptCodeToForward += ", " + x + ", " + y + ", " + width + ", " + height;
            }
            javaScriptCodeToForward += ");";

            return CocoonJS.App.forwardAsync(javaScriptCodeToForward);
        }
        else if (!navigator.isCocoonJS)
        {
            CocoonJS.App.EmulatedWebViewIFrame.style.width = (width ? width : window.innerWidth)+'px';
            CocoonJS.App.EmulatedWebViewIFrame.style.height = (height ? height : window.innerHeight)+'px';
            CocoonJS.App.EmulatedWebView.style.left = (x ? x : 0)+'px';
            CocoonJS.App.EmulatedWebView.style.top = (y ? y : 0)+'px';
            CocoonJS.App.EmulatedWebView.style.width = (width ? width : window.innerWidth)+'px';
            CocoonJS.App.EmulatedWebView.style.height = (height ? height : window.innerHeight)+'px';
            CocoonJS.App.EmulatedWebView.style.display = "block";
        }
    };

    /**
    * Hides the webview.
    * @function
    */
    CocoonJS.App.hideTheWebView = function()
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
            var javaScriptCodeToForward = "ext.IDTK_APP.makeCall('hide');";
            return CocoonJS.App.forwardAsync(javaScriptCodeToForward);
        }
        else if (!navigator.isCocoonJS)
        {
            CocoonJS.App.EmulatedWebView.style.display = "none";
        }
    };

    /**
    * Marks a audio file to be used as music by the system. CocoonJS, internally, differentiates among music files and sound files.
    * Music files are usually bigger in size and longer in duration that sound files. There can only be just one music file 
    * playing at a specific given time. The developer can mark as many files as he/she wants to be treated as music. When the corresponding
    * HTML5 audio object is used, the system will automatically know how to treat the audio resource as music or as sound.
    * Note that it is not mandatory to use this function. The system automatically tries to identify if a file is suitable to be treated as music
    * or as sound by checking file size and duration thresholds. It is recommended, though, that the developer specifies him/herself what he/she considers
    * to be music.
    * @function
    * @param {string} audioFilePath The same audio file path that will be used to create HTML5 audio objects.
    */
    CocoonJS.App.markAsMusic = function(audioFilePath)
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
           return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "addForceMusic", arguments);
        }
    };

    /**
    * Activates or deactivates the antialas functionality from the CocoonJS rendering.
    * @function
    * @param {boolean} enable A flag that indicates if the antialas should be activated (true) or deactivated (false).
    */
    CocoonJS.App.setAntialias = function(enable)
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
           return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "setDefaultAntialias", arguments);
        }
    };

    /**
    * Sets a callback function that will be called whenever the system tries to finish the app.
    * The developer can specify how the system will react to the finish of the app by returning a
    * boolean value in the callback function: true means, close the app, false means that the developer
    * will handle the app close.
    * A common example of this is the back button in Android devices. When the back button is pressed, this
    * callback will be called and the system will react depending on the developers choice finishing, or not,
    * the application.
    * @function
    * @param {function} appShouldFinishCallback A function object that will be called when the system
    * determines that the app should be finished. This function must return a true or a false value
    * depending on what the developer wants: true === finish the app, false === do not close the app.
    */
    CocoonJS.App.setAppShouldFinishCallback = function(appShouldFinishCallback)
    {
        if (navigator.isCocoonJS)
        {
            window.onidtkappfinish = appShouldFinishCallback;
        }
    }

    /**
    * Sets the texture reduction options. The texture reduction is a process that allows big images to be reduced/scaled down when they are loaded.
    * Although the quality of the images may decrease, it can be very useful in low end devices or those with limited amount of memory.
    * The function sets the threshold on image size (width or height) that will be used in order to know if an image should be reduced or not.
    * It also allows to specify a list of strings to identify in which images file paths should be applied (when they meet the size threshold requirement) 
    * The developer will still think that the image is of the original size. CocoonJS handles all of the internals to be able to show the image correctly.
    * IMPORTANT NOTE: This function should be called when the application is initialized before any image is set to be loaded for obvious reasons ;).
    * and in which sould be forbid (even if they meet the threshold requirement).
    * @function
    * @param {number} sizeThreshold This parameter specifies the minimun size (either width or height) that an image should have in order to be reduced.
    * @param {string or array} [applyTo] This parameter can either be a string or an array of strings. It's purpose is to specify one (the string) or more (the array) substring(s) 
    * that will be compared against the file path of an image to be loaded in order to know if the reduction should be applied or not. If the image meets the
    * threshold size requirement and it's file path contains this string (or strings), it will be reduced. This parameter can also be null.
    * @param {string or array} [forbidFor] This parameter can either be a string or an array of strings. It's purpose is to specify one (the string) or more (the array) substring(s) 
    * that will be compared against the file path of an image to be loaded in order to know if the reduction should be applied or not. If the image meets the
    * threshold size requirement and it's file path contains this string (or strings), it won't be reduced. This parameter should be used in order to mantain the 
    * quality of some images even they meet the size threshold requirement.
    */
    CocoonJS.App.setTextureReduction = function(sizeThreshold, applyTo, forbidFor)
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
            CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "setDefaultTextureReducerThreshold", arguments);
        }
    };


    /**
    * Prints to the console the memory usage of the currently alive textures
    * @function
    */
    CocoonJS.App.logMemoryInfo = function()
    {
        if (CocoonJS.App.nativeExtensionObjectAvailable)
        {
            return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_APP", "logMemoryInfo", arguments);
        }
    };

    /**
    * Enable CocoonJS Webview FPS overlay.
    * @function
    */
    CocoonJS.App.enableFPSInTheWebView = function(fpsLayout, textColor)
    {
        if (!CocoonJS.App.fpsInTheWebViewEnabled)
        {
            fpsLayout = fpsLayout ? fpsLayout : CocoonJS.App.FPSLayout.TOP_RIGHT;
            textColor = textColor ? textColor : "white";
            var jsCode = "" +
                "(function()" +
                "{" +
                    "var COCOONJS_WEBVIEW_EXTENSION_SCRIPT_FILES = ['js/CocoonJSExtensions/CocoonJS.js', 'js/CocoonJSExtensions/CocoonJS_App.js', 'js/CocoonJSExtensions/CocoonJS_App_ForWebView.js'];" +
                    "var loadedScriptCounter = 0;" + 
                    "var loadedScriptFunction = function() " +
                    "{ " +
                        "loadedScriptCounter++;"+
                        "if (loadedScriptCounter >= COCOONJS_WEBVIEW_EXTENSION_SCRIPT_FILES.length)"+
                        "{"+
                            "CocoonJS.App.enableFPS(" + JSON.stringify(fpsLayout) + ", " + JSON.stringify(textColor) + ");"+
                        "}"+
                    "};"+
                    "for (var i = 0; i < COCOONJS_WEBVIEW_EXTENSION_SCRIPT_FILES.length; i++)"+
                    "{"+
                        "var s = document.createElement('script');"+
                        "s.onload = loadedScriptFunction;"+
                        "s.src = COCOONJS_WEBVIEW_EXTENSION_SCRIPT_FILES[i];"+
                        "document.body.appendChild(s);"+
                    "}" +
                "})();";
            setTimeout(function()
            {
                CocoonJS.App.forward(jsCode);
            }, 3000);
            CocoonJS.App.fpsInTheWebViewEnabled = true;
        }
    };

    /**
    * Disable CocoonJS Webview FPS overlay.
    * @function
    */
    CocoonJS.App.disableFPSInTheWebView = function()
    {
        // TODO: Implement this function.
    };

    /**
     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.App.onLoadInTheWebViewSucceed} event calls.
     * @name OnLoadInTheWebViewSucceedListener
     * @function
     * @static
     * @memberOf CocoonJS.App
     * @param {string} pageURL The URL of the page that had been loaded in the webview.
     */
    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the WebView load has completed successfully.
    * The callback function's documentation is represented by {@link CocoonJS.App.OnLoadInTheWebViewSucceedListener}
    * @event
    * @static
    * @memberOf CocoonJS.App
    * @param {string} pageURL A string that represents the page URL loaded.
    */
    CocoonJS.App.onLoadInTheWebViewSucceed = new CocoonJS.EventHandler("IDTK_APP", "App", "forwardpageload");

    /**
     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.App.onLoadInTheWebViewFailed} event calls.
     * @name OnLoadInTheWebViewFailedListener
     * @function
     * @static
     * @memberOf CocoonJS.App
     * @param {string} pageURL The URL of the page that had been loaded in the webview.
     */
    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the WebView load fails.
    * The callback function's documentation is represented by {@link CocoonJS.App.OnLoadInTheWebViewFailedListener}
    * @event
    * @static
    * @memberOf CocoonJS.App
    */
    CocoonJS.App.onLoadInTheWebViewFailed = new CocoonJS.EventHandler("IDTK_APP", "App", "forwardpagefail");
    
})();

//////////////////////////////////////
// COCOONJS_AD.JS                   //
//////////////////////////////////////

(function()
{
    // The CocoonJS must exist before creating the extension.
    if (typeof window.CocoonJS === 'undefined' || window.CocoonJS === null) throw("The CocoonJS object must exist and be valid before creating any extension object.");

    /**
    * This namespace represents the CocoonJS Advertisement extension API.
    * @namespace
    */
    CocoonJS.Ad = {};

    CocoonJS.Ad.nativeExtensionObjectAvailable = CocoonJS.nativeExtensionObjectAvailable && typeof window.ext.IDTK_SRV_AD !== 'undefined';

    /**
    * The predefined possible layouts for a banner ad.
    * @namespace 
    */
	CocoonJS.Ad.BannerLayout = 
	{
		/**
		* Specifies that the banner must be shown in the top of the screen and vertically centered.
		*/
	    TOP_CENTER      : "TOP_CENTER",

		/**
		* Specifies that the banner must be shown in the bottom of the screen and vertically centered.
		*/
	    BOTTOM_CENTER   : "BOTTOM_CENTER"
	};

	/**
    * A rectangle object that contains the banner dimensions
    * @namespace 
    * @constructor
    * @param {int} x The top lef x coordinate of the rectangle.
    * @param {int} y The top lef y coordinate of the rectangle.
    * @param {width} y The rectangle width.
    * @param {height} y The rectangle height.
    */
	CocoonJS.Ad.Rectangle = function(x, y, width, height) 
	{
		/**
		* The top lef x coordinate of the rectangle 
		* @field 
		* @type {int}
		*/
	    this.x = x;

		/**
		* The top lef y coordinate of the rectangle 
		* @field 
		* @type {int}
		*/
	    this.y = y;

	    /**
		* The rectangle width
		* @field 
		* @type {int}
		*/
	    this.width = width;

	    /**
		* The rectangle height
		* @field 
		* @type {int}
		*/
	    this.height = height;
	};

	CocoonJS.Ad.Banner = function(id)
	{
		if (typeof id !== 'number') throw "The given ad ID is not a number.";

		this.id = id;
		var me = this;

		/**
    	* This {@link CocoonJS.EventHandler} object allows listening to events called when a banner is shown.
    	* The callback function does not receive any parameter.
    	* @static
    	* @event
    	*/
		this.onBannerShown = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onbannershow", function(sourceListener, args)
    	{
    		if (me.id === args[0]) 
    		{
    			sourceListener();
    		}
    	});

    	/**
    	* This {@link CocoonJS.EventHandler} object allows listening to events called when a banner is hidden.
    	* The callback function does not receive any parameter.
    	* @static
    	* @event
    	*/
		this.onBannerHidden = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onbannerhide", function(sourceListener, args)
    	{
    		if (me.id === args[0]) 
    		{
    			sourceListener();
    		}
    	});

    	/**
    	* This {@link CocoonJS.EventHandler} object allows listening to events called when a banner is ready (cached).
    	* The callback function does not receive any parameter.
    	* @param {number} width The banner width
    	* @param {number} height The banner height
    	* @static
    	* @event
    	*/
		this.onBannerReady = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onbannerready", function(sourceListener, args)
    	{
    		if (me.id === args[0]) 
    		{
    			sourceListener(args[1], args[2]);
    		}
    	});
	};

	CocoonJS.Ad.Banner.prototype = {

		/**
		* Shows a banner ad if available.
		* @function
		*/
		showBanner : function()
		{
			if (CocoonJS.Ad.nativeExtensionObjectAvailable)
			{
				CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "showBanner", [this.id], true);
			}
		},

		/**
		* Hides the banner ad if it was being shown.
		* @function
		*/
		hideBanner : function()
		{
			if (CocoonJS.Ad.nativeExtensionObjectAvailable)
			{
				CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "hideBanner", [this.id], true);
			}
		},

		/**
		* Refreshes the banner.
		* @function
		*/
		refreshBanner : function()
		{
			if (CocoonJS.Ad.nativeExtensionObjectAvailable)
			{
				CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "refreshBanner", [this.id], true);
			}
		},

		/**
		* Gets the rectangle representing the banner screen position.
		* @function
		* @return {CocoonJS.Ad.Rectangle} rectangle The rectangle representing the banner position and domensions.
		*/
		getRectangle : function()
		{
			if (CocoonJS.Ad.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "getRectangle", [this.id]);
			}
		},

		/**
		* Sets the rectangle where the banner ad is going to be shown.
		* @function
		* @param {CocoonJS.Ad.Rectangle} rect The rectangle representing the banner position and domensions.
		*/
		setRectangle : function(rect)
		{
			if (CocoonJS.Ad.nativeExtensionObjectAvailable)
			{
				CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "setRectangle", [this.id, rect],true);
			}
		},

		/**
		* Sets the rectangle where the banner ad is going to be shown.
		* You can use this method if you want to have better control of the banner screen positioning.
		* @function
		* @param {CocoonJS.Ad.BannerLayout} bannerLayout The layout where the bannerwill be placed.
		*/
		setBannerLayout : function(bannerLayout)
		{
			if (CocoonJS.Ad.nativeExtensionObjectAvailable)
			{
				CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "setBannerLayout", [this.id, bannerLayout],true);
			}
		}
	};

	CocoonJS.Ad.Fullscreen = function(id)
	{
		if (typeof id !== 'number') throw "The given ad ID is not a number.";

		this.id = id;
		var me = this;

		/**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a full screen ad is shown.
	    * The callback function does not receive any parameter.
	    * @static
	    * @event
	    */
		this.onFullScreenShown = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onfullscreenshow", function(sourceListener, args)
    	{
    		if (me.id === args[0]) {
    			sourceListener();
    		}
    	});

		/**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a full screen ad is hidden.
	    * The callback function does not receive any parameter.
	    * @static
	    * @event
	    */
    	this.onFullScreenHidden = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onfullscreenhide", function(sourceListener, args)
    	{
    		if (me.id === args[0]) {
    			sourceListener();
    		}
    	});

    	/**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a full screen ad is ready (cached).
	    * The callback function does not receive any parameter.
	    * @static
	    * @event
	    */
    	this.onFullScreenReady = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onfullscreenready", function(sourceListener, args)
    	{
    		if (me.id === args[0]) {
    			sourceListener();
    		}
    	});
	};

	CocoonJS.Ad.Fullscreen.prototype = {

		/**
		* Shows a full screen ad if available.
		* @function
		* @see CocoonJS.Ad.onFullScreenShown
		* @see CocoonJS.Ad.onFullScreenHidden
		*/
		showFullScreen : function()
		{
			if (CocoonJS.Ad.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "showFullScreen", [this.id], true);
			}
		},

		/**
		* Refreshes the fullscreen.
		* @function
		*/
		refreshFullScreen : function()
		{
			if (CocoonJS.Ad.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "refreshFullScreen", [this.id], true);
			}
		}
	};

	/**
	* Initialize the service with service level initialization parameters.
	* @function
	* @param {object} An object with the required initialization parameters for the service.
	*/
	CocoonJS.Ad.requestInitialization = function(parameters)
	{
        if (typeof parameters === "undefined") {
            parameters = {};
        }

		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "requestInitialization", arguments, true);
		}
	};

	/**
	* Creates a new banner ad.
	* @function
	* @param {object} An object containing the properties the ad will need for its initialization.
	*/
	CocoonJS.Ad.createBanner = function(parameters)
	{
		if (typeof parameters === "undefined") {
            parameters = {};
        }

		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			var adId = CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "createBanner", [parameters]);
			var banner = new CocoonJS.Ad.Banner(adId);

			return banner;
		}
	};

	/**
	* Releases a banner.
	* @function
	* @param {object} The banner ad object to be released.
	*/
	CocoonJS.Ad.releaseBanner = function(banner)
	{
		if (typeof banner === "undefined") {
            throw "The banner ad object to be released is undefined"
        }

		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "releaseBanner", [banner.id]);
		}
	};

	/**
	* Creates a new fullscreen ad.
	* @function
	* @param {object} An object containing the properties the ad will need for its initialization.
	*/
	CocoonJS.Ad.createFullscreen = function(parameters)
	{
		if (typeof parameters === "undefined") {
            parameters = {};
        }

		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			var adId = CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "createFullscreen", [parameters]);
			var fullscreen = new CocoonJS.Ad.Fullscreen(adId);

			return fullscreen;
		}
	};

	/**
	* Releases a fullscreen ad.
	* @function
	* @param {object} The fullscreen ad object to be released.
	*/
	CocoonJS.Ad.releaseFullscreen = function(fullscreen)
	{
		if (typeof fullscreen === "undefined") {
            throw "The fullscreen ad object to be released is undefined"
        }

		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "releaseFullscreen", [fullscreen.id]);
		}
	};

	/**
	* Shows a banner ad if available.
	* @function
	* @see CocoonJS.Ad.setBannerLayout
	* @see CocoonJS.Ad.onBannerShown
	*/
	CocoonJS.Ad.showBanner = function()
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "showBanner", arguments, true);
		}
	};

	/**
	* Hides the banner ad if it was being shown.
	* @function
	*/
	CocoonJS.Ad.hideBanner = function()
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "hideBanner", arguments, true);
		}
	};

	/**
	* Refreshes the banner.
	* @function
	*/
	CocoonJS.Ad.refreshBanner = function()
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "refreshBanner", arguments, true);
		}
	};

	/**
	* Shows a full screen ad if available.
	* @function
	* @see CocoonJS.Ad.onFullScreenShown
	* @see CocoonJS.Ad.onFullScreenHidden
	*/
	CocoonJS.Ad.showFullScreen = function()
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "showFullScreen", arguments, true);
		}
	};

	/**
	* Refreshes the fullscreen.
	* @function
	*/
	CocoonJS.Ad.refreshFullScreen = function()
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "refreshFullScreen", arguments, true);
		}
	};

	/**
	* Makes a request to preload a banner ad.
	* @function
	*/
	CocoonJS.Ad.preloadBanner = function()
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "preloadBanner", arguments, true);
		}
	};

	/**
	* Makes a request to preload a full screen ad.
	* @function
	*/
	CocoonJS.Ad.preloadFullScreen = function()
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "preloadFullScreen", arguments, true);
		}
	};

	/**
	* Sets the rectangle where the banner ad is going to be shown.
	* @function
	* @param {CocoonJS.Ad.Rectangle} rect The rectangle representing the banner position and domensions.
	*/
	CocoonJS.Ad.setRectangle = function()
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "setRectangle", arguments, true);
		}
	};

	/**
	* Gets the rectangle representing the banner screen position.
	* @function
	* @return {CocoonJS.Ad.Rectangle} rectangle The rectangle representing the banner position and domensions.
	*/
	CocoonJS.Ad.getRectangle = function()
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "getRectangle", arguments);
		}
	};

	/**
	* Sets the rectangle where the banner ad is going to be shown.
	* You can use this method if you want to have better control of the banner screen positioning.
	* @function
	* @param {CocoonJS.Ad.BannerLayout} bannerLayout The layout where the bannerwill be placed.
	*/
	CocoonJS.Ad.setBannerLayout = function(bannerLayout)
	{
		if (CocoonJS.Ad.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_AD", "setBannerLayout", arguments, true);
		}
	};

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when a banner is shown.
    * The callback function does not receive any parameter.
    * @static
    * @event
    */
	CocoonJS.Ad.onBannerShown = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onbannershow");

	/**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when a banner is hidden.
    * The callback function does not receive any parameter.
    * @static
    * @event
    */
	CocoonJS.Ad.onBannerHidden = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onbannerhide"); 

	/**
	* This {@link CocoonJS.EventHandler} object allows listening to events called when a banner is ready (cached).
	* The callback function does not receive any parameter.
	* @param {number} width The banner width
	* @param {number} height The banner height
	* @static
	* @event
	*/
	CocoonJS.Ad.onBannerReady = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onbannerready"); 

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when a full screen ad is shown.
    * The callback function does not receive any parameter.
    * @static
    * @event
    */
	CocoonJS.Ad.onFullScreenShown = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onfullscreenshow"); 

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when a full screen ad is hidden.
    * The callback function does not receive any parameter.
    * @static
    * @event
    */
	CocoonJS.Ad.onFullScreenHidden = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onfullscreenhide");

	/**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when a full screen ad is ready (cached).
    * The callback function does not receive any parameter.
    * @static
    * @event
    */
	CocoonJS.Ad.onFullScreenReady = new CocoonJS.EventHandler("IDTK_SRV_AD", "Ad", "onfullscreenready"); 

})();

//////////////////////////////////////
// COCOONJS_STORE.JS                //
//////////////////////////////////////

(function()
{
    // The CocoonJS must exist before creating the extension.
    if (typeof window.CocoonJS === 'undefined' || window.CocoonJS === null) throw("The CocoonJS object must exist and be valid before creating any extension object.");

    /**
    * This namespace represents the CocoonJS In-App Purchase extension.
    * @namespace
    */
    CocoonJS.Store = {};

    CocoonJS.Store.nativeExtensionObjectAvailable = CocoonJS.nativeExtensionObjectAvailable && typeof window.ext.IDTK_SRV_STORE !== 'undefined';

	/**
	* The data structure that represents the information of a product in the store.
	* @namespace
	* @constructor
	* @param {string} The id of the product.
	* @param {string} The alias of the product.
	* @param {CocoonJS.Store.ProductType} The product type @see CocoonJS.Store.ProductType.
	* @param {string} The title of the product.
	* @param {string} The description of the product.
	* @param {string} The localized price of the product.
	* @param {string} The URL of the asset to be downloaded for this purchase.
	*/
	CocoonJS.Store.ProductInfo = function(productAlias, productId, productType, title, description, price, localizedPrice, downloadURL)
	{
		/**
		* The id of the product.
		* @field
		* @type string
		*/
		this.productId = productId;

		/**
		* The alias of the product.
		* @field
		* @type string
		*/
		this.productAlias = productAlias;

		/**
		* The product type @see CocoonJS.Store.ProductType
		* @field
		* @type CocoonJS.Store.ProductType
		*/
		this.productType = productType;

		/**
		* The title of the product.
		* @field
		* @type string
		*/
		this.title = title;

		/**
		* The description of the product.
		* @field
		* @type string
		*/
		this.description = description;

		/**
		* The price of the product.
		* @field
		* @type string
		*/
		this.price = price;

		/**
		* The localized price of the product.
		* @field
		* @type string
		*/
		this.localizedPrice = localizedPrice;

		/**
		* The URL of the asset to be downloaded for this purchase.
		* @field
		* @type string
		*/
		this.downloadURL = downloadURL;

		return this;
	};

	/**
    * The predefined possible states of a purchase.
    * @namespace 
    */
	CocoonJS.Store.ProductType = 
	{
		/**
		* A consumable product. See platform documentation for further information.
		*/
	    CONSUMABLE : 0,

		/**
		* A non-cunsumable product. . See platform documentation for further information.
		*/
	    NON_CONSUMABLE : 1,

	    /**
		* An auto-renewable subscription. See platform documentation for further information.
		*/
	    AUTO_RENEWABLE_SUBSCRIPTION : 2,

	    /**
		* A free subscription. See platform documentation for further information.
		*/
	    FREE_SUBSCRIPTION : 3,

	    /**
		* A non-renewable subscription. See platform documentation for further information.
		*/
	    NON_RENEWABLE_SUBSCRIPTION : 4
	};

	/**
    * The predefined possible store types.
    * @namespace 
    */
	CocoonJS.Store.StoreType = 
	{
		/**
		* Apple AppStore
		*/
	    APP_STORE : 0,

	    /**
	    * Android Play Store
	    */
	    PLAY_STORE : 1,

		/**
		* Mock Store
		*/
		MOCK_STORE : 2,

		/**
	    * Amazon AppStore
	    */
	    CHROME_STORE : 3,

	    /**
	    * Amazon AppStore
	    */
	    AMAZON_STORE : 4,

	    /**
	    * Nook Store
	    */
	    NOOK_STORE : 5
	};

	/**
	* The data structure that represents the information of a purchase.
	* @namespace
	* @constructor
	* @param {string} The transaction id of a purchase.
	* @param {string} The time when the purchase was done in seconds since 1970.
	* @param {CocoonJS.Store.PurchaseState} The state of the purchase. @see CocoonJS.Store.PurchaseState
	* @param {string} The product id related to this purchase.
	* @param {number} The number of products of the productId kind purchased in this transaction.
	*/
	CocoonJS.Store.PurchaseInfo = function(transactionId, purchaseTime, purchaseState, productId, quantity)
	{
		/**
		* The transaction id of a purchase.
		* @field
		* @type string
		*/
		this.transactionId = transactionId;

		/**
		* The time when the purchase was done in seconds since 1970.
		* @field
		* @type string
		*/
		this.purchaseTime = purchaseTime;

		/**
		* The state of the purchase. @see CocoonJS.Store.PurchaseState
		* @field
		* @type CocoonJS.Store.PurchaseState
		*/
		this.purchaseState = purchaseState;

		/**
		* The product id related to this purchase.
		* @field
		* @type string
		*/
		this.productId = productId;

		/**
		* The number of products of the productId kind purchased in this transaction.
		* @field
		* @type number
		*/
		this.quantity = quantity;

		return this;
	};

	/**
    * The predefined possible states of a purchase.
    * @namespace 
    */
	CocoonJS.Store.PurchaseState = 
	{
		/**
		* The product has been successfully purchased. The transaction has ended successfully.
		*/
	    PURCHASED : 0,

		/**
		* The purchase has been canceled.
		*/
	    CANCELED : 1,

	    /**
		* The purchase has been refunded.
		*/
	    REFUNDED : 2,

	    /**
		* The purchase (subscriptions only) has expired and is no longer valid.
		*/
	    EXPIRED : 3
	};

	/**
	* Gets the name of the native store implementation. 
	* @return {CocoonJS.Store.StoreType} The store type
	* @function
	*/ 
	CocoonJS.Store.getStoreType = function()
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "getStoreType", arguments);
		}
	};

	/**
	* Initialize the service with service level initialization parameters.
	* @function
	* @param {object} An object with the required initialization parameters for the service.
	*/
	CocoonJS.Store.requestInitialization = function(parameters)
	{
        if (typeof parameters === "undefined") 
        {
            parameters = {};
        }
        else
        {
        	if (parameters['managed'] !== undefined) parameters['remote'] = parameters['managed'];
        	if (parameters['sandbox'] !== undefined) parameters['debug'] = parameters['sandbox'];
        }

		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "requestInitialization", arguments, true);
		}
	};

	/**
	* Starts the Store Service. 
	* This will make the system to initialize the Store Service and probably Store callbacks will start to be received after calling this method so you should have set your event handler before calling this method so don't lose any callback.
	* @function
	*/ 
	CocoonJS.Store.start = function()
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "start", arguments);
		}
	};

	/**
	* This method allows you to check is the  Store service is available in this platform. 
	* Not all iOS and Android devices will have the Store service available so you should check if it is before calling any other method.
	* @function
	* @return {boolean} True if the service is available and false otherwise.
	*/ 
	CocoonJS.Store.canPurchase = function()
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "canPurchase", arguments);
		}
	};

	/**
	* Fetches the products from the CocoonJS Cloud Compiling service store configuration. 
	* The request is monitored using the {@link CocoonJS.Store.onProductsFetchStarted}, {@link CocoonJS.Store.onProductsFetchCompleted} and {@link CocoonJS.Store.onProductsFetchFailed} event handlers.
	* @deprecated You should now use fetchProductsFromStore. We don't support cloud products now.
	* @function
	* @see CocoonJS.Store.onProductsFetchStarted
	* @see CocoonJS.Store.onProductsFetchCompleted
	* @see CocoonJS.Store.onProductsFetchFailed
	*/ 
	CocoonJS.Store.fetchProductsFromServer = function()
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "fetchProductsFromServer", arguments, true);
		}
	};

	/**
	* Fetches the products information from the Store. 
	* The request is monitored using the {@link CocoonJS.Store.onProductsFetchStarted}, {@link CocoonJS.Store.onProductsFetchCompleted} and {@link CocoonJS.Store.onProductsFetchFailed} event handlers.
	* @function
	* @param {array} productIds An array with the ids of the products to retrieve information from.
	* @see CocoonJS.Store.onProductsFetchStarted
	* @see CocoonJS.Store.onProductsFetchCompleted
	* @see CocoonJS.Store.onProductsFetchFailed
	*/ 
	CocoonJS.Store.fetchProductsFromStore = function(productIds)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "fetchProductsFromStore", arguments, true);
		}
	};

	/**
	* Finish a purchase transaction and removes the transaction from the transaction queue. 
	* This method must be called after a purchase finishes successfully and the  {@link CocoonJS.Store.onProductPurchaseCompleted} callback has been received. 
	* If the purchase includes some asset to download from an external server this method must be called after the asset has been successfully downloaded. 
	* If you do not finish the transaction because the asset has not been correctly downloaded the {@link CocoonJS.Store.onProductPurchaseStarted} method will be called again later on.
	* @function
	* @param {string} transactionId The transactionId of the purchase to finish.
	*/ 
	CocoonJS.Store.finishPurchase = function(transactionId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "finishPurchase", arguments, true);
		}
	};

	/**
	* Consumes a purchase. This makes that product to be purchasable again. 
	* @function
	* @param {string} transactionId The transaction Id of the purchase to consume.
	* @param {string} productId The product Id of the product to be consumed.
	*/ 
	CocoonJS.Store.consumePurchase = function(transactionId, productId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "consumePurchase", arguments, true);
		}
	};

	/**
	* Request a product purchase given it's product id. 
	* The request is monitored using the {@link CocoonJS.Store.onPurchaseProductStarted}, {@link CocoonJS.Store.onProductPurchaseStarted} and {@link CocoonJS.Store.onProductPurchaseFailed} event handlers.
	* @function
	* @param {string} productId The id or alias of the product to be purchased.
	* @see CocoonJS.Store.onProductPurchaseStarted
	* @see CocoonJS.Store.onProductPurchaseCompleted
	* @see CocoonJS.Store.onProductPurchaseFailed
	*/ 
	CocoonJS.Store.purchaseProduct = function(productId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "purchaseFeature", arguments, true);
		}
	};

	/**
	* Request a product purchase given it's product id showing a modal progress dialog. 
	* The request is monitored using the {@link CocoonJS.Store.onProductPurchaseStarted}, {@link CocoonJS.Store.onProductPurchaseCompleted} and {@link CocoonJS.Store.onProductPurchaseFailed} event handlers.
	* @function
	* @param {string} productId The id or alias of the product to be purchased.
	* @see CocoonJS.Store.onProductPurchaseStarted
	* @see CocoonJS.Store.onProductPurchaseCompleted
	* @see CocoonJS.Store.onProductPurchaseFailed
	*/ 
	CocoonJS.Store.puchaseProductModal = function(productId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "purchaseFeatureModal", arguments, true);
		}
	};

	/**
	* Request the purchase of a product given it's product id showing a dialog with a preview of the product (title and description). 
	* The request is monitored using the {@link CocoonJS.Store.onProductPurchaseStarted}, {@link CocoonJS.Store.onProductPurchaseCompleted} and {@link CocoonJS.Store.onProductPurchaseFailed} event handlers.
	* @function
	* @param {string} productId The id or alias of the product to be purchased.
	* @see CocoonJS.Store.onProductPurchaseStarted
	* @see CocoonJS.Store.onProductPurchaseCompleted
	* @see CocoonJS.Store.onProductPurchaseFailed
	*/ 
	CocoonJS.Store.purchaseProductModalWithPreview = function(productId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "purchaseFeatureModalWithPreview", arguments, true);
		}
	};

	/**
	* Returns if a product has been already purchased or not. 
	* @function
	* @param {string} productId The product id or alias of the product to be checked.
	* @returns {boolean} A flag that indicates whether the product has been already purchased (true) or not (false).
	*/
	CocoonJS.Store.isProductPurchased = function(productId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "isFeaturePurchased", arguments);
		}
	};

	/**
	* Restores all the purchases from the platform's market. 
	* For each already purchased product {@link CocoonJS.Store.onPurchaseProductStarted}, {@link CocoonJS.Store.onPurchaseProductCompleted} and {@link CocoonJS.Store.onPurchaseProductFailed} event handlers are called again
	* @function
	* @see CocoonJS.Store.onRestorePurchasesStarted
	* @see CocoonJS.Store.onRestorePurchasesCompleted
	* @see CocoonJS.Store.onRestorePurchasesFailed
	*/
	CocoonJS.Store.restorePurchases = function()
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "restorePurchases", arguments, true);
		}
	};

	/**
	* Restores all the purchases from the platform's market showing a modal progress dialog. 
	* For each already purchased product {@link CocoonJS.Store.onPurchaseProductStarted}, {@link CocoonJS.Store.onPurchaseProductCompleted} and {@link CocoonJS.Store.onPurchaseProductFailed} event handlers are called again
	* @function
	* @see CocoonJS.Store.onRestorePurchasesStarted
	* @see CocoonJS.Store.onRestorePurchasesCompleted
	* @see CocoonJS.Store.onRestorePurchasesFailed
	*/
	CocoonJS.Store.restorePurchasesModal = function()
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "restorePurchasesModal", arguments, true);
		}
	};

	/**
	* Returns all the products available to be purchased.
	* @function
	* @returns {array} An array with  all the {@link CocoonJS.Store.ProductInfo} objects available for purchase.
	*/
	CocoonJS.Store.getProducts = function()
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "getProducts", arguments);
		}
	};

	/**
	* Adds a product to the products local DB. 
	* @function
	* @param {CocoonJS.Store.ProductInfo} product The product to be added to the local products DB.
	*/
	CocoonJS.Store.addProduct = function(product)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "addProduct", arguments);
		}
	};

	/**
	* Removes a product from the products local DB given its productId. 
	* @function
	* @param {string} productId The product or alias of the product to be removed from the local products DB.
	*/
	CocoonJS.Store.removeProduct = function(productId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "removeProduct", arguments);
		}
	};

	/**
	* Returns all the locally stored purchases.
	* @function
	* @returns {array} An array with all the {@link CocoonJS.Store.PurchaseInfo} completed purchases.
	*/
	CocoonJS.Store.getPurchases = function()
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "getPurchases", arguments);
		}
	};

	/**
	* Adds a purchase to the local purchases DB. 
	* @function
	* @param {CocoonJS.Store.StorePurchase} purchase The purchase to be added.
	*/ 
	CocoonJS.Store.addPurchase = function(purchase)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "addPurchase", arguments);
		}
	};

	/**
	* Removes a purchase from the local purchases DB given it's transaction id. 
	* @function
	* @param {string} transactionId The id of the transaction to be removed.
	*/ 
	CocoonJS.Store.removePurchase = function(transactionId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "removePurchase", arguments);
		}
	};

	/**
	* (TESTING ONLY) Simulate a purchase cancel. 
	* This method is not allowed in production services and will only work in Mocks. 
	* The request is monitored using the {@link CocoonJS.Store.onPurchaseProductStarted}, {@link CocoonJS.Store.onProductPurchaseStarted} and {@link CocoonJS.Store.onProductPurchaseFailed} event handlers.
	* @function
	* @param {string} transactionId The transactionId of the purchase to be canceled.
	*/
	CocoonJS.Store.cancelPurchase = function(transactionId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "cancelPurchase", arguments);
		}
	};

	/**
	* (TESTING ONLY) Simulate a purchase refundment. 
	* This method is not allowed in production services and will only work in Mocks. 
	* The request is monitored using the {@link CocoonJS.Store.onPurchaseProductStarted}, {@link CocoonJS.Store.onProductPurchaseStarted} and {@link CocoonJS.Store.onProductPurchaseFailed} event handlers.
	* @function
	* @param {string} transactionId The transactionId of the purchase to be refunded.
	*/
	CocoonJS.Store.refundPurchase = function(transactionId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "refundPurchase", arguments);
		}
	};

	/**
	* (TESTING ONLY) Simulate a purchase expiration. 
	* This method is not allowed in production services and will only work in Mocks. 
	* The request is monitored using the {@link CocoonJS.Store.onPurchaseProductStarted}, {@link CocoonJS.Store.onProductPurchaseStarted} and {@link CocoonJS.Store.onProductPurchaseFailed} event handlers.
	* @function
	* @param {string} transactionId The transactionId of the purchase to be expired.
	*/
	CocoonJS.Store.expirePurchase = function(transactionId)
	{
		if (CocoonJS.Store.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_STORE", "expirePurchase", arguments);
		}
	};

	/**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the products fetch has started.
    * The callback function receives no parameters.
    * @static
    * @event
    */
	CocoonJS.Store.onProductsFetchStarted = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onProductsFetchStarted");

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the products fetch has completed.
    * The callback function receives a parameter with an the valid products array.
    * @static
    * @event
    * @param {array} validProducts An array of {@link CocoonJS.Store.ProductInfo} objects representing all the valid fetched products.
    */
	CocoonJS.Store.onProductsFetchCompleted = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onProductsFetchCompleted"); 

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the products fetch has failed.
    * The callback function receives an error message as a parameter.
    * @static
    * @event
    * @param {string} errorMessage The error message.
    */
	CocoonJS.Store.onProductsFetchFailed = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onProductsFetchFailed"); 

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the purchase of a product starts.
    * The callback function receives a parameters with the information of the purchased product @see CocoonJS.Store.ProductInfo.
    * @static
	* @event
    * @param {string} productId The product id of the product being purchased.
    */
	CocoonJS.Store.onProductPurchaseStarted = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onProductPurchaseStarted"); 

	/**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when a request for purchase verification has been received from the Store.
    * The callback function receives two parameters, one with the productId of the purchased product and another one with a JSON object containing the data to be verified.
    * In Andorid this JSON object will containt two keys: signedData and signature. You will need that information to verify the purchase against the backend server.
    * @static
    * @event
    * @param {string} productId The product id of the product to be verified.
    * @param {string} data The string with the data to be verified.
    */
	CocoonJS.Store.onProductPurchaseVerificationRequestReceived = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onProductPurchaseVerificationRequestReceived");

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the purchase of a product succeeds.
    * The callback function receives as parameter the information of the purchase {@see CocoonJS.Store.PurchaseInfo}.
    * @static
    * @event
    * @param {CocoonJS.Store.PurchaseInfo} purchaseInfo The purchase info.
    */
	CocoonJS.Store.onProductPurchaseCompleted = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onProductPurchaseCompleted"); 

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the purchase of a product fails.
    * The callback function receives a parameters with the product id and an error message.
    * @static
    * @event
    * @param {string} productId The product id.
    * @param {string} msg The error message.
    */
	CocoonJS.Store.onProductPurchaseFailed = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onProductPurchaseFailed"); 

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the restore purchases operation has started.
    * The callback function receives no parameters.
    * @static
    * @event
    */
	CocoonJS.Store.onRestorePurchasesStarted = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onRestorePurchasesStarted"); 

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the restore purchases operation has completed.
    * The callback function receives no parameters.
    * @static
    * @event
    */
	CocoonJS.Store.onRestorePurchasesCompleted = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onRestorePurchasesCompleted"); 

	/**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the restore purchases operation has failed.
    * The callback function receives an error message as a parameter.
    * @static
    * @event
    * @param {string} errorMessage The error message.
    */
	CocoonJS.Store.onRestorePurchasesFailed = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onRestorePurchasesFailed");

	/**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the consume purchase operation has started.
    * @static
    * @event
    * @param {string} transactionId The transaction id of the purchase being consumed.
    */
	CocoonJS.Store.onConsumePurchaseStarted = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onConsumePurchaseStarted"); 

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the consume purchase operation has completed.
    * @static
    * @event
    * @param {string} transactionId The transaction id of the consumed purchase.
    */
	CocoonJS.Store.onConsumePurchaseCompleted = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onConsumePurchaseCompleted"); 

	/**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the consume purchase operation has failed.
    * @static
    * @event
    * @param {string} transactionId The transaction id of the purchase that couldn't be consumed.
    * @param {string} errorMessage The error message.
    */
	CocoonJS.Store.onConsumePurchaseFailed = new CocoonJS.EventHandler("IDTK_SRV_STORE", "Store", "onConsumePurchaseFailed");

})();

//////////////////////////////////////
// COCOONJS_SOCIAL.JS               //
//////////////////////////////////////

(function()
{
    // The CocoonJS must exist before creating the extension.
    if (typeof window.CocoonJS === 'undefined' || window.CocoonJS === null) throw("The CocoonJS object must exist and be valid before creating any extension object.");

	/**
	* This type represents the access to a native Social extension API. As there can be more than
	* one service of this type, more than one instance can be created.
	* @namespace
	* @constructor
	* @param {string} nativeExtensionName The name of the native ext object extension property name.
	* @param {string} extensionName The name of the CocoonJS object extension property name.
	*/
	CocoonJS.Social = function(nativeExtensionName, extensionName)
	{
		if (typeof nativeExtensionName !== 'string') throw "The given native extension name '" + nativeExtensionName + "' is not a string.";
		if (typeof extensionName !== 'string') throw "The given extension name '" + extensionName + "' is not a string.";

		this.nativeExtensionName = nativeExtensionName;
		this.extensionName = extensionName;
	    this.nativeExtensionObjectAvailable = CocoonJS.nativeExtensionObjectAvailable && typeof window.ext[nativeExtensionName] !== 'undefined';

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestInitializationSucceed} event calls.
	     * @name OnRequestInitializationSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {object} initializationData The data structure passed when requestInitialization was called.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user information request suceeds.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestInitializationSucceedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
	    this.onRequestInitializationSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestInitializationSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestInitializationFailed} event calls.
	     * @name OnRequestInitializationFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {object} initializationData The data structure passed when the requestInitialization function was called.
	     * @param {string} errorMessage The message that describes why the request did fail.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user information request fails.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestInitializationFailedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
	    this.onRequestInitializationFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestInitializationFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestLoginSucceed} event calls.
	     * @name OnRequestLoginSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {CocoonJS.Social.UserInfo} userInfo The structure that describes the information of the user that logged in.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user login request succeeds.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestLoginSucceedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onRequestLoginSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestLoginSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestLoginFailed} event calls.
	     * @name OnRequestLoginFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {string} errorMessage The message that describes why the request did fail.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user login request fails.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestLoginFailedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onRequestLoginFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestLoginFailed");

	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user logs out.
	    * The callback function does not receive any parameter.
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onLogout = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onLogout");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestUserInfoSucceed} event calls.
	     * @name OnRequestUserInfoSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {CocoonJS.Social.UserInfo} userInfo The structure that describes the information of the request user id.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user information request suceeds.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnUserInfoRequestSucceedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onRequestUserInfoSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserInfoSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestUserInfoFailed} event calls.
	     * @name OnRequestUserInfoFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {string} userID The id used in the request.
	     * @param {string} errorMessage The message that describes why the request did fail.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user information request fails.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnUserInfoRequestFailedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onRequestUserInfoFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserInfoFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestUserImageURLSucceed} event calls.
	     * @name OnRequestUserImageURLSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {string} userID The id used in the request.
	     * @param {string} imageURL The URL of the image of the requested user. 
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user image URL request succeeds.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestUserImageURLSucceedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onRequestUserImageURLSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserImageURLSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestUserImageURLFailed} event calls.
	     * @name OnRequestUserImageURLFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {string} userID The id of the user the request was placed for.
	     * @param {string} errorMessage The message that describes why the request did fail.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user image URL request fails.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestUserImageURLFailedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onRequestUserImageURLFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserImageURLFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestUserFriendsUserInfosSucceed} event calls.
	     * @name OnRequestUserFriendsUserInfosSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {string} userID The id of the user for whom the friend user infos where requested.
	     * @param {array} friendsInfo An array of {@link CocoonJS.Social.UserInfo} objects representing the information of the friends of the user.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's friends info is successfully retrieved.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestUserFriendsUserInfosSucceedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onRequestUserFriendsUserInfosSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserFriendsUserInfosSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestUserFriendsUserInfosFailed} event calls.
	     * @name OnRequestUserFriendsUserInfosFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param 
	     * @param {string} userID The id of the user fro whom the friends infos were requested.
	     * @param {string} errorMessage The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's friends info fails to be retrieved.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestUserFriendsUserInfosFailedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onRequestUserFriendsUserInfosFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserFriendsUserInfosFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestMessagePublicationSucceed} event calls.
	     * @name OnRequestMessagePublicationSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
 	     * @param {CocoonJS.Social.Message} message The message that has been published.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user message publication request succeeds.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestMessagePublicationSucceedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    * @param {CocoonJS.Social.Message} message The message that has been published.
	    */
		this.onRequestMessagePublicationSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestMessagePublicationSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.Social.onRequestMessagePublicationFailed} event calls.
	     * @name OnRequestMessagePublicationFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.Social
	     * @param {CocoonJS.Social.Message} message The message that was supposed to be published.
	     * @param {string} errorMessage The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user message publication request fails.
	    * The callback function's documentation is represented by {@link CocoonJS.Social.OnRequestMessagePublicationFailedListener}
	    * @static
	    * @event
	    * @memberOf CocoonJS.Social
	    */
		this.onRequestMessagePublicationFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestMessagePublicationFailed");

		/**
        * @ignore
        */
        this.on= function(event, callback) {
            event= "on"+event[0].toUpperCase()+event.substr(1);
            var signal= this[event];
            if (signal) {
                signal.addEventListener(callback);
            } else {
                console.error("SocialGaming service: '"+this.extensionName+"' does not understand '"+event+' signal.');
            }

            return this;
        };

	    return this;
	};

	CocoonJS.Social.prototype = {
        userInfo : null,
        userInfoCocoonJS : null,

        /**
        * @ignore
        */
        getUserInfo : function() {
            return this.userInfo;
        },

        /**
        * Returns the information of the currently logged in user.
        * @return {@link CocoonJS.Social.UserInfo}
        */
        getLoggedInUserInfo : function() {
            if (this.nativeExtensionObjectAvailable) {
                return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "getLoggedInUserInfo", arguments);
            }
            else {
                return this.userInfoCocoonJS;
            }
        },

        /**
        * @ignore
        */
        setUserInfo : function( userInfo) {
            this.userInfo= userInfo;
        },

        /**
        * @ignore
        */
        setUserInfoCocoonJS : function( userInfoCocoonJS ) {
            this.userInfoCocoonJS = userInfoCocoonJS;
        },

		/**
        * Request initialization of the underlying social service.
        * @param {object} paramsObject A data structure to initialize the service. It will be dependable of the underlying service.
        * @see CocoonJS.Social.onRequestInitializationSucceed
        * @see CocoonJS.Social.onRequestInitializationFailed
        */
		requestInitialization : function(paramsObject) 
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestInitialization", arguments, true);
			}
		},

		/**
        * Returns a flag to indicate if the underlying service has been initialized or not.
        * @return {boolean} If the underlying service had been initialized using the requestInitialization function call.
        */
		isInitialized : function()
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "isInitialized", arguments);
			}
			else
			{
				return false;
			}
		},

		/**
		* Request to log in the social gaming application.
		* @see CocoonJS.Social.onRequestLoginSucceed
		* @see CocoonJS.Socual.onRequestLoginFailed
		*/
		requestLogin : function()
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestLogin", arguments, true);
			}
		},

		/**
		* Request to log out of the social gaming application.
		* @see CocoonJS.Social.onRequestLoginSucceed
		* @see CocoonJS.Social.onRequestLoginFailed
		* @see CocoonJS.Social.onLogout
		*/
		requestLogout : function()
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestLogout", arguments, true);
			}
		},

		/**
		* Check if the user is logged in.
		* @return {boolean} true if the user is still logged in, false otherwise.
		*/
		isLoggedIn : function()
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "isLoggedIn", arguments);
			}
			else
			{
				return false;
			}
		},

		/**
		* Returns all the granted permissions for the current session.
		* @return {Array} An array containin the user granted permissions.
		*/
		getPermissions : function() 
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "getPermissions", arguments);
			}
			else
			{
				return new Array();
			}
		},

		/**
		* Check if the user has granted the publish permission for the current session.
		* @return {boolean} true if the user has granted the publish permission for the current session, false otherwise.
		*/
		hasPublishPermission : function() 
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "hasPublishPermission", arguments);
			}
			else
			{
				return false;
			}
		},

		/**
		* Request to retrieve the current or a specific user's id. The request can be monitored using the {@link CocoonJS.Social.onUserInfoRequestSucceed} and {@link CocoonJS.Social.onUserInfoRequestFailed} event handlers.
		* @param {string} [userId] The id of the user to retireve the information from. If no userID is specified, the currently logged in user is assumed.
		* @see CocoonJS.Social.onRequestUserInfoSucceed
		* @see CocoonJS.Social.onRequestUserInfoFailed
		*/
		requestUserInfo : function(userID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestUserInfo", arguments, true);
			}
		},

		/**
		* Request to retrieve the Image of a user
		* @param {string} [userID] The id of the user to get the image for. If no userID is specified, the currently logged user is used.
		* @param {CocoonJS.Social.ImageSizeType} [imageSizeType] The size of the image. One of the possible values among the ones in the {@link CocoonJS.Social.ImageSizeType}. If no value is specified, SMALL is used.
		* @see CocoonJS.Social.onRequestUserImageURLSucceed;
		* @see CocoonJS.Social.onRequestUserImageURLFailed;
		*/
		requestUserImageURL : function( imageSizeType, userID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestUserImageURL", arguments, true);
			}
		},

		/**
		* Request for the information of all the friends of the currently logged user.
		* @param {string} [userID] The id of the user to get the friends infos for. If no userID is specified, the currently logged user is used.
		* @see CocoonJS.Social.onRequestUserFriendsUserInfosSucceed;
		* @see CocoonJS.Social.onRequestUserFriendsUserInfosFailed;
		*/
		requestUserFriendsUserInfos : function(userID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestUserFriendsUserInfos", arguments, true);
			}
		},

		/**
		* Request the publication of a message using a dialog.
		* @param {CocoonJS.Social.Message} message A object representing the information to be published.
		* @see CocoonJS.Social.onRequestMessagePublicationSucceed
		* @see CocoonJS.Social.onRequestMessagePublicationFailed
		*/
		requestMessagePublicationWithDialog : function(message)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestMessagePublicationWithDialog", arguments, true);
			}
		}
	};

	/**
	* This structure represents the possible images to be obtained for a user in the social gaming extension.
	* @namespace
	*/
	CocoonJS.Social.ImageSizeType = 
	{
		/**
		* Represent a thumbnail like image size.
		*/
	    THUMB : "thumb",

		/**
		* Represents the small image size.
		*/
	    SMALL : "small",

		/**
		* Represents the medium image size.
		*/
	    MEDIUM : "medium",

		/**
		* Represents the large image size.
		*/
	    LARGE : "large"
	};

	/**
	* The data structure that represents the information of a user inside the social gaming extension.
	* @namespace
	* @constructor
	* @param {string} userID The id of the user.
	* @param {string} userName The user name of the user.
	*/
	CocoonJS.Social.UserInfo = function(userID, userName)
	{
		/**
		* The id of the user.
		* @field
		* @type string
		*/
		this.userID = userID;

		/**
		* The user name of the user.
		* @field
		* @type string
		*/
		this.userName = userName;
	};

	/**
	* This type represents a message to be published.
	* @namespace
	* @constructor
	* @param {string} message The message to be published.
	* @param {string} mediaURL An URL to a media (image, video, ...)
	* @param {string} linkURL An URL to add to the message so the user can click on that link to get more information.
	* @param {string} linkText The text that will appear in the message link.
	* @param {string} linkCaption The text caption that will appear in the message link.
	*/
	CocoonJS.Social.Message = function(message, mediaURL, linkURL, linkText, linkCaption)
	{
		/**
		* The message to be published.
		* @field
		* @type string
		*/
		this.message = message;

		/**
		* An URL to a media (image, video, ...)
		* @field
		* @type string
		*/
		this.mediaURL = mediaURL;

		/**
		* An URL to add to the message so the user can click on that link to get more information.
		* @field
		* @type string
		*/
		this.linkURL = linkURL;

		/**
		* The text that will appear in the message link.
		* @field
		* @type string
		*/
		this.linkText = linkText;

		/**
		* The text caption that will appear in the message link.
		* @field
		* @type string
		*/
		this.linkCaption = linkCaption;

		return this;
	};

})();

//////////////////////////////////////
// COCOONJS_SOCIALGAMING.JS         //
//////////////////////////////////////

(function()
{
    // The CocoonJS must exist before creating the extension.
    if (typeof window.CocoonJS === 'undefined' || window.CocoonJS === null) throw("The CocoonJS object must exist and be valid before creating any extension object.");

    if (!CocoonJS.Social)
		throw("The CocoonJS.Social object must exist and be valid before creating any extension object.");

	/**
	* This type represents the access to a native Social Gamming extension API. As there can be more than
	* one service of this type, more than one instance can be created.
	* @namespace
	* @constructor
	* @param {string} nativeExtensionName The name of the native ext object extension property name.
	* @param {string} extensionName The name of the CocoonJS object extension property name.
	*/
	CocoonJS.SocialGaming = function(nativeExtensionName, extensionName)
	{
		CocoonJS.SocialGaming.superclass.constructor.call(this, nativeExtensionName, extensionName);

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestUserAndFriendsScoresSucceed} event calls.
	     * @name OnRequestUserAndFriendsScoresSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {array} userAndFriendsScoreInfos An array of {@link CocoonJS.SocialGaming.UserScoreInfo} objects representing the information of the user's and friends' scores.
	     */
		/**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user and friends scores request succeeds.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestUserAndFriendsScoresSucceedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestUserAndFriendsScoresSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserAndFriendsScoresSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestUserAndFriendsScoresFailed} event calls.
	     * @name OnRequestUserAndFriendsScoresFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the score and friends scores were requested.
	     * @param {string} leadeboardID The id of the leaderboard for whom the score and friends scores were requested.
	     * @param {string} errorMessage The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user and his/her friends scores request fails.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestUserAndFriendsScoresFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestUserAndFriendsScoresFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserAndFriendsScoresFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestUserScoreSucceed} event calls.
	     * @name OnRequestUserScoreSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {CocoonJS.SocialGaming.UserScoreInfo} userScoreInfo The info of the user's score.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's score information request suceeds.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestUserScoreSucceedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestUserScoreSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserScoreSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestUserScoreFailed} event calls.
	     * @name OnRequestUserScoreFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the score was requested.
	     * @param {string} leaderboardID The id of the leaderboard for whom the score was requested.
	     * @param {string} errorMessage The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's score information request fails.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestUserScoreFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestUserScoreFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserScoreFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onSubmitUserScoreSucceed} event calls.
	     * @name OnSubmitUserScoreSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the score has been submitted.
	     * @param {string} leaderboardID The id of the leaderboard for which the score has been submitted.
	     * @param {number} score The score that has been submitted.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's score submit suceeds.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnSubmitUserScoreSucceedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onSubmitUserScoreSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onSubmitUserScoreSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onSubmitUserScoreFailed} event calls.
	     * @name OnSubmitUserScoreFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the score submition was requested.
	     * @param {string} leaderboadID The id of the leaderboard for which the score submition was requested.
	     * @param {number} score The score that was submitted and failed.
	     * @param {string} errorMessage The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's score submit fails.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnSubmitUserScoreFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onSubmitUserScoreFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onSubmitUserScoreFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestUserAchievementsSucceed} event calls.
	     * @name OnRequestUserAchievementsSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the achievements where requested.
	     * @param {array} achievementsInfos An array of {@link CocoonJS.SocialGaming.AchievementInfo} objects representing the information of the user's achievements.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's achievements info are successfully retrieved.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestUserAchievementsSucceedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestUserAchievementsSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserAchievementsSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestUserAchievementsFailed} event calls.
	     * @name OnRequestUserAchievementsFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the achievements were requested.
	   	 * @param {string} msg The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's achievmeents info fails to be retrieved.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestUserAchievementsFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestUserAchievementsFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestUserAchievementsFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestAllAchievementsSucceed} event calls.
	     * @name OnRequestAllAchievementsSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {array} achievementsInfos An array of {@link CocoonJS.SocialGaming.AchievementInfo} objects representing the information of all the achievements.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's achievements info are successfully retrieved.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestAllAchievementsSucceedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestAllAchievementsSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestAllAchievementsSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestAllAchievementsFailed} event calls.
	     * @name OnRequestAllAchievementsFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	   	 * @param {string} msg The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the user's achievmeents info fails to be retrieved.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestAllAchievementsFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestAllAchievementsFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestAllAchievementsFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestAchievementInfoSucceed} event calls.
	     * @name OnRequestAchievementInfoSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {CocoonJS.SocialGaming.AchievementInfo} achievementInfo A {@link CocoonJS.SocialGaming.AchievementInfo} object representing the information of the achievement.
	     */
		/**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the request to retrieve the information of an achievement succeeds.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestAchievementInfoSucceedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestAchievementInfoSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestAchievementInfoSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onRequestAchievementInfoFailed} event calls.
	     * @name OnRequestAchievementInfoFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} achievementID The id of the achievement for which the information retrieval was requested.
	     * @param {string} errorMessage The error message.
	     */
		/**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the request to retrieve the information of an achievement fails.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnRequestAchievementInfoFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onRequestAchievementInfoFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onRequestAchievementInfoFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onSubmitUserAchievementSucceed} event calls.
	     * @name OnSubmitUserAchievementSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the achievement has been submitted.
	     * @param {string} achievementID The id of the achievement that has been submitted.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a user's achievement submition succeeds.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnSubmitUserAchievementSucceedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onSubmitUserAchievementSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onSubmitUserAchievementSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onSubmitUserAchievementFailed} event calls.
	     * @name OnSubmitUserAchievementFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the achievment was submitted.
	     * @param {string} achievementID The id of the achievement that was submitted.
	     * @param {string} msg The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a user's achievement submition fails.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnSubmitUserAchievementFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onSubmitUserAchievementFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onSubmitUserAchievementFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onResetUserAchievementsSucceed} event calls.
	     * @name OnResetUserAchievementsSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the achievements were reset.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a user's achievement reset succeeds.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnResetUserAchievementsSucceedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onResetUserAchievementsSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onResetUserAchievementsSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onResetUserAchievementsFailed} event calls.
	     * @name OnResetUserAchievementsFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} userID The id of the user for whom the achievements where tried to be reset.
	     * @param {string} msg The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a user's achievement reset fails.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnResetUserAchievementsFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onResetUserAchievementsFailed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onResetUserAchievementsFailed");

	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the users closes the achievements view.
	    * The callback function does not receive any parameter.
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onAchievementsViewClosed  = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onAchievementsViewClosed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onAchievementsViewFailed} event calls.
	     * @name OnAchievementsViewFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} errorMessage The message that describes why the call failed.
	     */
		/**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when the achievements view failed to show.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnAchievementsViewFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onAchievementsViewFailed  = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onAchievementsViewFailed");

		/**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when achievements view shows successfully.
	    * The callback function does not receive any parameter.
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
		this.onAchievementsViewSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onAchievementsViewSucceed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onLeaderboardViewClosed} event calls.
	     * @name OnLeaderboardViewClosedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} leaderboardID The id of the leaderboard for which it's vew was requested to be shown.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a user's achievement reset fails.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnLeaderboardViewClosedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
   		this.onLeaderboardViewClosed  = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onLeaderboardViewClosed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onLeaderboardViewFailed} event calls.
	     * @name OnLeaderboardViewFailedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} leaderboardID The id of the leaderboard for which it's vew was requested to be shown.
	     * @param {string} errorMessage The error message.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a user's achievement reset fails.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnLeaderboardViewFailedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
   		this.onLeaderboardViewFailed  = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onLeaderboardViewFailed");

	    /**
	     * FOR DOCUMENTATION PURPOSE ONLY! The documentation of the function callback for the {@link CocoonJS.SocialGaming.onLeaderboardViewSucceed} event calls.
	     * @name OnLeaderboardViewSucceedListener
	     * @function
	     * @static
	     * @memberOf CocoonJS.SocialGaming
	     * @param {string} leaderboardID The id of the leaderboard for which it's vew was requested to be shown.
	     */
	    /**
	    * This {@link CocoonJS.EventHandler} object allows listening to events called when a user's achievement reset fails.
	    * The callback function's documentation is represented by {@link CocoonJS.SocialGaming.OnLeaderboardViewSucceedListener}
	    * @event
	    * @static
	    * @memberOf CocoonJS.SocialGaming
	    */
   		this.onLeaderboardViewSucceed = new CocoonJS.EventHandler(this.nativeExtensionName, this.extensionName, "onLeaderboardViewSucceed");

		return this;
	};

	CocoonJS.SocialGaming.prototype = 
	{
        abstractToSocialGamingAchievementMap : null,
        abstractToSocialGamingAchievementMapInverse : null,

        /**
        * @ignore
        */
        setAbstractToSocialGamingAchievementMap : function( map ) {
            this.abstractToSocialGamingAchievementMap= map;

            // build a reciprocal map.
            this.abstractToSocialGamingAchievementMapInverse= {};
            for( var id in map ) {
                if ( map.hasOwnProperty(id) ) {
                    this.abstractToSocialGamingAchievementMapInverse[ map[id] ]= id;
                }
            }
            return this;
        },

        /**
        * @ignore
        */
        getAbstractToSocialGamingAchievementTranslation : function( achievementID ) {
            /**
             * If a translation map for abstract in-game achievements has been set, translate achievementID from
             * abstract to SocialGamingService.
             */
            if (this.abstractToSocialGamingAchievementMap) {
                var socialGamingAchievementID = this.abstractToSocialGamingAchievementMap[achievementID];
                if (socialGamingAchievementID) {
                    console.log("Abstract achieventID='" + achievementID + "' turned to '" + socialGamingAchievementID + "'");
                    achievementID = socialGamingAchievementID;
                } else {
                    console.log("Something may be wrong: abstract achievementID: '" + achievementID + "' w/o translation.")
                }
            }

            return achievementID;
        },

		/**
		* Request to retrieve the scores of all friends of a given user.
		* @param {string} [leaderboardID] The id of the leaderboard to request the scores for.
		* @param {string} [userID] The id of the user. If null or undefined is passed, the currently logged in user id is used.
		* @see CocoonJS.SocialGaming.onRequestUserAndFriendsScoresSucceed
		* @see CocoonJS.SocialGaming.onRequestUserAndFriendsScoresFailed
		*/
		requestUserAndFriendsScores : function(leaderboardID, userID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestUserAndFriendsScores", arguments, true);
			}
		},

		/**
		* Request to retrieve the score of a user.
		* @param {string} [leaderboardID] The id of the scores leaderboard to retireve the score from. If null or underfined is passed, the "leadeboard" id will be used.
		* @param {string} [userID] The id of the user to retireve the score from. If null or undefined is passed, the currently logged in user id is used.
		* @see CocoonJS.SocialGaming.onRequestUserScoreSucceed
		* @see CocoonJS.SocualGaming.onRequestUserScoreFailed
		*/
		requestUserScore : function(leaderboardID, userID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestUserScore", arguments, true);
			}
		},

		/**
		* Request to the server the score of a user.
		* @param {number} [score] the score to submit
		* @param {string} [leaderboardID] The id of the scores leaderboard to submit the score to. If null or underfined is passed, the "leadeboard" id will be used.
		* @param {string} [userID] The id of the user to submit the score for. If null or undefined is passed, the currently logged in user id is used.
		* @see CocoonJS.SocialGaming.onSubmitUserScoreSucceed
		* @see CocoonJS.SocualGaming.onSubmitUserScoreFailed
		*/
		submitUserScore : function(score, leaderboardID, userID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "submitUserScore", arguments, true);
			}
		},
		/**
		* Shows the leaderboard using a platform dependant view.
		* @param {string} [leaderboardID] The id of the scores leaderboard to show the view for. If null or underfined is passed, the "leadeboard" id will be used.
		* @see CocoonJS.SocialGaming.onLeaderboardViewClosed
		*/
		showLeaderboardView : function(leaderboardID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "showLeaderboardView", arguments, true);
			}
		},

		/**
		* Request to retrieve the user achievements. The request can be monitored using the {@link CocoonJS.SocialGaming.onRequestUserAchievementsSucceed} and {@link CocoonJS.Social.onRequestUserAchievementsFailed} event handlers.
		* @param {string} [userID] The id of the user to retireve the achievements from. if null/undefined/"" is specified, the currently logged in user is assumed.
		* @see CocoonJS.SocialGaming.onRequestUserAchievementsSucceed
		* @see CocoonJS.SocialGaming.onRequestUserAchievementsFailed
		*/
		requestUserAchievements : function(userID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestUserAchievements", arguments, true);
			}
		},

		/**
		* Request to retrieve all the achievements. The request can be monitored using the {@link CocoonJS.SocialGaming.onRequestAllAchievementsSucceed} and {@link CocoonJS.Social.onRequestAllAchievementsFailed} event handlers.
		* @see CocoonJS.SocialGaming.onRequestAllAchievementsSucceed
		* @see CocoonJS.SocialGaming.onRequestAllAchievementsFailed
		*/
		requestAllAchievements : function()
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestAllAchievements", arguments, true);
			}
		},

		/**
		* Request to retrieve the information about an achievement. 
		* @param {string} achievementID The id of the achievement to get the information for.
		* @param {CocoonJS.Social.ImageSizeType} [imageSizeType] The size of the image. One of the possible values among the ones in the {@link CocoonJS.Social.ImageSizeType}
		*/
		requestAchievementInfo : function(achievementID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "requestAchievementInfo", arguments, true);
			}
		},

		/**
		* Submits an achievement to the server. If the process fails, the achievement is stored to submit it later.
		* @param {string} [achievementID] the achievement identifier
		* @param {number} [percentComplete] an optional number between 0 and 100 that indicates a completion percentage.
		* @see CocoonJS.SocialGaming.onSubmitAchievementSucceed
		* @see CocoonJS.SocualGaming.onSubmitAchievementFailed
		*/
        submitUserAchievement:function (achievementID, userID) {
            achievementID = this.getAbstractToSocialGamingAchievementTranslation(achievementID);

            if (this.nativeExtensionObjectAvailable) {
                return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "submitUserAchievement", arguments, true);
            }
        },

		/**
		* Shows the achievements using a platform dependant view.
		* @see CocoonJS.SocialGaming.onAchievementsViewClosed
		*/
		showUserAchievementsView : function(userID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "showUserAchievementsView", arguments, true);
			}
		},

		/**
		* Resets all the achievements of the current user
		* @param {string} [userID] The id of the user to reset the achievements for. If null/undefined/"", the logged in user is assumed.
		* @see CocoonJS.SocialGaming.onResetAchievementsSucceed
		* @see CocoonJS.SocualGaming.onResetAchievementsFailed
		*/
		resetUserAchievements : function(userID)
		{
			if (this.nativeExtensionObjectAvailable)
			{
				return CocoonJS.makeNativeExtensionObjectFunctionCall(this.nativeExtensionName, "resetUserAchievements", arguments, true);
			}
		}
	};

	/**
    * @ignore
    */
	CocoonJS.extend(CocoonJS.SocialGaming, CocoonJS.Social);

	/**
	* The data structure that represents the information of the user score in the application.
	* @namespace
	* @constructor
	* @param {string} userID The user id.
	* @param {number} score The score of the user.
	* @param {string} userName The name of the user.
	* @param {string} imageURL The url of the user image.
	* @param {number} leaderboardID The id of the leaderboard the score belongs to.
	*/
	CocoonJS.SocialGaming.UserScoreInfo = function(userID, score, userName, imageURL, leaderboardID)
	{
		/**
		* The user id. 
		* @type string
		*/
		this.userID = userID;

		/**
		* The score of the user.
		* @type number
		*/
		this.score = score ? score : 0;

		/**
		* The name of the user.
		* @type string
		*/
        this.userName = userName;

		/**
		* The url of the user image.
		* @type string
		*/
        this.imageURL = imageURL;

        /**
		* The id of the leaderboard the score belongs to.
		* @type number
		*/
        this.leaderboardID = leaderboardID;
	};

	/**
	* The data structure that represents the information of an achievement in the application.
	* @namespace
	* @constructor
	* @param {string} achievementID The id of the achievement info.
	* @param {string} title The title of the achievement.
	* @param {string} description The description of the achievement.
	* @param {string} imageURL The url to the image representing the achievement.
	* @param {number} points The points value of the achievement
	*/
	CocoonJS.SocialGaming.AchievementInfo = function(achievementID, title, description, imageURL, points)
	{
		/**
		* The id of the achievement info.
		* @type string
		*/
		this.achievementID = achievementID;

		/**
		* The title of the achievement.
		* @type string
		*/
		this.title = title;

		/**
		* The description of the achievement.
		* @type string
		*/
		this.description = description;

		/**
		* The url to the image representing the achievement.
		* @type string
		*/
		this.imageURL = imageURL;

		/**
		* The points value of the achievement
		* @type number
		*/
		this.points = points ? points : 0;
	};

})();

/////////////////////////////////////////
// COCOONJS_SOCIALGAMING_GAMECENTER.JS //
/////////////////////////////////////////

(function()
{
    // The CocoonJS must exist before creating the extension.
    if (typeof window.CocoonJS === 'undefined' || window.CocoonJS === null) throw("The CocoonJS object must exist and be valid before creating any extension object.");
    if (typeof window.CocoonJS.SocialGaming === 'undefined' || window.CocoonJS === null) throw("The CocoonJS.SocialGaming object must exist and be valid before creating a Game Center extension object.");

	/**
	* This instance represents the extension object to access GameCenter related native functionalities.
	* The data structure for initialization: None.
	* @see CocoonJS.Social
	*/
	CocoonJS.SocialGaming.GameCenter = new CocoonJS.SocialGaming("IDTK_SRV_SOCIAL_GAMECENTER", "SocialGaming.GameCenter");
})();

//////////////////////////////
// COCOONJS_GAMEPAD.JS 		//
//////////////////////////////

(function () {
    // The CocoonJS must exist before creating the extension.
    if (typeof window.CocoonJS === 'undefined' || window.CocoonJS === null) throw("The CocoonJS object must exist and be valid before creating any extension object.");

    /**
     * This namespace represents the functionalities related to OUYA android gaming control.
     * @namespace
     */
    CocoonJS.Gamepad = {};

    CocoonJS.Gamepad.nativeExtensionObjectAvailable = CocoonJS.nativeExtensionObjectAvailable && typeof window.ext.Gamepad !== 'undefined';

    CocoonJS.Gamepad.Indices = {
        BUTTON_0                : 0, 
        BUTTON_1                : 1,
        BUTTON_2                : 2,
        BUTTON_3                : 3,
        BUTTON_LEFT_BUMPER      : 4,
        BUTTON_RIGHT_BUMPER     : 5,
        
        BUTTON_LEFT_TRIGGER     : 6,
        BUTTON_RIGHT_TRIGGER    : 7,
        
        BUTTON_LEFT_JOYSTICK    : 10,
        BUTTON_RIGHT_JOYSTICK   : 11,
        BUTTON_DPAD_UP          : 12,
        BUTTON_DPAD_DOWN        : 13,
        BUTTON_DPAD_LEFT        : 14,
        BUTTON_DPAD_RIGHT       : 15,
        
        AXE_LEFT_JOYSTICK_X     : 0,
        AXE_LEFT_JOYSTICK_Y     : 1,
        AXE_RIGHT_JOYSTICK_X    : 2,
        AXE_RIGHT_JOYSTICK_Y    : 3
    };

    // If the extension is present and the navigator does not provide the gamepad API:
    // 1.- Add the getGamepads function to the navigator object.
    // 2.- Replace the window add and remove event listener functions to call to the extension for the gamepad related events.
    var systemSupportsGamepads = navigator["getGamepads"] || navigator["webkitGetGamepads"];
    if (CocoonJS.Gamepad.nativeExtensionObjectAvailable && !systemSupportsGamepads)
    {
        navigator.getGamepads = function()
        {
            return window.ext.Gamepad.makeCall("getGamepads");
        };

        CocoonJS.Gamepad.originalWindowAddEventListener = window.addEventListener;
        CocoonJS.Gamepad.originalWindowRemoveEventListener = window.removeEventListener;

        window.addEventListener = function(eventName, callback)
        {
            console.log("The new window.addEventListener has been called.");
            if (eventName === "gamepadconnected" || eventName === "gamepaddisconnected")
            {
                window.ext.Gamepad.addEventListener(eventName, callback);
            }
            else
            {
                var argumentsArray = Array.prototype.slice.call(arguments);
                CocoonJS.Gamepad.originalWindowAddEventListener.apply(window, argumentsArray);
            }
        };
        window.removeEventListener = function(eventName, callback)
        {
            console.log("The new window.removeEventListener has been called.");
            if (eventName === "gamepadconnected" || eventName === "gamepaddisconnected")
            {
                window.ext.Gamepad.removeEventListener(eventName, callback);
            }
            else
            {
                var argumentsArray = Array.prototype.slice.call(arguments);
                CocoonJS.Gamepad.originalWindowRemoveEventListener.apply(window, argumentsArray);
            }
        };
    }
})();

//////////////////////////////
// COCOONJS_NOTIFICATION.JS //
//////////////////////////////

(function()
{
    // The CocoonJS must exist before creating the extension.
    if (typeof window.CocoonJS === 'undefined' || window.CocoonJS === null) throw("The CocoonJS object must exist and be valid before creating any extension object.");

    /**
    * This namespace represents the CocoonJS Notification extension.
    * @namespace
    */
    CocoonJS.Notification = {};

    CocoonJS.Notification.nativeExtensionObjectAvailable = CocoonJS.nativeExtensionObjectAvailable && typeof window.ext.IDTK_SRV_NOTIFICATION !== 'undefined';

	/**
	* The data structure that represents the information of a local notification.
	* @namespace
	* @constructor
	* @param {string} message The notification message.
	* @param {boolean} soundEnabled A flag that indicates if the sound should be enabled for the notification.
	* @param {number} badgeNumber The number that will appear in the badge of the application icon in the home screen.
	* @param {object} userData The JSON data to attached to the notification.
	* @param {string} contentBody The body content to be showed in the expanded notification information.
	* @param {string} contentTitle The title to be showed in the expanded notification information.
	* @param {number} date Time in millisecs from 1970 when the notification will be fired.
	*/
	CocoonJS.Notification.LocalNotification = function(message, soundEnabled, badgeNumber, userData, contentBody, contentTitle, scheduleTime)
	{
		/**
		* The notification message.
		* @field
		* @type string
		*/
		this.message = message;

		/**
		* A flag that indicates if the sound should be enabled for the notification.
		* @field
		* @type boolean
		*/
		this.soundEnabled = soundEnabled;

		/**
		* (iOS only) The number that will appear in the badge of the application icon in the home screen.
		* @field
		* @type number
		*/
		this.badgeNumber = badgeNumber;

		/**
		* The JSON data to attached to the notification.
		* @field
		* @type object
		*/
		this.userData = userData;

		/**
		* (Android only) The body content to be showed in the expanded notification information.
		* @field
		* @type string
		*/
		if (contentBody !== undefined)
			this.contentBody = contentBody;
		else
			this.contentBody = "";

		/**
		* (Android only) The title to be showed in the expanded notification information.
		* @field
		* @type string
		*/
		if (contentTitle !== undefined)
			this.contentTitle = contentTitle;
		else
			this.contentTitle = "";

		/**
		* Time in millisecs from 1970 when the local notification will be fired
		* @field
		* @type number
		*/
		var currentTime = new Date().getTime();
		if (scheduleTime !== undefined){
			this.scheduleTime = scheduleTime;
		}else{
			this.scheduleTime = currentTime;
		}
	};

	/**
	* The data structure that represents the information of a push notification.
	* @namespace
	* @constructor
	* @param {string} message The notification message.
	* @param {boolean} soundEnabled A flag that indicates if the sound should be enabled for the notification.
	* @param {number} badgeNumber The number that will appear in the badge of the application icon in the home screen.
	* @param {object} userData The JSON data to attached to the notification.
	* @param {array} channels An array containing the channels names this notification will be delivered to.
	* @param {number} expirationTime A time in seconds from 1970 when the notification is no longer valid and will not be delivered in case it has not already been delivered.
	* @param {number} expirationTimeInterval An incremental ammount of time in from now when the notification is no longer valid and will not be delivered in case it has not already been delivered.
	*/
	CocoonJS.Notification.PushNotification = function(message, soundEnabled, badgeNumber, userData, channels, expirationTime, expirationTimeInterval)
	{
		/**
		* The notification message.
		* @field
		* @type string
		*/
		this.message = message;

		/**
		* A flag that indicates if the sound should be enabled for the notification.
		* @field
		* @type boolean
		*/
		this.soundEnabled = soundEnabled;

		/**
		* The number that will appear in the badge of the application icon in the home screen.
		* @field
		* @type number
		*/
		this.badgeNumber = badgeNumber;

		/**
		* The JSON data to attached to the notification.
		* @field
		* @type object
		*/
		this.userData = userData

		/**
		* An array containing the channels names this notification will be delivered to.
		* @field
		* @type array
		*/
		this.channels = channels;

		/**
		* A time in seconds from 1970 when the notification is no longer valid and will not be delivered in case it has not already been delivered.
		* @field
		* @type number
		*/
		if (expirationTime !== undefined)
			this.expirationTime = expirationTime;
		else
			this.expirationTime = 0;

		/**
		* An incremental ammount of time in from now when the notification is no longer valid and will not be delivered in case it has not already been delivered.
		* @field
		* @type number
		*/
		if (expirationTimeInterval !== undefined)
			this.expirationTimeInterval = expirationTimeInterval;
		else
			this.expirationTimeInterval = 0;
	};

	/**
	* Start processing received notifications. The user must call this method when the game is ready to process notifications. Notifications received before being prepared are stored and processed later.
	*/
	CocoonJS.Notification.start = function()
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "start", arguments, true);
		}
	};


	/**
	* Register to be able to receive push notifications.
	* The registration process is controlled using the {@link CocoonJS.Notification.onRegisterForPushNotificationsSucceed} and {@link CocoonJS.Notification.onRegisterForPushNotificationsFailed} event handlers.
	* @function
	* @see {CocoonJS.Notification.onRegisterForPushNotificationsSucceed}
	* @see {CocoonJS.Notification.onRegisterForPushNotificationsFailed}
	*/
	CocoonJS.Notification.registerForPushNotifications = function()
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "registerForPushNotifications", arguments, true);
		}
	};

	/**
	* Unregister from receiving push notifications.
	* The unregistration process is controlled using the {@link CocoonJS.Notification.onUnregisterForPushNotificationsSucceed} event handler.
	* @function
	* @see CocoonJS.Notification.onUnregisterForPushNotificationsSucceed
	*/
	CocoonJS.Notification.unregisterForPushNotifications = function()
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "unregisterForPushNotifications", arguments, true);
		}
	};

	/**
	* Cancel the last sent local notification.
	* The last sent local notification will be remove from the notifications bar.
	* @function
	*/
	CocoonJS.Notification.cancelLastSentLocalNotificiation = function()
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "cancelLocalNotification", arguments, true);
		}
	};

	/**
	* Cancel all sent local notifications.
	* All the notifications will ve removed from the notifications bar.
	* @function
	*/
	CocoonJS.Notification.cancelAllLocalNotifications = function()
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "cancelAllLocalNotifications", arguments, true);
		}
	};

	/**
	* Send a local notification.
	* @function
	* @param {CocoonJS.Notification.LocalNotification} localNotification The local notification to be sent.
	*/
	CocoonJS.Notification.sendLocalNotification = function(localNotification)
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "sendLocalNotification", arguments, true);
		}
	};

	/**
	* Subscribe to a channel in order to receive notifications targeted to that channel.
	* @function
	* @param {string} channel The channel id to subscribe to.
	*/
	CocoonJS.Notification.subscribeToChannel = function(channel)
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "subscribe", arguments, true);
		}
	};

	/**
	* Unsubscribe from a channel in order to stop receiving notifications targeted to it.
	* @function
	* @param {string} channel The channel id to unsubscribe from.
	*/
	CocoonJS.Notification.unsubscribeFromChannel = function(channel)
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "unsubscribe", arguments, true);
		}
	};

	/**
	* Send a push notification.
	* @function
	* @param {CocoonJS.Notification.PushNotification} pushNotification The push notification object to be sent.
	* @see CocoonJS.Notification.onPushNotificationDeliverySucceed
	* @see CocoonJS.Notification.onPushNotificationDeliveryFailed
	*/
	CocoonJS.Notification.sendPushNotification = function(pushNotification)
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "sendPushNotification", arguments, true);
		}
	};

	/**
	* (iOS only) Set the badge number for this application.
	* This is useful if you want to modify the badge number set by a notification.
	* @function
	* @param {number} badgeNumber The number of the badge.
	*/
	CocoonJS.Notification.setBadgeNumber = function(badgeNumber)
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "setBadgeNumber", arguments);
		}
	};

	/**
	* (iOS only) Returns the current badge number.
	* @function
	* @returns {number} The badge number.
	*/
	CocoonJS.Notification.getBadgeNumber = function()
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "getBadgeNumber", arguments);
		}
	};

	/**
	* Returns the last received user data from a Local notification.
	* @function
	* @returns {object} The last received user data from a Local notification.
	*/
	CocoonJS.Notification.getLastReceivedLocalNotificationData = function()
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "getLastReceivedLocalNotificationData", arguments);
		}
	};

	/**
	* Returns the last received user data from a Push notification.
	* @function
	* @returns {object} The last received user data from a Push notification.
	*/
	CocoonJS.Notification.getLastReceivedPushNotificationData = function()
	{
		if (CocoonJS.Notification.nativeExtensionObjectAvailable)
		{
			return CocoonJS.makeNativeExtensionObjectFunctionCall("IDTK_SRV_NOTIFICATION", "getLastReceivedPushNotificationData", arguments);
		}
	};

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the registration for push notification succeeds.
    * The callback function does not receive any parameter.
    * @static
    * @event
    * @param {string} token The token (apid or device token) received at registration time.
    * @memberOf CocoonJS.Notification
    */
	CocoonJS.Notification.onRegisterForPushNotificationsSucceed = new CocoonJS.EventHandler("IDTK_SRV_NOTIFICATION", "Notification", "pushNotificationServiceRegistered");

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the unregistration for push notifications succeeds.
    * The callback function does not receive any parameter.
    * @static
    * @event
    * @memberOf CocoonJS.Notification
    */
	CocoonJS.Notification.onUnregisterForPushNotificationsSucceed = new CocoonJS.EventHandler("IDTK_SRV_NOTIFICATION", "Notification", "pushNotificationServiceUnregistered");

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the registration for push notifications fails.
    * The callback function receives a parameter with error information.
    * @static
    * @event
    * @param {string} msg The error message.
    */
	CocoonJS.Notification.onRegisterForPushNotificationsFailed = new CocoonJS.EventHandler("IDTK_SRV_NOTIFICATION", "Notification", "pushNotificationServiceFailedToRegister");

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when a push notification is received.
    * The callback function receives a parameter with the userData of the received notification.
    * @static
    * @event
    * @param {object} userData An object with the notification userData information.
    */
	CocoonJS.Notification.onPushNotificationReceived = new CocoonJS.EventHandler("IDTK_SRV_NOTIFICATION", "Notification", "pushNotificationReceived");

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when a local notification is received.
    * The callback function receives a parameter with the userData of the received notification.
    * @static
    * @event
    * @param {object} userData An object with the notification userData information.
    */
	CocoonJS.Notification.onLocalNotificationReceived = new CocoonJS.EventHandler("IDTK_SRV_NOTIFICATION", "Notification", "localNotificationReceived");

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when a notification is successfully delivered.
    * The callback function receives a parameter with the notificationId of the delivered notification.
    * @static
    * @event
    * @param {string} userData A string with the notification userData information.
    */
	CocoonJS.Notification.onPushNotificationDeliverySucceed = new CocoonJS.EventHandler("IDTK_SRV_NOTIFICATION", "Notification", "pushNotificationSuccessfullyDelivered");

    /**
    * This {@link CocoonJS.EventHandler} object allows listening to events called when the delivery of push a notification fails.
    * The callback function receives a parameter with error information.
    * @static
    * @event
    * @param {string} msg The error message.
    */
	CocoonJS.Notification.onPushNotificationDeliveryFailed = new CocoonJS.EventHandler("IDTK_SRV_NOTIFICATION", "Notification", "pushNotificationDeliveryError");

})();

/////////////////
// PATHFIND.JS //
/////////////////

// Pathfind.js
// Written by Ashley Gullen
// Copyright (c) 2013 Scirra Ltd.

// A* pathfinding javascript implementation

(function() {
	
	var PF_CLEAR = 0;
	var PF_OBSTACLE = 32767;
	
	function node()
	{
		this.parent = null;
		
		this.x = 0;
		this.y = 0;

		this.f = 0;
		this.g = 0;
		this.h = 0;
	};
	
	var nodeCache = [];			// for recycling nodes
	
	function allocNode()
	{
		var ret;
		
		if (nodeCache.length)
			ret = nodeCache.pop();
		else
			ret = new node();
			
		ret.parent = null;
		ret.x = 0;
		ret.y = 0;
		ret.f = 0;
		ret.g = 0;
		ret.h = 0;
		return ret;
	};
	
	function freeNode(n)
	{
		if (nodeCache.length < 64000)
			nodeCache.push(n);
	};
	
	function resultNode(x_, y_)
	{
		this.x = x_ || 0;
		this.y = y_ || 0;
	};
	
	var resultNodeCache = [];			// for recycling resultNodes
	
	function allocResultNode()
	{
		if (resultNodeCache.length)
			return resultNodeCache.pop();
		else
			return new resultNode(0, 0);
	};
	
	function freeResultNode(n)
	{
		if (resultNodeCache.length < 10000)
			resultNodeCache.push(n);
	};
	
	var workersSupported = (typeof Worker !== "undefined");
	var isInWebWorker = (typeof document === "undefined");		// no DOM in a worker
	var myInstance = null;										// single pathfinder instance for worker
	
	if (isInWebWorker)
	{
		self.addEventListener("message", function (e)
		{
			var d = e.data;
			
			if (!d)
				return;		// could be empty postMessage() to start worker
			
			if (d.cmd === "init")
			{
				if (!myInstance)
					myInstance = new pathfinder();
					
				myInstance.init(d.hcells, d.vcells, d.data, d.diagonals);
			}
			else if (d.cmd === "find")
			{
				// receive a pathfind job, process it them dispatch result
				myInstance.pathEnd.parent = null;
				myInstance.targetX = d.endX;
				myInstance.targetY = d.endY;
				
				if (myInstance.doLongFindPath(d.startX, d.startY))
				{
					self.postMessage({ cmd: "result", pathList: myInstance.pathList });
				}
				else
				{
					self.postMessage({ cmd: "result", pathList: null });
				}
			}
			else if (d.cmd === "setdiag")
			{
				// update diagonalsEnabled flag
				myInstance.diagonalsEnabled = d.diagonals;
			}
			
		}, false);
	}
	
	function pathfinder()
	{
		this.hcells = 0;
		this.vcells = 0;
		
		this.pathEnd = allocNode();
		
		this.cells = null;
		this.openList = [];
		this.closedList = [];
		this.closedCache = {};
		this.pathList = [];
		
		this.currentNode = null;
		this.targetX = 0;
		this.targetY = 0;
		this.diagonalsEnabled = true;
		
		this.worker = null;
		this.workerQueue = [];		// jobs awaiting completion from worker in order of requests made
		this.workerRecycle = [];
		
		var self = this;
		var i, len;
		
		if (workersSupported && !isInWebWorker)
		{
			// Create worker and receive results of pathfind jobs from it
			this.worker = new Worker("pathfind.js");
			
			this.worker.addEventListener("message", function (e) {
			
				if (!e || !e.data)
					return;
				
				if (e.data.cmd === "result")
				{
					if (e.data.pathList)
					{
						for (i = 0, len = self.pathList.length; i < len; i++)
							freeResultNode(self.pathList[i]);
						
						self.pathList = e.data.pathList;
						self.workerQueue[0].success();
					}
					else
						self.workerQueue[0].fail();
						
					self.workerRecycle.push(self.workerQueue.shift());
				}
			}, false);
			
			this.worker.addEventListener("error", function (e) {
				console.error(e);
			}, false);
			
			this.worker.postMessage(null);
		}
	};
	
	pathfinder.prototype.init = function (hcells_, vcells_, data_, diagonals_)
	{
		this.hcells = hcells_;
		this.vcells = vcells_;
		this.cells = data_;
		this.diagonalsEnabled = diagonals_;
		
		if (workersSupported && !isInWebWorker)
		{
			this.worker.postMessage({
				cmd: "init",
				hcells: hcells_,
				vcells: vcells_,
				diagonals: diagonals_,
				data: data_
			});
		}
	};
	
	pathfinder.prototype.isReady = function ()
	{
		return !!this.cells;
	};
	
	pathfinder.prototype.setDiagonals = function (d)
	{
		if (this.diagonalsEnabled === d)
			return;
		
		this.diagonalsEnabled = d;
		
		if (workersSupported && !isInWebWorker)
		{
			this.worker.postMessage({
				cmd: "setdiag",
				diagonals: d,
			});
		}
	};
	
	pathfinder.prototype.at = function (x_, y_)
	{
		if (x_ < 0 || y_ < 0 || x_ >= this.hcells || y_ >= this.vcells)
			return PF_OBSTACLE;
			
		return this.cells[x_][y_];
	};
	
	pathfinder.prototype.findPath = function (startX, startY, endX, endY, successCallback, failCallback)
	{
		if (!this.cells)
		{
			// not yet initialised
			failCallback();
			return;
		}
		
		startX = Math.floor(startX);
		startY = Math.floor(startY);
		endX = Math.floor(endX);
		endY = Math.floor(endY);
		
		this.targetX = endX;
		this.targetY = endY;
		this.pathEnd.parent = null;
		
		// Check the box made by the start and dest cells.
		// If the complete box is empty, allow a direct move to target.
		var minX = Math.min(startX, endX);
		var maxX = Math.max(startX, endX);
		var minY = Math.min(startY, endY);
		var maxY = Math.max(startY, endY);
		
		// Path goes out of bounds: no calculable path
		if (minX < 0 || minY < 0 || maxX >= this.hcells || maxY >= this.vcells)
		{
			failCallback();
			return;
		}
		
		var x, y, i, len, c, h, n;

		if (this.diagonalsEnabled)
		{
			var canMoveDirect = true;
			
			for (x = minX; x <= maxX; x++)
			{
				for (y = minY; y <= maxY; y++)
				{
					if (this.cells[x][y] !== 0)
					{
						canMoveDirect = false;
						
						// Break both loops
						x = maxX + 1;
						break;
					}
				}
			}

			// A "direct" path is available (box is empty)
			if (canMoveDirect)
			{
				for (i = 0, len = this.pathList.length; i < len; i++)
					freeResultNode(this.pathList[i]);
				this.pathList.length = 0;
			
				this.pathEnd.x = endX;
				this.pathEnd.y = endY;
				this.pathEnd.parent = null;
				n = allocResultNode();
				n.x = endX;
				n.y = endY;
				this.pathList.push(n);
				successCallback();
				return;
			}
		}
		
		if (workersSupported)
		{
			// recycle objects in the worker queue
			if (this.workerRecycle.length)
				h = this.workerRecycle.pop();
			else
				h = {};
			
			h.success = successCallback;
			h.fail = failCallback;
			
			// dispatch the heavy lifting to the worker thread
			this.workerQueue.push(h);

			this.worker.postMessage({
				cmd: "find",
				startX: startX,
				startY: startY,
				endX: endX,
				endY: endY
			});
		}
		else
		{
			// no web worker support, just run on main thread
			if (this.doLongFindPath(startX, startY))
				successCallback();
			else
				failCallback();
		}
	};
		
	pathfinder.prototype.doLongFindPath = function (startX, startY)
	{
		var i, len, c, n, p, lastDir = 8, curDir = -1, addNode;
		for (i = 0, len = this.openList.length; i < len; i++)
			freeNode(this.openList[i]);
		for (i = 0, len = this.closedList.length; i < len; i++)
			freeNode(this.closedList[i]);
		for (i = 0, len = this.pathList.length; i < len; i++)
			freeResultNode(this.pathList[i]);
		this.openList.length = 0;
		this.closedList.length = 0;
		this.closedCache = {};
		this.pathList.length = 0;

		// Add the start node to the open list
		var startNode = allocNode();
		startNode.x = startX;
		startNode.y = startY;

		this.openList.push(startNode);
		var obsLeft = false, obsTop = false, obsRight = false, obsBottom = false;
		var diagonals = this.diagonalsEnabled;
		
		// While there are nodes on the open list
		while (this.openList.length)
		{
			// Move the best F value to closed list
			c = this.openList.shift();
			this.closedList.unshift(c);
			this.closedCache[((c.x << 16) + c.y).toString()] = true;

			// Are we there yet?
			if (c.x === this.targetX && c.y === this.targetY)
			{
				this.pathEnd.parent = c.parent;
				this.pathEnd.x = c.x;
				this.pathEnd.y = c.y;
				
				// Link up the whole path to an indexable array
				p = this.pathEnd;
				
				while (p)
				{
					// filter redundant nodes in straight lines
					if (this.pathList.length === 0)
					{
						addNode = true;
						
						if (p.parent)
						{
							lastDir = this.nodeDirection(p, p.parent);
							curDir = lastDir;
						}
					}
					else if (!p.parent)
						addNode = false;
					else 
					{
						curDir = this.nodeDirection(p, p.parent);
						addNode = (curDir !== lastDir);
					}
					
					if (addNode)
					{
						n = allocResultNode();
						n.x = p.x;
						n.y = p.y;
						this.pathList.unshift(n);
						lastDir = curDir;
					}
					
					p = p.parent;
				}
				
				return true;
			}

			// Get current node
			this.currentNode = c;
			var x = c.x;
			var y = c.y;
			
			var obsLeft = (this.at(x - 1, y) === PF_OBSTACLE);
			var obsTop = (this.at(x, y - 1) === PF_OBSTACLE);
			var obsRight = (this.at(x + 1, y) === PF_OBSTACLE);
			var obsBottom = (this.at(x, y + 1) === PF_OBSTACLE);

			// Check adjacent 8 nodes.  No diagonals allowed if either cell being crossed is obstacle.
			if (!obsLeft)
				this.addCellToOpenList(x - 1, y, 10);

			if (diagonals && !obsLeft && !obsTop)
				this.addCellToOpenList(x - 1, y - 1, 14);

			if (!obsTop)
				this.addCellToOpenList(x, y - 1, 10);

			if (diagonals && !obsTop && !obsRight)
				this.addCellToOpenList(x + 1, y - 1, 14);

			if (!obsRight)
				this.addCellToOpenList(x + 1, y, 10);

			if (diagonals && !obsRight && !obsBottom)
				this.addCellToOpenList(x + 1, y + 1, 14);

			if (!obsBottom)
				this.addCellToOpenList(x, y + 1, 10);

			if (diagonals && !obsBottom && !obsLeft)
				this.addCellToOpenList(x - 1, y + 1, 14);
		}
		
		return false;
	};
	
	pathfinder.prototype.insertToOpenList = function (c)
	{
		var i, len;
		
		// Needs to go at end
		if (c.f >= this.openList[this.openList.length - 1].f)
		{
			this.openList.push(c);
		}
		else
		{
			for (i = 0, len = this.openList.length; i < len; i++)
			{
				if (c.f < this.openList[i].f)
				{
					this.openList.splice(i, 0, c);
					break;
				}
			}
		}
	};
	
	pathfinder.prototype.addCellToOpenList = function (x_, y_, g_)
	{
		// Ignore if cell on closed list
		if (this.closedCache.hasOwnProperty(((x_ << 16) + y_).toString()))
			return;
		
		var i, len, c;
		
		// Cell costs can be increased by changing the number in the map
		var curCellCost = this.at(x_, y_);

		// Is this cell already on the open list?
		for (i = 0, len = this.openList.length; i < len; i++)
		{
			c = this.openList[i];
			
			if (x_ === c.x && y_ === c.y)
			{
				// Is this a better path?
				if (this.currentNode.g + g_ + curCellCost < c.g)
				{
					// Update F, G and H and update parent
					c.parent = this.currentNode;
					c.g = this.currentNode.g + g_ + curCellCost;
					c.h = this.estimateH(c.x, c.y);
					c.f = c.g + c.h;

					// This node's F has changed:  Delete it then re-insert it in the right place

					if (this.openList.length === 1)
					{
						// no need to remove then re-insert same node, just leave it there
						return;
					}
					
					this.openList.splice(i, 1);
					this.insertToOpenList(c);
				}

				return;
			}
		}

		// Not on the open list; add it in the right place
		c = allocNode();
		c.x = x_;
		c.y = y_;
		c.h = this.estimateH(x_, y_);
		c.g = this.currentNode.g + g_ + curCellCost;
		c.f = c.h + c.g;
		c.parent = this.currentNode;

		// Insert this node sorted in the open list
		// The loop below won't add new largest F values
		if (!this.openList.length)
		{
			this.openList.push(c);
			return;
		}
		
		this.insertToOpenList(c);
	};
	
	function quickAbs(x)
	{
		return x < 0 ? -x : x;
	};
	
	pathfinder.prototype.estimateH = function (x_, y_)
	{
		var dx = quickAbs(x_ - this.targetX);
		var dy = quickAbs(y_ - this.targetY);

		return dx * 10 + dy * 10;
	};
	
	pathfinder.prototype.nodeDirection = function (a, b)
	{
		var ax = a.x;
		var ay = a.y;
		var bx = b.x;
		var by = b.y;

		if (ax === bx)
		{
			if (by > ay) return 6;
			if (by < ay) return 2;
			if (ay == by) return 8;
		}
		else if (ay === by)
		{
			if (bx > ax) return 4;
			if (by < ax) return 0;
		}
		else
		{
			if (bx < ax && by < ay) return 1;
			if (bx > ax && by < ay) return 3;
			if (bx < ax && by > ay) return 7;
			if (bx > ax && by > ay) return 5;
		}
		return 8;
	};
	
	if (!isInWebWorker)
	{
		window.PF_CLEAR = PF_CLEAR;
		window.PF_OBSTACLE = PF_OBSTACLE;
		window.Pathfinder = pathfinder;
		
		window.ResultNode = resultNode;
		window.allocResultNode = allocResultNode;
		window.freeResultNode = freeResultNode;
	}

})();
(function() {
'use strict';var cr={plugins_:{},behaviors:{}};"function"!==typeof Object.getPrototypeOf&&(Object.getPrototypeOf="object"===typeof"test".__proto__?function(a){return a.__proto__}:function(a){return a.constructor.prototype});
(function(){function a(a,g){this.x=a;this.y=g;cr.seal(this)}function b(a,g,c,b){this.set(a,g,c,b);cr.seal(this)}function e(){this.bly=this.blx=this.bry=this.brx=this.try_=this.trx=this.tly=this.tlx=0;cr.seal(this)}function d(){this.items={};this.item_count=0;this.values_cache=[];this.cache_valid=!0;cr.seal(this)}function c(){this.sum=this.t=this.y=this.c=0;cr.seal(this)}function f(a){this.pts_cache=[];this.set_pts(a);cr.seal(this)}cr.logexport=function(a){window.console&&window.console.log&&window.console.log(a)};
cr.seal=function(a){return a};cr.freeze=function(a){return a};cr.is_undefined=function(a){return"undefined"===typeof a};cr.is_number=function(a){return"number"===typeof a};cr.is_string=function(a){return"string"===typeof a};cr.isPOT=function(a){return 0<a&&0===(a-1&a)};cr.abs=function(a){return 0>a?-a:a};cr.max=function(a,g){return a>g?a:g};cr.min=function(a,g){return a<g?a:g};cr.PI=Math.PI;cr.round=function(a){return a+0.5|0};cr.floor=function(a){return a|0};a.prototype.offset=function(a,g){this.x+=
a;this.y+=g;return this};a.prototype.mul=function(a,g){this.x*=a;this.y*=g;return this};cr.vector2=a;cr.segments_intersect=function(a,g,c,b,h,f,t,s){if(cr.max(a,c)<cr.min(h,t)||cr.min(a,c)>cr.max(h,t)||cr.max(g,b)<cr.min(f,s)||cr.min(g,b)>cr.max(f,s))return!1;var m=h-a+t-c,x=f-g+s-b;a=c-a;g=b-g;h=t-h;f=s-f;s=cr.abs(g*h-f*a);a=a*x-g*m;return cr.abs(h*x-f*m)<=s&&cr.abs(a)<=s};b.prototype.set=function(a,g,c,b){this.left=a;this.top=g;this.right=c;this.bottom=b};b.prototype.width=function(){return this.right-
this.left};b.prototype.height=function(){return this.bottom-this.top};b.prototype.offset=function(a,g){this.left+=a;this.top+=g;this.right+=a;this.bottom+=g;return this};b.prototype.intersects_rect=function(a){return!(a.right<this.left||a.bottom<this.top||a.left>this.right||a.top>this.bottom)};b.prototype.contains_pt=function(a,g){return a>=this.left&&a<=this.right&&g>=this.top&&g<=this.bottom};cr.rect=b;e.prototype.set_from_rect=function(a){this.tlx=a.left;this.tly=a.top;this.trx=a.right;this.try_=
a.top;this.brx=a.right;this.bry=a.bottom;this.blx=a.left;this.bly=a.bottom};e.prototype.set_from_rotated_rect=function(a,g){if(0===g)this.set_from_rect(a);else{var c=Math.sin(g),b=Math.cos(g),h=a.left*c,f=a.top*c,t=a.right*c,c=a.bottom*c,s=a.left*b,m=a.top*b,x=a.right*b,b=a.bottom*b;this.tlx=s-f;this.tly=m+h;this.trx=x-f;this.try_=m+t;this.brx=x-c;this.bry=b+t;this.blx=s-c;this.bly=b+h}};e.prototype.offset=function(a,g){this.tlx+=a;this.tly+=g;this.trx+=a;this.try_+=g;this.brx+=a;this.bry+=g;this.blx+=
a;this.bly+=g;return this};e.prototype.bounding_box=function(a){a.left=cr.min(cr.min(this.tlx,this.trx),cr.min(this.brx,this.blx));a.top=cr.min(cr.min(this.tly,this.try_),cr.min(this.bry,this.bly));a.right=cr.max(cr.max(this.tlx,this.trx),cr.max(this.brx,this.blx));a.bottom=cr.max(cr.max(this.tly,this.try_),cr.max(this.bry,this.bly))};e.prototype.contains_pt=function(a,g){var c=this.trx-this.tlx,b=this.try_-this.tly,h=this.brx-this.tlx,f=this.bry-this.tly,t=a-this.tlx,s=g-this.tly,m=c*c+b*b,x=c*h+
b*f,b=c*t+b*s,z=h*h+f*f,r=h*t+f*s,q=1/(m*z-x*x),c=(z*b-x*r)*q,m=(m*r-x*b)*q;if(0<=c&&0<m&&1>c+m)return!0;c=this.blx-this.tlx;b=this.bly-this.tly;m=c*c+b*b;x=c*h+b*f;b=c*t+b*s;q=1/(m*z-x*x);c=(z*b-x*r)*q;m=(m*r-x*b)*q;return 0<=c&&0<m&&1>c+m};e.prototype.at=function(a,g){switch(a){case 0:return g?this.tlx:this.tly;case 1:return g?this.trx:this.try_;case 2:return g?this.brx:this.bry;case 3:return g?this.blx:this.bly;case 4:return g?this.tlx:this.tly;default:return g?this.tlx:this.tly}};e.prototype.midX=
function(){return(this.tlx+this.trx+this.brx+this.blx)/4};e.prototype.midY=function(){return(this.tly+this.try_+this.bry+this.bly)/4};e.prototype.intersects_segment=function(a,g,c,b){if(this.contains_pt(a,g)||this.contains_pt(c,b))return!0;var h,f,t,s,m;for(m=0;4>m;m++)if(h=this.at(m,!0),f=this.at(m,!1),t=this.at(m+1,!0),s=this.at(m+1,!1),cr.segments_intersect(a,g,c,b,h,f,t,s))return!0;return!1};e.prototype.intersects_quad=function(a){var g=a.midX(),c=a.midY();if(this.contains_pt(g,c))return!0;g=
this.midX();c=this.midY();if(a.contains_pt(g,c))return!0;var b,h,f,t,s,m,x,z;for(x=0;4>x;x++)for(z=0;4>z;z++)if(g=this.at(x,!0),c=this.at(x,!1),b=this.at(x+1,!0),h=this.at(x+1,!1),f=a.at(z,!0),t=a.at(z,!1),s=a.at(z+1,!0),m=a.at(z+1,!1),cr.segments_intersect(g,c,b,h,f,t,s,m))return!0;return!1};cr.quad=e;cr.RGB=function(a,g,c){return Math.max(Math.min(a,255),0)|Math.max(Math.min(g,255),0)<<8|Math.max(Math.min(c,255),0)<<16};cr.GetRValue=function(a){return a&255};cr.GetGValue=function(a){return(a&65280)>>
8};cr.GetBValue=function(a){return(a&16711680)>>16};cr.shallowCopy=function(a,g,c){for(var b in g)g.hasOwnProperty(b)&&(a[b]=g[b]);return a};cr.arrayRemove=function(a,g){var c,b;g=cr.floor(g);if(!(0>g||g>=a.length))if(0===g)a.shift();else if(g===a.length-1)a.pop();else{c=g;for(b=a.length-1;c<b;c++)a[c]=a[c+1];a.length=b}};cr.shallowAssignArray=function(a,g){a.length=g.length;var c,b;c=0;for(b=g.length;c<b;c++)a[c]=g[c]};cr.arrayFindRemove=function(a,g){var c=a.indexOf(g);-1!==c&&cr.arrayRemove(a,
c)};cr.clamp=function(a,g,c){return a<g?g:a>c?c:a};cr.to_radians=function(a){return a/(180/cr.PI)};cr.to_degrees=function(a){return a*(180/cr.PI)};cr.clamp_angle_degrees=function(a){a%=360;0>a&&(a+=360);return a};cr.clamp_angle=function(a){a%=2*cr.PI;0>a&&(a+=2*cr.PI);return a};cr.to_clamped_degrees=function(a){return cr.clamp_angle_degrees(cr.to_degrees(a))};cr.to_clamped_radians=function(a){return cr.clamp_angle(cr.to_radians(a))};cr.angleTo=function(a,g,c,b){return Math.atan2(b-g,c-a)};cr.angleDiff=
function(a,g){if(a===g)return 0;var c=Math.sin(a),b=Math.cos(a),h=Math.sin(g),f=Math.cos(g),c=c*h+b*f;return 1<=c?0:-1>=c?cr.PI:Math.acos(c)};cr.angleRotate=function(a,g,c){var b=Math.sin(a),h=Math.cos(a),f=Math.sin(g),t=Math.cos(g);return Math.acos(b*f+h*t)>c?0<h*f-b*t?cr.clamp_angle(a+c):cr.clamp_angle(a-c):cr.clamp_angle(g)};cr.angleClockwise=function(a,g){var c=Math.sin(a),b=Math.cos(a),h=Math.sin(g),f=Math.cos(g);return 0>=b*h-c*f};cr.rotatePtAround=function(a,g,c,b,h,f){if(0===c)return f?a:
g;var t=Math.sin(c);c=Math.cos(c);a-=b;g-=h;var s=a*t;a=a*c-g*t;g=g*c+s;return f?a+b:g+h};cr.distanceTo=function(a,g,c,b){a=c-a;g=b-g;return Math.sqrt(a*a+g*g)};cr.xor=function(a,g){return!a!==!g};cr.lerp=function(a,g,c){return a+(g-a)*c};cr.hasAnyOwnProperty=function(a){for(var g in a)if(a.hasOwnProperty(g))return!0;return!1};cr.wipe=function(a){for(var g in a)a.hasOwnProperty(g)&&delete a[g]};var g=+new Date;cr.performance_now=function(){if("undefined"!==typeof window.performance){var a=window.performance;
if("undefined"!==typeof a.now)return a.now();if("undefined"!==typeof a.webkitNow)return a.webkitNow();if("undefined"!==typeof a.msNow)return a.msNow()}return Date.now()-g};d.prototype.contains=function(a){return this.items.hasOwnProperty(a.toString())};d.prototype.add=function(a){var g=a.toString();this.items.hasOwnProperty(g)||(this.items[g]=a,this.item_count++,this.cache_valid=!1);return this};d.prototype.remove=function(a){a=a.toString();this.items.hasOwnProperty(a)&&(delete this.items[a],this.item_count--,
this.cache_valid=!1);return this};d.prototype.clear=function(){cr.wipe(this.items);this.item_count=0;this.values_cache.length=0;this.cache_valid=!0;return this};d.prototype.isEmpty=function(){return 0===this.item_count};d.prototype.count=function(){return this.item_count};d.prototype.update_cache=function(){if(!this.cache_valid){this.values_cache.length=this.item_count;var a,g=0;for(a in this.items)this.items.hasOwnProperty(a)&&(this.values_cache[g++]=this.items[a]);this.cache_valid=!0}};d.prototype.values=
function(){this.update_cache();return this.values_cache.slice(0)};d.prototype.valuesRef=function(){this.update_cache();return this.values_cache};cr.ObjectSet=d;c.prototype.add=function(a){this.y=a-this.c;this.t=this.sum+this.y;this.c=this.t-this.sum-this.y;this.sum=this.t};c.prototype.reset=function(){this.sum=this.t=this.y=this.c=0};cr.KahanAdder=c;cr.regexp_escape=function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")};f.prototype.set_pts=function(a){this.pts_array=a;this.pts_count=a.length/
2;this.pts_cache.length=a.length;this.cache_height=this.cache_width=-1;this.cache_angle=0};f.prototype.is_empty=function(){return!this.pts_array.length};f.prototype.set_from_quad=function(a,g,c,b,h){this.pts_cache.length=8;this.pts_count=4;var f=this.pts_cache;f[0]=a.tlx-g;f[1]=a.tly-c;f[2]=a.trx-g;f[3]=a.try_-c;f[4]=a.brx-g;f[5]=a.bry-c;f[6]=a.blx-g;f[7]=a.bly-c;this.cache_width=b;this.cache_height=h};f.prototype.set_from_poly=function(a){this.pts_count=a.pts_count;cr.shallowAssignArray(this.pts_cache,
a.pts_cache)};f.prototype.cache_poly=function(a,g,c){if(this.cache_width!==a||this.cache_height!==g||this.cache_angle!==c){this.cache_width=a;this.cache_height=g;this.cache_angle=c;var b,h,f,t=0,s=1,m=this.pts_array,x=this.pts_cache;0!==c&&(t=Math.sin(c),s=Math.cos(c));c=0;for(b=this.pts_count;c<b;c++)h=m[2*c]*a,f=m[2*c+1]*g,x[2*c]=h*s-f*t,x[2*c+1]=f*s+h*t}};f.prototype.contains_pt=function(a,g){var c=this.pts_cache;if(a===c[0]&&g===c[1])return!0;var b,h,f,t=this.pts_count,s=c[0],m=s,x=c[1],z=x;for(b=
1;b<t;b++)h=c[2*b],f=c[2*b+1],h<s&&(s=h),h>m&&(m=h),f<x&&(x=f),f>z&&(z=f);h=s-110;var x=x-101,m=m+131,z=z+120,r,q,d=0,e=0;for(b=0;b<t;b++)f=c[2*b],s=c[2*b+1],r=c[2*((b+1)%t)],q=c[2*((b+1)%t)+1],cr.segments_intersect(h,x,a,g,f,s,r,q)&&d++,cr.segments_intersect(m,z,a,g,f,s,r,q)&&e++;return 1===d%2||1===e%2};f.prototype.intersects_poly=function(a,g,c){var b=a.pts_cache,h=this.pts_cache;if(this.contains_pt(b[0]+g,b[1]+c)||a.contains_pt(h[0]-g,h[1]-c))return!0;var f,t,s,m,x,z,r,q,d,e,A,w;f=0;for(t=this.pts_count;f<
t;f++)for(x=h[2*f],z=h[2*f+1],r=h[2*((f+1)%t)],q=h[2*((f+1)%t)+1],s=0,m=a.pts_count;s<m;s++)if(d=b[2*s]+g,e=b[2*s+1]+c,A=b[2*((s+1)%m)]+g,w=b[2*((s+1)%m)+1]+c,cr.segments_intersect(x,z,r,q,d,e,A,w))return!0;return!1};f.prototype.intersects_segment=function(a,g,c,b,h,f){var t=this.pts_cache;if(this.contains_pt(c-a,b-g))return!0;var s,m,x,z,r,q;s=0;for(m=this.pts_count;s<m;s++)if(x=t[2*s]+a,z=t[2*s+1]+g,r=t[2*((s+1)%m)]+a,q=t[2*((s+1)%m)+1]+g,cr.segments_intersect(c,b,h,f,x,z,r,q))return!0;return!1};
cr.CollisionPoly=f;var h="lighter xor copy destination-over source-in destination-in source-out destination-out source-atop destination-atop".split(" ");cr.effectToCompositeOp=function(a){return 0>=a||11<=a?"source-over":h[a-1]};cr.setGLBlend=function(a,g,c){if(c)switch(a.srcBlend=c.ONE,a.destBlend=c.ONE_MINUS_SRC_ALPHA,g){case 1:a.srcBlend=c.ONE;a.destBlend=c.ONE;break;case 3:a.srcBlend=c.ONE;a.destBlend=c.ZERO;break;case 4:a.srcBlend=c.ONE_MINUS_DST_ALPHA;a.destBlend=c.ONE;break;case 5:a.srcBlend=
c.DST_ALPHA;a.destBlend=c.ZERO;break;case 6:a.srcBlend=c.ZERO;a.destBlend=c.SRC_ALPHA;break;case 7:a.srcBlend=c.ONE_MINUS_DST_ALPHA;a.destBlend=c.ZERO;break;case 8:a.srcBlend=c.ZERO;a.destBlend=c.ONE_MINUS_SRC_ALPHA;break;case 9:a.srcBlend=c.DST_ALPHA;a.destBlend=c.ONE_MINUS_SRC_ALPHA;break;case 10:a.srcBlend=c.ONE_MINUS_DST_ALPHA,a.destBlend=c.SRC_ALPHA}};cr.round6dp=function(a){return Math.round(1E6*a)/1E6};cr.equals_nocase=function(a,g){return"string"!==typeof a||"string"!==typeof g||a.length!==
g.length?!1:a===g?!0:a.toLowerCase()===g.toLowerCase()}})();var MatrixArray="undefined"!==typeof Float32Array?Float32Array:Array,glMatrixArrayType=MatrixArray,vec3={},mat3={},mat4={},quat4={};vec3.create=function(a){var b=new MatrixArray(3);a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2]);return b};vec3.set=function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];return b};vec3.add=function(a,b,e){if(!e||a===e)return a[0]+=b[0],a[1]+=b[1],a[2]+=b[2],a;e[0]=a[0]+b[0];e[1]=a[1]+b[1];e[2]=a[2]+b[2];return e};
vec3.subtract=function(a,b,e){if(!e||a===e)return a[0]-=b[0],a[1]-=b[1],a[2]-=b[2],a;e[0]=a[0]-b[0];e[1]=a[1]-b[1];e[2]=a[2]-b[2];return e};vec3.negate=function(a,b){b||(b=a);b[0]=-a[0];b[1]=-a[1];b[2]=-a[2];return b};vec3.scale=function(a,b,e){if(!e||a===e)return a[0]*=b,a[1]*=b,a[2]*=b,a;e[0]=a[0]*b;e[1]=a[1]*b;e[2]=a[2]*b;return e};
vec3.normalize=function(a,b){b||(b=a);var e=a[0],d=a[1],c=a[2],f=Math.sqrt(e*e+d*d+c*c);if(f){if(1===f)return b[0]=e,b[1]=d,b[2]=c,b}else return b[0]=0,b[1]=0,b[2]=0,b;f=1/f;b[0]=e*f;b[1]=d*f;b[2]=c*f;return b};vec3.cross=function(a,b,e){e||(e=a);var d=a[0],c=a[1];a=a[2];var f=b[0],g=b[1];b=b[2];e[0]=c*b-a*g;e[1]=a*f-d*b;e[2]=d*g-c*f;return e};vec3.length=function(a){var b=a[0],e=a[1];a=a[2];return Math.sqrt(b*b+e*e+a*a)};vec3.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]};
vec3.direction=function(a,b,e){e||(e=a);var d=a[0]-b[0],c=a[1]-b[1];a=a[2]-b[2];b=Math.sqrt(d*d+c*c+a*a);if(!b)return e[0]=0,e[1]=0,e[2]=0,e;b=1/b;e[0]=d*b;e[1]=c*b;e[2]=a*b;return e};vec3.lerp=function(a,b,e,d){d||(d=a);d[0]=a[0]+e*(b[0]-a[0]);d[1]=a[1]+e*(b[1]-a[1]);d[2]=a[2]+e*(b[2]-a[2]);return d};vec3.str=function(a){return"["+a[0]+", "+a[1]+", "+a[2]+"]"};
mat3.create=function(a){var b=new MatrixArray(9);a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8]);return b};mat3.set=function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];return b};mat3.identity=function(a){a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=1;a[5]=0;a[6]=0;a[7]=0;a[8]=1;return a};
mat3.transpose=function(a,b){if(!b||a===b){var e=a[1],d=a[2],c=a[5];a[1]=a[3];a[2]=a[6];a[3]=e;a[5]=a[7];a[6]=d;a[7]=c;return a}b[0]=a[0];b[1]=a[3];b[2]=a[6];b[3]=a[1];b[4]=a[4];b[5]=a[7];b[6]=a[2];b[7]=a[5];b[8]=a[8];return b};mat3.toMat4=function(a,b){b||(b=mat4.create());b[15]=1;b[14]=0;b[13]=0;b[12]=0;b[11]=0;b[10]=a[8];b[9]=a[7];b[8]=a[6];b[7]=0;b[6]=a[5];b[5]=a[4];b[4]=a[3];b[3]=0;b[2]=a[2];b[1]=a[1];b[0]=a[0];return b};
mat3.str=function(a){return"["+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+"]"};mat4.create=function(a){var b=new MatrixArray(16);a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b[9]=a[9],b[10]=a[10],b[11]=a[11],b[12]=a[12],b[13]=a[13],b[14]=a[14],b[15]=a[15]);return b};
mat4.set=function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return b};mat4.identity=function(a){a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=1;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a};
mat4.transpose=function(a,b){if(!b||a===b){var e=a[1],d=a[2],c=a[3],f=a[6],g=a[7],h=a[11];a[1]=a[4];a[2]=a[8];a[3]=a[12];a[4]=e;a[6]=a[9];a[7]=a[13];a[8]=d;a[9]=f;a[11]=a[14];a[12]=c;a[13]=g;a[14]=h;return a}b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b};
mat4.determinant=function(a){var b=a[0],e=a[1],d=a[2],c=a[3],f=a[4],g=a[5],h=a[6],l=a[7],k=a[8],n=a[9],v=a[10],u=a[11],p=a[12],t=a[13],s=a[14];a=a[15];return p*n*h*c-k*t*h*c-p*g*v*c+f*t*v*c+k*g*s*c-f*n*s*c-p*n*d*l+k*t*d*l+p*e*v*l-b*t*v*l-k*e*s*l+b*n*s*l+p*g*d*u-f*t*d*u-p*e*h*u+b*t*h*u+f*e*s*u-b*g*s*u-k*g*d*a+f*n*d*a+k*e*h*a-b*n*h*a-f*e*v*a+b*g*v*a};
mat4.inverse=function(a,b){b||(b=a);var e=a[0],d=a[1],c=a[2],f=a[3],g=a[4],h=a[5],l=a[6],k=a[7],n=a[8],v=a[9],u=a[10],p=a[11],t=a[12],s=a[13],m=a[14],x=a[15],z=e*h-d*g,r=e*l-c*g,q=e*k-f*g,G=d*l-c*h,y=d*k-f*h,A=c*k-f*l,w=n*s-v*t,D=n*m-u*t,E=n*x-p*t,B=v*m-u*s,H=v*x-p*s,K=u*x-p*m,C=1/(z*K-r*H+q*B+G*E-y*D+A*w);b[0]=(h*K-l*H+k*B)*C;b[1]=(-d*K+c*H-f*B)*C;b[2]=(s*A-m*y+x*G)*C;b[3]=(-v*A+u*y-p*G)*C;b[4]=(-g*K+l*E-k*D)*C;b[5]=(e*K-c*E+f*D)*C;b[6]=(-t*A+m*q-x*r)*C;b[7]=(n*A-u*q+p*r)*C;b[8]=(g*H-h*E+k*w)*C;
b[9]=(-e*H+d*E-f*w)*C;b[10]=(t*y-s*q+x*z)*C;b[11]=(-n*y+v*q-p*z)*C;b[12]=(-g*B+h*D-l*w)*C;b[13]=(e*B-d*D+c*w)*C;b[14]=(-t*G+s*r-m*z)*C;b[15]=(n*G-v*r+u*z)*C;return b};mat4.toRotationMat=function(a,b){b||(b=mat4.create());b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b};
mat4.toMat3=function(a,b){b||(b=mat3.create());b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[4];b[4]=a[5];b[5]=a[6];b[6]=a[8];b[7]=a[9];b[8]=a[10];return b};mat4.toInverseMat3=function(a,b){var e=a[0],d=a[1],c=a[2],f=a[4],g=a[5],h=a[6],l=a[8],k=a[9],n=a[10],v=n*g-h*k,u=-n*f+h*l,p=k*f-g*l,t=e*v+d*u+c*p;if(!t)return null;t=1/t;b||(b=mat3.create());b[0]=v*t;b[1]=(-n*d+c*k)*t;b[2]=(h*d-c*g)*t;b[3]=u*t;b[4]=(n*e-c*l)*t;b[5]=(-h*e+c*f)*t;b[6]=p*t;b[7]=(-k*e+d*l)*t;b[8]=(g*e-d*f)*t;return b};
mat4.multiply=function(a,b,e){e||(e=a);var d=a[0],c=a[1],f=a[2],g=a[3],h=a[4],l=a[5],k=a[6],n=a[7],v=a[8],u=a[9],p=a[10],t=a[11],s=a[12],m=a[13],x=a[14];a=a[15];var z=b[0],r=b[1],q=b[2],G=b[3],y=b[4],A=b[5],w=b[6],D=b[7],E=b[8],B=b[9],H=b[10],K=b[11],C=b[12],M=b[13],Q=b[14];b=b[15];e[0]=z*d+r*h+q*v+G*s;e[1]=z*c+r*l+q*u+G*m;e[2]=z*f+r*k+q*p+G*x;e[3]=z*g+r*n+q*t+G*a;e[4]=y*d+A*h+w*v+D*s;e[5]=y*c+A*l+w*u+D*m;e[6]=y*f+A*k+w*p+D*x;e[7]=y*g+A*n+w*t+D*a;e[8]=E*d+B*h+H*v+K*s;e[9]=E*c+B*l+H*u+K*m;e[10]=E*
f+B*k+H*p+K*x;e[11]=E*g+B*n+H*t+K*a;e[12]=C*d+M*h+Q*v+b*s;e[13]=C*c+M*l+Q*u+b*m;e[14]=C*f+M*k+Q*p+b*x;e[15]=C*g+M*n+Q*t+b*a;return e};mat4.multiplyVec3=function(a,b,e){e||(e=b);var d=b[0],c=b[1];b=b[2];e[0]=a[0]*d+a[4]*c+a[8]*b+a[12];e[1]=a[1]*d+a[5]*c+a[9]*b+a[13];e[2]=a[2]*d+a[6]*c+a[10]*b+a[14];return e};
mat4.multiplyVec4=function(a,b,e){e||(e=b);var d=b[0],c=b[1],f=b[2];b=b[3];e[0]=a[0]*d+a[4]*c+a[8]*f+a[12]*b;e[1]=a[1]*d+a[5]*c+a[9]*f+a[13]*b;e[2]=a[2]*d+a[6]*c+a[10]*f+a[14]*b;e[3]=a[3]*d+a[7]*c+a[11]*f+a[15]*b;return e};
mat4.translate=function(a,b,e){var d=b[0],c=b[1];b=b[2];var f,g,h,l,k,n,v,u,p,t,s,m;if(!e||a===e)return a[12]=a[0]*d+a[4]*c+a[8]*b+a[12],a[13]=a[1]*d+a[5]*c+a[9]*b+a[13],a[14]=a[2]*d+a[6]*c+a[10]*b+a[14],a[15]=a[3]*d+a[7]*c+a[11]*b+a[15],a;f=a[0];g=a[1];h=a[2];l=a[3];k=a[4];n=a[5];v=a[6];u=a[7];p=a[8];t=a[9];s=a[10];m=a[11];e[0]=f;e[1]=g;e[2]=h;e[3]=l;e[4]=k;e[5]=n;e[6]=v;e[7]=u;e[8]=p;e[9]=t;e[10]=s;e[11]=m;e[12]=f*d+k*c+p*b+a[12];e[13]=g*d+n*c+t*b+a[13];e[14]=h*d+v*c+s*b+a[14];e[15]=l*d+u*c+m*b+
a[15];return e};mat4.scale=function(a,b,e){var d=b[0],c=b[1];b=b[2];if(!e||a===e)return a[0]*=d,a[1]*=d,a[2]*=d,a[3]*=d,a[4]*=c,a[5]*=c,a[6]*=c,a[7]*=c,a[8]*=b,a[9]*=b,a[10]*=b,a[11]*=b,a;e[0]=a[0]*d;e[1]=a[1]*d;e[2]=a[2]*d;e[3]=a[3]*d;e[4]=a[4]*c;e[5]=a[5]*c;e[6]=a[6]*c;e[7]=a[7]*c;e[8]=a[8]*b;e[9]=a[9]*b;e[10]=a[10]*b;e[11]=a[11]*b;e[12]=a[12];e[13]=a[13];e[14]=a[14];e[15]=a[15];return e};
mat4.rotate=function(a,b,e,d){var c=e[0],f=e[1];e=e[2];var g=Math.sqrt(c*c+f*f+e*e),h,l,k,n,v,u,p,t,s,m,x,z,r,q,G,y,A,w,D,E;if(!g)return null;1!==g&&(g=1/g,c*=g,f*=g,e*=g);h=Math.sin(b);l=Math.cos(b);k=1-l;b=a[0];g=a[1];n=a[2];v=a[3];u=a[4];p=a[5];t=a[6];s=a[7];m=a[8];x=a[9];z=a[10];r=a[11];q=c*c*k+l;G=f*c*k+e*h;y=e*c*k-f*h;A=c*f*k-e*h;w=f*f*k+l;D=e*f*k+c*h;E=c*e*k+f*h;c=f*e*k-c*h;f=e*e*k+l;d?a!==d&&(d[12]=a[12],d[13]=a[13],d[14]=a[14],d[15]=a[15]):d=a;d[0]=b*q+u*G+m*y;d[1]=g*q+p*G+x*y;d[2]=n*q+t*
G+z*y;d[3]=v*q+s*G+r*y;d[4]=b*A+u*w+m*D;d[5]=g*A+p*w+x*D;d[6]=n*A+t*w+z*D;d[7]=v*A+s*w+r*D;d[8]=b*E+u*c+m*f;d[9]=g*E+p*c+x*f;d[10]=n*E+t*c+z*f;d[11]=v*E+s*c+r*f;return d};
mat4.rotateX=function(a,b,e){var d=Math.sin(b);b=Math.cos(b);var c=a[4],f=a[5],g=a[6],h=a[7],l=a[8],k=a[9],n=a[10],v=a[11];e?a!==e&&(e[0]=a[0],e[1]=a[1],e[2]=a[2],e[3]=a[3],e[12]=a[12],e[13]=a[13],e[14]=a[14],e[15]=a[15]):e=a;e[4]=c*b+l*d;e[5]=f*b+k*d;e[6]=g*b+n*d;e[7]=h*b+v*d;e[8]=c*-d+l*b;e[9]=f*-d+k*b;e[10]=g*-d+n*b;e[11]=h*-d+v*b;return e};
mat4.rotateY=function(a,b,e){var d=Math.sin(b);b=Math.cos(b);var c=a[0],f=a[1],g=a[2],h=a[3],l=a[8],k=a[9],n=a[10],v=a[11];e?a!==e&&(e[4]=a[4],e[5]=a[5],e[6]=a[6],e[7]=a[7],e[12]=a[12],e[13]=a[13],e[14]=a[14],e[15]=a[15]):e=a;e[0]=c*b+l*-d;e[1]=f*b+k*-d;e[2]=g*b+n*-d;e[3]=h*b+v*-d;e[8]=c*d+l*b;e[9]=f*d+k*b;e[10]=g*d+n*b;e[11]=h*d+v*b;return e};
mat4.rotateZ=function(a,b,e){var d=Math.sin(b);b=Math.cos(b);var c=a[0],f=a[1],g=a[2],h=a[3],l=a[4],k=a[5],n=a[6],v=a[7];e?a!==e&&(e[8]=a[8],e[9]=a[9],e[10]=a[10],e[11]=a[11],e[12]=a[12],e[13]=a[13],e[14]=a[14],e[15]=a[15]):e=a;e[0]=c*b+l*d;e[1]=f*b+k*d;e[2]=g*b+n*d;e[3]=h*b+v*d;e[4]=c*-d+l*b;e[5]=f*-d+k*b;e[6]=g*-d+n*b;e[7]=h*-d+v*b;return e};
mat4.frustum=function(a,b,e,d,c,f,g){g||(g=mat4.create());var h=b-a,l=d-e,k=f-c;g[0]=2*c/h;g[1]=0;g[2]=0;g[3]=0;g[4]=0;g[5]=2*c/l;g[6]=0;g[7]=0;g[8]=(b+a)/h;g[9]=(d+e)/l;g[10]=-(f+c)/k;g[11]=-1;g[12]=0;g[13]=0;g[14]=-(2*f*c)/k;g[15]=0;return g};mat4.perspective=function(a,b,e,d,c){a=e*Math.tan(a*Math.PI/360);b*=a;return mat4.frustum(-b,b,-a,a,e,d,c)};
mat4.ortho=function(a,b,e,d,c,f,g){g||(g=mat4.create());var h=b-a,l=d-e,k=f-c;g[0]=2/h;g[1]=0;g[2]=0;g[3]=0;g[4]=0;g[5]=2/l;g[6]=0;g[7]=0;g[8]=0;g[9]=0;g[10]=-2/k;g[11]=0;g[12]=-(a+b)/h;g[13]=-(d+e)/l;g[14]=-(f+c)/k;g[15]=1;return g};
mat4.lookAt=function(a,b,e,d){d||(d=mat4.create());var c,f,g,h,l,k,n,v,u=a[0],p=a[1];a=a[2];f=e[0];g=e[1];c=e[2];e=b[1];k=b[2];if(u===b[0]&&p===e&&a===k)return mat4.identity(d);e=u-b[0];k=p-b[1];n=a-b[2];v=1/Math.sqrt(e*e+k*k+n*n);e*=v;k*=v;n*=v;b=g*n-c*k;c=c*e-f*n;f=f*k-g*e;(v=Math.sqrt(b*b+c*c+f*f))?(v=1/v,b*=v,c*=v,f*=v):f=c=b=0;g=k*f-n*c;h=n*b-e*f;l=e*c-k*b;(v=Math.sqrt(g*g+h*h+l*l))?(v=1/v,g*=v,h*=v,l*=v):l=h=g=0;d[0]=b;d[1]=g;d[2]=e;d[3]=0;d[4]=c;d[5]=h;d[6]=k;d[7]=0;d[8]=f;d[9]=l;d[10]=n;d[11]=
0;d[12]=-(b*u+c*p+f*a);d[13]=-(g*u+h*p+l*a);d[14]=-(e*u+k*p+n*a);d[15]=1;return d};mat4.fromRotationTranslation=function(a,b,e){e||(e=mat4.create());var d=a[0],c=a[1],f=a[2],g=a[3],h=d+d,l=c+c,k=f+f;a=d*h;var n=d*l,d=d*k,v=c*l,c=c*k,f=f*k,h=h*g,l=l*g,g=g*k;e[0]=1-(v+f);e[1]=n+g;e[2]=d-l;e[3]=0;e[4]=n-g;e[5]=1-(a+f);e[6]=c+h;e[7]=0;e[8]=d+l;e[9]=c-h;e[10]=1-(a+v);e[11]=0;e[12]=b[0];e[13]=b[1];e[14]=b[2];e[15]=1;return e};
mat4.str=function(a){return"["+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+", "+a[9]+", "+a[10]+", "+a[11]+", "+a[12]+", "+a[13]+", "+a[14]+", "+a[15]+"]"};quat4.create=function(a){var b=new MatrixArray(4);a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3]);return b};quat4.set=function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];return b};
quat4.calculateW=function(a,b){var e=a[0],d=a[1],c=a[2];if(!b||a===b)return a[3]=-Math.sqrt(Math.abs(1-e*e-d*d-c*c)),a;b[0]=e;b[1]=d;b[2]=c;b[3]=-Math.sqrt(Math.abs(1-e*e-d*d-c*c));return b};quat4.inverse=function(a,b){if(!b||a===b)return a[0]*=-1,a[1]*=-1,a[2]*=-1,a;b[0]=-a[0];b[1]=-a[1];b[2]=-a[2];b[3]=a[3];return b};quat4.length=function(a){var b=a[0],e=a[1],d=a[2];a=a[3];return Math.sqrt(b*b+e*e+d*d+a*a)};
quat4.normalize=function(a,b){b||(b=a);var e=a[0],d=a[1],c=a[2],f=a[3],g=Math.sqrt(e*e+d*d+c*c+f*f);if(0===g)return b[0]=0,b[1]=0,b[2]=0,b[3]=0,b;g=1/g;b[0]=e*g;b[1]=d*g;b[2]=c*g;b[3]=f*g;return b};quat4.multiply=function(a,b,e){e||(e=a);var d=a[0],c=a[1],f=a[2];a=a[3];var g=b[0],h=b[1],l=b[2];b=b[3];e[0]=d*b+a*g+c*l-f*h;e[1]=c*b+a*h+f*g-d*l;e[2]=f*b+a*l+d*h-c*g;e[3]=a*b-d*g-c*h-f*l;return e};
quat4.multiplyVec3=function(a,b,e){e||(e=b);var d=b[0],c=b[1],f=b[2];b=a[0];var g=a[1],h=a[2];a=a[3];var l=a*d+g*f-h*c,k=a*c+h*d-b*f,n=a*f+b*c-g*d,d=-b*d-g*c-h*f;e[0]=l*a+d*-b+k*-h-n*-g;e[1]=k*a+d*-g+n*-b-l*-h;e[2]=n*a+d*-h+l*-g-k*-b;return e};quat4.toMat3=function(a,b){b||(b=mat3.create());var e=a[0],d=a[1],c=a[2],f=a[3],g=e+e,h=d+d,l=c+c,k=e*g,n=e*h,e=e*l,v=d*h,d=d*l,c=c*l,g=g*f,h=h*f,f=f*l;b[0]=1-(v+c);b[1]=n+f;b[2]=e-h;b[3]=n-f;b[4]=1-(k+c);b[5]=d+g;b[6]=e+h;b[7]=d-g;b[8]=1-(k+v);return b};
quat4.toMat4=function(a,b){b||(b=mat4.create());var e=a[0],d=a[1],c=a[2],f=a[3],g=e+e,h=d+d,l=c+c,k=e*g,n=e*h,e=e*l,v=d*h,d=d*l,c=c*l,g=g*f,h=h*f,f=f*l;b[0]=1-(v+c);b[1]=n+f;b[2]=e-h;b[3]=0;b[4]=n-f;b[5]=1-(k+c);b[6]=d+g;b[7]=0;b[8]=e+h;b[9]=d-g;b[10]=1-(k+v);b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b};
quat4.slerp=function(a,b,e,d){d||(d=a);var c=a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3],f,g;if(1<=Math.abs(c))return d!==a&&(d[0]=a[0],d[1]=a[1],d[2]=a[2],d[3]=a[3]),d;f=Math.acos(c);g=Math.sqrt(1-c*c);if(0.001>Math.abs(g))return d[0]=0.5*a[0]+0.5*b[0],d[1]=0.5*a[1]+0.5*b[1],d[2]=0.5*a[2]+0.5*b[2],d[3]=0.5*a[3]+0.5*b[3],d;c=Math.sin((1-e)*f)/g;e=Math.sin(e*f)/g;d[0]=a[0]*c+b[0]*e;d[1]=a[1]*c+b[1]*e;d[2]=a[2]*c+b[2]*e;d[3]=a[3]*c+b[3]*e;return d};
quat4.str=function(a){return"["+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+"]"};
(function(){function a(a,c){this.height=this.width=0;this.cam=vec3.create([0,0,100]);this.look=vec3.create([0,0,0]);this.up=vec3.create([0,1,0]);this.worldScale=vec3.create([1,1,1]);this.matP=mat4.create();this.matMV=mat4.create();this.lastMV=mat4.create();this.currentMV=mat4.create();this.gl=a;this.initState()}function b(a,c,b){this.gl=a;this.shaderProgram=c;this.name=b;this.locAPos=a.getAttribLocation(c,"aPos");this.locATex=a.getAttribLocation(c,"aTex");this.locMatP=a.getUniformLocation(c,"matP");
this.locMatMV=a.getUniformLocation(c,"matMV");this.locOpacity=a.getUniformLocation(c,"opacity");this.locSamplerFront=a.getUniformLocation(c,"samplerFront");this.locSamplerBack=a.getUniformLocation(c,"samplerBack");this.locDestStart=a.getUniformLocation(c,"destStart");this.locDestEnd=a.getUniformLocation(c,"destEnd");this.locSeconds=a.getUniformLocation(c,"seconds");this.locPixelWidth=a.getUniformLocation(c,"pixelWidth");this.locPixelHeight=a.getUniformLocation(c,"pixelHeight");this.locLayerScale=
a.getUniformLocation(c,"layerScale");this.locOpacity&&a.uniform1f(this.locOpacity,1);this.locSamplerFront&&a.uniform1i(this.locSamplerFront,0);this.locSamplerBack&&a.uniform1i(this.locSamplerBack,1);this.locDestStart&&a.uniform2f(this.locDestStart,0,0);this.locDestEnd&&a.uniform2f(this.locDestEnd,1,1);this.hasCurrentMatMV=!1}function e(a,c){this.type=a;this.glwrap=c;this.gl=c.gl;this.indexCount=this.startIndex=this.opacityParam=0;this.mat4param=this.texParam=null;this.shaderParams=[];cr.seal(this)}
function d(a){--a;for(var c=1;32>c;c<<=1)a|=a>>c;return a+1}a.prototype.initState=function(){var a=this.gl,c;this.lastOpacity=1;this.lastTexture=null;this.currentOpacity=1;a.clearColor(0,0,0,0);a.clear(a.COLOR_BUFFER_BIT);a.enable(a.BLEND);a.blendFunc(a.ONE,a.ONE_MINUS_SRC_ALPHA);a.disable(a.CULL_FACE);a.disable(a.DEPTH_TEST);this.maxTextureSize=a.getParameter(a.MAX_TEXTURE_SIZE);this.lastSrcBlend=a.ONE;this.lastDestBlend=a.ONE_MINUS_SRC_ALPHA;this.pointBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,
this.pointBuffer);this.vertexBuffers=Array(4);this.texcoordBuffers=Array(4);for(c=0;4>c;c++)this.vertexBuffers[c]=a.createBuffer(),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffers[c]),this.texcoordBuffers[c]=a.createBuffer(),a.bindBuffer(a.ARRAY_BUFFER,this.texcoordBuffers[c]);this.curBuffer=0;this.indexBuffer=a.createBuffer();a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer);this.vertexData=new Float32Array(16E3);this.texcoordData=new Float32Array(16E3);this.pointData=new Float32Array(32E3);for(var b=
new Uint16Array(12E3),f=c=0;12E3>c;)b[c++]=f,b[c++]=f+1,b[c++]=f+2,b[c++]=f,b[c++]=f+2,b[c++]=f+3,f+=4;a.bufferData(a.ELEMENT_ARRAY_BUFFER,b,a.STATIC_DRAW);this.pointPtr=this.vertexPtr=0;this.shaderPrograms=[];c=this.createShaderProgram({src:"varying mediump vec2 vTex;\nuniform lowp float opacity;\nuniform lowp sampler2D samplerFront;\nvoid main(void) {\n\tgl_FragColor = texture2D(samplerFront, vTex);\n\tgl_FragColor *= opacity;\n}"},"attribute highp vec2 aPos;\nattribute mediump vec2 aTex;\nvarying mediump vec2 vTex;\nuniform highp mat4 matP;\nuniform highp mat4 matMV;\nvoid main(void) {\n\tgl_Position = matP * matMV * vec4(aPos.x, aPos.y, 0.0, 1.0);\n\tvTex = aTex;\n}",
"<default>");this.shaderPrograms.push(c);c=this.createShaderProgram({src:"uniform mediump sampler2D samplerFront;\nvarying lowp float opacity;\nvoid main(void) {\n\tgl_FragColor = texture2D(samplerFront, gl_PointCoord);\n\tgl_FragColor *= opacity;\n}"},"attribute vec4 aPos;\nvarying float opacity;\nuniform mat4 matP;\nuniform mat4 matMV;\nvoid main(void) {\n\tgl_Position = matP * matMV * vec4(aPos.x, aPos.y, 0.0, 1.0);\n\tgl_PointSize = aPos.z;\n\topacity = aPos.w;\n}","<point>");this.shaderPrograms.push(c);
for(var d in cr.shaders)cr.shaders.hasOwnProperty(d)&&this.shaderPrograms.push(this.createShaderProgram(cr.shaders[d],"attribute highp vec2 aPos;\nattribute mediump vec2 aTex;\nvarying mediump vec2 vTex;\nuniform highp mat4 matP;\nuniform highp mat4 matMV;\nvoid main(void) {\n\tgl_Position = matP * matMV * vec4(aPos.x, aPos.y, 0.0, 1.0);\n\tvTex = aTex;\n}",d));a.activeTexture(a.TEXTURE0);a.bindTexture(a.TEXTURE_2D,null);this.batch=[];this.batchPtr=0;this.hasPointBatchTop=this.hasQuadBatchTop=!1;
this.currentProgram=this.lastProgram=-1;this.currentShader=null;this.fbo=a.createFramebuffer();this.renderToTex=null;this.tmpVec3=vec3.create([0,0,0]);a=a.getParameter(a.ALIASED_POINT_SIZE_RANGE);this.minPointSize=a[0];this.maxPointSize=a[1];this.switchProgram(0);cr.seal(this)};a.prototype.createShaderProgram=function(a,c,f){var d=this.gl,e=d.createShader(d.FRAGMENT_SHADER);d.shaderSource(e,a.src);d.compileShader(e);if(!d.getShaderParameter(e,d.COMPILE_STATUS))return d.deleteShader(e),null;var v=
d.createShader(d.VERTEX_SHADER);d.shaderSource(v,c);d.compileShader(v);if(!d.getShaderParameter(v,d.COMPILE_STATUS))return d.deleteShader(e),d.deleteShader(v),null;c=d.createProgram();d.attachShader(c,e);d.attachShader(c,v);d.linkProgram(c);if(!d.getProgramParameter(c,d.LINK_STATUS))return d.deleteShader(e),d.deleteShader(v),d.deleteProgram(c),null;d.useProgram(c);d.validateProgram(c);d.deleteShader(e);d.deleteShader(v);f=new b(d,c,f);f.extendBoxHorizontal=a.extendBoxHorizontal||0;f.extendBoxVertical=
a.extendBoxVertical||0;f.crossSampling=!!a.crossSampling;f.animated=!!a.animated;f.parameters=a.parameters||[];a=0;for(e=f.parameters.length;a<e;a++)f.parameters[a][1]=d.getUniformLocation(c,f.parameters[a][0]),d.uniform1f(f.parameters[a][1],0);cr.seal(f);return f};a.prototype.getShaderIndex=function(a){var c,b;c=0;for(b=this.shaderPrograms.length;c<b;c++)if(this.shaderPrograms[c].name===a)return c;return-1};a.prototype.project=function(a,c,b){var f=[0,0,this.width,this.height],d=this.matMV,e=this.matP,
u=[0,0,0,0,0,0,0,0];u[0]=d[0]*a+d[4]*c+d[12];u[1]=d[1]*a+d[5]*c+d[13];u[2]=d[2]*a+d[6]*c+d[14];u[3]=d[3]*a+d[7]*c+d[15];u[4]=e[0]*u[0]+e[4]*u[1]+e[8]*u[2]+e[12]*u[3];u[5]=e[1]*u[0]+e[5]*u[1]+e[9]*u[2]+e[13]*u[3];u[6]=e[2]*u[0]+e[6]*u[1]+e[10]*u[2]+e[14]*u[3];u[7]=-u[2];0!==u[7]&&(u[7]=1/u[7],u[4]*=u[7],u[5]*=u[7],u[6]*=u[7],b[0]=(0.5*u[4]+0.5)*f[2]+f[0],b[1]=(0.5*u[5]+0.5)*f[3]+f[1])};a.prototype.setSize=function(a,c,b){if(this.width!==a||this.height!==c||b){this.endBatch();this.width=a;this.height=
c;this.gl.viewport(0,0,a,c);mat4.perspective(45,a/c,1,1E3,this.matP);mat4.lookAt(this.cam,this.look,this.up,this.matMV);a=[0,0];c=[0,0];this.project(0,0,a);this.project(1,1,c);this.worldScale[0]=1/(c[0]-a[0]);this.worldScale[1]=-1/(c[1]-a[1]);a=0;for(c=this.shaderPrograms.length;a<c;a++)b=this.shaderPrograms[a],b.hasCurrentMatMV=!1,b.locMatP&&(this.gl.useProgram(b.shaderProgram),this.gl.uniformMatrix4fv(b.locMatP,!1,this.matP));this.gl.useProgram(this.shaderPrograms[this.lastProgram].shaderProgram);
this.gl.bindTexture(this.gl.TEXTURE_2D,null);this.lastTexture=null}};a.prototype.resetModelView=function(){mat4.lookAt(this.cam,this.look,this.up,this.matMV);mat4.scale(this.matMV,this.worldScale)};a.prototype.translate=function(a,c){if(0!==a||0!==c)this.tmpVec3[0]=a,this.tmpVec3[1]=c,this.tmpVec3[2]=0,mat4.translate(this.matMV,this.tmpVec3)};a.prototype.scale=function(a,c){if(1!==a||1!==c)this.tmpVec3[0]=a,this.tmpVec3[1]=c,this.tmpVec3[2]=1,mat4.scale(this.matMV,this.tmpVec3)};a.prototype.rotateZ=
function(a){0!==a&&mat4.rotateZ(this.matMV,a)};a.prototype.updateModelView=function(){for(var a=!1,c=0;16>c;c++)if(this.lastMV[c]!==this.matMV[c]){a=!0;break}a&&(a=this.pushBatch(),a.type=5,a.mat4param?mat4.set(this.matMV,a.mat4param):a.mat4param=mat4.create(this.matMV),mat4.set(this.matMV,this.lastMV),this.hasPointBatchTop=this.hasQuadBatchTop=!1)};e.prototype.doSetTexture=function(){this.gl.bindTexture(this.gl.TEXTURE_2D,this.texParam)};e.prototype.doSetOpacity=function(){var a=this.opacityParam,
c=this.glwrap;c.currentOpacity=a;c=c.currentShader;c.locOpacity&&this.gl.uniform1f(c.locOpacity,a)};e.prototype.doQuad=function(){this.gl.drawElements(this.gl.TRIANGLES,this.indexCount,this.gl.UNSIGNED_SHORT,2*this.startIndex)};e.prototype.doSetBlend=function(){this.gl.blendFunc(this.startIndex,this.indexCount)};e.prototype.doUpdateModelView=function(){var a,c,b,f=this.glwrap.shaderPrograms,d=this.glwrap.currentProgram;a=0;for(c=f.length;a<c;a++)b=f[a],a===d&&b.locMatMV?(this.gl.uniformMatrix4fv(b.locMatMV,
!1,this.mat4param),b.hasCurrentMatMV=!0):b.hasCurrentMatMV=!1;mat4.set(this.mat4param,this.glwrap.currentMV)};e.prototype.doRenderToTexture=function(){var a=this.gl,c=this.glwrap;this.texParam?(a.bindFramebuffer(a.FRAMEBUFFER,c.fbo),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,this.texParam,0)):(a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,null,0),a.bindFramebuffer(a.FRAMEBUFFER,null))};e.prototype.doClear=function(){var a=this.gl;0===this.startIndex?
(a.clearColor(this.mat4param[0],this.mat4param[1],this.mat4param[2],this.mat4param[3]),a.clear(a.COLOR_BUFFER_BIT)):(a.enable(a.SCISSOR_TEST),a.scissor(this.mat4param[0],this.mat4param[1],this.mat4param[2],this.mat4param[3]),a.clearColor(0,0,0,0),a.clear(this.gl.COLOR_BUFFER_BIT),a.disable(a.SCISSOR_TEST))};e.prototype.doPoints=function(){var a=this.gl,c=this.glwrap,b=c.shaderPrograms[1];a.useProgram(b.shaderProgram);!b.hasCurrentMatMV&&b.locMatMV&&(a.uniformMatrix4fv(b.locMatMV,!1,c.currentMV),b.hasCurrentMatMV=
!0);a.enableVertexAttribArray(b.locAPos);a.bindBuffer(a.ARRAY_BUFFER,c.pointBuffer);a.vertexAttribPointer(b.locAPos,4,a.FLOAT,!1,0,0);a.drawArrays(a.POINTS,this.startIndex/4,this.indexCount);b=c.currentShader;a.useProgram(b.shaderProgram);0<=b.locAPos&&(a.enableVertexAttribArray(b.locAPos),a.bindBuffer(a.ARRAY_BUFFER,c.vertexBuffers[c.curBuffer]),a.vertexAttribPointer(b.locAPos,2,a.FLOAT,!1,0,0));0<=b.locATex&&(a.enableVertexAttribArray(b.locATex),a.bindBuffer(a.ARRAY_BUFFER,c.texcoordBuffers[c.curBuffer]),
a.vertexAttribPointer(b.locATex,2,a.FLOAT,!1,0,0))};e.prototype.doSetProgram=function(){var a=this.gl,c=this.glwrap,b=c.shaderPrograms[this.startIndex];c.currentProgram=this.startIndex;c.currentShader=b;a.useProgram(b.shaderProgram);!b.hasCurrentMatMV&&b.locMatMV&&(a.uniformMatrix4fv(b.locMatMV,!1,c.currentMV),b.hasCurrentMatMV=!0);b.locOpacity&&a.uniform1f(b.locOpacity,c.currentOpacity);0<=b.locAPos&&(a.enableVertexAttribArray(b.locAPos),a.bindBuffer(a.ARRAY_BUFFER,c.vertexBuffers[c.curBuffer]),
a.vertexAttribPointer(b.locAPos,2,a.FLOAT,!1,0,0));0<=b.locATex&&(a.enableVertexAttribArray(b.locATex),a.bindBuffer(a.ARRAY_BUFFER,c.texcoordBuffers[c.curBuffer]),a.vertexAttribPointer(b.locATex,2,a.FLOAT,!1,0,0))};e.prototype.doSetProgramParameters=function(){var a,c,b=this.glwrap.currentShader,f=this.gl;b.locSamplerBack&&(f.activeTexture(f.TEXTURE1),f.bindTexture(f.TEXTURE_2D,this.texParam),f.activeTexture(f.TEXTURE0));b.locPixelWidth&&f.uniform1f(b.locPixelWidth,this.mat4param[0]);b.locPixelHeight&&
f.uniform1f(b.locPixelHeight,this.mat4param[1]);b.locDestStart&&f.uniform2f(b.locDestStart,this.mat4param[2],this.mat4param[3]);b.locDestEnd&&f.uniform2f(b.locDestEnd,this.mat4param[4],this.mat4param[5]);b.locLayerScale&&f.uniform1f(b.locLayerScale,this.mat4param[6]);b.locSeconds&&f.uniform1f(b.locSeconds,cr.performance_now()/1E3);if(b.parameters.length)for(a=0,c=b.parameters.length;a<c;a++)f.uniform1f(b.parameters[a][1],this.shaderParams[a])};a.prototype.pushBatch=function(){this.batchPtr===this.batch.length&&
this.batch.push(new e(0,this));return this.batch[this.batchPtr++]};a.prototype.endBatch=function(){if(0!==this.batchPtr&&!this.gl.isContextLost()){var a=this.gl;0<this.pointPtr&&(a.bindBuffer(a.ARRAY_BUFFER,this.pointBuffer),a.bufferData(a.ARRAY_BUFFER,this.pointData.subarray(0,this.pointPtr),a.STREAM_DRAW),c&&0<=c.locAPos&&"<point>"===c.name&&a.vertexAttribPointer(c.locAPos,4,a.FLOAT,!1,0,0));if(0<this.vertexPtr){var c=this.currentShader;a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffers[this.curBuffer]);
a.bufferData(a.ARRAY_BUFFER,this.vertexData.subarray(0,this.vertexPtr),a.STREAM_DRAW);c&&0<=c.locAPos&&"<point>"!==c.name&&a.vertexAttribPointer(c.locAPos,2,a.FLOAT,!1,0,0);a.bindBuffer(a.ARRAY_BUFFER,this.texcoordBuffers[this.curBuffer]);a.bufferData(a.ARRAY_BUFFER,this.texcoordData.subarray(0,this.vertexPtr),a.STREAM_DRAW);c&&0<=c.locATex&&"<point>"!==c.name&&a.vertexAttribPointer(c.locATex,2,a.FLOAT,!1,0,0)}for(var b,a=0,c=this.batchPtr;a<c;a++)switch(b=this.batch[a],b.type){case 1:b.doQuad();
break;case 2:b.doSetTexture();break;case 3:b.doSetOpacity();break;case 4:b.doSetBlend();break;case 5:b.doUpdateModelView();break;case 6:b.doRenderToTexture();break;case 7:b.doClear();break;case 8:b.doPoints();break;case 9:b.doSetProgram();break;case 10:b.doSetProgramParameters()}this.pointPtr=this.vertexPtr=this.batchPtr=0;this.hasPointBatchTop=this.hasQuadBatchTop=!1;this.curBuffer++;4<=this.curBuffer&&(this.curBuffer=0)}};a.prototype.setOpacity=function(a){if(a!==this.lastOpacity){var c=this.pushBatch();
c.type=3;this.lastOpacity=c.opacityParam=a;this.hasPointBatchTop=this.hasQuadBatchTop=!1}};a.prototype.setTexture=function(a){if(a!==this.lastTexture){var c=this.pushBatch();c.type=2;this.lastTexture=c.texParam=a;this.hasPointBatchTop=this.hasQuadBatchTop=!1}};a.prototype.setBlend=function(a,c){if(a!==this.lastSrcBlend||c!==this.lastDestBlend){var b=this.pushBatch();b.type=4;b.startIndex=a;b.indexCount=c;this.lastSrcBlend=a;this.lastDestBlend=c;this.hasPointBatchTop=this.hasQuadBatchTop=!1}};a.prototype.setAlphaBlend=
function(){this.setBlend(this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA)};a.prototype.quad=function(a,c,b,f,d,e,u,p){15992<=this.vertexPtr&&this.endBatch();var t=this.vertexPtr,s=this.vertexData,m=this.texcoordData;if(this.hasQuadBatchTop)this.batch[this.batchPtr-1].indexCount+=6;else{var x=this.pushBatch();x.type=1;x.startIndex=3*(t/4);x.indexCount=6;this.hasQuadBatchTop=!0;this.hasPointBatchTop=!1}s[t]=a;m[t++]=0;s[t]=c;m[t++]=0;s[t]=b;m[t++]=1;s[t]=f;m[t++]=0;s[t]=d;m[t++]=1;s[t]=e;m[t++]=1;s[t]=u;m[t++]=
0;s[t]=p;m[t++]=1;this.vertexPtr=t};a.prototype.quadTex=function(a,c,b,f,d,e,u,p,t){15992<=this.vertexPtr&&this.endBatch();var s=this.vertexPtr,m=this.vertexData,x=this.texcoordData;if(this.hasQuadBatchTop)this.batch[this.batchPtr-1].indexCount+=6;else{var z=this.pushBatch();z.type=1;z.startIndex=3*(s/4);z.indexCount=6;this.hasQuadBatchTop=!0;this.hasPointBatchTop=!1}m[s]=a;x[s++]=t.left;m[s]=c;x[s++]=t.top;m[s]=b;x[s++]=t.right;m[s]=f;x[s++]=t.top;m[s]=d;x[s++]=t.right;m[s]=e;x[s++]=t.bottom;m[s]=
u;x[s++]=t.left;m[s]=p;x[s++]=t.bottom;this.vertexPtr=s};a.prototype.point=function(a,c,b,f){7996<=this.pointPtr&&this.endBatch();var d=this.pointPtr,e=this.pointData;if(this.hasPointBatchTop)this.batch[this.batchPtr-1].indexCount++;else{var u=this.pushBatch();u.type=8;u.startIndex=d;u.indexCount=1;this.hasPointBatchTop=!0;this.hasQuadBatchTop=!1}e[d++]=a;e[d++]=c;e[d++]=b;e[d++]=f;this.pointPtr=d};a.prototype.switchProgram=function(a){if(this.lastProgram!==a){if(!this.shaderPrograms[a]){if(0===this.lastProgram)return;
a=0}var c=this.pushBatch();c.type=9;this.lastProgram=c.startIndex=a;this.hasPointBatchTop=this.hasQuadBatchTop=!1}};a.prototype.programUsesDest=function(a){a=this.shaderPrograms[a];return!(!a.locDestStart&&!a.locDestEnd)};a.prototype.programUsesCrossSampling=function(a){return this.shaderPrograms[a].crossSampling};a.prototype.programExtendsBox=function(a){a=this.shaderPrograms[a];return 0!==a.extendBoxHorizontal||0!==a.extendBoxVertical};a.prototype.getProgramBoxExtendHorizontal=function(a){return this.shaderPrograms[a].extendBoxHorizontal};
a.prototype.getProgramBoxExtendVertical=function(a){return this.shaderPrograms[a].extendBoxVertical};a.prototype.getProgramParameterType=function(a,c){return this.shaderPrograms[a].parameters[c][2]};a.prototype.programIsAnimated=function(a){return this.shaderPrograms[a].animated};a.prototype.setProgramParameters=function(a,c,b,f,d,e,u,p,t){var s=this.shaderPrograms[this.lastProgram];if(s.locPixelWidth||s.locPixelHeight||s.locSeconds||s.locSamplerBack||s.locDestStart||s.locDestEnd||s.locLayerScale||
t.length){s=this.pushBatch();s.type=10;s.mat4param?mat4.set(this.matMV,s.mat4param):s.mat4param=mat4.create();s.mat4param[0]=c;s.mat4param[1]=b;s.mat4param[2]=f;s.mat4param[3]=d;s.mat4param[4]=e;s.mat4param[5]=u;s.mat4param[6]=p;s.texParam=a;if(t.length)for(s.shaderParams.length=t.length,a=0,c=t.length;a<c;a++)s.shaderParams[a]=t[a];this.hasPointBatchTop=this.hasQuadBatchTop=!1}};a.prototype.clear=function(a,c,b,f){var d=this.pushBatch();d.type=7;d.startIndex=0;d.mat4param||(d.mat4param=mat4.create());
d.mat4param[0]=a;d.mat4param[1]=c;d.mat4param[2]=b;d.mat4param[3]=f;this.hasPointBatchTop=this.hasQuadBatchTop=!1};a.prototype.clearRect=function(a,c,b,f){var d=this.pushBatch();d.type=7;d.startIndex=1;d.mat4param||(d.mat4param=mat4.create());d.mat4param[0]=a;d.mat4param[1]=c;d.mat4param[2]=b;d.mat4param[3]=f;this.hasPointBatchTop=this.hasQuadBatchTop=!1};a.prototype.present=function(){this.endBatch();this.gl.flush()};var c=[],f={};a.prototype.loadTexture=function(a,b,e,k,n){b=!!b;e=!!e;var v=a.src+
","+b+","+e+(b?","+n:""),u=null;if("undefined"!==typeof a.src&&f.hasOwnProperty(v))return u=f[v],u.c2refcount++,u;this.endBatch();var p=this.gl,t=cr.isPOT(a.width)&&cr.isPOT(a.height),u=p.createTexture();p.bindTexture(p.TEXTURE_2D,u);p.pixelStorei(p.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);var s=p.RGBA,m=p.RGBA,x=p.UNSIGNED_BYTE;if(k)switch(k){case 1:m=s=p.RGB;break;case 2:x=p.UNSIGNED_SHORT_4_4_4_4;break;case 3:x=p.UNSIGNED_SHORT_5_5_5_1;break;case 4:m=s=p.RGB,x=p.UNSIGNED_SHORT_5_6_5}!t&&b?(k=document.createElement("canvas"),
k.width=d(a.width),k.height=d(a.height),k.getContext("2d").drawImage(a,0,0,a.width,a.height,0,0,k.width,k.height),p.texImage2D(p.TEXTURE_2D,0,s,m,x,k)):p.texImage2D(p.TEXTURE_2D,0,s,m,x,a);b?"repeat-x"===n?(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.REPEAT),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE)):("repeat-y"===n?p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE):p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.REPEAT),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,
p.REPEAT)):(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE));e?(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.LINEAR),t?(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.LINEAR_MIPMAP_LINEAR),p.generateMipmap(p.TEXTURE_2D)):p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.LINEAR)):(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.NEAREST));p.bindTexture(p.TEXTURE_2D,
null);this.lastTexture=null;u.c2width=a.width;u.c2height=a.height;u.c2refcount=1;u.c2texkey=v;c.push(u);return f[v]=u};a.prototype.createEmptyTexture=function(a,b,f,d){this.endBatch();var e=this.gl,v=e.createTexture();e.bindTexture(e.TEXTURE_2D,v);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,a,b,0,e.RGBA,d?e.UNSIGNED_SHORT_4_4_4_4:e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,
f?e.LINEAR:e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,f?e.LINEAR:e.NEAREST);e.bindTexture(e.TEXTURE_2D,null);this.lastTexture=null;v.c2width=a;v.c2height=b;c.push(v);return v};a.prototype.videoToTexture=function(a,c,b){this.endBatch();var f=this.gl;f.bindTexture(f.TEXTURE_2D,c);f.texImage2D(f.TEXTURE_2D,0,f.RGBA,f.RGBA,b?f.UNSIGNED_SHORT_4_4_4_4:f.UNSIGNED_BYTE,a);f.bindTexture(f.TEXTURE_2D,null);this.lastTexture=null};a.prototype.deleteTexture=function(a){a&&("undefined"!==typeof a.c2refcount&&
1<a.c2refcount?a.c2refcount--:(this.endBatch(),this.gl.bindTexture(this.gl.TEXTURE_2D,null),this.lastTexture=null,cr.arrayFindRemove(c,a),"undefined"!==typeof a.c2texkey&&delete f[a.c2texkey],this.gl.deleteTexture(a)))};a.prototype.estimateVRAM=function(){var a=8*this.width*this.height,b,f,d;b=0;for(f=c.length;b<f;b++)d=c[b],a+=4*d.c2width*d.c2height;return a};a.prototype.textureCount=function(){return c.length};a.prototype.setRenderingToTexture=function(a){if(a!==this.renderToTex){var c=this.pushBatch();
c.type=6;this.renderToTex=c.texParam=a;this.hasPointBatchTop=this.hasQuadBatchTop=!1}};cr.GLWrap=a})();
(function(){function a(a){if(a&&(a.getContext||a.dc)&&!a.c2runtime){a.c2runtime=this;var c=this;this.isPhoneGap="undefined"!==typeof window.device&&("undefined"!==typeof window.device.cordova||"undefined"!==typeof window.device.phonegap);this.isDirectCanvas=!!a.dc;this.isAppMobi="undefined"!==typeof window.AppMobi||this.isDirectCanvas;if(this.isCocoonJs=!!window.c2cocoonjs)CocoonJS.App.onSuspended.addEventListener(function(){c.setSuspended(!0)}),CocoonJS.App.onActivated.addEventListener(function(){c.setSuspended(!1)});
this.isDomFree=this.isDirectCanvas||this.isCocoonJs;this.isTizen=/tizen/i.test(navigator.userAgent);this.isAndroid=/android/i.test(navigator.userAgent)&&!this.isTizen;this.isIE=/msie/i.test(navigator.userAgent);this.isiPhone=/iphone/i.test(navigator.userAgent)||/ipod/i.test(navigator.userAgent);this.isiPad=/ipad/i.test(navigator.userAgent);this.isiOS=this.isiPhone||this.isiPad;this.isChrome=/chrome/i.test(navigator.userAgent)||/chromium/i.test(navigator.userAgent);this.isSafari=!this.isChrome&&/safari/i.test(navigator.userAgent);
this.isWindows=/windows/i.test(navigator.userAgent);this.isNodeWebkit="undefined"!==typeof window.c2nodewebkit;this.isArcade="undefined"!==typeof window.is_scirra_arcade;this.isWindows8App=!("undefined"===typeof window.c2isWindows8||!window.c2isWindows8);this.isWindowsPhone8=!("undefined"===typeof window.c2isWindowsPhone8||!window.c2isWindowsPhone8);this.isBlackberry10=!("undefined"===typeof window.c2isBlackberry10||!window.c2isBlackberry10);this.devicePixelRatio=1;this.isMobile=this.isPhoneGap||
this.isAppMobi||this.isCocoonJs||this.isAndroid||this.isiOS||this.isWindowsPhone8||this.isBlackberry10||this.isTizen;this.isMobile||(this.isMobile=/(blackberry|bb10|playbook|palm|symbian|nokia|windows\s+ce|phone|mobile|tablet)/i.test(navigator.userAgent));"undefined"===typeof cr_is_preview||this.isNodeWebkit||"?nw"!==window.location.search&&!/nodewebkit/i.test(navigator.userAgent)||(this.isNodeWebkit=!0);this.isDebug="undefined"!==typeof cr_is_preview&&-1<window.location.search.indexOf("debug");this.canvas=
a;this.canvasdiv=document.getElementById("c2canvasdiv");this.ctx=this.glwrap=this.gl=null;this.canvas.oncontextmenu=function(a){a.preventDefault&&a.preventDefault();return!1};this.canvas.onselectstart=function(a){a.preventDefault&&a.preventDefault();return!1};this.isDirectCanvas&&(window.c2runtime=this);this.isNodeWebkit&&(window.ondragover=function(a){a.preventDefault();return!1},window.ondrop=function(a){a.preventDefault();return!1});this.width=a.width;this.height=a.height;this.lastwidth=this.width;
this.lastheight=this.height;this.redraw=!0;this.isSuspended=!1;Date.now||(Date.now=function(){return+new Date});this.plugins=[];this.types={};this.types_by_index=[];this.behaviors=[];this.layouts={};this.layouts_by_index=[];this.eventsheets={};this.eventsheets_by_index=[];this.wait_for_textures=[];this.triggers_to_postinit=[];this.all_global_vars=[];this.all_local_vars=[];this.deathRow=new cr.ObjectSet;this.isInClearDeathRow=!1;this.isInOnDestroy=0;this.isRunningEvents=!1;this.createRow=[];this.isLoadingState=
!1;this.lastSaveJson=this.loadFromJson=this.loadFromSlot=this.saveToSlot="";this.suspendDrawing=this.signalledContinuousPreview=!1;this.zeroDtCount=this.cpuutilisation=this.logictime=this.dt1=this.dt=0;this.timescale=1;this.kahanTime=new cr.KahanAdder;this.last_tick_time=0;this.measuring_dt=!0;this.objectcount=this.framecount=this.execcount=this.tickcount=this.last_fps_time=this.fps=0;this.changelayout=null;this.destroycallbacks=[];this.event_stack=[];this.event_stack_index=-1;this.localvar_stack=
[[]];this.trigger_depth=this.localvar_stack_index=0;this.pushEventStack(null);this.loop_stack=[];this.loop_stack_index=-1;this.next_puid=this.next_uid=0;this.layout_first_tick=!0;this.family_count=0;this.suspend_events=[];this.timeout_id=this.raf_id=0;this.isloading=!0;this.loadingprogress=0;this.isNodeFullscreen=!1;this.stackLocalCount=0;this.had_a_click=!1;this.objects_to_tick=new cr.ObjectSet;this.objects_to_tick2=new cr.ObjectSet;this.registered_collisions=[];this.temp_poly=new cr.CollisionPoly([]);
this.temp_poly2=new cr.CollisionPoly([]);this.allGroups=[];this.activeGroups={};this.cndsBySid={};this.actsBySid={};this.varsBySid={};this.blocksBySid={};this.layout_tex=this.layer_tex=this.layer_ctx=this.layer_canvas=this.running_layout=null;this.uses_background_blending=this.is_WebGL_context_lost=!1;this.fx_tex=[null,null];this.fullscreen_scaling=0;this.files_subfolder="";this.objectsByUid={};this.snapshotCanvas=this.loaderlogo=null;this.snapshotData="";this.load();this.devicePixelRatio=(this.isRetina=
!this.isDomFree&&this.useiOSRetina&&(this.isiOS||this.isTizen))?window.devicePixelRatio||1:1;this.ClearDeathRow();var m;"undefined"!==typeof jQuery&&0<this.fullscreen_mode&&this.setSize(jQuery(window).width(),jQuery(window).height());try{if(this.enableWebGL&&(this.isCocoonJs||!this.isDomFree)){m={depth:!1,antialias:!this.isMobile};var b=!0;if(this.isChrome&&this.isWindows){var f=document.createElement("canvas");"OES_texture_float,OES_standard_derivatives,WEBKIT_WEBGL_lose_context"===(f.getContext("webgl",
m)||f.getContext("experimental-webgl",m)).getSupportedExtensions().toString()&&(b=!1)}b&&(this.gl=a.getContext("webgl",m)||a.getContext("experimental-webgl",m))}}catch(r){}if(this.gl){this.isDomFree||(this.overlay_canvas=document.createElement("canvas"),jQuery(this.overlay_canvas).appendTo(this.canvas.parentNode),this.overlay_canvas.oncontextmenu=function(a){return!1},this.overlay_canvas.onselectstart=function(a){return!1},this.overlay_canvas.width=a.width,this.overlay_canvas.height=a.height,this.positionOverlayCanvas(),
this.overlay_ctx=this.overlay_canvas.getContext("2d"));this.glwrap=new cr.GLWrap(this.gl,this.isMobile);this.glwrap.setSize(a.width,a.height);this.ctx=null;this.canvas.addEventListener("webglcontextlost",function(a){a.preventDefault();c.onContextLost();window.cr_setSuspended(!0)},!1);this.canvas.addEventListener("webglcontextrestored",function(a){c.glwrap.initState();c.glwrap.setSize(c.glwrap.width,c.glwrap.height,!0);c.layer_tex=null;c.layout_tex=null;c.fx_tex[0]=null;c.fx_tex[1]=null;c.onContextRestored();
c.redraw=!0;window.cr_setSuspended(!1)},!1);var q,g,d,e,h;a=0;for(m=this.types_by_index.length;a<m;a++)for(q=this.types_by_index[a],b=0,f=q.effect_types.length;b<f;b++)d=q.effect_types[b],d.shaderindex=this.glwrap.getShaderIndex(d.id),this.uses_background_blending=this.uses_background_blending||this.glwrap.programUsesDest(d.shaderindex);a=0;for(m=this.layouts_by_index.length;a<m;a++){e=this.layouts_by_index[a];b=0;for(f=e.effect_types.length;b<f;b++)d=e.effect_types[b],d.shaderindex=this.glwrap.getShaderIndex(d.id);
b=0;for(f=e.layers.length;b<f;b++)for(h=e.layers[b],q=0,g=h.effect_types.length;q<g;q++)d=h.effect_types[q],d.shaderindex=this.glwrap.getShaderIndex(d.id),this.uses_background_blending=this.uses_background_blending||this.glwrap.programUsesDest(d.shaderindex)}}else{if(0<this.fullscreen_mode&&this.isDirectCanvas){this.canvas=null;document.oncontextmenu=function(a){return!1};document.onselectstart=function(a){return!1};this.ctx=AppMobi.canvas.getContext("2d");try{this.ctx.samplingMode=this.linearSampling?
"smooth":"sharp",this.ctx.globalScale=1,this.ctx.HTML5CompatibilityMode=!0}catch(n){}0!==this.width&&0!==this.height&&(this.ctx.width=this.width,this.ctx.height=this.height)}this.ctx||(this.isCocoonJs?(m={antialias:!!this.linearSampling},this.ctx=a.getContext("2d",m)):this.ctx=a.getContext("2d"),this.ctx.webkitImageSmoothingEnabled=this.linearSampling,this.ctx.mozImageSmoothingEnabled=this.linearSampling,this.ctx.msImageSmoothingEnabled=this.linearSampling,this.ctx.imageSmoothingEnabled=this.linearSampling);
this.overlay_ctx=this.overlay_canvas=null}this.tickFunc=function(){c.tick()};window==window.top||this.isDomFree||this.isWindows8App||(document.addEventListener("mousedown",function(){window.focus()},!0),document.addEventListener("touchstart",function(){window.focus()},!0));"undefined"!==typeof cr_is_preview&&(this.isCocoonJs&&console.log("[Construct 2] In preview-over-wifi via CocoonJS mode"),-1<window.location.search.indexOf("continuous")&&(cr.logexport("Reloading for continuous preview"),this.loadFromSlot=
"__c2_continuouspreview",this.suspendDrawing=!0),this.pauseOnBlur&&!this.isMobile&&(jQuery(window).focus(function(){c.setSuspended(!1)}),jQuery(window).blur(function(){c.setSuspended(!0)})));this.go();this.extra={};cr.seal(this)}}function b(a){a.target.result.createObjectStore("saves",{keyPath:"slot"})}function e(a,c,m,f){var g=indexedDB.open("_C2SaveStates");g.onupgradeneeded=b;g.onerror=f;g.onsuccess=function(b){b=b.target.result;b.onerror=f;b.transaction(["saves"],"readwrite").objectStore("saves").put({slot:a,
data:c}).onsuccess=m}}function d(a,c,m){var f=indexedDB.open("_C2SaveStates");f.onupgradeneeded=b;f.onerror=m;f.onsuccess=function(b){b=b.target.result;b.onerror=m;var r=b.transaction(["saves"]).objectStore("saves").get(a);r.onsuccess=function(a){r.result?c(r.result.data):c(null)}}}function c(){cr.logexport("Reloading for continuous preview");window.c2cocoonjs?CocoonJS.App.reload():-1<window.location.search.indexOf("continuous")?window.location.reload(!0):window.location+="?continuous"}function f(a){var c,
m={};for(c in a)!a.hasOwnProperty(c)||a[c]instanceof cr.ObjectSet||"undefined"===typeof a[c].c2userdata&&(m[c]=a[c]);return m}a.prototype.setSize=function(a,c){var m=this.hideAddressBar&&this.isiPhone&&!navigator.standalone&&!this.isDomFree&&!this.isPhoneGap,b=0;m&&(this.isiPhone?b=60:this.isAndroid&&(b=56),c+=b);var f=0,r=0,q=0,g=0,d=0,d=this.fullscreen_mode,e=document.mozFullScreen||document.webkitIsFullScreen||document.fullScreen||this.isNodeFullscreen;e&&0<this.fullscreen_scaling&&(d=this.fullscreen_scaling);
4<=d?(q=this.original_width/this.original_height,a/c>q?(q*=c,5===d?(d=q/this.original_width,1<d?d=Math.floor(d):1>d&&(d=1/Math.ceil(1/d)),q=this.original_width*d,g=this.original_height*d,f=(a-q)/2,r=(c-g)/2,a=q,c=g):(f=(a-q)/2,a=q)):(g=a/q,5===d?(d=g/this.original_height,1<d?d=Math.floor(d):1>d&&(d=1/Math.ceil(1/d)),q=this.original_width*d,g=this.original_height*d,f=(a-q)/2,r=(c-g)/2,a=q):r=(c-g)/2,c=g),e&&!this.isNodeWebkit&&(r=f=0),f=Math.floor(f),r=Math.floor(r),a=Math.floor(a),c=Math.floor(c)):
this.isNodeWebkit&&this.isNodeFullscreen&&0===this.fullscreen_mode_set&&(f=Math.floor((a-this.original_width)/2),r=Math.floor((c-this.original_height)/2),a=this.original_width,c=this.original_height);this.isRetina&&this.isiPad&&1<this.devicePixelRatio&&(1024<=a&&(a=1023),1024<=c&&(c=1023));e=this.devicePixelRatio;this.width=a*e;this.height=c*e;this.redraw=!0;this.canvasdiv&&!this.isDomFree&&(jQuery(this.canvasdiv).css({width:a+"px",height:c+"px","margin-left":f,"margin-top":r}),"undefined"!==typeof cr_is_preview&&
jQuery("#borderwrap").css({width:a+"px",height:c+"px"}));this.canvas&&(this.canvas.width=a*e,this.canvas.height=c*e,this.isRetina&&jQuery(this.canvas).css({width:a+"px",height:c+"px"}));this.overlay_canvas&&(this.overlay_canvas.width=a,this.overlay_canvas.height=c);this.glwrap&&this.glwrap.setSize(a,c);this.isDirectCanvas&&this.ctx&&(this.ctx.width=a,this.ctx.height=c);this.ctx&&(this.ctx.webkitImageSmoothingEnabled=this.linearSampling,this.ctx.mozImageSmoothingEnabled=this.linearSampling,this.ctx.msImageSmoothingEnabled=
this.linearSampling,this.ctx.imageSmoothingEnabled=this.linearSampling);m&&0<b&&window.setTimeout(function(){window.scrollTo(0,1)},100)};a.prototype.onContextLost=function(){this.is_WebGL_context_lost=!0;var a,c,m;a=0;for(c=this.types_by_index.length;a<c;a++)if(m=this.types_by_index[a],m.onLostWebGLContext)m.onLostWebGLContext()};a.prototype.onContextRestored=function(){this.is_WebGL_context_lost=!1;var a,c,m;a=0;for(c=this.types_by_index.length;a<c;a++)if(m=this.types_by_index[a],m.onRestoreWebGLContext)m.onRestoreWebGLContext()};
a.prototype.positionOverlayCanvas=function(){if(!this.isDomFree){var a=document.mozFullScreen||document.webkitIsFullScreen||document.fullScreen||this.isNodeFullscreen?jQuery(this.canvas).offset():jQuery(this.canvas).position();a.position="absolute";jQuery(this.overlay_canvas).css(a)}};var g=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame||window.oCancelAnimationFrame;a.prototype.setSuspended=function(a){var c;if(a&&!this.isSuspended)for(cr.logexport("[Construct 2] Suspending"),
this.isSuspended=!0,0!==this.raf_id&&g&&g(this.raf_id),0!==this.timeout_id&&clearTimeout(this.timeout_id),a=0,c=this.suspend_events.length;a<c;a++)this.suspend_events[a](!0);else if(!a&&this.isSuspended){cr.logexport("[Construct 2] Resuming");this.isSuspended=!1;this.last_tick_time=cr.performance_now();this.last_fps_time=cr.performance_now();a=this.logictime=this.framecount=0;for(c=this.suspend_events.length;a<c;a++)this.suspend_events[a](!1);this.tick()}};a.prototype.addSuspendCallback=function(a){this.suspend_events.push(a)};
a.prototype.load=function(){var a=cr.getProjectModel();this.name=a[0];this.first_layout=a[1];this.fullscreen_mode=a[11];this.fullscreen_mode_set=a[11];this.isDomFree&&(4<=a[11]||0===a[11])&&(cr.logexport("[Construct 2] Letterbox scale fullscreen modes are not supported on this platform - falling back to 'Scale outer'"),this.fullscreen_mode_set=this.fullscreen_mode=3);this.uses_loader_layout=a[17];this.loaderstyle=a[18];0===this.loaderstyle&&(this.loaderlogo=new Image,this.loaderlogo.src="loading-logo.png");
this.next_uid=a[20];this.system=new cr.system_object(this);var c,m,b,f,r,q,d,g,e;c=0;for(m=a[2].length;c<m;c++){d=a[2][c];cr.add_common_aces(d);e=new d[0](this);e.singleglobal=d[1];e.is_world=d[2];e.must_predraw=d[9];if(e.onCreate)e.onCreate();cr.seal(e);this.plugins.push(e)}a=cr.getProjectModel();c=0;for(m=a[3].length;c<m;c++){d=a[3][c];r=d[1];e=null;b=0;for(f=this.plugins.length;b<f;b++)if(this.plugins[b]instanceof r){e=this.plugins[b];break}var h=new e.Type(e);h.name=d[0];h.is_family=d[2];h.instvar_sids=
d[3].slice(0);h.vars_count=d[3].length;h.behs_count=d[4];h.fx_count=d[5];h.sid=d[11];h.is_family?(h.members=[],h.family_index=this.family_count++,h.families=null):(h.members=null,h.family_index=-1,h.families=[]);h.family_var_map=null;h.family_beh_map=null;h.family_fx_map=null;h.is_contained=!1;h.container=null;d[6]?(h.texture_file=d[6][0],h.texture_filesize=d[6][1],h.texture_pixelformat=d[6][2]):(h.texture_file=null,h.texture_filesize=0,h.texture_pixelformat=0);h.animations=d[7]?d[7]:null;h.index=
c;h.instances=[];h.deadCache=[];h.solstack=[new cr.selection(h)];h.cur_sol=0;h.default_instance=null;h.stale_iids=!0;h.updateIIDs=cr.type_updateIIDs;h.getFirstPicked=cr.type_getFirstPicked;h.getPairedInstance=cr.type_getPairedInstance;h.getCurrentSol=cr.type_getCurrentSol;h.pushCleanSol=cr.type_pushCleanSol;h.pushCopySol=cr.type_pushCopySol;h.popSol=cr.type_popSol;h.getBehaviorByName=cr.type_getBehaviorByName;h.getBehaviorIndexByName=cr.type_getBehaviorIndexByName;h.getEffectIndexByName=cr.type_getEffectIndexByName;
h.applySolToContainer=cr.type_applySolToContainer;h.extra={};h.toString=cr.type_toString;h.behaviors=[];b=0;for(f=d[8].length;b<f;b++){g=d[8][b];var n=g[1],p=null;r=0;for(q=this.behaviors.length;r<q;r++)if(this.behaviors[r]instanceof n){p=this.behaviors[r];break}if(!p){p=new n(this);p.my_instances=new cr.ObjectSet;if(p.onCreate)p.onCreate();cr.seal(p);this.behaviors.push(p)}r=new p.Type(p,h);r.name=g[0];r.sid=g[2];r.onCreate();cr.seal(r);h.behaviors.push(r)}h.global=d[9];h.isOnLoaderLayout=d[10];
h.effect_types=[];b=0;for(f=d[12].length;b<f;b++)h.effect_types.push({id:d[12][b][0],name:d[12][b][1],shaderindex:-1,active:!0,index:b});if(!this.uses_loader_layout||h.is_family||h.isOnLoaderLayout||!e.is_world)h.onCreate(),cr.seal(h);h.name&&(this.types[h.name]=h);this.types_by_index.push(h);e.singleglobal&&(b=new e.Instance(h),b.uid=this.next_uid++,b.puid=this.next_puid++,b.iid=0,b.get_iid=cr.inst_get_iid,b.toString=cr.inst_toString,b.properties=d[13],b.onCreate(),cr.seal(b),h.instances.push(b),
this.objectsByUid[b.uid.toString()]=b)}c=0;for(m=a[4].length;c<m;c++)for(r=a[4][c],q=this.types_by_index[r[0]],b=1,f=r.length;b<f;b++)d=this.types_by_index[r[b]],d.families.push(q),q.members.push(d);c=0;for(m=a[22].length;c<m;c++){r=a[22][c];q=[];b=0;for(f=r.length;b<f;b++)q.push(this.types_by_index[r[b]]);b=0;for(f=q.length;b<f;b++)q[b].is_contained=!0,q[b].container=q}if(0<this.family_count)for(c=0,m=this.types_by_index.length;c<m;c++)if(d=this.types_by_index[c],!d.is_family&&d.families.length){d.family_var_map=
Array(this.family_count);d.family_beh_map=Array(this.family_count);d.family_fx_map=Array(this.family_count);h=[];b=p=n=g=0;for(f=d.families.length;b<f;b++)for(e=d.families[b],d.family_var_map[e.family_index]=g,g+=e.vars_count,d.family_beh_map[e.family_index]=n,n+=e.behs_count,d.family_fx_map[e.family_index]=p,p+=e.fx_count,r=0,q=e.effect_types.length;r<q;r++)h.push(cr.shallowCopy({},e.effect_types[r]));d.effect_types=h.concat(d.effect_types);b=0;for(f=d.effect_types.length;b<f;b++)d.effect_types[b].index=
b}c=0;for(m=a[5].length;c<m;c++)d=a[5][c],b=new cr.layout(this,d),cr.seal(b),this.layouts[b.name]=b,this.layouts_by_index.push(b);c=0;for(m=a[6].length;c<m;c++)d=a[6][c],b=new cr.eventsheet(this,d),cr.seal(b),this.eventsheets[b.name]=b,this.eventsheets_by_index.push(b);c=0;for(m=this.eventsheets_by_index.length;c<m;c++)this.eventsheets_by_index[c].postInit();c=0;for(m=this.triggers_to_postinit.length;c<m;c++)this.triggers_to_postinit[c].postInit();this.triggers_to_postinit.length=0;this.files_subfolder=
a[7];this.pixel_rounding=a[8];this.original_width=a[9];this.original_height=a[10];this.aspect_scale=1;this.enableWebGL=a[12];this.linearSampling=a[13];this.clearBackground=a[14];this.versionstr=a[15];c=a[16];2===c&&(c=this.isiPhone?1:0);this.useiOSRetina=0!==c;this.hideAddressBar=a[19];this.pauseOnBlur=a[21];this.start_time=Date.now()};a.prototype.findWaitingTexture=function(a){var c,m;c=0;for(m=this.wait_for_textures.length;c<m;c++)if(this.wait_for_textures[c].cr_src===a)return this.wait_for_textures[c];
return null};a.prototype.areAllTexturesLoaded=function(){var a=0,c=0,m=!0,b,f;b=0;for(f=this.wait_for_textures.length;b<f;b++){var r=this.wait_for_textures[b].cr_filesize;if(!r||0>=r)r=5E4;a+=r;this.wait_for_textures[b].complete||this.wait_for_textures[b].loaded?c+=r:m=!1}this.progress=0==a?0:c/a;return m};a.prototype.go=function(){if(this.ctx||this.glwrap){var a=this.ctx||this.overlay_ctx;this.overlay_canvas&&this.positionOverlayCanvas();this.progress=0;this.last_progress=-1;if(this.areAllTexturesLoaded())this.go_textures_done();
else{var c=Date.now()-this.start_time,m=1;this.isTizen&&(m=this.devicePixelRatio);if(a){if(3!==this.loaderstyle&&500<=c&&this.last_progress!=this.progress){a.clearRect(0,0,this.width,this.height);var c=this.width/(2*m),m=this.height/(2*m),b=0===this.loaderstyle&&this.loaderlogo.complete,f=40,r=0,q=80;b&&(q=this.loaderlogo.width,f=q/2,r=this.loaderlogo.height/2,a.drawImage(this.loaderlogo,cr.floor(c-f),cr.floor(m-r)));1>=this.loaderstyle?(m+=r+(b?12:0),c=cr.floor(c-f)+0.5,m=cr.floor(m)+0.5,a.fillStyle=
"DodgerBlue",a.fillRect(c,m,Math.floor(q*this.progress),6),a.strokeStyle="black",a.strokeRect(c,m,q,6),a.strokeStyle="white",a.strokeRect(c-1,m-1,q+2,8)):2===this.loaderstyle&&(a.font="12pt Arial",a.fillStyle="#999",a.textBaseLine="middle",b=Math.round(100*this.progress)+"%",f=a.measureText?a.measureText(b):null,a.fillText(b,c-(f?f.width:0)/2,m))}this.last_progress=this.progress}setTimeout(function(a){return function(){a.go()}}(this),100)}}};a.prototype.go_textures_done=function(){this.overlay_canvas&&
(this.canvas.parentNode.removeChild(this.overlay_canvas),this.overlay_canvas=this.overlay_ctx=null);this.start_time=Date.now();this.last_fps_time=cr.performance_now();var a,c,m;if(this.uses_loader_layout)for(a=0,c=this.types_by_index.length;a<c;a++)m=this.types_by_index[a],m.is_family||m.isOnLoaderLayout||!m.plugin.is_world||(m.onCreate(),cr.seal(m));else this.isloading=!1;a=0;for(c=this.layouts_by_index.length;a<c;a++)this.layouts_by_index[a].createGlobalNonWorlds();2<=this.fullscreen_mode&&(a=this.original_width/
this.original_height,c=this.width/this.height,this.aspect_scale=2!==this.fullscreen_mode&&c>a||2===this.fullscreen_mode&&c<a?this.height/this.original_height:this.width/this.original_width);this.first_layout?this.layouts[this.first_layout].startRunning():this.layouts_by_index[0].startRunning();this.uses_loader_layout||(this.loadingprogress=1,this.trigger(cr.system_object.prototype.cnds.OnLoadFinished,null));this.tick();this.isDirectCanvas&&AppMobi.webview.execute("onGameReady();")};var h=window.requestAnimationFrame||
window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame;a.prototype.tick=function(){if(this.running_layout){var a=cr.performance_now();if(this.isArcade){var c=jQuery(window).width(),m=jQuery(window).height();if(this.lastwidth!==c||this.lastheight!==m)this.lastwidth=c,this.lastheight=m,this.setSize(c,m)}this.isloading&&(c=this.areAllTexturesLoaded(),this.loadingprogress=this.progress,c&&(this.isloading=!1,this.progress=1,this.trigger(cr.system_object.prototype.cnds.OnLoadFinished,
null)));this.logic();!this.redraw&&!this.isCocoonJs||this.is_WebGL_context_lost||this.suspendDrawing||(this.redraw=!1,this.glwrap?this.drawGL():this.draw(),this.snapshotCanvas&&(this.canvas&&this.canvas.toDataURL&&(this.snapshotData=this.canvas.toDataURL(this.snapshotCanvas[0],this.snapshotCanvas[1]),this.trigger(cr.system_object.prototype.cnds.OnCanvasSnapshot,null)),this.snapshotCanvas=null));this.hit_breakpoint||(this.tickcount++,this.execcount++,this.framecount++);this.logictime+=cr.performance_now()-
a;this.isSuspended||(h?this.raf_id=h(this.tickFunc,this.canvas):this.timeout_id=setTimeout(this.tickFunc,this.isMobile?1:16))}};a.prototype.logic=function(){var a,c,m,b,f,r,q,d,g;a=cr.performance_now();1E3<=a-this.last_fps_time&&(this.last_fps_time+=1E3,this.fps=this.framecount,this.framecount=0,this.cpuutilisation=this.logictime,this.logictime=0);this.measuring_dt&&(0!==this.last_tick_time&&(c=a-this.last_tick_time,0!==c||this.isDebug?(this.dt1=c/1E3,0.5<this.dt1?this.dt1=0:0.1<this.dt1&&(this.dt1=
0.1)):(this.zeroDtCount++,10<=this.zeroDtCout&&(this.measuring_dt=!1),this.dt1=1/60)),this.last_tick_time=a);this.dt=this.dt1*this.timescale;this.kahanTime.add(this.dt);a=document.mozFullScreen||document.webkitIsFullScreen||document.fullScreen||this.isNodeFullscreen;2<=this.fullscreen_mode||a&&0<this.fullscreen_scaling?(c=this.original_width/this.original_height,m=this.width/this.height,b=this.fullscreen_mode,a&&0<this.fullscreen_scaling&&(b=this.fullscreen_scaling),this.aspect_scale=2!==b&&m>c||
2===b&&m<c?this.height/this.original_height:this.width/this.original_width,this.running_layout&&(this.running_layout.scrollToX(this.running_layout.scrollX),this.running_layout.scrollToY(this.running_layout.scrollY))):this.aspect_scale=1;this.ClearDeathRow();this.isInOnDestroy++;this.system.runWaits();this.isInOnDestroy--;this.ClearDeathRow();this.isInOnDestroy++;a=0;for(c=this.types_by_index.length;a<c;a++)if(q=this.types_by_index[a],!q.is_family&&(q.behaviors.length||q.families.length))for(m=0,b=
q.instances.length;m<b;m++)for(d=q.instances[m],f=0,r=d.behavior_insts.length;f<r;f++)d.behavior_insts[f].tick();a=0;for(c=this.types_by_index.length;a<c;a++)if(q=this.types_by_index[a],!q.is_family&&(q.behaviors.length||q.families.length))for(m=0,b=q.instances.length;m<b;m++)for(d=q.instances[m],f=0,r=d.behavior_insts.length;f<r;f++)g=d.behavior_insts[f],g.posttick&&g.posttick();m=this.objects_to_tick.valuesRef();a=0;for(c=m.length;a<c;a++)m[a].tick();this.isInOnDestroy--;this.handleSaveLoad();for(a=
0;this.changelayout&&10>a++;)this.doChangeLayout(this.changelayout);a=0;for(c=this.eventsheets_by_index.length;a<c;a++)this.eventsheets_by_index[a].hasRun=!1;this.running_layout.event_sheet&&this.running_layout.event_sheet.run();this.registered_collisions.length=0;this.layout_first_tick=!1;this.isInOnDestroy++;a=0;for(c=this.types_by_index.length;a<c;a++)if(q=this.types_by_index[a],!q.is_family&&(q.behaviors.length||q.families.length))for(m=0,b=q.instances.length;m<b;m++)for(d=q.instances[m],f=0,
r=d.behavior_insts.length;f<r;f++)g=d.behavior_insts[f],g.tick2&&g.tick2();m=this.objects_to_tick2.valuesRef();a=0;for(c=m.length;a<c;a++)m[a].tick2();this.isInOnDestroy--};a.prototype.doChangeLayout=function(a){var c=this.running_layout;this.running_layout.stopRunning();var m,b,f,r,q,d,g;if(this.glwrap)for(m=0,b=this.types_by_index.length;m<b;m++)q=this.types_by_index[m],q.is_family||!q.unloadTextures||q.global&&0!==q.instances.length||-1!==a.initial_types.indexOf(q)||q.unloadTextures();c==a&&(this.system.waits.length=
0);a.startRunning();m=0;for(b=this.types_by_index.length;m<b;m++)if(q=this.types_by_index[m],q.global||q.plugin.singleglobal)for(a=0,c=q.instances.length;a<c;a++){d=q.instances[a];if(d.onLayoutChange)d.onLayoutChange();if(d.behavior_insts)for(f=0,r=d.behavior_insts.length;f<r;f++)if(g=d.behavior_insts[f],g.onLayoutChange)g.onLayoutChange()}this.layout_first_tick=this.redraw=!0;this.ClearDeathRow()};a.prototype.tickMe=function(a){this.objects_to_tick.add(a)};a.prototype.untickMe=function(a){this.objects_to_tick.remove(a)};
a.prototype.tick2Me=function(a){this.objects_to_tick2.add(a)};a.prototype.untick2Me=function(a){this.objects_to_tick2.remove(a)};a.prototype.getDt=function(a){return a&&-1!==a.my_timescale?this.dt1*a.my_timescale:this.dt};a.prototype.draw=function(){this.running_layout.draw(this.ctx);this.isDirectCanvas&&this.ctx.present()};a.prototype.drawGL=function(){this.running_layout.drawGL(this.glwrap);this.glwrap.present()};a.prototype.addDestroyCallback=function(a){a&&this.destroycallbacks.push(a)};a.prototype.removeDestroyCallback=
function(a){cr.arrayFindRemove(this.destroycallbacks,a)};a.prototype.getObjectByUID=function(a){return this.objectsByUid[a.toString()]};a.prototype.DestroyInstance=function(a){var c,m;if(!this.deathRow.contains(a)){this.deathRow.add(a);if(a.is_contained)for(c=0,m=a.siblings.length;c<m;c++)this.DestroyInstance(a.siblings[c]);this.isInClearDeathRow&&this.deathRow.values_cache.push(a);this.isInOnDestroy++;this.trigger(Object.getPrototypeOf(a.type.plugin).cnds.OnDestroyed,a);this.isInOnDestroy--}};a.prototype.ClearDeathRow=
function(){var a,c,m,b,f,r,q,d,g,e;this.isInClearDeathRow=!0;b=0;for(r=this.createRow.length;b<r;b++)for(a=this.createRow[b],c=a.type,c.instances.push(a),f=0,q=c.families.length;f<q;f++)c.families[f].instances.push(a),c.families[f].stale_iids=!0;this.createRow.length=0;r=this.deathRow.valuesRef();for(b=0;b<r.length;b++){a=r[b];c=a.type;m=c.instances;f=0;for(q=this.destroycallbacks.length;f<q;f++)this.destroycallbacks[f](a);cr.arrayFindRemove(m,a);a.layer&&(cr.arrayRemove(a.layer.instances,a.get_zindex()),
a.layer.zindices_stale=!0);f=0;for(q=c.families.length;f<q;f++)cr.arrayFindRemove(c.families[f].instances,a),c.families[f].stale_iids=!0;if(a.behavior_insts)for(f=0,q=a.behavior_insts.length;f<q;f++){m=a.behavior_insts[f];if(m.onDestroy)m.onDestroy();m.behavior.my_instances.remove(a)}this.objects_to_tick.remove(a);this.objects_to_tick2.remove(a);f=0;for(q=this.system.waits.length;f<q;f++)if(g=this.system.waits[f],g.sols.hasOwnProperty(c.index)&&cr.arrayFindRemove(g.sols[c.index].insts,a),!c.is_family)for(m=
0,d=c.families.length;m<d;m++)e=c.families[m],g.sols.hasOwnProperty(e.index)&&cr.arrayFindRemove(g.sols[e.index].insts,a);if(a.onDestroy)a.onDestroy();this.objectsByUid.hasOwnProperty(a.uid.toString())&&delete this.objectsByUid[a.uid.toString()];this.objectcount--;64>c.deadCache.length&&c.deadCache.push(a);c.stale_iids=!0}this.deathRow.isEmpty()||(this.redraw=!0);this.deathRow.clear();this.isInClearDeathRow=!1};a.prototype.createInstance=function(a,c,b,f){if(a.is_family){var d=cr.floor(Math.random()*
a.members.length);return this.createInstance(a.members[d],c,b,f)}return a.default_instance?this.createInstanceFromInit(a.default_instance,c,!1,b,f,!1):null};var l=[];a.prototype.createInstanceFromInit=function(a,c,b,f,d,r){var q,g,e,h;if(!a)return null;var n=this.types_by_index[a[1]],p=n.plugin.is_world;if(this.isloading&&p&&!n.isOnLoaderLayout||p&&!this.glwrap&&11===a[0][11])return null;var v=c;p||(c=null);var k;n.deadCache.length?(k=n.deadCache.pop(),k.recycled=!0,n.plugin.Instance.call(k,n)):(k=
new n.plugin.Instance(n),k.recycled=!1);k.uid=b&&!r?a[2]:this.next_uid++;this.objectsByUid[k.uid.toString()]=k;k.puid=this.next_puid++;k.iid=n.instances.length;q=0;for(g=this.createRow.length;q<g;++q)this.createRow[q].type===n&&k.iid++;k.get_iid=cr.inst_get_iid;e=a[3];if(k.recycled)cr.wipe(k.extra);else{k.extra={};if("undefined"!==typeof cr_is_preview)for(k.instance_var_names=[],k.instance_var_names.length=e.length,q=0,g=e.length;q<g;q++)k.instance_var_names[q]=e[q][1];k.instance_vars=[];k.instance_vars.length=
e.length}q=0;for(g=e.length;q<g;q++)k.instance_vars[q]=e[q][0];if(p){var u=a[0];k.x=cr.is_undefined(f)?u[0]:f;k.y=cr.is_undefined(d)?u[1]:d;k.z=u[2];k.width=u[3];k.height=u[4];k.depth=u[5];k.angle=u[6];k.opacity=u[7];k.hotspotX=u[8];k.hotspotY=u[9];k.blend_mode=u[10];q=u[11];!this.glwrap&&n.effect_types.length&&(k.blend_mode=q);k.compositeOp=cr.effectToCompositeOp(k.blend_mode);this.gl&&cr.setGLBlend(k,k.blend_mode,this.gl);if(k.recycled){q=0;for(g=u[12].length;q<g;q++)for(e=0,h=u[12][q].length;e<
h;e++)k.effect_params[q][e]=u[12][q][e];k.bbox.set(0,0,0,0);k.bquad.set_from_rect(k.bbox);k.bbox_changed_callbacks.length=0}else{k.effect_params=u[12].slice(0);q=0;for(g=k.effect_params.length;q<g;q++)k.effect_params[q]=u[12][q].slice(0);k.active_effect_types=[];k.active_effect_flags=[];k.active_effect_flags.length=n.effect_types.length;k.bbox=new cr.rect(0,0,0,0);k.bquad=new cr.quad;k.bbox_changed_callbacks=[];k.set_bbox_changed=cr.set_bbox_changed;k.add_bbox_changed_callback=cr.add_bbox_changed_callback;
k.contains_pt=cr.inst_contains_pt;k.update_bbox=cr.update_bbox;k.get_zindex=cr.inst_get_zindex}q=0;for(g=n.effect_types.length;q<g;q++)k.active_effect_flags[q]=!0;k.updateActiveEffects=cr.inst_updateActiveEffects;k.updateActiveEffects();k.uses_shaders=!!k.active_effect_types.length;k.bbox_changed=!0;k.visible=!0;k.my_timescale=-1;k.layer=c;k.zindex=c.instances.length;"undefined"===typeof k.collision_poly&&(k.collision_poly=null);this.redraw=k.collisionsEnabled=!0}k.toString=cr.inst_toString;var K;
q=l.length=0;for(g=n.families.length;q<g;q++)l.push.apply(l,n.families[q].behaviors);l.push.apply(l,n.behaviors);if(k.recycled)for(q=0,g=l.length;q<g;q++){var C=l[q];K=k.behavior_insts[q];K.recycled=!0;C.behavior.Instance.call(K,C,k);u=a[4][q];e=0;for(h=u.length;e<h;e++)K.properties[e]=u[e];K.onCreate();C.behavior.my_instances.add(k)}else for(k.behavior_insts=[],q=0,g=l.length;q<g;q++)C=l[q],K=new C.behavior.Instance(C,k),K.recycled=!1,K.properties=a[4][q].slice(0),K.onCreate(),cr.seal(K),k.behavior_insts.push(K),
C.behavior.my_instances.add(k);u=a[5];if(k.recycled)for(q=0,g=u.length;q<g;q++)k.properties[q]=u[q];else k.properties=u.slice(0);this.createRow.push(k);c&&c.instances.push(k);this.objectcount++;if(n.is_contained){if(k.is_contained=!0,k.recycled?k.siblings.length=0:k.siblings=[],!b&&!r){q=0;for(g=n.container.length;q<g;q++)if(n.container[q]!==n){if(!n.container[q].default_instance)return null;k.siblings.push(this.createInstanceFromInit(n.container[q].default_instance,v,!1,p?k.x:f,p?k.y:d,!0))}q=0;
for(g=k.siblings.length;q<g;q++)for(k.siblings[q].siblings.push(k),e=0;e<g;e++)q!==e&&k.siblings[q].siblings.push(k.siblings[e])}}else k.is_contained=!1,k.siblings=null;k.onCreate();k.recycled||cr.seal(k);q=0;for(g=k.behavior_insts.length;q<g;q++)k.behavior_insts[q].postCreate&&k.behavior_insts[q].postCreate();return k};a.prototype.getLayerByName=function(a){var c,b;c=0;for(b=this.running_layout.layers.length;c<b;c++){var f=this.running_layout.layers[c];if(cr.equals_nocase(f.name,a))return f}return null};
a.prototype.getLayerByNumber=function(a){a=cr.floor(a);0>a&&(a=0);a>=this.running_layout.layers.length&&(a=this.running_layout.layers.length-1);return this.running_layout.layers[a]};a.prototype.getLayer=function(a){return cr.is_number(a)?this.getLayerByNumber(a):this.getLayerByName(a.toString())};a.prototype.clearSol=function(a){var c,b;c=0;for(b=a.length;c<b;c++)a[c].getCurrentSol().select_all=!0};a.prototype.pushCleanSol=function(a){var c,b;c=0;for(b=a.length;c<b;c++)a[c].pushCleanSol()};a.prototype.pushCopySol=
function(a){var c,b;c=0;for(b=a.length;c<b;c++)a[c].pushCopySol()};a.prototype.popSol=function(a){var c,b;c=0;for(b=a.length;c<b;c++)a[c].popSol()};a.prototype.testAndSelectCanvasPointOverlap=function(a,c,b,f){var d=a.getCurrentSol(),r,q,g,e,h,n;if(d.select_all)for(f||(d.select_all=!1,d.instances.length=0),r=0,e=a.instances.length;r<e;r++){if(g=a.instances[r],g.update_bbox(),h=g.layer.canvasToLayer(c,b,!0),n=g.layer.canvasToLayer(c,b,!1),g.contains_pt(h,n)){if(f)return!1;d.instances.push(g)}}else{r=
q=0;for(e=d.instances.length;r<e;r++)if(g=d.instances[r],g.update_bbox(),h=g.layer.canvasToLayer(c,b,!0),n=g.layer.canvasToLayer(c,b,!1),g.contains_pt(h,n)){if(f)return!1;d.instances[q]=d.instances[r];q++}f||(d.instances.length=q)}a.applySolToContainer();return f?!0:d.hasObjects()};a.prototype.testOverlap=function(a,c){if(!(a&&c&&a!==c&&a.collisionsEnabled&&c.collisionsEnabled))return!1;a.update_bbox();c.update_bbox();var b=a.layer,f=c.layer,d,r,q,g,e,h;if(b===f||b.parallaxX===f.parallaxX&&f.parallaxY===
f.parallaxY&&b.scale===f.scale&&b.angle===f.angle&&b.zoomRate===f.zoomRate){if(!a.bbox.intersects_rect(c.bbox)||!a.bquad.intersects_quad(c.bquad))return!1;e=a.collision_poly&&!a.collision_poly.is_empty();d=c.collision_poly&&!c.collision_poly.is_empty();if(!e&&!d)return!0;e?(a.collision_poly.cache_poly(a.width,a.height,a.angle),e=a.collision_poly):(this.temp_poly.set_from_quad(a.bquad,a.x,a.y,a.width,a.height),e=this.temp_poly);d?(c.collision_poly.cache_poly(c.width,c.height,c.angle),h=c.collision_poly):
(this.temp_poly.set_from_quad(c.bquad,c.x,c.y,c.width,c.height),h=this.temp_poly);return e.intersects_poly(h,c.x-a.x,c.y-a.y)}e=a.collision_poly&&!a.collision_poly.is_empty();d=c.collision_poly&&!c.collision_poly.is_empty();e?(a.collision_poly.cache_poly(a.width,a.height,a.angle),this.temp_poly.set_from_poly(a.collision_poly)):this.temp_poly.set_from_quad(a.bquad,a.x,a.y,a.width,a.height);e=this.temp_poly;d?(c.collision_poly.cache_poly(c.width,c.height,c.angle),this.temp_poly2.set_from_poly(c.collision_poly)):
this.temp_poly2.set_from_quad(c.bquad,c.x,c.y,c.width,c.height);h=this.temp_poly2;d=0;for(r=e.pts_count;d<r;d++)q=e.pts_cache[2*d],g=e.pts_cache[2*d+1],e.pts_cache[2*d]=b.layerToCanvas(q+a.x,g+a.y,!0),e.pts_cache[2*d+1]=b.layerToCanvas(q+a.x,g+a.y,!1);d=0;for(r=h.pts_count;d<r;d++)q=h.pts_cache[2*d],g=h.pts_cache[2*d+1],h.pts_cache[2*d]=f.layerToCanvas(q+c.x,g+c.y,!0),h.pts_cache[2*d+1]=f.layerToCanvas(q+c.x,g+c.y,!1);return e.intersects_poly(h,0,0)};var k=new cr.quad,n=new cr.rect(0,0,0,0);a.prototype.testRectOverlap=
function(a,c){if(!c||!c.collisionsEnabled)return!1;c.update_bbox();if(!c.bbox.intersects_rect(a))return!1;k.set_from_rect(a);if(!c.bquad.intersects_quad(k))return!1;if(!c.collision_poly||c.collision_poly.is_empty())return!0;c.collision_poly.cache_poly(c.width,c.height,c.angle);k.offset(-a.left,-a.top);this.temp_poly.set_from_quad(k,0,0,1,1);return c.collision_poly.intersects_poly(this.temp_poly,a.left-c.x,a.top-c.y)};a.prototype.testSegmentOverlap=function(a,c,b,f,d){if(!d||!d.collisionsEnabled)return!1;
d.update_bbox();n.set(cr.min(a,b),cr.min(c,f),cr.max(a,b),cr.max(c,f));if(!d.bbox.intersects_rect(n)||!d.bquad.intersects_segment(a,c,b,f))return!1;if(!d.collision_poly||d.collision_poly.is_empty())return!0;d.collision_poly.cache_poly(d.width,d.height,d.angle);return d.collision_poly.intersects_segment(d.x,d.y,a,c,b,f)};a.prototype.typeHasBehavior=function(a,c){if(!c)return!1;var b,f,d,r,q;b=0;for(f=a.behaviors.length;b<f;b++)if(a.behaviors[b].behavior instanceof c)return!0;if(!a.is_family)for(b=
0,f=a.families.length;b<f;b++)for(q=a.families[b],d=0,r=q.behaviors.length;d<r;d++)if(q.behaviors[d].behavior instanceof c)return!0;return!1};a.prototype.typeHasNoSaveBehavior=function(a){return this.typeHasBehavior(a,cr.behaviors.NoSave)};a.prototype.typeHasPersistBehavior=function(a){return this.typeHasBehavior(a,cr.behaviors.Persist)};a.prototype.getSolidBehavior=function(){if(!cr.behaviors.solid)return null;var a,c;a=0;for(c=this.behaviors.length;a<c;a++)if(this.behaviors[a]instanceof cr.behaviors.solid)return this.behaviors[a];
return null};a.prototype.testOverlapSolid=function(a){var c=this.getSolidBehavior();if(!c)return null;var b,f,d=c.my_instances.valuesRef(),c=0;for(b=d.length;c<b;++c)if(f=d[c],f.extra.solidEnabled&&this.testOverlap(a,f))return f;return null};a.prototype.testRectOverlapSolid=function(a){var c=this.getSolidBehavior();if(!c)return null;var b,f,d=c.my_instances.valuesRef(),c=0;for(b=d.length;c<b;++c)if(f=d[c],f.extra.solidEnabled&&this.testRectOverlap(a,f))return f;return null};var v=[];a.prototype.testOverlapJumpThru=
function(a,c){var b=null,f,d;if(!cr.behaviors.jumpthru)return null;f=0;for(d=this.behaviors.length;f<d;f++)if(this.behaviors[f]instanceof cr.behaviors.jumpthru){b=this.behaviors[f];break}if(!b)return null;var r=null;c&&(r=v,r.length=0);var q=b.my_instances.valuesRef();f=0;for(d=q.length;f<d;++f)if(b=q[f],b.extra.jumpthruEnabled&&this.testOverlap(a,b))if(c)r.push(b);else return b;return r};a.prototype.pushOutSolid=function(a,c,b,f,d,r){f=f||50;var q=a.x,g=a.y,e,h=null,n=null;for(e=0;e<f;e++)if(a.x=
q+c*e,a.y=g+b*e,a.set_bbox_changed(),!this.testOverlap(a,h)&&((h=this.testOverlapSolid(a))&&(n=h),!h&&(d&&(h=r?this.testOverlap(a,r)?r:null:this.testOverlapJumpThru(a))&&(n=h),!h)))return n&&this.pushInFractional(a,c,b,n,16),!0;a.x=q;a.y=g;a.set_bbox_changed();return!1};a.prototype.pushOut=function(a,c,b,f,d){f=f||50;var r=a.x,q=a.y,g;for(g=0;g<f;g++)if(a.x=r+c*g,a.y=q+b*g,a.set_bbox_changed(),!this.testOverlap(a,d))return!0;a.x=r;a.y=q;a.set_bbox_changed();return!1};a.prototype.pushInFractional=
function(a,c,b,f,d){var r=2,q,g=!1;q=!1;for(var e=a.x,h=a.y;r<=d;)q=1/r,r*=2,a.x+=c*q*(g?1:-1),a.y+=b*q*(g?1:-1),a.set_bbox_changed(),this.testOverlap(a,f)?q=g=!0:(q=g=!1,e=a.x,h=a.y);q&&(a.x=e,a.y=h,a.set_bbox_changed())};a.prototype.pushOutSolidNearest=function(a,c){var b=cr.is_undefined(c)?100:c,f=0,d=a.x,r=a.y,q=0,g=0,e=0,h=this.testOverlapSolid(a);if(!h)return!0;for(;f<=b;){switch(q){case 0:g=0;e=-1;f++;break;case 1:g=1;e=-1;break;case 2:g=1;e=0;break;case 3:e=g=1;break;case 4:g=0;e=1;break;
case 5:g=-1;e=1;break;case 6:g=-1;e=0;break;case 7:e=g=-1}q=(q+1)%8;a.x=cr.floor(d+g*f);a.y=cr.floor(r+e*f);a.set_bbox_changed();if(!this.testOverlap(a,h)&&(h=this.testOverlapSolid(a),!h))return!0}a.x=d;a.y=r;a.set_bbox_changed();return!1};a.prototype.registerCollision=function(a,c){a.collisionsEnabled&&c.collisionsEnabled&&this.registered_collisions.push([a,c])};a.prototype.checkRegisteredCollision=function(a,c){var b,f,d;b=0;for(f=this.registered_collisions.length;b<f;b++)if(d=this.registered_collisions[b],
d[0]==a&&d[1]==c||d[0]==c&&d[1]==a)return!0;return!1};a.prototype.calculateSolidBounceAngle=function(a,c,b,f){var d=a.x,r=a.y,q=cr.max(10,cr.distanceTo(c,b,d,r)),g=cr.angleTo(c,b,d,r),e=f||this.testOverlapSolid(a);if(!e)return cr.clamp_angle(g+cr.PI);var h=e,n,p,l,k,v=cr.to_radians(5);for(n=1;36>n;n++)if(p=g-n*v,a.x=c+Math.cos(p)*q,a.y=b+Math.sin(p)*q,a.set_bbox_changed(),!this.testOverlap(a,h)&&(h=f?null:this.testOverlapSolid(a),!h)){l=p;break}36===n&&(l=cr.clamp_angle(g+cr.PI));h=e;for(n=1;36>n;n++)if(p=
g+n*v,a.x=c+Math.cos(p)*q,a.y=b+Math.sin(p)*q,a.set_bbox_changed(),!this.testOverlap(a,h)&&(h=f?null:this.testOverlapSolid(a),!h)){k=p;break}36===n&&(k=cr.clamp_angle(g+cr.PI));a.x=d;a.y=r;a.set_bbox_changed();if(k===l)return k;a=cr.angleDiff(k,l)/2;a=cr.angleClockwise(k,l)?cr.clamp_angle(l+a+cr.PI):cr.clamp_angle(k+a);l=Math.cos(g);g=Math.sin(g);k=Math.cos(a);a=Math.sin(a);c=l*k+g*a;return cr.angleTo(0,0,l-2*c*k,g-2*c*a)};var u=[],p=-1;a.prototype.trigger=function(a,c,b){if(!this.running_layout)return!1;
var f=this.running_layout.event_sheet;if(!f)return!1;p++;p===u.length?u.push(new cr.ObjectSet):u[p].clear();a=this.triggerOnSheet(a,c,f,b);p--;return a};a.prototype.triggerOnSheet=function(a,c,b,f){var d=u[p];if(d.contains(b))return!1;d.add(b);var d=b.includes.valuesRef(),r=!1,q,g,e;q=0;for(g=d.length;q<g;q++)d[q].isActive()&&(e=this.triggerOnSheet(a,c,d[q].include_sheet,f),r=r||e);if(c)for(e=this.triggerOnSheetForTypeName(a,c,c.type.name,b,f),r=r||e,q=0,g=c.type.families.length;q<g;q++)e=this.triggerOnSheetForTypeName(a,
c,c.type.families[q].name,b,f),r=r||e;else e=this.triggerOnSheetForTypeName(a,c,"system",b,f),r=r||e;return r};a.prototype.triggerOnSheetForTypeName=function(a,c,b,f,d){var r,q=!1,g=!1,g="undefined"!==typeof d,e=(g?f.fasttriggers:f.triggers)[b];if(!e)return q;var h=null;f=0;for(r=e.length;f<r;f++)if(e[f].method==a){h=e[f].evs;break}if(!h)return q;a=g?h[d]:h;if(!a)return null;f=0;for(r=a.length;f<r;f++)d=a[f][0],g=a[f][1],g=this.executeSingleTrigger(c,b,d,g),q=q||g;return q};a.prototype.executeSingleTrigger=
function(a,c,b,f){var d,r,g=!1;this.trigger_depth++;var e=this.getCurrentEventStack().current_event;e&&this.pushCleanSol(e.solModifiersIncludingParents);var h=1<this.trigger_depth;this.pushCleanSol(b.solModifiersIncludingParents);h&&this.pushLocalVarStack();var n=this.pushEventStack(b);n.current_event=b;a&&(d=this.types[c].getCurrentSol(),d.select_all=!1,d.instances.length=1,d.instances[0]=a,this.types[c].applySolToContainer());a=!0;if(b.parent){c=n.temp_parents_arr;for(d=b.parent;d;)c.push(d),d=
d.parent;c.reverse();d=0;for(r=c.length;d<r;d++)if(!c[d].run_pretrigger()){a=!1;break}}a&&(this.execcount++,b.orblock?b.run_orblocktrigger(f):b.run(),g=g||n.last_event_true);this.popEventStack();h&&this.popLocalVarStack();this.popSol(b.solModifiersIncludingParents);e&&this.popSol(e.solModifiersIncludingParents);0!==this.isInOnDestroy||0!==p||this.isRunningEvents||this.deathRow.isEmpty()&&!this.createRow.length||this.ClearDeathRow();this.trigger_depth--;return g};a.prototype.getCurrentCondition=function(){var a=
this.getCurrentEventStack();return a.current_event.conditions[a.cndindex]};a.prototype.getCurrentAction=function(){var a=this.getCurrentEventStack();return a.current_event.actions[a.actindex]};a.prototype.pushLocalVarStack=function(){this.localvar_stack_index++;this.localvar_stack_index>=this.localvar_stack.length&&this.localvar_stack.push([])};a.prototype.popLocalVarStack=function(){this.localvar_stack_index--};a.prototype.getCurrentLocalVarStack=function(){return this.localvar_stack[this.localvar_stack_index]};
a.prototype.pushEventStack=function(a){this.event_stack_index++;this.event_stack_index>=this.event_stack.length&&this.event_stack.push(new cr.eventStackFrame);var c=this.getCurrentEventStack();c.reset(a);return c};a.prototype.popEventStack=function(){this.event_stack_index--};a.prototype.getCurrentEventStack=function(){return this.event_stack[this.event_stack_index]};a.prototype.pushLoopStack=function(a){this.loop_stack_index++;this.loop_stack_index>=this.loop_stack.length&&this.loop_stack.push(cr.seal({name:a,
index:0,stopped:!1}));var c=this.getCurrentLoop();c.name=a;c.index=0;c.stopped=!1;return c};a.prototype.popLoopStack=function(){this.loop_stack_index--};a.prototype.getCurrentLoop=function(){return this.loop_stack[this.loop_stack_index]};a.prototype.getEventVariableByName=function(a,c){for(var b,f,d,r,g,e;c;){b=0;for(f=c.subevents.length;b<f;b++)if(e=c.subevents[b],e instanceof cr.eventvariable&&cr.equals_nocase(a,e.name))return e;c=c.parent}b=0;for(f=this.eventsheets_by_index.length;b<f;b++)for(g=
this.eventsheets_by_index[b],d=0,r=g.events.length;d<r;d++)if(e=g.events[d],e instanceof cr.eventvariable&&cr.equals_nocase(a,e.name))return e;return null};a.prototype.getLayoutBySid=function(a){var c,b;c=0;for(b=this.layouts_by_index.length;c<b;c++)if(this.layouts_by_index[c].sid===a)return this.layouts_by_index[c];return null};a.prototype.getObjectTypeBySid=function(a){var c,b;c=0;for(b=this.types_by_index.length;c<b;c++)if(this.types_by_index[c].sid===a)return this.types_by_index[c];return null};
a.prototype.getGroupBySid=function(a){var c,b;c=0;for(b=this.allGroups.length;c<b;c++)if(this.allGroups[c].sid===a)return this.allGroups[c];return null};a.prototype.signalContinuousPreview=function(){this.signalledContinuousPreview=!0};a.prototype.handleSaveLoad=function(){var a=this,b=this.saveToSlot,f=this.lastSaveJson,g=this.loadFromSlot,h=!1;this.signalledContinuousPreview&&(h=!0,b="__c2_continuouspreview",this.signalledContinuousPreview=!1);if(b.length){this.ClearDeathRow();f=this.saveToJSONString();
if(window.indexedDB&&!this.isCocoonJs)e(b,f,function(){cr.logexport("Saved state to IndexedDB storage ("+f.length+" bytes)");a.lastSaveJson=f;a.trigger(cr.system_object.prototype.cnds.OnSaveComplete,null);a.lastSaveJson="";h&&c()},function(d){try{localStorage.setItem("__c2save_"+b,f),cr.logexport("Saved state to WebStorage ("+f.length+" bytes)"),a.lastSaveJson=f,a.trigger(cr.system_object.prototype.cnds.OnSaveComplete,null),a.lastSaveJson="",h&&c()}catch(r){cr.logexport("Failed to save game state: "+
d+"; "+r)}});else try{localStorage.setItem("__c2save_"+b,f),cr.logexport("Saved state to WebStorage ("+f.length+" bytes)"),a.lastSaveJson=f,this.trigger(cr.system_object.prototype.cnds.OnSaveComplete,null),a.lastSaveJson="",h&&c()}catch(r){cr.logexport("Error saving to WebStorage: "+r)}this.loadFromJson=this.loadFromSlot=this.saveToSlot=""}g.length&&(window.indexedDB&&!this.isCocoonJs?d(g,function(c){c?(a.loadFromJson=c,cr.logexport("Loaded state from IndexedDB storage ("+a.loadFromJson.length+" bytes)")):
(a.loadFromJson=localStorage.getItem("__c2save_"+g)||"",cr.logexport("Loaded state from WebStorage ("+a.loadFromJson.length+" bytes)"));a.suspendDrawing=!1;a.loadFromJson.length||a.trigger(cr.system_object.prototype.cnds.OnLoadFailed,null)},function(c){a.loadFromJson=localStorage.getItem("__c2save_"+g)||"";cr.logexport("Loaded state from WebStorage ("+a.loadFromJson.length+" bytes)");a.suspendDrawing=!1;a.loadFromJson.length||a.trigger(cr.system_object.prototype.cnds.OnLoadFailed,null)}):(this.loadFromJson=
localStorage.getItem("__c2save_"+g)||"",cr.logexport("Loaded state from WebStorage ("+this.loadFromJson.length+" bytes)"),this.suspendDrawing=!1,a.loadFromJson.length||a.trigger(cr.system_object.prototype.cnds.OnLoadFailed,null)),this.saveToSlot=this.loadFromSlot="");this.loadFromJson.length&&(this.ClearDeathRow(),this.loadFromJSONString(this.loadFromJson),this.lastSaveJson=this.loadFromJson,this.trigger(cr.system_object.prototype.cnds.OnLoadComplete,null),this.loadFromJson=this.lastSaveJson="")};
a.prototype.saveToJSONString=function(){var a,c,b,d,g,r,q,e={c2save:!0,version:1,rt:{time:this.kahanTime.sum,timescale:this.timescale,tickcount:this.tickcount,execcount:this.execcount,next_uid:this.next_uid,running_layout:this.running_layout.sid,start_time_offset:Date.now()-this.start_time},types:{},layouts:{},events:{groups:{},cnds:{},acts:{},vars:{}}};a=0;for(c=this.types_by_index.length;a<c;a++)if(g=this.types_by_index[a],!g.is_family&&!this.typeHasNoSaveBehavior(g)){r={instances:[]};cr.hasAnyOwnProperty(g.extra)&&
(r.ex=f(g.extra));b=0;for(d=g.instances.length;b<d;b++)r.instances.push(this.saveInstanceToJSON(g.instances[b]));e.types[g.sid.toString()]=r}a=0;for(c=this.layouts_by_index.length;a<c;a++)b=this.layouts_by_index[a],e.layouts[b.sid.toString()]=b.saveToJSON();d=e.events.groups;a=0;for(c=this.allGroups.length;a<c;a++)b=this.allGroups[a],d[b.sid.toString()]=!!this.activeGroups[b.group_name];c=e.events.cnds;for(q in this.cndsBySid)this.cndsBySid.hasOwnProperty(q)&&(a=this.cndsBySid[q],cr.hasAnyOwnProperty(a.extra)&&
(c[q]={ex:f(a.extra)}));c=e.events.acts;for(q in this.actsBySid)this.actsBySid.hasOwnProperty(q)&&(a=this.actsBySid[q],cr.hasAnyOwnProperty(a.extra)&&(c[q]={ex:a.extra}));c=e.events.vars;for(q in this.varsBySid)this.varsBySid.hasOwnProperty(q)&&(a=this.varsBySid[q],a.is_constant||a.parent&&!a.is_static||(c[q]=a.data));e.system=this.system.saveToJSON();return JSON.stringify(e)};a.prototype.refreshUidMap=function(){var a,c,b,f,d,r;this.objectsByUid={};a=0;for(c=this.types_by_index.length;a<c;a++)if(b=
this.types_by_index[a],!b.is_family)for(f=0,d=b.instances.length;f<d;f++)r=b.instances[f],this.objectsByUid[r.uid.toString()]=r};a.prototype.loadFromJSONString=function(a){a=JSON.parse(a);if(a.c2save&&!(1<a.version)){var c=a.rt;this.kahanTime.reset();this.kahanTime.sum=c.time;this.timescale=c.timescale;this.tickcount=c.tickcount;this.execcount=c.execcount;this.start_time=Date.now()-c.start_time_offset;var b=c.running_layout;if(b!==this.running_layout.sid)if(b=this.getLayoutBySid(b))this.doChangeLayout(b);
else return;this.isLoadingState=!0;var f,d,r,g,e,h,n;h=a.types;for(d in h)if(h.hasOwnProperty(d)&&(g=this.getObjectTypeBySid(parseInt(d,10)))&&!g.is_family&&!this.typeHasNoSaveBehavior(g)){h[d].ex?g.extra=h[d].ex:cr.wipe(g.extra);e=g.instances;r=h[d].instances;b=0;for(f=cr.min(e.length,r.length);b<f;b++)this.loadInstanceFromJSON(e[b],r[b]);b=r.length;for(f=e.length;b<f;b++)this.DestroyInstance(e[b]);b=e.length;for(f=r.length;b<f;b++){e=null;if(g.plugin.is_world&&(e=this.running_layout.getLayerBySid(r[b].w.l),
!e))continue;e=this.createInstanceFromInit(g.default_instance,e,!1,0,0,!0);this.loadInstanceFromJSON(e,r[b])}g.stale_iids=!0}this.ClearDeathRow();this.refreshUidMap();f=a.layouts;for(d in f)f.hasOwnProperty(d)&&(b=this.getLayoutBySid(parseInt(d,10)))&&b.loadFromJSON(f[d]);f=a.events.groups;for(d in f)f.hasOwnProperty(d)&&(b=this.getGroupBySid(parseInt(d,10)))&&(this.activeGroups[b.group_name]=f[d]);b=a.events.cnds;for(d in b)b.hasOwnProperty(d)&&this.cndsBySid.hasOwnProperty(d)&&(this.cndsBySid[d].extra=
b[d].ex);b=a.events.acts;for(d in b)b.hasOwnProperty(d)&&this.actsBySid.hasOwnProperty(d)&&(this.actsBySid[d].extra=b[d].ex);b=a.events.vars;for(d in b)b.hasOwnProperty(d)&&this.varsBySid.hasOwnProperty(d)&&(this.varsBySid[d].data=b[d]);this.next_uid=c.next_uid;this.isLoadingState=!1;this.system.loadFromJSON(a.system);b=0;for(f=this.types_by_index.length;b<f;b++)if(g=this.types_by_index[b],!g.is_family)for(d=0,a=g.instances.length;d<a;d++){e=g.instances[d];if(g.is_contained)for(h=e.get_iid(),c=e.siblings.length=
0,r=g.container.length;c<r;c++)n=g.container[c],g!==n&&e.siblings.push(n.instances[h]);e.afterLoad&&e.afterLoad();if(e.behavior_insts)for(c=0,r=e.behavior_insts.length;c<r;c++)h=e.behavior_insts[c],h.afterLoad&&h.afterLoad()}this.redraw=!0}};a.prototype.saveInstanceToJSON=function(a){var c,b,d,g,r;g=a.type;d=g.plugin;var e={uid:a.uid};cr.hasAnyOwnProperty(a.extra)&&(e.ex=f(a.extra));if(a.instance_vars&&a.instance_vars.length)for(e.ivs={},c=0,b=a.instance_vars.length;c<b;c++)e.ivs[a.type.instvar_sids[c].toString()]=
a.instance_vars[c];if(d.is_world){d={x:a.x,y:a.y,w:a.width,h:a.height,l:a.layer.sid,zi:a.get_zindex()};0!==a.angle&&(d.a=a.angle);1!==a.opacity&&(d.o=a.opacity);0.5!==a.hotspotX&&(d.hX=a.hotspotX);0.5!==a.hotspotY&&(d.hY=a.hotspotY);0!==a.blend_mode&&(d.bm=a.blend_mode);a.visible||(d.v=a.visible);a.collisionsEnabled||(d.ce=a.collisionsEnabled);-1!==a.my_timescale&&(d.mts=a.my_timescale);if(g.effect_types.length)for(d.fx=[],c=0,b=g.effect_types.length;c<b;c++)r=g.effect_types[c],d.fx.push({name:r.name,
active:a.active_effect_flags[r.index],params:a.effect_params[r.index]});e.w=d}if(a.behavior_insts&&a.behavior_insts.length)for(e.behs={},c=0,b=a.behavior_insts.length;c<b;c++)g=a.behavior_insts[c],g.saveToJSON&&(e.behs[g.type.sid.toString()]=g.saveToJSON());a.saveToJSON&&(e.data=a.saveToJSON());return e};a.prototype.getInstanceVarIndexBySid=function(a,c){var b,f;b=0;for(f=a.instvar_sids.length;b<f;b++)if(a.instvar_sids[b]===c)return b;return-1};a.prototype.getBehaviorIndexBySid=function(a,c){var b,
f;b=0;for(f=a.behavior_insts.length;b<f;b++)if(a.behavior_insts[b].type.sid===c)return b;return-1};a.prototype.loadInstanceFromJSON=function(a,c){var b,f,d,g,e,h;h=a.type;d=h.plugin;a.uid=c.uid;c.ex?a.extra=c.ex:cr.wipe(a.extra);if(f=c.ivs)for(b in f)f.hasOwnProperty(b)&&(g=this.getInstanceVarIndexBySid(h,parseInt(b,10)),0>g||g>=a.instance_vars.length||(a.instance_vars[g]=f[b]));if(d.is_world){g=c.w;a.layer.sid!==g.l&&(f=a.layer,a.layer=this.running_layout.getLayerBySid(g.l),a.layer?(a.layer.instances.push(a),
a.layer.zindices_stale=!0,cr.arrayFindRemove(f.instances,a),f.zindices_stale=!0):(a.layer=f,this.DestroyInstance(a)));a.x=g.x;a.y=g.y;a.width=g.w;a.height=g.h;a.zindex=g.zi;a.angle=g.hasOwnProperty("a")?g.a:0;a.opacity=g.hasOwnProperty("o")?g.o:1;a.hotspotX=g.hasOwnProperty("hX")?g.hX:0.5;a.hotspotY=g.hasOwnProperty("hY")?g.hY:0.5;a.visible=g.hasOwnProperty("v")?g.v:!0;a.collisionsEnabled=g.hasOwnProperty("ce")?g.ce:!0;a.my_timescale=g.hasOwnProperty("mts")?g.mts:-1;a.blend_mode=g.hasOwnProperty("bm")?
g.bm:0;a.compositeOp=cr.effectToCompositeOp(a.blend_mode);this.gl&&cr.setGLBlend(a,a.blend_mode,this.gl);a.set_bbox_changed();if(g.hasOwnProperty("fx"))for(f=0,d=g.fx.length;f<d;f++)e=h.getEffectIndexByName(g.fx[f].name),0>e||(a.active_effect_flags[e]=g.fx[f].active,a.effect_params[e]=g.fx[f].params);a.updateActiveEffects()}if(h=c.behs)for(b in h)h.hasOwnProperty(b)&&(g=this.getBehaviorIndexBySid(a,parseInt(b,10)),0>g||a.behavior_insts[g].loadFromJSON(h[b]));c.data&&a.loadFromJSON(c.data)};cr.runtime=
a;cr.createRuntime=function(c){return new a(document.getElementById(c))};cr.createDCRuntime=function(c,b){return new a({dc:!0,width:c,height:b})};window.cr_createRuntime=cr.createRuntime;window.cr_createDCRuntime=cr.createDCRuntime;window.createCocoonJSRuntime=function(){window.c2cocoonjs=!0;var c=document.createElement("screencanvas")||document.createElement("canvas");document.body.appendChild(c);c=new a(c);window.c2runtime=c;window.addEventListener("orientationchange",function(){window.c2runtime.setSize(window.innerWidth,
window.innerHeight)});window.c2runtime.setSize(window.innerWidth,window.innerHeight);return c}})();window.cr_getC2Runtime=function(){var a=document.getElementById("c2canvas");return a?a.c2runtime:window.c2runtime?window.c2runtime:null};window.cr_sizeCanvas=function(a,b){if(0!==a&&0!==b){var e=window.cr_getC2Runtime();e&&e.setSize(a,b)}};window.cr_setSuspended=function(a){var b=window.cr_getC2Runtime();b&&b.setSuspended(a)};
(function(){function a(a,b){this.runtime=a;this.event_sheet=null;this.scrollX=this.runtime.original_width/2;this.scrollY=this.runtime.original_height/2;this.scale=1;this.angle=0;this.first_visit=!0;this.name=b[0];this.width=b[1];this.height=b[2];this.unbounded_scrolling=b[3];this.sheetname=b[4];this.sid=b[5];var d=b[6],e,l;this.layers=[];this.initial_types=[];e=0;for(l=d.length;e<l;e++){var k=new cr.layer(this,d[e]);k.number=e;cr.seal(k);this.layers.push(k)}d=b[7];this.initial_nonworld=[];e=0;for(l=
d.length;e<l;e++){var k=d[e],n=this.runtime.types_by_index[k[1]];n.default_instance||(n.default_instance=k);this.initial_nonworld.push(k);-1===this.initial_types.indexOf(n)&&this.initial_types.push(n)}this.effect_types=[];this.active_effect_types=[];this.effect_params=[];e=0;for(l=b[8].length;e<l;e++)this.effect_types.push({id:b[8][e][0],name:b[8][e][1],shaderindex:-1,active:!0,index:e}),this.effect_params.push(b[8][e][2].slice(0));this.updateActiveEffects();this.rcTex=new cr.rect(0,0,1,1);this.rcTex2=
new cr.rect(0,0,1,1);this.persist_data={}}function b(a,b){this.layout=a;this.runtime=a.runtime;this.instances=[];this.scale=1;this.angle=0;this.disableAngle=!1;this.tmprect=new cr.rect(0,0,0,0);this.tmpquad=new cr.quad;this.viewBottom=this.viewTop=this.viewRight=this.viewLeft=0;this.zindices_stale=!1;this.name=b[0];this.index=b[1];this.sid=b[2];this.visible=b[3];this.background_color=b[4];this.transparent=b[5];this.parallaxX=b[6];this.parallaxY=b[7];this.opacity=b[8];this.forceOwnTexture=b[9];this.zoomRate=
b[10];this.blend_mode=b[11];this.effect_fallback=b[12];this.compositeOp="source-over";this.destBlend=this.srcBlend=0;this.render_offscreen=!1;var d=b[13],e,l;this.initial_instances=[];e=0;for(l=d.length;e<l;e++){var k=d[e],n=this.runtime.types_by_index[k[1]];n.default_instance||(n.default_instance=k);this.initial_instances.push(k);-1===this.layout.initial_types.indexOf(n)&&this.layout.initial_types.push(n)}this.effect_types=[];this.active_effect_types=[];this.effect_params=[];e=0;for(l=b[14].length;e<
l;e++)this.effect_types.push({id:b[14][e][0],name:b[14][e][1],shaderindex:-1,active:!0,index:e}),this.effect_params.push(b[14][e][2].slice(0));this.updateActiveEffects();this.rcTex=new cr.rect(0,0,1,1);this.rcTex2=new cr.rect(0,0,1,1)}function e(a,b){return a.zindex-b.zindex}a.prototype.saveObjectToPersist=function(a){var b=a.type.sid.toString();this.persist_data.hasOwnProperty(b)||(this.persist_data[b]=[]);this.persist_data[b].push(this.runtime.saveInstanceToJSON(a))};a.prototype.hasOpaqueBottomLayer=
function(){var a=this.layers[0];return!a.transparent&&1===a.opacity&&!a.forceOwnTexture&&a.visible};a.prototype.updateActiveEffects=function(){this.active_effect_types.length=0;var a,b,d;a=0;for(b=this.effect_types.length;a<b;a++)d=this.effect_types[a],d.active&&this.active_effect_types.push(d)};a.prototype.getEffectByName=function(a){var b,d,e;b=0;for(d=this.effect_types.length;b<d;b++)if(e=this.effect_types[b],e.name===a)return e;return null};var d=[];a.prototype.startRunning=function(){this.sheetname&&
(this.event_sheet=this.runtime.eventsheets[this.sheetname]);this.runtime.running_layout=this;this.scrollX=this.runtime.original_width/2;this.scrollY=this.runtime.original_height/2;var a,b,g,h,l,k,n;a=0;for(g=this.runtime.types_by_index.length;a<g;a++)if(b=this.runtime.types_by_index[a],!b.is_family)for(l=b.instances,b=0,h=l.length;b<h;b++)if(k=l[b],k.layer){var v=k.layer.number;v>=this.layers.length&&(v=this.layers.length-1);k.layer=this.layers[v];k.layer.instances.push(k);k.layer.zindices_stale=
!0}d.length=0;this.boundScrolling();a=0;for(g=this.layers.length;a<g;a++)k=this.layers[a],k.createInitialInstances(),k.disableAngle=!0,b=k.canvasToLayer(0,0,!0),h=k.canvasToLayer(0,0,!1),k.disableAngle=!1,this.runtime.pixel_rounding&&(b=b+0.5|0,h=h+0.5|0),k.rotateViewport(b,h,null);l=!1;if(!this.first_visit){for(n in this.persist_data)if(this.persist_data.hasOwnProperty(n)&&(b=this.runtime.getObjectTypeBySid(parseInt(n,10)))&&!b.is_family&&this.runtime.typeHasPersistBehavior(b)){h=this.persist_data[n];
a=0;for(g=h.length;a<g;a++){k=null;if(b.plugin.is_world&&(k=this.getLayerBySid(h[a].w.l),!k))continue;k=this.runtime.createInstanceFromInit(b.default_instance,k,!1,0,0,!0);this.runtime.loadInstanceFromJSON(k,h[a]);l=!0;d.push(k)}h.length=0}a=0;for(g=this.layers.length;a<g;a++)this.layers[a].instances.sort(e),this.layers[a].zindices_stale=!0}l&&(this.runtime.ClearDeathRow(),this.runtime.refreshUidMap());for(a=0;a<d.length;a++)if(k=d[a],k.type.is_contained)for(g=k.get_iid(),b=0,h=k.type.container.length;b<
h;b++)n=k.type.container[b],k.type!==n&&(n.instances.length>g?k.siblings.push(n.instances[g]):n.default_instance&&(l=this.runtime.createInstanceFromInit(n.default_instance,k.layer,!0,k.x,k.y,!0),this.runtime.ClearDeathRow(),n.updateIIDs(),k.siblings.push(l),d.push(l)));a=0;for(g=this.initial_nonworld.length;a<g;a++)this.runtime.createInstanceFromInit(this.initial_nonworld[a],null,!0);this.runtime.changelayout=null;this.runtime.ClearDeathRow();if(this.runtime.ctx&&!this.runtime.isDomFree)for(a=0,g=
this.runtime.types_by_index.length;a<g;a++)n=this.runtime.types_by_index[a],!n.is_family&&n.instances.length&&n.preloadCanvas2D&&n.preloadCanvas2D(this.runtime.ctx);a=0;for(g=d.length;a<g;a++)k=d[a],this.runtime.trigger(Object.getPrototypeOf(k.type.plugin).cnds.OnCreated,k);d.length=0;this.runtime.trigger(cr.system_object.prototype.cnds.OnLayoutStart,null);this.first_visit=!1};a.prototype.createGlobalNonWorlds=function(){var a,b,d,e,l;b=a=0;for(d=this.initial_nonworld.length;a<d;a++)e=this.initial_nonworld[a],
l=this.runtime.types_by_index[e[1]],l.global?this.runtime.createInstanceFromInit(e,null,!0):(this.initial_nonworld[b]=e,b++);this.initial_nonworld.length=b};a.prototype.stopRunning=function(){this.runtime.trigger(cr.system_object.prototype.cnds.OnLayoutEnd,null);this.runtime.system.waits.length=0;var a,b,d,e,l,k;a=0;for(b=this.layers.length;a<b;a++){l=this.layers[a].instances;d=0;for(e=l.length;d<e;d++)k=l[d],k.type.global||(this.runtime.typeHasPersistBehavior(k.type)&&this.saveObjectToPersist(k),
this.runtime.DestroyInstance(k));this.runtime.ClearDeathRow();l.length=0;this.layers[a].zindices_stale=!0}a=0;for(b=this.runtime.types_by_index.length;a<b;a++)if(l=this.runtime.types_by_index[a],!(l.global||l.plugin.is_world||l.plugin.singleglobal||l.is_family)){d=0;for(e=l.instances.length;d<e;d++)this.runtime.DestroyInstance(l.instances[d]);this.runtime.ClearDeathRow()}};a.prototype.draw=function(a){a.globalAlpha=1;a.globalCompositeOperation="source-over";this.runtime.clearBackground&&!this.hasOpaqueBottomLayer()&&
a.clearRect(0,0,this.runtime.width,this.runtime.height);var b,d,e;b=0;for(d=this.layers.length;b<d;b++)e=this.layers[b],e.visible&&0<e.opacity&&11!==e.blend_mode&&e.draw(a)};a.prototype.drawGL=function(a){var b=0<this.active_effect_types.length||this.runtime.uses_background_blending;if(b){this.runtime.layout_tex||(this.runtime.layout_tex=a.createEmptyTexture(this.runtime.width,this.runtime.height,this.runtime.linearSampling));if(this.runtime.layout_tex.c2width!==this.runtime.width||this.runtime.layout_tex.c2height!==
this.runtime.height)a.deleteTexture(this.runtime.layout_tex),this.runtime.layout_tex=a.createEmptyTexture(this.runtime.width,this.runtime.height,this.runtime.linearSampling);a.setRenderingToTexture(this.runtime.layout_tex)}this.runtime.clearBackground&&!this.hasOpaqueBottomLayer()&&a.clear(0,0,0,0);var d,e;d=0;for(e=this.layers.length;d<e;d++)this.layers[d].visible&&0<this.layers[d].opacity&&this.layers[d].drawGL(a);b&&(1>=this.active_effect_types.length?(1===this.active_effect_types.length?(b=this.active_effect_types[0].index,
a.switchProgram(this.active_effect_types[0].shaderindex),a.setProgramParameters(null,1/this.runtime.width,1/this.runtime.height,0,0,1,1,this.scale,this.effect_params[b]),a.programIsAnimated(this.active_effect_types[0].shaderindex)&&(this.runtime.redraw=!0)):a.switchProgram(0),a.setRenderingToTexture(null),a.setOpacity(1),a.setTexture(this.runtime.layout_tex),a.setAlphaBlend(),a.resetModelView(),a.updateModelView(),b=this.runtime.width/2,d=this.runtime.height/2,a.quad(-b,d,b,d,b,-d,-b,-d),a.setTexture(null)):
this.renderEffectChain(a,null,null,null))};a.prototype.getRenderTarget=function(){return 0<this.active_effect_types.length||this.runtime.uses_background_blending?this.runtime.layout_tex:null};a.prototype.getMinLayerScale=function(){var a=this.layers[0].getScale(),b,d,e;b=1;for(d=this.layers.length;b<d;b++)e=this.layers[b],(0!==e.parallaxX||0!==e.parallaxY)&&e.getScale()<a&&(a=e.getScale());return a};a.prototype.scrollToX=function(a){if(!this.unbounded_scrolling){var b=this.runtime.width*(1/this.getMinLayerScale())/
2;a>this.width-b&&(a=this.width-b);a<b&&(a=b)}this.scrollX!==a&&(this.scrollX=a,this.runtime.redraw=!0)};a.prototype.scrollToY=function(a){if(!this.unbounded_scrolling){var b=this.runtime.height*(1/this.getMinLayerScale())/2;a>this.height-b&&(a=this.height-b);a<b&&(a=b)}this.scrollY!==a&&(this.scrollY=a,this.runtime.redraw=!0)};a.prototype.boundScrolling=function(){this.scrollToX(this.scrollX);this.scrollToY(this.scrollY)};a.prototype.renderEffectChain=function(a,b,d,e){var l=d?d.active_effect_types:
b?b.active_effect_types:this.active_effect_types,k=d?d.layer.getScale():b?b.getScale():1,n=this.runtime.fx_tex,v,u,p,t,s=0,m=1,x,z=this.runtime.width,r=this.runtime.height,q=z/2,G=r/2,y=b?b.rcTex:this.rcTex,A=b?b.rcTex2:this.rcTex2,w=0,D=0,E=0,B=0,H=z,K=z,C=r,M=r,Q=p=0,V=d?d.layer.getAngle():0;if(d){v=0;for(u=l.length;v<u;v++)p+=a.getProgramBoxExtendHorizontal(l[v].shaderindex),Q+=a.getProgramBoxExtendVertical(l[v].shaderindex);t=d.bbox;w=b.layerToCanvas(t.left,t.top,!0);E=b.layerToCanvas(t.left,
t.top,!1);H=b.layerToCanvas(t.right,t.bottom,!0);C=b.layerToCanvas(t.right,t.bottom,!1);0!==V&&(v=b.layerToCanvas(t.right,t.top,!0),u=b.layerToCanvas(t.right,t.top,!1),D=b.layerToCanvas(t.left,t.bottom,!0),B=b.layerToCanvas(t.left,t.bottom,!1),t=Math.min(w,H,v,D),H=Math.max(w,H,v,D),w=t,t=Math.min(E,C,u,B),C=Math.max(E,C,u,B),E=t);w-=p;E-=Q;H+=p;C+=Q;A.left=w/z;A.top=1-E/r;A.right=H/z;A.bottom=1-C/r;D=w=Math.floor(w);B=E=Math.floor(E);K=H=Math.ceil(H);M=C=Math.ceil(C);D-=p;B-=Q;K+=p;M+=Q;0>w&&(w=
0);0>E&&(E=0);H>z&&(H=z);C>r&&(C=r);0>D&&(D=0);0>B&&(B=0);K>z&&(K=z);M>r&&(M=r);y.left=w/z;y.top=1-E/r;y.right=H/z;y.bottom=1-C/r}else y.left=A.left=0,y.top=A.top=0,y.right=A.right=1,y.bottom=A.bottom=1;Q=d&&((d.angle||V)&&a.programUsesDest(l[0].shaderindex)||0!==p||0!==Q||1!==d.opacity||d.type.plugin.must_predraw)||b&&!d&&1!==b.opacity;a.setAlphaBlend();if(Q){n[s]||(n[s]=a.createEmptyTexture(z,r,this.runtime.linearSampling));if(n[s].c2width!==z||n[s].c2height!==r)a.deleteTexture(n[s]),n[s]=a.createEmptyTexture(z,
r,this.runtime.linearSampling);a.switchProgram(0);a.setRenderingToTexture(n[s]);x=M-B;a.clearRect(D,r-B-x,K-D,x);d?d.drawGL(a):(a.setTexture(this.runtime.layer_tex),a.setOpacity(b.opacity),a.resetModelView(),a.translate(-q,-G),a.updateModelView(),a.quadTex(w,C,H,C,H,E,w,E,y));A.left=A.top=0;A.right=A.bottom=1;d&&(t=y.top,y.top=y.bottom,y.bottom=t);s=1;m=0}a.setOpacity(1);p=l.length-1;var V=a.programUsesCrossSampling(l[p].shaderindex),T=0;v=0;for(u=l.length;v<u;v++){n[s]||(n[s]=a.createEmptyTexture(z,
r,this.runtime.linearSampling));if(n[s].c2width!==z||n[s].c2height!==r)a.deleteTexture(n[s]),n[s]=a.createEmptyTexture(z,r,this.runtime.linearSampling);a.switchProgram(l[v].shaderindex);T=l[v].index;a.programIsAnimated(l[v].shaderindex)&&(this.runtime.redraw=!0);0!=v||Q?(a.setProgramParameters(e,1/z,1/r,A.left,A.top,A.right,A.bottom,k,d?d.effect_params[T]:b?b.effect_params[T]:this.effect_params[T]),v!==p||V?(a.setRenderingToTexture(n[s]),x=M-B,t=r-B-x,a.clearRect(D,t,K-D,x)):(d?a.setBlend(d.srcBlend,
d.destBlend):b&&a.setBlend(b.srcBlend,b.destBlend),a.setRenderingToTexture(e)),a.setTexture(n[m]),a.resetModelView(),a.translate(-q,-G),a.updateModelView(),a.quadTex(w,C,H,C,H,E,w,E,y),v!==p||V||a.setTexture(null)):(a.setRenderingToTexture(n[s]),x=M-B,t=r-B-x,a.clearRect(D,t,K-D,x),d?(a.setProgramParameters(e,1/d.width,1/d.height,A.left,A.top,A.right,A.bottom,k,d.effect_params[T]),d.drawGL(a)):(a.setProgramParameters(e,1/z,1/r,0,0,1,1,k,b?b.effect_params[T]:this.effect_params[T]),a.setTexture(b?this.runtime.layer_tex:
this.runtime.layout_tex),a.resetModelView(),a.translate(-q,-G),a.updateModelView(),a.quadTex(w,C,H,C,H,E,w,E,y)),A.left=A.top=0,A.right=A.bottom=1,d&&!V&&(t=C,C=E,E=t));s=0===s?1:0;m=0===s?1:0}V&&(a.switchProgram(0),d?a.setBlend(d.srcBlend,d.destBlend):b&&a.setBlend(b.srcBlend,b.destBlend),a.setRenderingToTexture(e),a.setTexture(n[m]),a.resetModelView(),a.translate(-q,-G),a.updateModelView(),d&&1===l.length&&!Q?a.quadTex(w,E,H,E,H,C,w,C,y):a.quadTex(w,C,H,C,H,E,w,E,y),a.setTexture(null))};a.prototype.getLayerBySid=
function(a){var b,d;b=0;for(d=this.layers.length;b<d;b++)if(this.layers[b].sid===a)return this.layers[b];return null};a.prototype.saveToJSON=function(){var a,b,d,e={sx:this.scrollX,sy:this.scrollY,s:this.scale,a:this.angle,w:this.width,h:this.height,fv:this.first_visit,persist:this.persist_data,fx:[],layers:{}};a=0;for(b=this.effect_types.length;a<b;a++)d=this.effect_types[a],e.fx.push({name:d.name,active:d.active,params:this.effect_params[d.index]});a=0;for(b=this.layers.length;a<b;a++)d=this.layers[a],
e.layers[d.sid.toString()]=d.saveToJSON();return e};a.prototype.loadFromJSON=function(a){var b,d,e,l;this.scrollX=a.sx;this.scrollY=a.sy;this.scale=a.s;this.angle=a.a;this.width=a.w;this.height=a.h;this.persist_data=a.persist;"undefined"!==typeof a.fv&&(this.first_visit=a.fv);var k=a.fx;b=0;for(d=k.length;b<d;b++)if(e=this.getEffectByName(k[b].name))e.active=k[b].active,this.effect_params[e.index]=k[b].params;this.updateActiveEffects();b=a.layers;for(l in b)b.hasOwnProperty(l)&&(a=this.getLayerBySid(parseInt(l,
10)))&&a.loadFromJSON(b[l])};cr.layout=a;b.prototype.updateActiveEffects=function(){this.active_effect_types.length=0;var a,b,d;a=0;for(b=this.effect_types.length;a<b;a++)d=this.effect_types[a],d.active&&this.active_effect_types.push(d)};b.prototype.getEffectByName=function(a){var b,d,e;b=0;for(d=this.effect_types.length;b<d;b++)if(e=this.effect_types[b],e.name===a)return e;return null};b.prototype.createInitialInstances=function(){var a,b,e,h,l,k;b=a=0;for(e=this.initial_instances.length;a<e;a++){h=
this.initial_instances[a];l=this.runtime.types_by_index[h[1]];k=this.runtime.typeHasPersistBehavior(l);l=!0;if(!k||this.layout.first_visit)h=this.runtime.createInstanceFromInit(h,this,!0),d.push(h),h.type.global&&(l=!1);l&&(this.initial_instances[b]=this.initial_instances[a],b++)}this.initial_instances.length=b;this.runtime.ClearDeathRow();!this.runtime.glwrap&&this.effect_types.length&&(this.blend_mode=this.effect_fallback);this.compositeOp=cr.effectToCompositeOp(this.blend_mode);this.runtime.gl&&
cr.setGLBlend(this,this.blend_mode,this.runtime.gl)};b.prototype.updateZIndices=function(){if(this.zindices_stale){var a,b;a=0;for(b=this.instances.length;a<b;a++)this.instances[a].zindex=a;this.zindices_stale=!1}};b.prototype.getScale=function(){return this.getNormalScale()*this.runtime.aspect_scale};b.prototype.getNormalScale=function(){return(this.scale*this.layout.scale-1)*this.zoomRate+1};b.prototype.getAngle=function(){return this.disableAngle?0:cr.clamp_angle(this.layout.angle+this.angle)};
b.prototype.draw=function(a){this.render_offscreen=this.forceOwnTexture||1!==this.opacity||0!==this.blend_mode;var b=this.runtime.canvas,d=a;a.globalAlpha=1;a.globalCompositeOperation="source-over";this.render_offscreen&&(this.runtime.layer_canvas||(this.runtime.layer_canvas=document.createElement("canvas"),b=this.runtime.layer_canvas,b.width=this.runtime.width,b.height=this.runtime.height,this.runtime.layer_ctx=b.getContext("2d")),b=this.runtime.layer_canvas,d=this.runtime.layer_ctx,b.width!==this.runtime.width&&
(b.width=this.runtime.width),b.height!==this.runtime.height&&(b.height=this.runtime.height),this.transparent&&d.clearRect(0,0,this.runtime.width,this.runtime.height));this.transparent||(d.fillStyle="rgb("+this.background_color[0]+","+this.background_color[1]+","+this.background_color[2]+")",d.fillRect(0,0,this.runtime.width,this.runtime.height));d.save();this.disableAngle=!0;var e=this.canvasToLayer(0,0,!0),l=this.canvasToLayer(0,0,!1);this.disableAngle=!1;this.runtime.pixel_rounding&&(e=e+0.5|0,
l=l+0.5|0);this.rotateViewport(e,l,d);var k=this.getScale();d.scale(k,k);d.translate(-e,-l);for(var n,e=0,l=this.instances.length;e<l;e++)k=this.instances[e],k.visible&&0!==k.width&&0!==k.height&&(k.update_bbox(),n=k.bbox,n.right<this.viewLeft||n.bottom<this.viewTop||n.left>this.viewRight||n.top>this.viewBottom||(d.globalCompositeOperation=k.compositeOp,k.draw(d)));d.restore();this.render_offscreen&&(a.globalCompositeOperation=this.compositeOp,a.globalAlpha=this.opacity,a.drawImage(b,0,0))};b.prototype.rotateViewport=
function(a,b,d){var e=this.getScale();this.viewLeft=a;this.viewTop=b;this.viewRight=a+this.runtime.width*(1/e);this.viewBottom=b+this.runtime.height*(1/e);a=this.getAngle();0!==a&&(d&&(d.translate(this.runtime.width/2,this.runtime.height/2),d.rotate(-a),d.translate(this.runtime.width/-2,this.runtime.height/-2)),this.tmprect.set(this.viewLeft,this.viewTop,this.viewRight,this.viewBottom),this.tmprect.offset((this.viewLeft+this.viewRight)/-2,(this.viewTop+this.viewBottom)/-2),this.tmpquad.set_from_rotated_rect(this.tmprect,
a),this.tmpquad.bounding_box(this.tmprect),this.tmprect.offset((this.viewLeft+this.viewRight)/2,(this.viewTop+this.viewBottom)/2),this.viewLeft=this.tmprect.left,this.viewTop=this.tmprect.top,this.viewRight=this.tmprect.right,this.viewBottom=this.tmprect.bottom)};b.prototype.drawGL=function(a){var b=this.runtime.width,d=this.runtime.height,e=0,l=0;if(this.render_offscreen=this.forceOwnTexture||1!==this.opacity||0<this.active_effect_types.length||0!==this.blend_mode){this.runtime.layer_tex||(this.runtime.layer_tex=
a.createEmptyTexture(this.runtime.width,this.runtime.height,this.runtime.linearSampling));if(this.runtime.layer_tex.c2width!==this.runtime.width||this.runtime.layer_tex.c2height!==this.runtime.height)a.deleteTexture(this.runtime.layer_tex),this.runtime.layer_tex=a.createEmptyTexture(this.runtime.width,this.runtime.height,this.runtime.linearSampling);a.setRenderingToTexture(this.runtime.layer_tex);this.transparent&&a.clear(0,0,0,0)}this.transparent||a.clear(this.background_color[0]/255,this.background_color[1]/
255,this.background_color[2]/255,1);this.disableAngle=!0;var l=this.canvasToLayer(0,0,!0),k=this.canvasToLayer(0,0,!1);this.disableAngle=!1;this.runtime.pixel_rounding&&(l=l+0.5|0,k=k+0.5|0);this.rotateViewport(l,k,null);k=this.getScale();a.resetModelView();a.scale(k,k);a.rotateZ(-this.getAngle());a.translate((this.viewLeft+this.viewRight)/-2,(this.viewTop+this.viewBottom)/-2);a.updateModelView();var n,v,u;n=0;for(v=this.instances.length;n<v;n++)if(u=this.instances[n],u.visible&&0!==u.width&&0!==
u.height&&(u.update_bbox(),e=u.bbox,!(e.right<this.viewLeft||e.bottom<this.viewTop||e.left>this.viewRight||e.top>this.viewBottom)))if(u.uses_shaders)if(e=u.active_effect_types[0].shaderindex,l=u.active_effect_types[0].index,1!==u.active_effect_types.length||a.programUsesCrossSampling(e)||a.programExtendsBox(e)||(u.angle||u.layer.getAngle())&&a.programUsesDest(e)||1!==u.opacity||u.type.plugin.must_predraw)this.layout.renderEffectChain(a,this,u,this.render_offscreen?this.runtime.layer_tex:this.layout.getRenderTarget()),
a.resetModelView(),a.scale(k,k),a.rotateZ(-this.getAngle()),a.translate((this.viewLeft+this.viewRight)/-2,(this.viewTop+this.viewBottom)/-2),a.updateModelView();else{a.switchProgram(e);a.setBlend(u.srcBlend,u.destBlend);a.programIsAnimated(e)&&(this.runtime.redraw=!0);var p=0,t=0,s=0,m=0;a.programUsesDest(e)&&(e=u.bbox,p=this.layerToCanvas(e.left,e.top,!0),t=this.layerToCanvas(e.left,e.top,!1),s=this.layerToCanvas(e.right,e.bottom,!0),e=this.layerToCanvas(e.right,e.bottom,!1),p/=b,t=1-t/d,s/=b,m=
1-e/d);a.setProgramParameters(this.render_offscreen?this.runtime.layer_tex:this.layout.getRenderTarget(),1/u.width,1/u.height,p,t,s,m,this.getScale(),u.effect_params[l]);u.drawGL(a)}else a.switchProgram(0),a.setBlend(u.srcBlend,u.destBlend),u.drawGL(a);this.render_offscreen&&(e=this.active_effect_types.length?this.active_effect_types[0].shaderindex:0,l=this.active_effect_types.length?this.active_effect_types[0].index:0,0===this.active_effect_types.length||1===this.active_effect_types.length&&!a.programUsesCrossSampling(e)&&
1===this.opacity?(1===this.active_effect_types.length?(a.switchProgram(e),a.setProgramParameters(this.layout.getRenderTarget(),1/this.runtime.width,1/this.runtime.height,0,0,1,1,this.getScale(),this.effect_params[l]),a.programIsAnimated(e)&&(this.runtime.redraw=!0)):a.switchProgram(0),a.setRenderingToTexture(this.layout.getRenderTarget()),a.setOpacity(this.opacity),a.setTexture(this.runtime.layer_tex),a.setBlend(this.srcBlend,this.destBlend),a.resetModelView(),a.updateModelView(),b=this.runtime.width/
2,d=this.runtime.height/2,a.quad(-b,d,b,d,b,-d,-b,-d),a.setTexture(null)):this.layout.renderEffectChain(a,this,null,this.layout.getRenderTarget()))};b.prototype.canvasToLayer=function(a,b,d){var e=this.runtime.devicePixelRatio;this.runtime.isRetina&&0<this.runtime.fullscreen_mode&&(a*=e,b*=e);var e=this.runtime.original_width/2,l=this.runtime.original_height/2,e=(this.layout.scrollX-e)*this.parallaxX+e,l=(this.layout.scrollY-l)*this.parallaxY+l,k=1/this.getScale(),e=e-this.runtime.width*k/2,l=l-this.runtime.height*
k/2,e=e+a*k,l=l+b*k;b=this.getAngle();0!==b&&(e-=this.layout.scrollX,l-=this.layout.scrollY,a=Math.cos(b),b=Math.sin(b),k=e*a-l*b,l=l*a+e*b,e=k+this.layout.scrollX,l+=this.layout.scrollY);return d?e:l};b.prototype.layerToCanvas=function(a,b,d){var e=this.getAngle();if(0!==e){a-=this.layout.scrollX;b-=this.layout.scrollY;var l=Math.cos(-e),e=Math.sin(-e),k=a*l-b*e;b=b*l+a*e;a=k+this.layout.scrollX;b+=this.layout.scrollY}l=this.runtime.original_width/2;e=this.runtime.original_height/2;l=(this.layout.scrollX-
l)*this.parallaxX+l;e=(this.layout.scrollY-e)*this.parallaxY+e;k=1/this.getScale();l-=this.runtime.width*k/2;e-=this.runtime.height*k/2;l=(a-l)/k;e=(b-e)/k;a=this.runtime.devicePixelRatio;this.runtime.isRetina&&0<this.runtime.fullscreen_mode&&(l/=a,e/=a);return d?l:e};b.prototype.rotatePt=function(a,b,d){if(0===this.getAngle())return d?a:b;var e=this.layerToCanvas(a,b,!0);b=this.layerToCanvas(a,b,!1);this.disableAngle=!0;a=this.canvasToLayer(e,b,!0);e=this.canvasToLayer(e,b,!0);this.disableAngle=
!1;return d?a:e};b.prototype.saveToJSON=function(){var a,b,d,e={s:this.scale,a:this.angle,vl:this.viewLeft,vt:this.viewTop,vr:this.viewRight,vb:this.viewBottom,v:this.visible,bc:this.background_color,t:this.transparent,px:this.parallaxX,py:this.parallaxY,o:this.opacity,zr:this.zoomRate,fx:[],instances:[]};a=0;for(b=this.effect_types.length;a<b;a++)d=this.effect_types[a],e.fx.push({name:d.name,active:d.active,params:this.effect_params[d.index]});return e};b.prototype.loadFromJSON=function(a){var b,
d;this.scale=a.s;this.angle=a.a;this.viewLeft=a.vl;this.viewTop=a.vt;this.viewRight=a.vr;this.viewBottom=a.vb;this.visible=a.v;this.background_color=a.bc;this.transparent=a.t;this.parallaxX=a.px;this.parallaxY=a.py;this.opacity=a.o;this.zoomRate=a.zr;var h=a.fx;a=0;for(b=h.length;a<b;a++)if(d=this.getEffectByName(h[a].name))d.active=h[a].active,this.effect_params[d.index]=h[a].params;this.updateActiveEffects();this.instances.sort(e);this.zindices_stale=!0};cr.layer=b})();
(function(){function a(a,b){var c,d=a.length;switch(d){case 0:return!0;case 1:return a[0]===b[0];case 2:return a[0]===b[0]&&a[1]===b[1];default:for(c=0;c<d;c++)if(a[c]!==b[c])return!1;return!0}}function b(a,b){return a.index-b.index}function e(c){var d,e,r,f;2===c.length?c[0].index>c[1].index&&(d=c[0],c[0]=c[1],c[1]=d):2<c.length&&c.sort(b);c.length>=p.length&&(p.length=c.length+1);p[c.length]||(p[c.length]=[]);f=p[c.length];d=0;for(e=f.length;d<e;d++)if(r=f[d],a(c,r))return r;f.push(c);return c}
function d(a,b){this.runtime=a;this.triggers={};this.fasttriggers={};this.hasRun=!1;this.includes=new cr.ObjectSet;this.name=b[0];var c=b[1];this.events=[];var d,e;d=0;for(e=c.length;d<e;d++)this.init_event(c[d],null,this.events)}function c(a){this.type=a;this.instances=[];this.else_instances=[];this.select_all=!0}function f(a,b,c){this.sheet=a;this.parent=b;this.runtime=a.runtime;this.solModifiers=[];this.solModifiersIncludingParents=[];this.has_else_block=this.toplevelgroup=this.toplevelevent=this.initially_activated=
this.group=this.solWriterAfterCnds=!1;this.conditions=[];this.actions=[];this.subevents=[];c[1]?(this.group_name=c[1][1].toLowerCase(),this.group=!0,this.initially_activated=!!c[1][0],this.runtime.allGroups.push(this),this.runtime.activeGroups[this.group_name.toLowerCase()]=this.initially_activated):(this.group_name="",this.initially_activated=this.group=!1);this.orblock=c[2];this.sid=c[4];this.group||(this.runtime.blocksBySid[this.sid.toString()]=this);var d=c[5];a=0;for(b=d.length;a<b;a++){var e=
new cr.condition(this,d[a]);e.index=a;cr.seal(e);this.conditions.push(e);this.addSolModifier(e.type)}d=c[6];a=0;for(b=d.length;a<b;a++)e=new cr.action(this,d[a]),e.index=a,cr.seal(e),this.actions.push(e);if(8===c.length)for(c=c[7],a=0,b=c.length;a<b;a++)this.sheet.init_event(c[a],this,this.subevents);this.is_else_block=!1;this.conditions.length&&(this.is_else_block=null==this.conditions[0].type&&this.conditions[0].func==cr.system_object.prototype.cnds.Else)}function g(a,b){var c,d,e;if(a&&(-1===b.indexOf(a)&&
b.push(a),a.is_contained))for(c=0,d=a.container.length;c<d;c++)e=a.container[c],a!==e&&-1===b.indexOf(e)&&b.push(e)}function h(a,b){this.block=a;this.sheet=a.sheet;this.runtime=a.runtime;this.parameters=[];this.results=[];this.extra={};this.index=-1;this.func=b[1];this.trigger=0<b[3];this.fasttrigger=2===b[3];this.looping=b[4];this.inverted=b[5];this.isstatic=b[6];this.sid=b[7];this.runtime.cndsBySid[this.sid.toString()]=this;-1===b[0]?(this.type=null,this.run=this.run_system,this.behaviortype=null,
this.beh_index=-1):(this.type=this.runtime.types_by_index[b[0]],this.run=this.isstatic?this.run_static:this.run_object,b[2]?(this.behaviortype=this.type.getBehaviorByName(b[2]),this.beh_index=this.type.getBehaviorIndexByName(b[2])):(this.behaviortype=null,this.beh_index=-1),this.block.parent&&this.block.parent.setSolWriterAfterCnds());this.fasttrigger&&(this.run=this.run_true);if(10===b.length){var c,d,e=b[9];c=0;for(d=e.length;c<d;c++){var f=new cr.parameter(this,e[c]);cr.seal(f);this.parameters.push(f)}this.results.length=
e.length}}function l(a,b){this.block=a;this.sheet=a.sheet;this.runtime=a.runtime;this.parameters=[];this.results=[];this.extra={};this.index=-1;this.func=b[1];-1===b[0]?(this.type=null,this.run=this.run_system,this.behaviortype=null,this.beh_index=-1):(this.type=this.runtime.types_by_index[b[0]],this.run=this.run_object,b[2]?(this.behaviortype=this.type.getBehaviorByName(b[2]),this.beh_index=this.type.getBehaviorIndexByName(b[2])):(this.behaviortype=null,this.beh_index=-1));this.sid=b[3];this.runtime.actsBySid[this.sid.toString()]=
this;if(6===b.length){var c,d,e=b[5];c=0;for(d=e.length;c<d;c++){var f=new cr.parameter(this,e[c]);cr.seal(f);this.parameters.push(f)}this.results.length=e.length}}function k(a,b){this.owner=a;this.block=a.block;this.sheet=a.sheet;this.runtime=a.runtime;this.type=b[0];this.expression=null;this.combosel=this.solindex=0;this.layout=null;this.key=0;this.object=null;this.index=0;this.variadicret=this.subparams=this.fileinfo=this.eventvar=this.varname=null;var c,d,e;switch(b[0]){case 0:case 7:this.expression=
new cr.expNode(this,b[1]);this.solindex=0;this.get=this.get_exp;break;case 1:this.expression=new cr.expNode(this,b[1]);this.solindex=0;this.get=this.get_exp_str;break;case 5:this.expression=new cr.expNode(this,b[1]);this.solindex=0;this.get=this.get_layer;break;case 3:case 8:this.combosel=b[1];this.get=this.get_combosel;break;case 6:this.layout=this.runtime.layouts[b[1]];this.get=this.get_layout;break;case 9:this.key=b[1];this.get=this.get_key;break;case 4:this.object=this.runtime.types_by_index[b[1]];
this.get=this.get_object;this.block.addSolModifier(this.object);this.owner instanceof cr.action?this.block.setSolWriterAfterCnds():this.block.parent&&this.block.parent.setSolWriterAfterCnds();break;case 10:this.index=b[1];this.get=a.type.is_family?this.get_familyvar:this.get_instvar;break;case 11:this.varname=b[1];this.eventvar=null;this.get=this.get_eventvar;break;case 2:case 12:this.fileinfo=b[1];this.get=this.get_audiofile;break;case 13:for(this.get=this.get_variadic,this.subparams=[],this.variadicret=
[],c=1,d=b.length;c<d;c++)e=new cr.parameter(this.owner,b[c]),cr.seal(e),this.subparams.push(e),this.variadicret.push(0)}}function n(a,b,c){this.sheet=a;this.parent=b;this.runtime=a.runtime;this.solModifiers=[];this.name=c[1];this.vartype=c[2];this.initial=c[3];this.is_static=!!c[4];this.is_constant=!!c[5];this.sid=c[6];this.runtime.varsBySid[this.sid.toString()]=this;this.data=this.initial;this.parent?(this.localIndex=this.is_static||this.is_constant?-1:this.runtime.stackLocalCount++,this.runtime.all_local_vars.push(this)):
(this.localIndex=-1,this.runtime.all_global_vars.push(this))}function v(a,b,c){this.sheet=a;this.parent=b;this.runtime=a.runtime;this.solModifiers=[];this.include_sheet=null;this.include_sheet_name=c[1]}function u(){this.temp_parents_arr=[];this.reset(null);cr.seal(this)}var p=[];d.prototype.toString=function(){return this.name};d.prototype.init_event=function(a,b,c){switch(a[0]){case 0:a=new cr.eventblock(this,b,a);cr.seal(a);if(a.orblock)for(c.push(a),c=0,b=a.conditions.length;c<b;c++)a.conditions[c].trigger&&
this.init_trigger(a,c);else a.is_trigger()?this.init_trigger(a,0):c.push(a);break;case 1:a=new cr.eventvariable(this,b,a);cr.seal(a);c.push(a);break;case 2:a=new cr.eventinclude(this,b,a),cr.seal(a),c.push(a)}};d.prototype.postInit=function(){var a,b;a=0;for(b=this.events.length;a<b;a++)this.events[a].postInit(a<b-1&&this.events[a+1].is_else_block)};d.prototype.run=function(a){this.runtime.resuming_breakpoint||(this.hasRun=!0,a||(this.runtime.isRunningEvents=!0));var b,c;b=0;for(c=this.events.length;b<
c;b++){var d=this.events[b];d.run();this.runtime.clearSol(d.solModifiers);this.runtime.deathRow.isEmpty()&&!this.runtime.createRow.length||this.runtime.ClearDeathRow()}a||(this.runtime.isRunningEvents=!1)};d.prototype.init_trigger=function(a,b){a.orblock||this.runtime.triggers_to_postinit.push(a);var c,d,e=a.conditions[b],f;f=e.type?e.type.name:"system";var g=(c=e.fasttrigger)?this.fasttriggers:this.triggers;g[f]||(g[f]=[]);f=g[f];g=e.func;if(c){if(e.parameters.length&&(e=e.parameters[0],1===e.type&&
2===e.expression.type)){e=e.expression.value.toLowerCase();c=0;for(d=f.length;c<d;c++)if(f[c].method==g){c=f[c].evs;c[e]?c[e].push([a,b]):c[e]=[[a,b]];return}c={};c[e]=[[a,b]];f.push({method:g,evs:c})}}else{c=0;for(d=f.length;c<d;c++)if(f[c].method==g){f[c].evs.push([a,b]);return}f.push({method:g,evs:[[a,b]]})}};cr.eventsheet=d;c.prototype.hasObjects=function(){return this.select_all?this.type.instances.length:this.instances.length};c.prototype.getObjects=function(){return this.select_all?this.type.instances:
this.instances};c.prototype.pick_one=function(a){a&&(a.runtime.getCurrentEventStack().current_event.orblock?(this.select_all&&(this.instances.length=0,cr.shallowAssignArray(this.else_instances,a.type.instances),this.select_all=!1),a=this.else_instances.indexOf(a),-1!==a&&(this.instances.push(this.else_instances[a]),this.else_instances.splice(a,1))):(this.select_all=!1,this.instances.length=1,this.instances[0]=a))};cr.selection=c;f.prototype.postInit=function(a){var b,c=this.parent;if(this.group)for(this.toplevelgroup=
!0;c;){if(!c.group){this.toplevelgroup=!1;break}c=c.parent}this.toplevelevent=!this.is_trigger()&&(!this.parent||this.parent.group&&this.parent.toplevelgroup);this.has_else_block=!!a;this.solModifiersIncludingParents=this.solModifiers.slice(0);for(c=this.parent;c;){a=0;for(b=c.solModifiers.length;a<b;a++)this.addParentSolModifier(c.solModifiers[a]);c=c.parent}this.solModifiers=e(this.solModifiers);this.solModifiersIncludingParents=e(this.solModifiersIncludingParents);a=0;for(b=this.conditions.length;a<
b;a++)this.conditions[a].postInit();a=0;for(b=this.actions.length;a<b;a++)this.actions[a].postInit();a=0;for(b=this.subevents.length;a<b;a++)this.subevents[a].postInit(a<b-1&&this.subevents[a+1].is_else_block)};f.prototype.addSolModifier=function(a){g(a,this.solModifiers)};f.prototype.addParentSolModifier=function(a){g(a,this.solModifiersIncludingParents)};f.prototype.setSolWriterAfterCnds=function(){this.solWriterAfterCnds=!0;this.parent&&this.parent.setSolWriterAfterCnds()};f.prototype.is_trigger=
function(){return this.conditions.length?this.conditions[0].trigger:!1};f.prototype.run=function(){var a,b=!1,c,d=this.runtime.getCurrentEventStack();d.current_event=this;this.is_else_block||(d.else_branch_ran=!1);if(this.orblock){0===this.conditions.length&&(b=!0);d.cndindex=0;for(a=this.conditions.length;d.cndindex<a;d.cndindex++)this.conditions[d.cndindex].trigger||(c=this.conditions[d.cndindex].run())&&(b=!0);(d.last_event_true=b)&&this.run_actions_and_subevents()}else{d.cndindex=0;for(a=this.conditions.length;d.cndindex<
a;d.cndindex++)if(c=this.conditions[d.cndindex].run(),!c){d.last_event_true=!1;!this.toplevelevent||this.runtime.deathRow.isEmpty()&&!this.runtime.createRow.length||this.runtime.ClearDeathRow();return}d.last_event_true=!0;this.run_actions_and_subevents()}this.end_run(d)};f.prototype.end_run=function(a){a.last_event_true&&this.has_else_block&&(a.else_branch_ran=!0);!this.toplevelevent||this.runtime.deathRow.isEmpty()&&!this.runtime.createRow.length||this.runtime.ClearDeathRow()};f.prototype.run_orblocktrigger=
function(a){this.runtime.getCurrentEventStack().current_event=this;this.conditions[a].run()&&this.run_actions_and_subevents()};f.prototype.run_actions_and_subevents=function(){var a=this.runtime.getCurrentEventStack(),b;a.actindex=0;for(b=this.actions.length;a.actindex<b;a.actindex++)if(this.actions[a.actindex].run())return;this.run_subevents()};f.prototype.resume_actions_and_subevents=function(){var a=this.runtime.getCurrentEventStack(),b;for(b=this.actions.length;a.actindex<b;a.actindex++)if(this.actions[a.actindex].run())return;
this.run_subevents()};f.prototype.run_subevents=function(){if(this.subevents.length){var a,b,c,d,e=this.subevents.length-1;this.runtime.pushEventStack(this);if(this.solWriterAfterCnds)for(a=0,b=this.subevents.length;a<b;a++)c=this.subevents[a],(d=!this.toplevelgroup||!this.group&&a<e)&&this.runtime.pushCopySol(c.solModifiers),c.run(),d?this.runtime.popSol(c.solModifiers):this.runtime.clearSol(c.solModifiers);else for(a=0,b=this.subevents.length;a<b;a++)this.subevents[a].run();this.runtime.popEventStack()}};
f.prototype.run_pretrigger=function(){var a=this.runtime.getCurrentEventStack();a.current_event=this;var b=!1,c;a.cndindex=0;for(c=this.conditions.length;a.cndindex<c;a.cndindex++)if(this.conditions[a.cndindex].run())b=!0;else if(!this.orblock)return!1;return this.orblock?b:!0};f.prototype.retrigger=function(){this.runtime.execcount++;var a=this.runtime.getCurrentEventStack().cndindex,b=this.runtime.pushEventStack(this);if(!this.orblock)for(b.cndindex=a+1,a=this.conditions.length;b.cndindex<a;b.cndindex++)if(!this.conditions[b.cndindex].run())return this.runtime.popEventStack(),
!1;this.run_actions_and_subevents();this.runtime.popEventStack();return!0};f.prototype.isFirstConditionOfType=function(a){var b=a.index;if(0===b)return!0;for(--b;0<=b;--b)if(this.conditions[b].type===a.type)return!1;return!0};cr.eventblock=f;h.prototype.postInit=function(){var a,b;a=0;for(b=this.parameters.length;a<b;a++)this.parameters[a].postInit()};h.prototype.run_true=function(){return!0};h.prototype.run_system=function(){var a,b;a=0;for(b=this.parameters.length;a<b;a++)this.results[a]=this.parameters[a].get();
return cr.xor(this.func.apply(this.runtime.system,this.results),this.inverted)};h.prototype.run_static=function(){var a,b;a=0;for(b=this.parameters.length;a<b;a++)this.results[a]=this.parameters[a].get(a);a=this.func.apply(this.behaviortype?this.behaviortype:this.type,this.results);this.type.applySolToContainer();return a};h.prototype.run_object=function(){var a,b,c,d,e,f,g,h=this.type.getCurrentSol(),n=this.block.orblock&&!this.trigger,p=0,k=this.type.is_contained;if(h.select_all){h.instances.length=
0;a=h.else_instances.length=0;for(c=this.type.instances.length;a<c;a++){f=this.type.instances[a];b=0;for(d=this.parameters.length;b<d;b++)this.results[b]=this.parameters[b].get(a);-1<this.beh_index?(this.type.is_family&&(p=f.type.family_beh_map[this.type.family_index]),b=this.func.apply(f.behavior_insts[this.beh_index+p],this.results)):b=this.func.apply(f,this.results);(e=cr.xor(b,this.inverted))?h.instances.push(f):n&&h.else_instances.push(f)}this.type.finish&&this.type.finish(!0);h.select_all=!1;
this.type.applySolToContainer();return h.hasObjects()}var l=0,s=(e=n&&!this.block.isFirstConditionOfType(this))?h.else_instances:h.instances,t=!1;a=0;for(c=s.length;a<c;a++){f=s[a];b=0;for(d=this.parameters.length;b<d;b++)this.results[b]=this.parameters[b].get(a);-1<this.beh_index?(this.type.is_family&&(p=f.type.family_beh_map[this.type.family_index]),b=this.func.apply(f.behavior_insts[this.beh_index+p],this.results)):b=this.func.apply(f,this.results);if(cr.xor(b,this.inverted))if(t=!0,e){if(h.instances.push(f),
k)for(b=0,d=f.siblings.length;b<d;b++)g=f.siblings[b],g.type.getCurrentSol().instances.push(g)}else{s[l]=f;if(k)for(b=0,d=f.siblings.length;b<d;b++)g=f.siblings[b],g.type.getCurrentSol().instances[l]=g;l++}else if(e){s[l]=f;if(k)for(b=0,d=f.siblings.length;b<d;b++)g=f.siblings[b],g.type.getCurrentSol().else_instances[l]=g;l++}else if(n&&(h.else_instances.push(f),k))for(b=0,d=f.siblings.length;b<d;b++)g=f.siblings[b],g.type.getCurrentSol().else_instances.push(g)}s.length=l;if(k)for(a=0,c=this.type.container.length;a<
c;a++)f=this.type.container[a].getCurrentSol(),e?f.else_instances.length=l:f.instances.length=l;p=t;if(e&&!t)for(a=0,c=h.instances.length;a<c;a++){f=h.instances[a];b=0;for(d=this.parameters.length;b<d;b++)this.results[b]=this.parameters[b].get(a);b=-1<this.beh_index?this.func.apply(f.behavior_insts[this.beh_index],this.results):this.func.apply(f,this.results);if(cr.xor(b,this.inverted)){t=!0;break}}this.type.finish&&this.type.finish(p||n);return n?t:h.hasObjects()};cr.condition=h;l.prototype.postInit=
function(){var a,b;a=0;for(b=this.parameters.length;a<b;a++)this.parameters[a].postInit()};l.prototype.run_system=function(){var a,b;a=0;for(b=this.parameters.length;a<b;a++)this.results[a]=this.parameters[a].get();return this.func.apply(this.runtime.system,this.results)};l.prototype.run_object=function(){var a=this.type.getCurrentSol().getObjects(),b,c,d,e,f;b=0;for(d=a.length;b<d;b++){f=a[b];c=0;for(e=this.parameters.length;c<e;c++)this.results[c]=this.parameters[c].get(b);-1<this.beh_index?(c=
0,this.type.is_family&&(c=f.type.family_beh_map[this.type.family_index]),this.func.apply(f.behavior_insts[this.beh_index+c],this.results)):this.func.apply(f,this.results)}return!1};cr.action=l;var t=[],s=-1;k.prototype.postInit=function(){var a,b;if(11===this.type)this.eventvar=this.runtime.getEventVariableByName(this.varname,this.block.parent);else if(13===this.type)for(a=0,b=this.subparams.length;a<b;a++)this.subparams[a].postInit();this.expression&&this.expression.postInit()};k.prototype.pushTempValue=
function(){s++;t.length===s&&t.push(new cr.expvalue);return t[s]};k.prototype.popTempValue=function(){s--};k.prototype.get_exp=function(a){this.solindex=a||0;a=this.pushTempValue();this.expression.get(a);this.popTempValue();return a.data};k.prototype.get_exp_str=function(a){this.solindex=a||0;a=this.pushTempValue();this.expression.get(a);this.popTempValue();return cr.is_string(a.data)?a.data:""};k.prototype.get_object=function(){return this.object};k.prototype.get_combosel=function(){return this.combosel};
k.prototype.get_layer=function(a){this.solindex=a||0;a=this.pushTempValue();this.expression.get(a);this.popTempValue();return a.is_number()?this.runtime.getLayerByNumber(a.data):this.runtime.getLayerByName(a.data)};k.prototype.get_layout=function(){return this.layout};k.prototype.get_key=function(){return this.key};k.prototype.get_instvar=function(){return this.index};k.prototype.get_familyvar=function(a){var b=this.owner.type,c=null,c=b.getCurrentSol(),d=c.getObjects(),c=d.length?d[a%d.length].type:
c.else_instances[a%c.else_instances.length].type;return this.index+c.family_var_map[b.family_index]};k.prototype.get_eventvar=function(){return this.eventvar};k.prototype.get_audiofile=function(){return this.fileinfo};k.prototype.get_variadic=function(){var a,b;a=0;for(b=this.subparams.length;a<b;a++)this.variadicret[a]=this.subparams[a].get();return this.variadicret};cr.parameter=k;n.prototype.postInit=function(){this.solModifiers=e(this.solModifiers)};n.prototype.setValue=function(a){var b=this.runtime.getCurrentLocalVarStack();
this.parent&&!this.is_static&&b?(this.localIndex>=b.length&&(b.length=this.localIndex+1),b[this.localIndex]=a):this.data=a};n.prototype.getValue=function(){var a=this.runtime.getCurrentLocalVarStack();return!this.parent||this.is_static||!a||this.is_constant?this.data:this.localIndex>=a.length||"undefined"===typeof a[this.localIndex]?this.initial:a[this.localIndex]};n.prototype.run=function(){!this.parent||this.is_static||this.is_constant||this.setValue(this.initial)};cr.eventvariable=n;v.prototype.toString=
function(){return"include:"+this.include_sheet.toString()};v.prototype.postInit=function(){this.include_sheet=this.runtime.eventsheets[this.include_sheet_name];this.sheet.includes.add(this);this.solModifiers=e(this.solModifiers)};v.prototype.run=function(){this.parent&&this.runtime.pushCleanSol(this.runtime.types_by_index);this.include_sheet.hasRun||this.include_sheet.run(!0);this.parent&&this.runtime.popSol(this.runtime.types_by_index)};v.prototype.isActive=function(){for(var a=this.parent;a;){if(a.group&&
!this.runtime.activeGroups[a.group_name.toLowerCase()])return!1;a=a.parent}return!0};cr.eventinclude=v;u.prototype.reset=function(a){this.current_event=a;this.actindex=this.cndindex=0;this.temp_parents_arr.length=0;this.any_true_state=this.else_branch_ran=this.last_event_true=!1};u.prototype.isModifierAfterCnds=function(){return this.current_event.solWriterAfterCnds?!0:this.cndindex<this.current_event.conditions.length-1?!!this.current_event.solModifiers.length:!1};cr.eventStackFrame=u})();
(function(){function a(a,b){this.owner=a;this.runtime=a.runtime;this.type=b[0];this.get=[this.eval_int,this.eval_float,this.eval_string,this.eval_unaryminus,this.eval_add,this.eval_subtract,this.eval_multiply,this.eval_divide,this.eval_mod,this.eval_power,this.eval_and,this.eval_or,this.eval_equal,this.eval_notequal,this.eval_less,this.eval_lessequal,this.eval_greater,this.eval_greaterequal,this.eval_conditional,this.eval_system_exp,this.eval_object_behavior_exp,this.eval_instvar_exp,this.eval_object_behavior_exp,
this.eval_eventvar_exp][this.type];var c=null;this.object_type=this.parameters=this.results=this.func=this.third=this.second=this.first=this.value=null;this.beh_index=-1;this.instance_expr=null;this.varindex=-1;this.eventvar=this.varname=this.behavior_type=null;this.return_string=!1;switch(this.type){case 0:case 1:case 2:this.value=b[1];break;case 3:this.first=new cr.expNode(a,b[1]);break;case 18:this.first=new cr.expNode(a,b[1]);this.second=new cr.expNode(a,b[2]);this.third=new cr.expNode(a,b[3]);
break;case 19:this.func=b[1];this.results=[];this.parameters=[];3===b.length?(c=b[2],this.results.length=c.length+1):this.results.length=1;break;case 20:this.object_type=this.runtime.types_by_index[b[1]];this.beh_index=-1;this.func=b[2];this.return_string=b[3];this.instance_expr=b[4]?new cr.expNode(a,b[4]):null;this.results=[];this.parameters=[];6===b.length?(c=b[5],this.results.length=c.length+1):this.results.length=1;break;case 21:this.object_type=this.runtime.types_by_index[b[1]];this.return_string=
b[2];this.instance_expr=b[3]?new cr.expNode(a,b[3]):null;this.varindex=b[4];break;case 22:this.object_type=this.runtime.types_by_index[b[1]];this.behavior_type=this.object_type.getBehaviorByName(b[2]);this.beh_index=this.object_type.getBehaviorIndexByName(b[2]);this.func=b[3];this.return_string=b[4];this.instance_expr=b[5]?new cr.expNode(a,b[5]):null;this.results=[];this.parameters=[];7===b.length?(c=b[6],this.results.length=c.length+1):this.results.length=1;break;case 23:this.varname=b[1],this.eventvar=
null}4<=this.type&&17>=this.type&&(this.first=new cr.expNode(a,b[1]),this.second=new cr.expNode(a,b[2]));if(c){var f,g;f=0;for(g=c.length;f<g;f++)this.parameters.push(new cr.expNode(a,c[f]))}cr.seal(this)}function b(a,b){this.type=a||cr.exptype.Integer;this.data=b||0;this.object_class=null;this.type==cr.exptype.Integer&&(this.data=Math.floor(this.data));cr.seal(this)}a.prototype.postInit=function(){23===this.type&&(this.eventvar=this.owner.runtime.getEventVariableByName(this.varname,this.owner.block.parent));
this.first&&this.first.postInit();this.second&&this.second.postInit();this.third&&this.third.postInit();this.instance_expr&&this.instance_expr.postInit();if(this.parameters){var a,b;a=0;for(b=this.parameters.length;a<b;a++)this.parameters[a].postInit()}};a.prototype.eval_system_exp=function(a){this.results[0]=a;a=this.owner.pushTempValue();var b,c;b=0;for(c=this.parameters.length;b<c;b++)this.parameters[b].get(a),this.results[b+1]=a.data;this.owner.popTempValue();this.func.apply(this.runtime.system,
this.results)};a.prototype.eval_object_behavior_exp=function(a){var b=this.object_type.getCurrentSol(),c=b.getObjects();if(!c.length)if(b.else_instances.length)c=b.else_instances;else{this.return_string?a.set_string(""):a.set_int(0);return}this.results[0]=a;a.object_class=this.object_type;a=this.owner.pushTempValue();var f,b=0;for(f=this.parameters.length;b<f;b++)this.parameters[b].get(a),this.results[b+1]=a.data;b=this.owner.solindex;this.instance_expr&&(this.instance_expr.get(a),a.is_number()&&
(b=a.data,c=this.object_type.instances));this.owner.popTempValue();b%=c.length;0>b&&(b+=c.length);c=c[b];-1<this.beh_index?(a=0,this.object_type.is_family&&(a=c.type.family_beh_map[this.object_type.family_index]),this.func.apply(c.behavior_insts[this.beh_index+a],this.results)):this.func.apply(c,this.results)};a.prototype.eval_instvar_exp=function(a){var b=this.object_type.getCurrentSol(),c=b.getObjects();if(!c.length)if(b.else_instances.length)c=b.else_instances;else{this.return_string?a.set_string(""):
a.set_int(0);return}b=this.owner.solindex;if(this.instance_expr){var f=this.owner.pushTempValue();this.instance_expr.get(f);if(f.is_number()){b=f.data;c=this.object_type.instances;b%=c.length;0>b&&(b+=c.length);c=c[b].instance_vars[this.varindex];cr.is_string(c)?a.set_string(c):a.set_float(c);this.owner.popTempValue();return}this.owner.popTempValue()}b%=c.length;0>b&&(b+=c.length);c=c[b];b=0;this.object_type.is_family&&(b=c.type.family_var_map[this.object_type.family_index]);c=c.instance_vars[this.varindex+
b];cr.is_string(c)?a.set_string(c):a.set_float(c)};a.prototype.eval_int=function(a){a.type=cr.exptype.Integer;a.data=this.value};a.prototype.eval_float=function(a){a.type=cr.exptype.Float;a.data=this.value};a.prototype.eval_string=function(a){a.type=cr.exptype.String;a.data=this.value};a.prototype.eval_unaryminus=function(a){this.first.get(a);a.is_number()&&(a.data=-a.data)};a.prototype.eval_add=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.is_number()&&b.is_number()&&
(a.data+=b.data,b.is_float()&&a.make_float());this.owner.popTempValue()};a.prototype.eval_subtract=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.is_number()&&b.is_number()&&(a.data-=b.data,b.is_float()&&a.make_float());this.owner.popTempValue()};a.prototype.eval_multiply=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.is_number()&&b.is_number()&&(a.data*=b.data,b.is_float()&&a.make_float());this.owner.popTempValue()};a.prototype.eval_divide=
function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.is_number()&&b.is_number()&&(a.data/=b.data,a.make_float());this.owner.popTempValue()};a.prototype.eval_mod=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.is_number()&&b.is_number()&&(a.data%=b.data,b.is_float()&&a.make_float());this.owner.popTempValue()};a.prototype.eval_power=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.is_number()&&b.is_number()&&
(a.data=Math.pow(a.data,b.data),b.is_float()&&a.make_float());this.owner.popTempValue()};a.prototype.eval_and=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.is_number()?b.is_string()?a.set_string(a.data.toString()+b.data):a.data&&b.data?a.set_int(1):a.set_int(0):a.is_string()&&(b.is_string()?a.data+=b.data:a.data+=(Math.round(1E10*b.data)/1E10).toString());this.owner.popTempValue()};a.prototype.eval_or=function(a){this.first.get(a);var b=this.owner.pushTempValue();
this.second.get(b);a.is_number()&&b.is_number()&&(a.data||b.data?a.set_int(1):a.set_int(0));this.owner.popTempValue()};a.prototype.eval_conditional=function(a){this.first.get(a);a.data?this.second.get(a):this.third.get(a)};a.prototype.eval_equal=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.set_int(a.data===b.data?1:0);this.owner.popTempValue()};a.prototype.eval_notequal=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.set_int(a.data!==
b.data?1:0);this.owner.popTempValue()};a.prototype.eval_less=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.set_int(a.data<b.data?1:0);this.owner.popTempValue()};a.prototype.eval_lessequal=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.set_int(a.data<=b.data?1:0);this.owner.popTempValue()};a.prototype.eval_greater=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.set_int(a.data>b.data?1:0);
this.owner.popTempValue()};a.prototype.eval_greaterequal=function(a){this.first.get(a);var b=this.owner.pushTempValue();this.second.get(b);a.set_int(a.data>=b.data?1:0);this.owner.popTempValue()};a.prototype.eval_eventvar_exp=function(a){var b=this.eventvar.getValue();cr.is_number(b)?a.set_float(b):a.set_string(b)};cr.expNode=a;b.prototype.is_int=function(){return this.type===cr.exptype.Integer};b.prototype.is_float=function(){return this.type===cr.exptype.Float};b.prototype.is_number=function(){return this.type===
cr.exptype.Integer||this.type===cr.exptype.Float};b.prototype.is_string=function(){return this.type===cr.exptype.String};b.prototype.make_int=function(){this.is_int()||(this.is_float()?this.data=Math.floor(this.data):this.is_string()&&(this.data=parseInt(this.data,10)),this.type=cr.exptype.Integer)};b.prototype.make_float=function(){this.is_float()||(this.is_string()&&(this.data=parseFloat(this.data)),this.type=cr.exptype.Float)};b.prototype.make_string=function(){this.is_string()||(this.data=this.data.toString(),
this.type=cr.exptype.String)};b.prototype.set_int=function(a){this.type=cr.exptype.Integer;this.data=Math.floor(a)};b.prototype.set_float=function(a){this.type=cr.exptype.Float;this.data=a};b.prototype.set_string=function(a){this.type=cr.exptype.String;this.data=a};b.prototype.set_any=function(a){cr.is_number(a)?(this.type=cr.exptype.Float,this.data=a):cr.is_string(a)?(this.type=cr.exptype.String,this.data=a.toString()):(this.type=cr.exptype.Integer,this.data=0)};cr.expvalue=b;cr.exptype={Integer:0,
Float:1,String:2}})();cr.system_object=function(a){this.runtime=a;this.waits=[]};
cr.system_object.prototype.saveToJSON=function(){var a={},b,e,d,c,f,g,h,l;a.waits=[];var k=a.waits,n;b=0;for(e=this.waits.length;b<e;b++){g=this.waits[b];n={t:g.time,ev:g.ev.sid,sm:[],sols:{}};g.ev.actions[g.actindex]&&(n.act=g.ev.actions[g.actindex].sid);d=0;for(c=g.solModifiers.length;d<c;d++)n.sm.push(g.solModifiers[d].sid);for(f in g.sols)if(g.sols.hasOwnProperty(f)){h=this.runtime.types_by_index[parseInt(f,10)];l={sa:g.sols[f].sa,insts:[]};d=0;for(c=g.sols[f].insts.length;d<c;d++)l.insts.push(g.sols[f].insts[d].uid);
n.sols[h.sid.toString()]=l}k.push(n)}return a};
cr.system_object.prototype.loadFromJSON=function(a){a=a.waits;var b,e,d,c,f,g,h,l,k,n,v;b=this.waits.length=0;for(e=a.length;b<e;b++)if(g=a[b],l=this.runtime.blocksBySid[g.ev.toString()]){k=-1;d=0;for(c=l.actions.length;d<c;d++)if(l.actions[d].sid===g.act){k=d;break}if(-1!==k){h={sols:{},solModifiers:[],deleteme:!1};h.time=g.t;h.ev=l;h.actindex=k;d=0;for(c=g.sm.length;d<c;d++)(l=this.runtime.getObjectTypeBySid(g.sm[d]))&&h.solModifiers.push(l);for(f in g.sols)if(g.sols.hasOwnProperty(f)&&(l=this.runtime.getObjectTypeBySid(parseInt(f,
10)))){k=g.sols[f];n={sa:k.sa,insts:[]};d=0;for(c=k.insts.length;d<c;d++)(v=this.runtime.getObjectByUID(k.insts[d]))&&n.insts.push(v);h.sols[l.index.toString()]=n}this.waits.push(h)}}};
(function(){function a(){}function b(a,b){var c=a.extra.c2_foreachordered_val,d=b.extra.c2_foreachordered_val;if(cr.is_number(c)&&cr.is_number(d))return c-d;c=""+c;d=""+d;return c<d?-1:c>d?1:0}function e(a,b){k&&a===n&&b===v||(k=RegExp(a,b),n=a,v=b);k.lastIndex=0;return k}function d(){}function c(){}function f(a,b,c){if(a!==m||b!==x||c!==z){var d=e(b,c);s=a.match(d);m=a;x=b;z=c}}var g=cr.system_object.prototype;a.prototype.EveryTick=function(){return!0};a.prototype.OnLayoutStart=function(){return!0};
a.prototype.OnLayoutEnd=function(){return!0};a.prototype.Compare=function(a,b,c){return cr.do_cmp(a,b,c)};a.prototype.CompareTime=function(a,b){var c=this.runtime.kahanTime.sum;if(0===a){var d=this.runtime.getCurrentCondition();return!d.extra.CompareTime_executed&&c>=b?d.extra.CompareTime_executed=!0:!1}return cr.do_cmp(c,a,b)};a.prototype.LayerVisible=function(a){return a?a.visible:!1};a.prototype.LayerCmpOpacity=function(a,b,c){return a?cr.do_cmp(100*a.opacity,b,c):!1};a.prototype.Repeat=function(a){var b=
this.runtime.getCurrentEventStack(),c=b.current_event,d=b.isModifierAfterCnds(),b=this.runtime.pushLoopStack();if(d)for(d=0;d<a&&!b.stopped;d++)this.runtime.pushCopySol(c.solModifiers),b.index=d,c.retrigger(),this.runtime.popSol(c.solModifiers);else for(d=0;d<a&&!b.stopped;d++)b.index=d,c.retrigger();this.runtime.popLoopStack();return!1};a.prototype.While=function(a){var b=this.runtime.getCurrentEventStack();a=b.current_event;var c=b.isModifierAfterCnds(),b=this.runtime.pushLoopStack();if(c)for(c=
0;!b.stopped;c++)this.runtime.pushCopySol(a.solModifiers),b.index=c,a.retrigger()||(b.stopped=!0),this.runtime.popSol(a.solModifiers);else for(c=0;!b.stopped;c++)b.index=c,a.retrigger()||(b.stopped=!0);this.runtime.popLoopStack();return!1};a.prototype.For=function(a,b,c){var d=this.runtime.getCurrentEventStack(),e=d.current_event,d=d.isModifierAfterCnds();a=this.runtime.pushLoopStack(a);if(c<b)if(d)for(;b>=c&&!a.stopped;--b)this.runtime.pushCopySol(e.solModifiers),a.index=b,e.retrigger(),this.runtime.popSol(e.solModifiers);
else for(;b>=c&&!a.stopped;--b)a.index=b,e.retrigger();else if(d)for(;b<=c&&!a.stopped;++b)this.runtime.pushCopySol(e.solModifiers),a.index=b,e.retrigger(),this.runtime.popSol(e.solModifiers);else for(;b<=c&&!a.stopped;++b)a.index=b,e.retrigger();this.runtime.popLoopStack();return!1};var h=[],l=-1;a.prototype.ForEach=function(a){var b=a.getCurrentSol();l++;h.length===l&&h.push([]);var c=h[l];cr.shallowAssignArray(c,b.getObjects());var d=this.runtime.getCurrentEventStack(),e=d.current_event,f=d.isModifierAfterCnds(),
d=this.runtime.pushLoopStack(),g,m,n,p,k,s,t=a.is_contained;if(f)for(f=0,g=c.length;f<g&&!d.stopped;f++){this.runtime.pushCopySol(e.solModifiers);p=c[f];b=a.getCurrentSol();b.select_all=!1;b.instances.length=1;b.instances[0]=p;if(t)for(m=0,n=p.siblings.length;m<n;m++)k=p.siblings[m],s=k.type.getCurrentSol(),s.select_all=!1,s.instances.length=1,s.instances[0]=k;d.index=f;e.retrigger();this.runtime.popSol(e.solModifiers)}else for(b.select_all=!1,b.instances.length=1,f=0,g=c.length;f<g&&!d.stopped;f++){p=
c[f];b.instances[0]=p;if(t)for(m=0,n=p.siblings.length;m<n;m++)k=p.siblings[m],s=k.type.getCurrentSol(),s.select_all=!1,s.instances.length=1,s.instances[0]=k;d.index=f;e.retrigger()}c.length=0;this.runtime.popLoopStack();l--;return!1};a.prototype.ForEachOrdered=function(a,c,d){c=a.getCurrentSol();l++;h.length===l&&h.push([]);var e=h[l];cr.shallowAssignArray(e,c.getObjects());var f=this.runtime.getCurrentEventStack(),g=f.current_event,m=this.runtime.getCurrentCondition(),n=f.isModifierAfterCnds(),
f=this.runtime.pushLoopStack(),p,k,s,t,v;p=0;for(k=e.length;p<k;p++)e[p].extra.c2_foreachordered_val=m.parameters[1].get(p);e.sort(b);1===d&&e.reverse();d=a.is_contained;if(n)for(p=0,k=e.length;p<k&&!f.stopped;p++){this.runtime.pushCopySol(g.solModifiers);s=e[p];c=a.getCurrentSol();c.select_all=!1;c.instances.length=1;c.instances[0]=s;if(d)for(m=0,n=s.siblings.length;m<n;m++)t=s.siblings[m],v=t.type.getCurrentSol(),v.select_all=!1,v.instances.length=1,v.instances[0]=t;f.index=p;g.retrigger();this.runtime.popSol(g.solModifiers)}else for(c.select_all=
!1,c.instances.length=1,p=0,k=e.length;p<k&&!f.stopped;p++){s=e[p];c.instances[0]=s;if(d)for(m=0,n=s.siblings.length;m<n;m++)t=s.siblings[m],v=t.type.getCurrentSol(),v.select_all=!1,v.instances.length=1,v.instances[0]=t;f.index=p;g.retrigger()}e.length=0;this.runtime.popLoopStack();l--;return!1};a.prototype.PickByComparison=function(a,b,c,d){var e,f,g,m;if(a){l++;h.length===l&&h.push([]);var n=h[l],p=a.getCurrentSol();cr.shallowAssignArray(n,p.getObjects());p.select_all&&(p.else_instances.length=
0);var k=this.runtime.getCurrentCondition();g=e=0;for(f=n.length;e<f;e++)m=n[e],n[g]=m,b=k.parameters[1].get(e),d=k.parameters[3].get(e),cr.do_cmp(b,c,d)?g++:p.else_instances.push(m);n.length=g;p.select_all=!1;cr.shallowAssignArray(p.instances,n);n.length=0;l--;a.applySolToContainer();return!!p.instances.length}};a.prototype.PickByEvaluate=function(a,b){var c,d,e,f;if(a){l++;h.length===l&&h.push([]);var g=h[l],m=a.getCurrentSol();cr.shallowAssignArray(g,m.getObjects());m.select_all&&(m.else_instances.length=
0);var n=this.runtime.getCurrentCondition();e=c=0;for(d=g.length;c<d;c++)f=g[c],g[e]=f,(b=n.parameters[1].get(c))?e++:m.else_instances.push(f);g.length=e;m.select_all=!1;cr.shallowAssignArray(m.instances,g);g.length=0;l--;a.applySolToContainer();return!!m.instances.length}};a.prototype.TriggerOnce=function(){var a=this.runtime.getCurrentCondition().extra;"undefined"===typeof a.TriggerOnce_lastTick&&(a.TriggerOnce_lastTick=-1);var b=a.TriggerOnce_lastTick,c=this.runtime.tickcount;a.TriggerOnce_lastTick=
c;return this.runtime.layout_first_tick||b!==c-1};a.prototype.Every=function(a){var b=this.runtime.getCurrentCondition(),c=b.extra.Every_lastTime||0,d=this.runtime.kahanTime.sum;"undefined"===typeof b.extra.Every_seconds&&(b.extra.Every_seconds=a);var e=b.extra.Every_seconds;return d>=c+e?(b.extra.Every_lastTime=c+e,d>=b.extra.Every_lastTime+e&&(b.extra.Every_lastTime=d),b.extra.Every_seconds=a,!0):!1};a.prototype.PickNth=function(a,b){if(!a)return!1;var c=a.getCurrentSol(),d=c.getObjects();b=cr.floor(b);
if(0>b||b>=d.length)return!1;c.pick_one(d[b]);a.applySolToContainer();return!0};a.prototype.PickRandom=function(a){if(!a)return!1;var b=a.getCurrentSol(),c=b.getObjects(),d=cr.floor(Math.random()*c.length);if(d>=c.length)return!1;b.pick_one(c[d]);a.applySolToContainer();return!0};a.prototype.CompareVar=function(a,b,c){return cr.do_cmp(a.getValue(),b,c)};a.prototype.IsGroupActive=function(a){return this.runtime.activeGroups[a.toLowerCase()]};a.prototype.IsPreview=function(){return"undefined"!==typeof cr_is_preview};
a.prototype.PickAll=function(a){if(!a||!a.instances.length)return!1;a.getCurrentSol().select_all=!0;a.applySolToContainer();return!0};a.prototype.IsMobile=function(){return this.runtime.isMobile};a.prototype.CompareBetween=function(a,b,c){return a>=b&&a<=c};a.prototype.Else=function(){var a=this.runtime.getCurrentEventStack();return a.else_branch_ran?!1:!a.last_event_true};a.prototype.OnLoadFinished=function(){return!0};a.prototype.OnCanvasSnapshot=function(){return!0};a.prototype.EffectsSupported=
function(){return!!this.runtime.glwrap};a.prototype.OnSaveComplete=function(){return!0};a.prototype.OnLoadComplete=function(){return!0};a.prototype.OnLoadFailed=function(){return!0};a.prototype.ObjectUIDExists=function(a){return!!this.runtime.getObjectByUID(a)};a.prototype.IsOnPlatform=function(a){var b=this.runtime;switch(a){case 0:return!b.isDomFree&&!b.isNodeWebkit&&!b.isPhoneGap&&!b.isWindows8App&&!b.isWindowsPhone8&&!b.isBlackberry10;case 1:return b.isiOS;case 2:return b.isAndroid;case 3:return b.isWindows8App;
case 4:return b.isWindowsPhone8;case 5:return b.isBlackberry10;case 6:return b.isTizen;case 7:return b.isNodeWebkit;case 8:return b.isCocoonJs;case 9:return b.isPhoneGap;case 10:return b.isArcade;case 11:return b.isNodeWebkit;default:return!1}};var k=null,n="",v="";a.prototype.RegexTest=function(a,b,c){return e(b,c).test(a)};var u=[];a.prototype.PickOverlappingPoint=function(a,b,c){if(!a)return!1;var d=a.getCurrentSol(),e=d.getObjects(),f=this.runtime.getCurrentEventStack().current_event.orblock,
g=this.runtime.getCurrentCondition(),m,h;d.select_all?(cr.shallowAssignArray(u,e),d.else_instances.length=0,d.select_all=!1,d.instances.length=0):f?(cr.shallowAssignArray(u,d.else_instances),d.else_instances.length=0):(cr.shallowAssignArray(u,e),d.instances.length=0);e=0;for(f=u.length;e<f;++e)m=u[e],(h=cr.xor(m.contains_pt(b,c),g.inverted))?d.instances.push(m):d.else_instances.push(m);a.applySolToContainer();return cr.xor(!!d.instances.length,g.inverted)};g.cnds=new a;d.prototype.GoToLayout=function(a){this.runtime.isloading||
this.runtime.changelayout||(this.runtime.changelayout=a)};d.prototype.CreateObject=function(a,b,c,d){if(b&&a&&(b=this.runtime.createInstance(a,b,c,d))){this.runtime.isInOnDestroy++;var e;this.runtime.trigger(Object.getPrototypeOf(a.plugin).cnds.OnCreated,b);if(b.is_contained)for(c=0,d=b.siblings.length;c<d;c++)e=b.siblings[c],this.runtime.trigger(Object.getPrototypeOf(e.type.plugin).cnds.OnCreated,e);this.runtime.isInOnDestroy--;a=a.getCurrentSol();a.select_all=!1;a.instances.length=1;a.instances[0]=
b;if(b.is_contained)for(c=0,d=b.siblings.length;c<d;c++)e=b.siblings[c],a=e.type.getCurrentSol(),a.select_all=!1,a.instances.length=1,a.instances[0]=e}};d.prototype.SetLayerVisible=function(a,b){a&&a.visible!==b&&(a.visible=b,this.runtime.redraw=!0)};d.prototype.SetLayerOpacity=function(a,b){a&&(b=cr.clamp(b/100,0,1),a.opacity!==b&&(a.opacity=b,this.runtime.redraw=!0))};d.prototype.SetLayerScaleRate=function(a,b){a&&a.zoomRate!==b&&(a.zoomRate=b,this.runtime.redraw=!0)};d.prototype.SetLayoutScale=
function(a){this.runtime.running_layout&&this.runtime.running_layout.scale!==a&&(this.runtime.running_layout.scale=a,this.runtime.running_layout.boundScrolling(),this.runtime.redraw=!0)};d.prototype.ScrollX=function(a){this.runtime.running_layout.scrollToX(a)};d.prototype.ScrollY=function(a){this.runtime.running_layout.scrollToY(a)};d.prototype.Scroll=function(a,b){this.runtime.running_layout.scrollToX(a);this.runtime.running_layout.scrollToY(b)};d.prototype.ScrollToObject=function(a){if(a=a.getFirstPicked())this.runtime.running_layout.scrollToX(a.x),
this.runtime.running_layout.scrollToY(a.y)};d.prototype.SetVar=function(a,b){0===a.vartype?cr.is_number(b)?a.setValue(b):a.setValue(parseFloat(b)):1===a.vartype&&a.setValue(b.toString())};d.prototype.AddVar=function(a,b){0===a.vartype?cr.is_number(b)?a.setValue(a.getValue()+b):a.setValue(a.getValue()+parseFloat(b)):1===a.vartype&&a.setValue(a.getValue()+b.toString())};d.prototype.SubVar=function(a,b){0===a.vartype&&(cr.is_number(b)?a.setValue(a.getValue()-b):a.setValue(a.getValue()-parseFloat(b)))};
d.prototype.SetGroupActive=function(a,b){var c=this.runtime.activeGroups,d=a.toLowerCase();switch(b){case 0:c[d]=!1;break;case 1:c[d]=!0;break;case 2:c[d]=!c[d]}};d.prototype.SetTimescale=function(a){0>a&&(a=0);this.runtime.timescale=a};d.prototype.SetObjectTimescale=function(a,b){var c=b;0>c&&(c=0);if(a){var d=a.getCurrentSol().getObjects(),e,f;e=0;for(f=d.length;e<f;e++)d[e].my_timescale=c}};d.prototype.RestoreObjectTimescale=function(a){if(!a)return!1;a=a.getCurrentSol().getObjects();var b,c;b=
0;for(c=a.length;b<c;b++)a[b].my_timescale=-1};var p=[],t=[];d.prototype.Wait=function(a){if(!(0>a)){var b,c,d,e=this.runtime.getCurrentEventStack(),f;f=p.length?p.pop():{sols:{},solModifiers:[]};f.deleteme=!1;f.time=this.runtime.kahanTime.sum+a;f.ev=e.current_event;f.actindex=e.actindex+1;a=0;for(b=this.runtime.types_by_index.length;a<b;a++)d=this.runtime.types_by_index[a],c=d.getCurrentSol(),c.select_all&&-1===e.current_event.solModifiers.indexOf(d)||(f.solModifiers.push(d),d=void 0,d=t.length?
t.pop():{insts:[]},d.sa=!1,d.sa=c.select_all,cr.shallowAssignArray(d.insts,c.instances),f.sols[a.toString()]=d);this.waits.push(f);return!0}};d.prototype.SetLayerScale=function(a,b){a&&a.scale!==b&&(a.scale=b,this.runtime.redraw=!0)};d.prototype.ResetGlobals=function(){var a,b,c;a=0;for(b=this.runtime.all_global_vars.length;a<b;a++)c=this.runtime.all_global_vars[a],c.data=c.initial};d.prototype.SetLayoutAngle=function(a){a=cr.to_radians(a);a=cr.clamp_angle(a);this.runtime.running_layout&&this.runtime.running_layout.angle!==
a&&(this.runtime.running_layout.angle=a,this.runtime.redraw=!0)};d.prototype.SetLayerAngle=function(a,b){a&&(b=cr.to_radians(b),b=cr.clamp_angle(b),a.angle!==b&&(a.angle=b,this.runtime.redraw=!0))};d.prototype.SetLayerParallax=function(a,b,c){!a||a.parallaxX===b/100&&a.parallaxY===c/100||(a.parallaxX=b/100,a.parallaxY=c/100,this.runtime.redraw=!0)};d.prototype.SetLayerBackground=function(a,b){if(a){var c=cr.GetRValue(b),d=cr.GetGValue(b),e=cr.GetBValue(b);if(a.background_color[0]!==c||a.background_color[1]!==
d||a.background_color[2]!==e)a.background_color[0]=c,a.background_color[1]=d,a.background_color[2]=e,this.runtime.redraw=!0}};d.prototype.SetLayerTransparent=function(a,b){a&&!!b!==!!a.transparent&&(a.transparent=!!b,this.runtime.redraw=!0)};d.prototype.StopLoop=function(){0>this.runtime.loop_stack_index||(this.runtime.getCurrentLoop().stopped=!0)};d.prototype.GoToLayoutByName=function(a){if(!this.runtime.isloading&&!this.runtime.changelayout)for(var b in this.runtime.layouts)if(this.runtime.layouts.hasOwnProperty(b)&&
cr.equals_nocase(b,a)){this.runtime.changelayout=this.runtime.layouts[b];break}};d.prototype.RestartLayout=function(a){if(!this.runtime.isloading&&!this.runtime.changelayout&&this.runtime.running_layout){this.runtime.changelayout=this.runtime.running_layout;var b,c;a=0;for(b=this.runtime.allGroups.length;a<b;a++)c=this.runtime.allGroups[a],this.runtime.activeGroups[c.group_name.toLowerCase()]=c.initially_activated}};d.prototype.SnapshotCanvas=function(a,b){this.runtime.snapshotCanvas=[0===a?"image/png":
"image/jpeg",b/100];this.runtime.redraw=!0};d.prototype.SetCanvasSize=function(a,b){0>=a||0>=b||this.runtime.setSize(a,b)};d.prototype.SetLayoutEffectEnabled=function(a,b){if(this.runtime.running_layout&&this.runtime.glwrap){var c=this.runtime.running_layout.getEffectByName(b);if(c){var d=1===a;c.active!=d&&(c.active=d,this.runtime.running_layout.updateActiveEffects(),this.runtime.redraw=!0)}}};d.prototype.SetLayerEffectEnabled=function(a,b,c){a&&this.runtime.glwrap&&(c=a.getEffectByName(c))&&(b=
1===b,c.active!=b&&(c.active=b,a.updateActiveEffects(),this.runtime.redraw=!0))};d.prototype.SetLayoutEffectParam=function(a,b,c){if(this.runtime.running_layout&&this.runtime.glwrap&&(a=this.runtime.running_layout.getEffectByName(a))){var d=this.runtime.running_layout.effect_params[a.index];b=Math.floor(b);0>b||b>=d.length||(1===this.runtime.glwrap.getProgramParameterType(a.shaderindex,b)&&(c/=100),d[b]!==c&&(d[b]=c,a.active&&(this.runtime.redraw=!0)))}};d.prototype.SetLayerEffectParam=function(a,
b,c,d){a&&this.runtime.glwrap&&(b=a.getEffectByName(b))&&(a=a.effect_params[b.index],c=Math.floor(c),0>c||c>=a.length||(1===this.runtime.glwrap.getProgramParameterType(b.shaderindex,c)&&(d/=100),a[c]!==d&&(a[c]=d,b.active&&(this.runtime.redraw=!0))))};d.prototype.SaveState=function(a){this.runtime.saveToSlot=a};d.prototype.LoadState=function(a){this.runtime.loadFromSlot=a};d.prototype.LoadStateJSON=function(a){this.runtime.loadFromJson=a};g.acts=new d;c.prototype["int"]=function(a,b){cr.is_string(b)?
(a.set_int(parseInt(b,10)),isNaN(a.data)&&(a.data=0)):a.set_int(b)};c.prototype["float"]=function(a,b){cr.is_string(b)?(a.set_float(parseFloat(b)),isNaN(a.data)&&(a.data=0)):a.set_float(b)};c.prototype.str=function(a,b){cr.is_string(b)?a.set_string(b):a.set_string(b.toString())};c.prototype.len=function(a,b){a.set_int(b.length||0)};c.prototype.random=function(a,b,c){void 0===c?a.set_float(Math.random()*b):a.set_float(Math.random()*(c-b)+b)};c.prototype.sqrt=function(a,b){a.set_float(Math.sqrt(b))};
c.prototype.abs=function(a,b){a.set_float(Math.abs(b))};c.prototype.round=function(a,b){a.set_int(Math.round(b))};c.prototype.floor=function(a,b){a.set_int(Math.floor(b))};c.prototype.ceil=function(a,b){a.set_int(Math.ceil(b))};c.prototype.sin=function(a,b){a.set_float(Math.sin(cr.to_radians(b)))};c.prototype.cos=function(a,b){a.set_float(Math.cos(cr.to_radians(b)))};c.prototype.tan=function(a,b){a.set_float(Math.tan(cr.to_radians(b)))};c.prototype.asin=function(a,b){a.set_float(cr.to_degrees(Math.asin(b)))};
c.prototype.acos=function(a,b){a.set_float(cr.to_degrees(Math.acos(b)))};c.prototype.atan=function(a,b){a.set_float(cr.to_degrees(Math.atan(b)))};c.prototype.exp=function(a,b){a.set_float(Math.exp(b))};c.prototype.ln=function(a,b){a.set_float(Math.log(b))};c.prototype.log10=function(a,b){a.set_float(Math.log(b)/Math.LN10)};c.prototype.max=function(a){var b=arguments[1],c,d;c=2;for(d=arguments.length;c<d;c++)b<arguments[c]&&(b=arguments[c]);a.set_float(b)};c.prototype.min=function(a){var b=arguments[1],
c,d;c=2;for(d=arguments.length;c<d;c++)b>arguments[c]&&(b=arguments[c]);a.set_float(b)};c.prototype.dt=function(a){a.set_float(this.runtime.dt)};c.prototype.timescale=function(a){a.set_float(this.runtime.timescale)};c.prototype.wallclocktime=function(a){a.set_float((Date.now()-this.runtime.start_time)/1E3)};c.prototype.time=function(a){a.set_float(this.runtime.kahanTime.sum)};c.prototype.tickcount=function(a){a.set_int(this.runtime.tickcount)};c.prototype.objectcount=function(a){a.set_int(this.runtime.objectcount)};
c.prototype.fps=function(a){a.set_int(this.runtime.fps)};c.prototype.loopindex=function(a,b){var c,d,e;if(this.runtime.loop_stack.length)if(b){d=0;for(e=this.runtime.loop_stack.length;d<e;d++)if(c=this.runtime.loop_stack[d],c.name===b){a.set_int(c.index);return}a.set_int(0)}else c=this.runtime.getCurrentLoop(),a.set_int(c?c.index:-1);else a.set_int(0)};c.prototype.distance=function(a,b,c,d,e){a.set_float(cr.distanceTo(b,c,d,e))};c.prototype.angle=function(a,b,c,d,e){a.set_float(cr.to_degrees(cr.angleTo(b,
c,d,e)))};c.prototype.scrollx=function(a){a.set_float(this.runtime.running_layout.scrollX)};c.prototype.scrolly=function(a){a.set_float(this.runtime.running_layout.scrollY)};c.prototype.newline=function(a){a.set_string("\n")};c.prototype.lerp=function(a,b,c,d){a.set_float(cr.lerp(b,c,d))};c.prototype.windowwidth=function(a){a.set_int(this.runtime.width)};c.prototype.windowheight=function(a){a.set_int(this.runtime.height)};c.prototype.uppercase=function(a,b){a.set_string(cr.is_string(b)?b.toUpperCase():
"")};c.prototype.lowercase=function(a,b){a.set_string(cr.is_string(b)?b.toLowerCase():"")};c.prototype.clamp=function(a,b,c,d){b<c?a.set_float(c):b>d?a.set_float(d):a.set_float(b)};c.prototype.layerscale=function(a,b){var c=this.runtime.getLayer(b);c?a.set_float(c.scale):a.set_float(0)};c.prototype.layeropacity=function(a,b){var c=this.runtime.getLayer(b);c?a.set_float(100*c.opacity):a.set_float(0)};c.prototype.layerscalerate=function(a,b){var c=this.runtime.getLayer(b);c?a.set_float(c.zoomRate):
a.set_float(0)};c.prototype.layerparallaxx=function(a,b){var c=this.runtime.getLayer(b);c?a.set_float(100*c.parallaxX):a.set_float(0)};c.prototype.layerparallaxy=function(a,b){var c=this.runtime.getLayer(b);c?a.set_float(100*c.parallaxY):a.set_float(0)};c.prototype.layoutscale=function(a){this.runtime.running_layout?a.set_float(this.runtime.running_layout.scale):a.set_float(0)};c.prototype.layoutangle=function(a){a.set_float(cr.to_degrees(this.runtime.running_layout.angle))};c.prototype.layerangle=
function(a,b){var c=this.runtime.getLayer(b);c?a.set_float(cr.to_degrees(c.angle)):a.set_float(0)};c.prototype.layoutwidth=function(a){a.set_int(this.runtime.running_layout.width)};c.prototype.layoutheight=function(a){a.set_int(this.runtime.running_layout.height)};c.prototype.find=function(a,b,c){cr.is_string(b)&&cr.is_string(c)?a.set_int(b.search(RegExp(cr.regexp_escape(c),"i"))):a.set_int(-1)};c.prototype.left=function(a,b,c){a.set_string(cr.is_string(b)?b.substr(0,c):"")};c.prototype.right=function(a,
b,c){a.set_string(cr.is_string(b)?b.substr(b.length-c):"")};c.prototype.mid=function(a,b,c,d){a.set_string(cr.is_string(b)?b.substr(c,d):"")};c.prototype.tokenat=function(a,b,c,d){cr.is_string(b)&&cr.is_string(d)?(b=b.split(d),c=cr.floor(c),0>c||c>=b.length?a.set_string(""):a.set_string(b[c])):a.set_string("")};c.prototype.tokencount=function(a,b,c){cr.is_string(b)&&b.length?a.set_int(b.split(c).length):a.set_int(0)};c.prototype.replace=function(a,b,c,d){cr.is_string(b)&&cr.is_string(c)&&cr.is_string(d)?
a.set_string(b.replace(RegExp(cr.regexp_escape(c),"gi"),d)):a.set_string(cr.is_string(b)?b:"")};c.prototype.trim=function(a,b){a.set_string(cr.is_string(b)?b.trim():"")};c.prototype.pi=function(a){a.set_float(cr.PI)};c.prototype.layoutname=function(a){this.runtime.running_layout?a.set_string(this.runtime.running_layout.name):a.set_string("")};c.prototype.renderer=function(a){a.set_string(this.runtime.gl?"webgl":"canvas2d")};c.prototype.anglediff=function(a,b,c){a.set_float(cr.to_degrees(cr.angleDiff(cr.to_radians(b),
cr.to_radians(c))))};c.prototype.choose=function(a){var b=cr.floor(Math.random()*(arguments.length-1));a.set_any(arguments[b+1])};c.prototype.rgb=function(a,b,c,d){a.set_int(cr.RGB(b,c,d))};c.prototype.projectversion=function(a){a.set_string(this.runtime.versionstr)};c.prototype.anglelerp=function(a,b,c,d){b=cr.to_radians(b);c=cr.to_radians(c);var e=cr.angleDiff(b,c);cr.angleClockwise(c,b)?a.set_float(cr.to_clamped_degrees(b+e*d)):a.set_float(cr.to_clamped_degrees(b-e*d))};c.prototype.anglerotate=
function(a,b,c,d){b=cr.to_radians(b);c=cr.to_radians(c);d=cr.to_radians(d);a.set_float(cr.to_clamped_degrees(cr.angleRotate(b,c,d)))};c.prototype.zeropad=function(a,b,c){var d=0>b?"-":"";0>b&&(b=-b);c-=b.toString().length;for(var e=0;e<c;e++)d+="0";a.set_string(d+b.toString())};c.prototype.cpuutilisation=function(a){a.set_float(this.runtime.cpuutilisation/1E3)};c.prototype.viewportleft=function(a,b){var c=this.runtime.getLayer(b);a.set_float(c?c.viewLeft:0)};c.prototype.viewporttop=function(a,b){var c=
this.runtime.getLayer(b);a.set_float(c?c.viewTop:0)};c.prototype.viewportright=function(a,b){var c=this.runtime.getLayer(b);a.set_float(c?c.viewRight:0)};c.prototype.viewportbottom=function(a,b){var c=this.runtime.getLayer(b);a.set_float(c?c.viewBottom:0)};c.prototype.loadingprogress=function(a){a.set_float(this.runtime.loadingprogress)};c.prototype.unlerp=function(a,b,c,d){a.set_float((d-b)/(c-b))};c.prototype.canvassnapshot=function(a){a.set_string(this.runtime.snapshotData)};c.prototype.urlencode=
function(a,b){a.set_string(encodeURIComponent(b))};c.prototype.urldecode=function(a,b){a.set_string(decodeURIComponent(b))};c.prototype.canvastolayerx=function(a,b,c,d){b=this.runtime.getLayer(b);a.set_float(b?b.canvasToLayer(c,d,!0):0)};c.prototype.canvastolayery=function(a,b,c,d){b=this.runtime.getLayer(b);a.set_float(b?b.canvasToLayer(c,d,!1):0)};c.prototype.layertocanvasx=function(a,b,c,d){b=this.runtime.getLayer(b);a.set_float(b?b.layerToCanvas(c,d,!0):0)};c.prototype.layertocanvasy=function(a,
b,c,d){b=this.runtime.getLayer(b);a.set_float(b?b.layerToCanvas(c,d,!1):0)};c.prototype.savestatejson=function(a){a.set_string(this.runtime.lastSaveJson)};c.prototype.imagememoryusage=function(a){this.runtime.glwrap?a.set_float(Math.round(100*this.runtime.glwrap.estimateVRAM()/1048576)/100):a.set_float(0)};c.prototype.regexsearch=function(a,b,c,d){c=e(c,d);a.set_int(b?b.search(c):-1)};c.prototype.regexreplace=function(a,b,c,d,f){c=e(c,d);a.set_string(b?b.replace(c,f):"")};var s=[],m="",x="",z="";
c.prototype.regexmatchcount=function(a,b,c,d){e(c,d);f(b,c,d);a.set_int(s?s.length:0)};c.prototype.regexmatchat=function(a,b,c,d,g){g=Math.floor(g);e(c,d);f(b,c,d);!s||0>g||g>=s.length?a.set_string(""):a.set_string(s[g])};c.prototype.infinity=function(a){a.set_float(Infinity)};g.exps=new c;g.runWaits=function(){var a,b,c,d,e,f,g=this.runtime.getCurrentEventStack();a=0;for(c=this.waits.length;a<c;a++)if(d=this.waits[a],!(d.time>this.runtime.kahanTime.sum)){g.current_event=d.ev;g.actindex=d.actindex;
g.cndindex=0;for(b in d.sols)d.sols.hasOwnProperty(b)&&(e=this.runtime.types_by_index[parseInt(b,10)].getCurrentSol(),f=d.sols[b],e.select_all=f.sa,cr.shallowAssignArray(e.instances,f.insts),e=f,e.insts.length=0,t.push(e));d.ev.resume_actions_and_subevents();this.runtime.clearSol(d.solModifiers);d.deleteme=!0}b=a=0;for(c=this.waits.length;a<c;a++)d=this.waits[a],this.waits[b]=d,d.deleteme?(cr.wipe(d.sols),d.solModifiers.length=0,p.push(d)):b++;this.waits.length=b}})();
cr.add_common_aces=function(a){var b=a[0].prototype,e=a[1],d=a[3],c=a[4],f=a[5],g=a[6],h=a[7];a=a[8];b.cnds||(b.cnds={});b.acts||(b.acts={});b.exps||(b.exps={});var l=b.cnds,k=b.acts,b=b.exps;d&&(l.CompareX=function(a,b){return cr.do_cmp(this.x,a,b)},l.CompareY=function(a,b){return cr.do_cmp(this.y,a,b)},l.IsOnScreen=function(){var a=this.layer;this.update_bbox();var b=this.bbox;return!(b.right<a.viewLeft||b.bottom<a.viewTop||b.left>a.viewRight||b.top>a.viewBottom)},l.IsOutsideLayout=function(){this.update_bbox();
var a=this.bbox,b=this.runtime.running_layout;return 0>a.right||0>a.bottom||a.left>b.width||a.top>b.height},l.PickDistance=function(a,b,c){var d=this.getCurrentSol(),e=d.getObjects();if(!e.length)return!1;var f=e[0],g=f,h=cr.distanceTo(f.x,f.y,b,c),k,l,q;k=1;for(l=e.length;k<l;k++)if(f=e[k],q=cr.distanceTo(f.x,f.y,b,c),0===a&&q<h||1===a&&q>h)h=q,g=f;d.pick_one(g);return!0},k.SetX=function(a){this.x!==a&&(this.x=a,this.set_bbox_changed())},k.SetY=function(a){this.y!==a&&(this.y=a,this.set_bbox_changed())},
k.SetPos=function(a,b){if(this.x!==a||this.y!==b)this.x=a,this.y=b,this.set_bbox_changed()},k.SetPosToObject=function(a,b){var c=a.getPairedInstance(this);if(c){var d;c.getImagePoint?(d=c.getImagePoint(b,!0),c=c.getImagePoint(b,!1)):(d=c.x,c=c.y);if(this.x!==d||this.y!==c)this.x=d,this.y=c,this.set_bbox_changed()}},k.MoveForward=function(a){0!==a&&(this.x+=Math.cos(this.angle)*a,this.y+=Math.sin(this.angle)*a,this.set_bbox_changed())},k.MoveAtAngle=function(a,b){0!==b&&(this.x+=Math.cos(cr.to_radians(a))*
b,this.y+=Math.sin(cr.to_radians(a))*b,this.set_bbox_changed())},b.X=function(a){a.set_float(this.x)},b.Y=function(a){a.set_float(this.y)},b.dt=function(a){a.set_float(this.runtime.getDt(this))});c&&(l.CompareWidth=function(a,b){return cr.do_cmp(this.width,a,b)},l.CompareHeight=function(a,b){return cr.do_cmp(this.height,a,b)},k.SetWidth=function(a){this.width!==a&&(this.width=a,this.set_bbox_changed())},k.SetHeight=function(a){this.height!==a&&(this.height=a,this.set_bbox_changed())},k.SetSize=function(a,
b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.set_bbox_changed()},b.Width=function(a){a.set_float(this.width)},b.Height=function(a){a.set_float(this.height)},b.BBoxLeft=function(a){this.update_bbox();a.set_float(this.bbox.left)},b.BBoxTop=function(a){this.update_bbox();a.set_float(this.bbox.top)},b.BBoxRight=function(a){this.update_bbox();a.set_float(this.bbox.right)},b.BBoxBottom=function(a){this.update_bbox();a.set_float(this.bbox.bottom)});f&&(l.AngleWithin=function(a,b){return cr.angleDiff(this.angle,
cr.to_radians(b))<=cr.to_radians(a)},l.IsClockwiseFrom=function(a){return cr.angleClockwise(this.angle,cr.to_radians(a))},l.IsBetweenAngles=function(a,b){var c=cr.to_clamped_radians(a),d=cr.to_clamped_radians(b),e=cr.clamp_angle(this.angle);return cr.angleClockwise(d,c)?cr.angleClockwise(e,c)&&!cr.angleClockwise(e,d):!(!cr.angleClockwise(e,c)&&cr.angleClockwise(e,d))},k.SetAngle=function(a){a=cr.to_radians(cr.clamp_angle_degrees(a));isNaN(a)||this.angle===a||(this.angle=a,this.set_bbox_changed())},
k.RotateClockwise=function(a){0===a||isNaN(a)||(this.angle+=cr.to_radians(a),this.angle=cr.clamp_angle(this.angle),this.set_bbox_changed())},k.RotateCounterclockwise=function(a){0===a||isNaN(a)||(this.angle-=cr.to_radians(a),this.angle=cr.clamp_angle(this.angle),this.set_bbox_changed())},k.RotateTowardAngle=function(a,b){var c=cr.angleRotate(this.angle,cr.to_radians(b),cr.to_radians(a));isNaN(c)||this.angle===c||(this.angle=c,this.set_bbox_changed())},k.RotateTowardPosition=function(a,b,c){b=Math.atan2(c-
this.y,b-this.x);a=cr.angleRotate(this.angle,b,cr.to_radians(a));isNaN(a)||this.angle===a||(this.angle=a,this.set_bbox_changed())},k.SetTowardPosition=function(a,b){var c=Math.atan2(b-this.y,a-this.x);isNaN(c)||this.angle===c||(this.angle=c,this.set_bbox_changed())},b.Angle=function(a){a.set_float(cr.to_clamped_degrees(this.angle))});e||(l.CompareInstanceVar=function(a,b,c){return cr.do_cmp(this.instance_vars[a],b,c)},l.IsBoolInstanceVarSet=function(a){return this.instance_vars[a]},l.PickInstVarHiLow=
function(a,b){var c=this.getCurrentSol(),d=c.getObjects();if(!d.length)return!1;var e=d[0],f=e,g=e.instance_vars[b],h,k,l;h=1;for(k=d.length;h<k;h++)if(e=d[h],l=e.instance_vars[b],0===a&&l<g||1===a&&l>g)g=l,f=e;c.pick_one(f);return!0},l.PickByUID=function(a){var b,c,d,e,f;if(this.runtime.getCurrentCondition().inverted){f=this.getCurrentSol();if(f.select_all)for(f.select_all=!1,f.instances.length=0,f.else_instances.length=0,d=this.instances,b=0,c=d.length;b<c;b++)e=d[b],e.uid===a?f.else_instances.push(e):
f.instances.push(e);else{d=b=0;for(c=f.instances.length;b<c;b++)e=f.instances[b],f.instances[d]=e,e.uid===a?f.else_instances.push(e):d++;f.instances.length=d}return!!f.instances.length}e=this.runtime.getObjectByUID(a);if(!e)return!1;f=this.getCurrentSol();if(!f.select_all&&-1===f.instances.indexOf(e))return!1;if(this.is_family)for(a=e.type.families,b=0,c=a.length;b<c;b++){if(a[b]===this)return f.pick_one(e),!0}else if(e.type===this)return f.pick_one(e),!0;return!1},l.OnCreated=function(){return!0},
l.OnDestroyed=function(){return!0},k.SetInstanceVar=function(a,b){var c=this.instance_vars;cr.is_number(c[a])?cr.is_number(b)?c[a]=b:c[a]=parseFloat(b):cr.is_string(c[a])&&(cr.is_string(b)?c[a]=b:c[a]=b.toString())},k.AddInstanceVar=function(a,b){var c=this.instance_vars;cr.is_number(c[a])?cr.is_number(b)?c[a]+=b:c[a]+=parseFloat(b):cr.is_string(c[a])&&(cr.is_string(b)?c[a]+=b:c[a]+=b.toString())},k.SubInstanceVar=function(a,b){var c=this.instance_vars;cr.is_number(c[a])&&(cr.is_number(b)?c[a]-=b:
c[a]-=parseFloat(b))},k.SetBoolInstanceVar=function(a,b){this.instance_vars[a]=b?1:0},k.ToggleBoolInstanceVar=function(a){this.instance_vars[a]=1-this.instance_vars[a]},k.Destroy=function(){this.runtime.DestroyInstance(this)},b.Count=function(a){var b=a.object_class.instances.length,c,d,e;c=0;for(d=this.runtime.createRow.length;c<d;c++)e=this.runtime.createRow[c],a.object_class.is_family?0<=e.type.families.indexOf(a.object_class)&&b++:e.type===a.object_class&&b++;a.set_int(b)},b.PickedCount=function(a){a.set_int(a.object_class.getCurrentSol().getObjects().length)},
b.UID=function(a){a.set_int(this.uid)},b.IID=function(a){a.set_int(this.get_iid())});g&&(l.IsVisible=function(){return this.visible},k.SetVisible=function(a){!a!==!this.visible&&(this.visible=a,this.runtime.redraw=!0)},l.CompareOpacity=function(a,b){return cr.do_cmp(cr.round6dp(100*this.opacity),a,b)},k.SetOpacity=function(a){a/=100;0>a?a=0:1<a&&(a=1);a!==this.opacity&&(this.opacity=a,this.runtime.redraw=!0)},b.Opacity=function(a){a.set_float(cr.round6dp(100*this.opacity))});h&&(l.IsOnLayer=function(a){return a?
this.layer===a:!1},l.PickTopBottom=function(a){var b=this.getCurrentSol(),c=b.getObjects();if(!c.length)return!1;var d=c[0],e=d,f,g;f=1;for(g=c.length;f<g;f++)if(d=c[f],0===a){if(d.layer.index>e.layer.index||d.layer.index===e.layer.index&&d.get_zindex()>e.get_zindex())e=d}else if(d.layer.index<e.layer.index||d.layer.index===e.layer.index&&d.get_zindex()<e.get_zindex())e=d;b.pick_one(e);return!0},k.MoveToTop=function(){var a=this.get_zindex();a!==this.layer.instances.length-1&&(cr.arrayRemove(this.layer.instances,
a),this.layer.instances.push(this),this.runtime.redraw=!0,this.layer.zindices_stale=!0)},k.MoveToBottom=function(){var a=this.get_zindex();0!==a&&(cr.arrayRemove(this.layer.instances,a),this.layer.instances.unshift(this),this.runtime.redraw=!0,this.layer.zindices_stale=!0)},k.MoveToLayer=function(a){a&&a!=this.layer&&(cr.arrayRemove(this.layer.instances,this.get_zindex()),this.layer.zindices_stale=!0,this.layer=a,this.zindex=a.instances.length,a.instances.push(this),this.runtime.redraw=!0)},k.ZMoveToObject=
function(a,b){var c=0===a;if(b){var d=b.getFirstPicked(this);if(d&&d.uid!==this.uid){this.layer.index!==d.layer.index&&(cr.arrayRemove(this.layer.instances,this.get_zindex()),this.layer.zindices_stale=!0,this.layer=d.layer,this.zindex=d.layer.instances.length,d.layer.instances.push(this));var e=this.get_zindex(),d=d.get_zindex();cr.arrayRemove(this.layer.instances,e);e<d&&d--;c&&d++;d===this.layer.instances.length?this.layer.instances.push(this):this.layer.instances.splice(d,0,this);this.layer.zindices_stale=
!0;this.runtime.redraw=!0}}},b.LayerNumber=function(a){a.set_int(this.layer.number)},b.LayerName=function(a){a.set_string(this.layer.name)},b.ZIndex=function(a){a.set_int(this.get_zindex())});a&&(k.SetEffectEnabled=function(a,b){if(this.runtime.glwrap){var c=this.type.getEffectIndexByName(b);if(!(0>c)){var d=1===a;this.active_effect_flags[c]!==d&&(this.active_effect_flags[c]=d,this.updateActiveEffects(),this.runtime.redraw=!0)}}},k.SetEffectParam=function(a,b,c){if(this.runtime.glwrap){var d=this.type.getEffectIndexByName(a);
0>d||(a=this.type.effect_types[d],d=this.effect_params[d],b=Math.floor(b),0>b||b>=d.length||(1===this.runtime.glwrap.getProgramParameterType(a.shaderindex,b)&&(c/=100),d[b]!==c&&(d[b]=c,a.active&&(this.runtime.redraw=!0))))}})};cr.set_bbox_changed=function(){this.bbox_changed=!0;this.runtime.redraw=!0;var a,b;a=0;for(b=this.bbox_changed_callbacks.length;a<b;a++)this.bbox_changed_callbacks[a](this)};cr.add_bbox_changed_callback=function(a){a&&this.bbox_changed_callbacks.push(a)};
cr.update_bbox=function(){if(this.bbox_changed){this.bbox.set(this.x,this.y,this.x+this.width,this.y+this.height);this.bbox.offset(-this.hotspotX*this.width,-this.hotspotY*this.height);this.angle?(this.bbox.offset(-this.x,-this.y),this.bquad.set_from_rotated_rect(this.bbox,this.angle),this.bquad.offset(this.x,this.y),this.bquad.bounding_box(this.bbox)):this.bquad.set_from_rect(this.bbox);var a=0;this.bbox.left>this.bbox.right&&(a=this.bbox.left,this.bbox.left=this.bbox.right,this.bbox.right=a);this.bbox.top>
this.bbox.bottom&&(a=this.bbox.top,this.bbox.top=this.bbox.bottom,this.bbox.bottom=a);this.bbox_changed=!1}};cr.inst_contains_pt=function(a,b){return this.bbox.contains_pt(a,b)&&this.bquad.contains_pt(a,b)?this.collision_poly&&!this.collision_poly.is_empty()?(this.collision_poly.cache_poly(this.width,this.height,this.angle),this.collision_poly.contains_pt(a-this.x,b-this.y)):!0:!1};cr.inst_get_iid=function(){this.type.updateIIDs();return this.iid};
cr.inst_get_zindex=function(){this.layer.updateZIndices();return this.zindex};cr.inst_updateActiveEffects=function(){this.active_effect_types.length=0;var a,b;a=0;for(b=this.active_effect_flags.length;a<b;a++)this.active_effect_flags[a]&&this.active_effect_types.push(this.type.effect_types[a]);this.uses_shaders=!!this.active_effect_types.length};cr.inst_toString=function(){return"Inst"+this.puid};
cr.type_getFirstPicked=function(a){if(a&&a.is_contained&&a.type!=this){var b,e,d;b=0;for(e=a.siblings.length;b<e;b++)if(d=a.siblings[b],d.type==this)return d}a=this.getCurrentSol().getObjects();return a.length?a[0]:null};cr.type_getPairedInstance=function(a){var b=this.getCurrentSol().getObjects();return b.length?b[a.get_iid()%b.length]:null};
cr.type_updateIIDs=function(){if(this.stale_iids&&!this.is_family){var a,b;a=0;for(b=this.instances.length;a<b;a++)this.instances[a].iid=a;var e=a,d=this.runtime.createRow;a=0;for(b=d.length;a<b;++a)d[a].type===this&&(d[a].iid=e++);this.stale_iids=!1}};cr.type_getCurrentSol=function(){return this.solstack[this.cur_sol]};cr.type_pushCleanSol=function(){this.cur_sol++;this.cur_sol===this.solstack.length?this.solstack.push(new cr.selection(this)):this.solstack[this.cur_sol].select_all=!0};
cr.type_pushCopySol=function(){this.cur_sol++;this.cur_sol===this.solstack.length&&this.solstack.push(new cr.selection(this));var a=this.solstack[this.cur_sol],b=this.solstack[this.cur_sol-1];b.select_all?a.select_all=!0:(a.select_all=!1,cr.shallowAssignArray(a.instances,b.instances),cr.shallowAssignArray(a.else_instances,b.else_instances))};cr.type_popSol=function(){this.cur_sol--};
cr.type_getBehaviorByName=function(a){var b,e,d,c,f,g=0;if(!this.is_family)for(b=0,e=this.families.length;b<e;b++)for(f=this.families[b],d=0,c=f.behaviors.length;d<c;d++){if(a===f.behaviors[d].name)return this.extra.lastBehIndex=g,f.behaviors[d];g++}b=0;for(e=this.behaviors.length;b<e;b++){if(a===this.behaviors[b].name)return this.extra.lastBehIndex=g,this.behaviors[b];g++}return null};cr.type_getBehaviorIndexByName=function(a){return this.getBehaviorByName(a)?this.extra.lastBehIndex:-1};
cr.type_getEffectIndexByName=function(a){var b,e;b=0;for(e=this.effect_types.length;b<e;b++)if(this.effect_types[b].name===a)return b;return-1};
cr.type_applySolToContainer=function(){if(this.is_contained&&!this.is_family){var a,b,e,d,c,f,g;this.updateIIDs();f=this.getCurrentSol();var h=f.select_all,l=(a=this.runtime.getCurrentEventStack())&&a.current_event&&a.current_event.orblock;a=0;for(b=this.container.length;a<b;a++)if(c=this.container[a],c!==this&&(c.updateIIDs(),g=c.getCurrentSol(),g.select_all=h,!h)){g.instances.length=f.instances.length;e=0;for(d=f.instances.length;e<d;e++)g.instances[e]=c.instances[f.instances[e].iid];if(l)for(g.else_instances.length=
f.else_instances.length,e=0,d=f.else_instances.length;e<d;e++)g.else_instances[e]=c.instances[f.else_instances[e].iid]}}};cr.type_toString=function(){return"Type"+this.sid};cr.do_cmp=function(a,b,e){if("undefined"===typeof a||"undefined"===typeof e)return!1;switch(b){case 0:return a===e;case 1:return a!==e;case 2:return a<e;case 3:return a<=e;case 4:return a>e;case 5:return a>=e;default:return!1}};cr.shaders={};window.cr_cjs_accelerated_physics=!0;cr.plugins_.Audio=function(a){this.runtime=a};
(function(){function a(a){a=Math.pow(10,a/20);0>a&&(a=0);1<a&&(a=1);return a}function b(a){0>a&&(a=0);1<a&&(a=1);return 20*(Math.log(a)/Math.log(10))}function e(a){a=a.toLowerCase();return N.hasOwnProperty(a)&&N[a].length?N[a][0].getInputNode():I.destination}function d(){return I.createGain?I.createGain():I.createGainNode()}function c(a){return I.createDelay?I.createDelay(a):I.createDelayNode(a)}function f(a){a.start?a.start(0):a.noteOn(0)}function g(a,b,c){a.start?a.start(0,b):a.noteGrainOn(0,b,
c-b)}function h(a){a.stop?a.stop(0):a.noteOff(0)}function l(a,b,c,d){if(a)if(a.cancelScheduledValues(0),0===d)a.value=b;else{var e=I.currentTime;d+=e;switch(c){case 0:a.setValueAtTime(b,d);break;case 1:a.setValueAtTime(a.value,e);a.linearRampToValueAtTime(b,d);break;case 2:a.setValueAtTime(a.value,e),a.exponentialRampToValueAtTime(b,d)}}}function k(a,b,c,e,f,g){this.type="filter";this.params=[a,b,c,e,f,g];this.inputNode=d();this.wetNode=d();this.wetNode.gain.value=g;this.dryNode=d();this.dryNode.gain.value=
1-g;this.filterNode=I.createBiquadFilter();this.filterNode.type="number"===typeof this.filterNode.type?a:ja[a];this.filterNode.frequency.value=b;this.filterNode.detune&&(this.filterNode.detune.value=c);this.filterNode.Q.value=e;this.filterNode.gain.value=f;this.inputNode.connect(this.filterNode);this.inputNode.connect(this.dryNode);this.filterNode.connect(this.wetNode)}function n(a,b,e){this.type="delay";this.params=[a,b,e];this.inputNode=d();this.wetNode=d();this.wetNode.gain.value=e;this.dryNode=
d();this.dryNode.gain.value=1-e;this.mainNode=d();this.delayNode=c(a);this.delayNode.delayTime.value=a;this.delayGainNode=d();this.delayGainNode.gain.value=b;this.inputNode.connect(this.mainNode);this.inputNode.connect(this.dryNode);this.mainNode.connect(this.wetNode);this.mainNode.connect(this.delayNode);this.delayNode.connect(this.delayGainNode);this.delayGainNode.connect(this.mainNode)}function v(a,b,c,e){this.type="convolve";this.params=[b,c,e];this.inputNode=d();this.wetNode=d();this.wetNode.gain.value=
c;this.dryNode=d();this.dryNode.gain.value=1-c;this.convolveNode=I.createConvolver();a&&(this.convolveNode.normalize=b,this.convolveNode.buffer=a);this.inputNode.connect(this.convolveNode);this.inputNode.connect(this.dryNode);this.convolveNode.connect(this.wetNode)}function u(a,b,e,g,m){this.type="flanger";this.params=[a,b,e,g,m];this.inputNode=d();this.dryNode=d();this.dryNode.gain.value=1-m/2;this.wetNode=d();this.wetNode.gain.value=m/2;this.feedbackNode=d();this.feedbackNode.gain.value=g;this.delayNode=
c(a+b);this.delayNode.delayTime.value=a;this.oscNode=I.createOscillator();this.oscNode.frequency.value=e;this.oscGainNode=d();this.oscGainNode.gain.value=b;this.inputNode.connect(this.delayNode);this.inputNode.connect(this.dryNode);this.delayNode.connect(this.wetNode);this.delayNode.connect(this.feedbackNode);this.feedbackNode.connect(this.delayNode);this.oscNode.connect(this.oscGainNode);this.oscGainNode.connect(this.delayNode.delayTime);f(this.oscNode)}function p(a,b,c,e,g,m){this.type="phaser";
this.params=[a,b,c,e,g,m];this.inputNode=d();this.dryNode=d();this.dryNode.gain.value=1-m/2;this.wetNode=d();this.wetNode.gain.value=m/2;this.filterNode=I.createBiquadFilter();this.filterNode.type="number"===typeof this.filterNode.type?7:"allpass";this.filterNode.frequency.value=a;this.filterNode.detune&&(this.filterNode.detune.value=b);this.filterNode.Q.value=c;this.oscNode=I.createOscillator();this.oscNode.frequency.value=g;this.oscGainNode=d();this.oscGainNode.gain.value=e;this.inputNode.connect(this.filterNode);
this.inputNode.connect(this.dryNode);this.filterNode.connect(this.wetNode);this.oscNode.connect(this.oscGainNode);this.oscGainNode.connect(this.filterNode.frequency);f(this.oscNode)}function t(a){this.type="gain";this.params=[a];this.node=d();this.node.gain.value=a}function s(a,b){this.type="tremolo";this.params=[a,b];this.node=d();this.node.gain.value=1-b/2;this.oscNode=I.createOscillator();this.oscNode.frequency.value=a;this.oscGainNode=d();this.oscGainNode.gain.value=b/2;this.oscNode.connect(this.oscGainNode);
this.oscGainNode.connect(this.node.gain);f(this.oscNode)}function m(a,b){this.type="ringmod";this.params=[a,b];this.inputNode=d();this.wetNode=d();this.wetNode.gain.value=b;this.dryNode=d();this.dryNode.gain.value=1-b;this.ringNode=d();this.ringNode.gain.value=0;this.oscNode=I.createOscillator();this.oscNode.frequency.value=a;this.oscNode.connect(this.ringNode.gain);f(this.oscNode);this.inputNode.connect(this.ringNode);this.inputNode.connect(this.dryNode);this.ringNode.connect(this.wetNode)}function x(a,
b,c,e,f){this.type="distortion";this.params=[a,b,c,e,f];this.inputNode=d();this.preGain=d();this.postGain=d();this.setDrive(c,Math.pow(10,e/20));this.wetNode=d();this.wetNode.gain.value=f;this.dryNode=d();this.dryNode.gain.value=1-f;this.waveShaper=I.createWaveShaper();this.curve=new Float32Array(65536);this.generateColortouchCurve(a,b);this.waveShaper.curve=this.curve;this.inputNode.connect(this.preGain);this.inputNode.connect(this.dryNode);this.preGain.connect(this.waveShaper);this.waveShaper.connect(this.postGain);
this.postGain.connect(this.wetNode)}function z(a,b,c,d,e){this.type="compressor";this.params=[a,b,c,d,e];this.node=I.createDynamicsCompressor();this.node.threshold.value=a;this.node.knee.value=b;this.node.ratio.value=c;this.node.attack.value=d;this.node.release.value=e}function r(a,b){this.type="analyser";this.params=[a,b];this.node=I.createAnalyser();this.node.fftSize=a;this.node.smoothingTimeConstant=b;this.freqBins=new Float32Array(this.node.frequencyBinCount);this.signal=new Uint8Array(a);this.rms=
this.peak=0}function q(){this.obj=null;this.loadUid=0;this.speeds=[];this.moveAngle=this.lastY=this.lastX=0}function G(a,b){this.src=a;this.myapi=J;this.is_music=b;this.added_end_listener=!1;var c=this;this.mediaSourceNode=this.outNode=null;this.panWhenReady=[];this.seekWhenReady=0;this.pauseWhenReady=!1;J!==F||!b||M.isMobile||M.isNodeWebkit||(this.myapi=R,this.outNode=d());this.audioData=this.bufferObject=null;var e;switch(this.myapi){case R:this.bufferObject=new Audio;J===F&&I.createMediaElementSource&&
this.bufferObject.addEventListener("canplay",function(){c.mediaSourceNode=I.createMediaElementSource(c.bufferObject);c.mediaSourceNode.connect(c.outNode)});this.bufferObject.autoplay=!1;this.bufferObject.preload="auto";this.bufferObject.src=a;break;case F:e=new XMLHttpRequest;e.open("GET",a,!0);e.responseType="arraybuffer";e.onload=function(){c.audioData=e.response;c.decodeAudioBuffer()};e.send();break;case U:this.bufferObject=!0;break;case aa:this.bufferObject=!0}}function y(a,b){var c=this;this.tag=
b;this.stopped=this.fresh=!0;this.src=a.src;this.buffer=a;this.myapi=J;this.is_music=a.is_music;this.playbackRate=1;this.pgended=!0;this.is_paused=this.resume_me=!1;this.resume_position=0;this.is_silent=this.is_muted=this.looping=!1;this.mutevol=this.volume=1;this.startTime=M.kahanTime.sum;this.pannerNode=this.gainNode=null;this.pannerEnabled=!1;this.objectTracker=null;this.panConeOuterGain=this.panConeOuter=this.panConeInner=this.panAngle=this.panY=this.panX=0;this.instanceObject=null;var f=!1;switch(this.myapi){case R:this.is_music?
(this.instanceObject=a.bufferObject,f=!a.added_end_listener,a.added_end_listener=!0):(this.instanceObject=new Audio,this.instanceObject.autoplay=!1,this.instanceObject.src=a.bufferObject.src,f=!0);f&&this.instanceObject.addEventListener("ended",function(){V=c.tag;c.stopped=!0;M.trigger(cr.plugins_.Audio.prototype.cnds.OnEnded,Q)});break;case F:this.gainNode=d();this.gainNode.connect(e(b));this.buffer.myapi===F?a.bufferObject&&(this.instanceObject=I.createBufferSource(),this.instanceObject.buffer=
a.bufferObject,this.instanceObject.connect(this.gainNode)):(this.instanceObject=this.buffer.bufferObject,this.buffer.outNode.connect(this.gainNode));break;case U:this.instanceObject=new window.Media(T+this.src,null,null,function(a){a===window.Media.MEDIA_STOPPED&&(c.pgended=!0,c.stopped=!0,V=c.tag,M.trigger(cr.plugins_.Audio.prototype.cnds.OnEnded,Q))});break;case aa:this.instanceObject=!0}}function A(a){O.length=0;if(a.length){var b,c,d;b=0;for(c=L.length;b<c;b++)d=L[b],cr.equals_nocase(a,d.tag)&&
O.push(d)}else P&&!P.hasEnded()&&(O.length=1,O[0]=P)}function w(a){var b,c,d,e,f=I.destination;if(N.hasOwnProperty(a)&&(d=N[a],d.length))for(f=d[0].getInputNode(),b=0,c=d.length;b<c;b++)e=d[b],b+1===c?e.connectTo(I.destination):e.connectTo(d[b+1].getInputNode());A(a);b=0;for(c=O.length;b<c;b++)O[b].reconnect(f);ca&&ga===a&&(ca.disconnect(),ca.connect(f))}function D(a,b){N.hasOwnProperty(a)?N[a].push(b):N[a]=[b];w(a)}function E(){}function B(){}function H(){}function K(a,b){var c=null;N.hasOwnProperty(a)&&
(c=N[a]);return c&&0<=b&&b<c.length&&c[b].freqBins?c[b]:null}var C=cr.plugins_.Audio.prototype;C.Type=function(a){this.plugin=a;this.runtime=a.runtime};C.Type.prototype.onCreate=function(){};var M=null,Q=null,V="",T="",R=0,F=1,U=2,aa=3,J=R,I=null,da=[],L=[],P=null,W=!1,fa=0,S=!1,X=1,Y=0,Z=0,ha=1,ia=1,ka=10,la=1E4,ma=1,ca=null,ga="",N={},ja="lowpass highpass bandpass lowshelf highshelf peaking notch allpass".split(" ");k.prototype.connectTo=function(a){this.wetNode.disconnect();this.wetNode.connect(a);
this.dryNode.disconnect();this.dryNode.connect(a)};k.prototype.remove=function(){this.inputNode.disconnect();this.filterNode.disconnect();this.wetNode.disconnect();this.dryNode.disconnect()};k.prototype.getInputNode=function(){return this.inputNode};k.prototype.setParam=function(a,b,c,d){switch(a){case 0:b/=100;0>b&&(b=0);1<b&&(b=1);this.params[4]=b;l(this.wetNode.gain,b,c,d);l(this.dryNode.gain,1-b,c,d);break;case 1:this.params[0]=b;l(this.filterNode.frequency,b,c,d);break;case 2:this.params[1]=
b;l(this.filterNode.detune,b,c,d);break;case 3:this.params[2]=b;l(this.filterNode.Q,b,c,d);break;case 4:this.params[3]=b,l(this.filterNode.gain,b,c,d)}};n.prototype.connectTo=function(a){this.wetNode.disconnect();this.wetNode.connect(a);this.dryNode.disconnect();this.dryNode.connect(a)};n.prototype.remove=function(){this.inputNode.disconnect();this.mainNode.disconnect();this.delayNode.disconnect();this.delayGainNode.disconnect();this.wetNode.disconnect();this.dryNode.disconnect()};n.prototype.getInputNode=
function(){return this.inputNode};n.prototype.setParam=function(b,c,d,e){switch(b){case 0:c/=100;0>c&&(c=0);1<c&&(c=1);this.params[2]=c;l(this.wetNode.gain,c,d,e);l(this.dryNode.gain,1-c,d,e);break;case 4:this.params[1]=a(c);l(this.delayGainNode.gain,a(c),d,e);break;case 5:this.params[0]=c,l(this.delayNode.delayTime,c,d,e)}};v.prototype.connectTo=function(a){this.wetNode.disconnect();this.wetNode.connect(a);this.dryNode.disconnect();this.dryNode.connect(a)};v.prototype.remove=function(){this.inputNode.disconnect();
this.convolveNode.disconnect();this.wetNode.disconnect();this.dryNode.disconnect()};v.prototype.getInputNode=function(){return this.inputNode};v.prototype.setParam=function(a,b,c,d){switch(a){case 0:b/=100,0>b&&(b=0),1<b&&(b=1),this.params[1]=b,l(this.wetNode.gain,b,c,d),l(this.dryNode.gain,1-b,c,d)}};u.prototype.connectTo=function(a){this.dryNode.disconnect();this.dryNode.connect(a);this.wetNode.disconnect();this.wetNode.connect(a)};u.prototype.remove=function(){this.inputNode.disconnect();this.delayNode.disconnect();
this.oscNode.disconnect();this.oscGainNode.disconnect();this.dryNode.disconnect();this.wetNode.disconnect();this.feedbackNode.disconnect()};u.prototype.getInputNode=function(){return this.inputNode};u.prototype.setParam=function(a,b,c,d){switch(a){case 0:b/=100;0>b&&(b=0);1<b&&(b=1);this.params[4]=b;l(this.wetNode.gain,b/2,c,d);l(this.dryNode.gain,1-b/2,c,d);break;case 6:this.params[1]=b/1E3;l(this.oscGainNode.gain,b/1E3,c,d);break;case 7:this.params[2]=b;l(this.oscNode.frequency,b,c,d);break;case 8:this.params[3]=
b/100,l(this.feedbackNode.gain,b/100,c,d)}};p.prototype.connectTo=function(a){this.dryNode.disconnect();this.dryNode.connect(a);this.wetNode.disconnect();this.wetNode.connect(a)};p.prototype.remove=function(){this.inputNode.disconnect();this.filterNode.disconnect();this.oscNode.disconnect();this.oscGainNode.disconnect();this.dryNode.disconnect();this.wetNode.disconnect()};p.prototype.getInputNode=function(){return this.inputNode};p.prototype.setParam=function(a,b,c,d){switch(a){case 0:b/=100;0>b&&
(b=0);1<b&&(b=1);this.params[5]=b;l(this.wetNode.gain,b/2,c,d);l(this.dryNode.gain,1-b/2,c,d);break;case 1:this.params[0]=b;l(this.filterNode.frequency,b,c,d);break;case 2:this.params[1]=b;l(this.filterNode.detune,b,c,d);break;case 3:this.params[2]=b;l(this.filterNode.Q,b,c,d);break;case 6:this.params[3]=b;l(this.oscGainNode.gain,b,c,d);break;case 7:this.params[4]=b,l(this.oscNode.frequency,b,c,d)}};t.prototype.connectTo=function(a){this.node.disconnect();this.node.connect(a)};t.prototype.remove=
function(){this.node.disconnect()};t.prototype.getInputNode=function(){return this.node};t.prototype.setParam=function(b,c,d,e){switch(b){case 4:this.params[0]=a(c),l(this.node.gain,a(c),d,e)}};s.prototype.connectTo=function(a){this.node.disconnect();this.node.connect(a)};s.prototype.remove=function(){this.oscNode.disconnect();this.oscGainNode.disconnect();this.node.disconnect()};s.prototype.getInputNode=function(){return this.node};s.prototype.setParam=function(a,b,c,d){switch(a){case 0:b/=100;0>
b&&(b=0);1<b&&(b=1);this.params[1]=b;l(this.node.gain.value,1-b/2,c,d);l(this.oscGainNode.gain.value,b/2,c,d);break;case 7:this.params[0]=b,l(this.oscNode.frequency,b,c,d)}};m.prototype.connectTo=function(a){this.wetNode.disconnect();this.wetNode.connect(a);this.dryNode.disconnect();this.dryNode.connect(a)};m.prototype.remove=function(){this.oscNode.disconnect();this.ringNode.disconnect();this.inputNode.disconnect();this.wetNode.disconnect();this.dryNode.disconnect()};m.prototype.getInputNode=function(){return this.inputNode};
m.prototype.setParam=function(a,b,c,d){switch(a){case 0:b/=100;0>b&&(b=0);1<b&&(b=1);this.params[1]=b;l(this.wetNode.gain,b,c,d);l(this.dryNode.gain,1-b,c,d);break;case 7:this.params[0]=b,l(this.oscNode.frequency,b,c,d)}};x.prototype.setDrive=function(a,b){0.01>a&&(a=0.01);this.preGain.gain.value=a;this.postGain.gain.value=Math.pow(1/a,0.6)*b};x.prototype.shape=function(a,b,c){var d=1.05*c*b-b;c=0>a?-1:1;a=0>a?-a:a;b=a<b?a:b+d*(1-Math.exp(-(1/d)*(a-b)));return b*c};x.prototype.generateColortouchCurve=
function(a,b){for(var c=Math.pow(10,a/20),d=Math.pow(10,b/20),e=0,f=0;32768>f;++f)e=f/32768,e=this.shape(e,c,d),this.curve[32768+f]=e,this.curve[32768-f-1]=-e};x.prototype.connectTo=function(a){this.wetNode.disconnect();this.wetNode.connect(a);this.dryNode.disconnect();this.dryNode.connect(a)};x.prototype.remove=function(){this.inputNode.disconnect();this.preGain.disconnect();this.waveShaper.disconnect();this.postGain.disconnect();this.wetNode.disconnect();this.dryNode.disconnect()};x.prototype.getInputNode=
function(){return this.inputNode};x.prototype.setParam=function(a,b,c,d){switch(a){case 0:b/=100,0>b&&(b=0),1<b&&(b=1),this.params[4]=b,l(this.wetNode.gain,b,c,d),l(this.dryNode.gain,1-b,c,d)}};z.prototype.connectTo=function(a){this.node.disconnect();this.node.connect(a)};z.prototype.remove=function(){this.node.disconnect()};z.prototype.getInputNode=function(){return this.node};z.prototype.setParam=function(a,b,c,d){};r.prototype.tick=function(){this.node.getFloatFrequencyData(this.freqBins);this.node.getByteTimeDomainData(this.signal);
for(var a=this.node.fftSize,c=0,d=this.peak=0,e=0;c<a;c++)e=(this.signal[c]-128)/128,0>e&&(e=-e),this.peak<e&&(this.peak=e),d+=e*e;this.peak=b(this.peak);this.rms=b(Math.sqrt(d/a))};r.prototype.connectTo=function(a){this.node.disconnect();this.node.connect(a)};r.prototype.remove=function(){this.node.disconnect()};r.prototype.getInputNode=function(){return this.node};r.prototype.setParam=function(a,b,c,d){};q.prototype.setObject=function(a){if(this.obj=a)this.lastX=this.obj.x,this.lastY=this.obj.y;
this.speeds.length=0};q.prototype.hasObject=function(){return!!this.obj};q.prototype.tick=function(a){this.obj&&(this.moveAngle=cr.angleTo(this.lastX,this.lastY,this.obj.x,this.obj.y),a=cr.distanceTo(this.lastX,this.lastY,this.obj.x,this.obj.y)/a,4>this.speeds.length||this.speeds.shift(),this.speeds.push(a),this.lastX=this.obj.x,this.lastY=this.obj.y)};q.prototype.getSpeed=function(){if(!this.speeds.length)return 0;var a,b,c=0;a=0;for(b=this.speeds.length;a<b;a++)c+=this.speeds[a];return c/this.speeds.length};
q.prototype.getVelocityX=function(){return Math.cos(this.moveAngle)*this.getSpeed()};q.prototype.getVelocityY=function(){return Math.sin(this.moveAngle)*this.getSpeed()};var na=!1;G.prototype.decodeAudioBuffer=function(){if(!this.bufferObject&&this.audioData){var a=this;if(I.decodeAudioData)I.decodeAudioData(this.audioData,function(b){a.bufferObject=b;var c,d,e;if(cr.is_undefined(a.playTagWhenReady))cr.is_undefined(a.convolveWhenReady)||(c=a.convolveWhenReady.convolveNode,c.normalize=a.normalizeWhenReady,
c.buffer=b);else if(a.panWhenReady.length){c=0;for(d=a.panWhenReady.length;c<d;c++){b=a.panWhenReady[c];e=new y(a,b.thistag);e.setPannerEnabled(!0);if("undefined"!==typeof b.objUid&&(b.obj=M.getObjectByUID(b.objUid),!b.obj))continue;if(b.obj){var f=cr.rotatePtAround(b.obj.x,b.obj.y,-b.obj.layer.getAngle(),Y,Z,!0),g=cr.rotatePtAround(b.obj.x,b.obj.y,-b.obj.layer.getAngle(),Y,Z,!1);e.setPan(f,g,cr.to_degrees(b.obj.angle-b.obj.layer.getAngle()),b.ia,b.oa,b.og);e.setObject(b.obj)}else e.setPan(b.x,b.y,
b.a,b.ia,b.oa,b.og);e.play(a.loopWhenReady,a.volumeWhenReady,a.seekWhenReady);a.pauseWhenReady&&e.pause();L.push(e)}a.panWhenReady.length=0}else e=new y(a,a.playTagWhenReady),e.play(a.loopWhenReady,a.volumeWhenReady,a.seekWhenReady),a.pauseWhenReady&&e.pause(),L.push(e)});else if(this.bufferObject=I.createBuffer(this.audioData,!1),cr.is_undefined(this.playTagWhenReady))cr.is_undefined(this.convolveWhenReady)||(b=this.convolveWhenReady.convolveNode,b.normalize=this.normalizeWhenReady,b.buffer=this.bufferObject);
else{var b=new y(this,this.playTagWhenReady);b.play(this.loopWhenReady,this.volumeWhenReady,this.seekWhenReady);this.pauseWhenReady&&b.pause();L.push(b)}}};G.prototype.isLoaded=function(){switch(this.myapi){case R:return 4===this.bufferObject.readyState;case F:return!!this.audioData;case U:return!0;case aa:return!0}return!1};y.prototype.hasEnded=function(){switch(this.myapi){case R:return this.instanceObject.ended;case F:return this.buffer.myapi===F?!this.fresh&&!this.stopped&&this.instanceObject.loop||
this.is_paused?!1:M.kahanTime.sum-this.startTime>this.buffer.bufferObject.duration:this.instanceObject.ended;case U:return this.pgended;case aa:!0}return!0};y.prototype.canBeRecycled=function(){return this.fresh||this.stopped?!0:this.hasEnded()};y.prototype.setPannerEnabled=function(a){J===F&&(!this.pannerEnabled&&a?(this.pannerNode||(this.pannerNode=I.createPanner(),this.pannerNode.panningModel="number"===typeof this.pannerNode.panningModel?ha:["equalpower","HRTF","soundfield"][ha],this.pannerNode.distanceModel=
"number"===typeof this.pannerNode.distanceModel?ia:["linear","inverse","exponential"][ia],this.pannerNode.refDistance=ka,this.pannerNode.maxDistance=la,this.pannerNode.rolloffFactor=ma),this.gainNode.disconnect(),this.gainNode.connect(this.pannerNode),this.pannerNode.connect(e(this.tag)),this.pannerEnabled=!0):this.pannerEnabled&&!a&&(this.pannerNode.disconnect(),this.gainNode.disconnect(),this.gainNode.connect(e(this.tag)),this.pannerEnabled=!1))};y.prototype.setPan=function(a,b,c,d,e,f){this.pannerEnabled&&
J===F&&(this.pannerNode.setPosition(a,b,0),this.pannerNode.setOrientation(Math.cos(cr.to_radians(c)),Math.sin(cr.to_radians(c)),0),this.pannerNode.coneInnerAngle=d,this.pannerNode.coneOuterAngle=e,this.pannerNode.coneOuterGain=f,this.panX=a,this.panY=b,this.panAngle=c,this.panConeInner=d,this.panConeOuter=e,this.panConeOuterGain=f)};y.prototype.setObject=function(a){this.pannerEnabled&&J===F&&(this.objectTracker||(this.objectTracker=new q),this.objectTracker.setObject(a))};y.prototype.tick=function(a){if(this.pannerEnabled&&
J===F&&this.objectTracker&&this.objectTracker.hasObject()&&this.isPlaying()){this.objectTracker.tick(a);a=this.objectTracker.obj;var b=cr.rotatePtAround(a.x,a.y,-a.layer.getAngle(),Y,Z,!0),c=cr.rotatePtAround(a.x,a.y,-a.layer.getAngle(),Y,Z,!1);this.pannerNode.setPosition(b,c,0);b=0;"undefined"!==typeof this.objectTracker.obj.angle&&(b=a.angle-a.layer.getAngle(),this.pannerNode.setOrientation(Math.cos(b),Math.sin(b),0));this.pannerNode.setVelocity(this.objectTracker.getVelocityX(),this.objectTracker.getVelocityY(),
0)}};y.prototype.play=function(a,b,c){var d=this.instanceObject;this.looping=a;this.volume=b;c=c||0;switch(this.myapi){case R:1!==d.playbackRate&&(d.playbackRate=1);d.volume!==b*X&&(d.volume=b*X);d.loop!==a&&(d.loop=a);d.muted&&(d.muted=!1);if(d.currentTime!==c)try{d.currentTime=c}catch(e){}this.instanceObject.play();break;case F:this.muted=!1;this.mutevol=1;if(this.buffer.myapi===F)this.fresh||(this.instanceObject=I.createBufferSource(),this.instanceObject.buffer=this.buffer.bufferObject,this.instanceObject.connect(this.gainNode)),
this.instanceObject.loop=a,this.gainNode.gain.value=b*X,0===c?f(this.instanceObject):g(this.instanceObject,c,this.getDuration());else{1!==d.playbackRate&&(d.playbackRate=1);d.loop!==a&&(d.loop=a);this.gainNode.gain.value=b*X;if(d.currentTime!==c)try{d.currentTime=c}catch(m){}d.play()}break;case U:(!this.fresh&&this.stopped||0!==c)&&d.seekTo(c);d.play();this.pgended=!1;break;case aa:M.isDirectCanvas?AppMobi.context.playSound(this.src):AppMobi.player.playSound(this.src)}this.playbackRate=1;this.startTime=
M.kahanTime.sum-c;this.is_paused=this.stopped=this.fresh=!1};y.prototype.stop=function(){switch(this.myapi){case R:this.instanceObject.paused||this.instanceObject.pause();break;case F:this.buffer.myapi===F?h(this.instanceObject):this.instanceObject.paused||this.instanceObject.pause();break;case U:this.instanceObject.stop()}this.stopped=!0;this.is_paused=!1};y.prototype.pause=function(){if(!(this.fresh||this.stopped||this.hasEnded()||this.is_paused)){switch(this.myapi){case R:this.instanceObject.paused||
this.instanceObject.pause();break;case F:this.buffer.myapi===F?(this.resume_position=this.getPlaybackTime(),this.looping&&(this.resume_position%=this.getDuration()),h(this.instanceObject)):this.instanceObject.paused||this.instanceObject.pause();break;case U:this.instanceObject.pause()}this.is_paused=!0}};y.prototype.resume=function(){if(!this.fresh&&!this.stopped&&!this.hasEnded()&&this.is_paused){switch(this.myapi){case R:this.instanceObject.play();break;case F:this.buffer.myapi===F?(this.instanceObject=
I.createBufferSource(),this.instanceObject.buffer=this.buffer.bufferObject,this.instanceObject.connect(this.gainNode),this.instanceObject.loop=this.looping,this.gainNode.gain.value=X*this.volume*this.mutevol,this.startTime=M.kahanTime.sum-this.resume_position,g(this.instanceObject,this.resume_position,this.getDuration())):this.instanceObject.play();break;case U:this.instanceObject.play()}this.is_paused=!1}};y.prototype.seek=function(a){if(!(this.fresh||this.stopped||this.hasEnded()))switch(this.myapi){case R:try{this.instanceObject.currentTime=
a}catch(b){}break;case F:if(this.buffer.myapi===F)this.is_paused?this.resume_position=a:(this.pause(),this.resume_position=a,this.resume());else try{this.instanceObject.currentTime=a}catch(c){}}};y.prototype.reconnect=function(a){this.myapi===F&&(this.pannerEnabled?(this.pannerNode.disconnect(),this.pannerNode.connect(a)):(this.gainNode.disconnect(),this.gainNode.connect(a)))};y.prototype.getDuration=function(){switch(this.myapi){case R:if("undefined"!==typeof this.instanceObject.duration)return this.instanceObject.duration;
break;case F:return this.buffer.bufferObject.duration;case U:return this.instanceObject.getDuration()}return 0};y.prototype.getPlaybackTime=function(){var a=this.getDuration(),b=0;switch(this.myapi){case R:"undefined"!==typeof this.instanceObject.currentTime&&(b=this.instanceObject.currentTime);break;case F:if(this.buffer.myapi===F){if(this.is_paused)return this.resume_position;b=M.kahanTime.sum-this.startTime}else"undefined"!==typeof this.instanceObject.currentTime&&(b=this.instanceObject.currentTime)}!this.looping&&
b>a&&(b=a);return b};y.prototype.isPlaying=function(){return!this.is_paused&&!this.fresh&&!this.stopped&&!this.hasEnded()};y.prototype.setVolume=function(a){this.volume=a;this.updateVolume()};y.prototype.updateVolume=function(){var a=this.volume*X;switch(this.myapi){case R:this.instanceObject.volume&&this.instanceObject.volume!==a&&(this.instanceObject.volume=a);break;case F:this.gainNode.gain.value=a*this.mutevol}};y.prototype.getVolume=function(){return this.volume};y.prototype.doSetMuted=function(a){switch(this.myapi){case R:this.instanceObject.muted!==
!!a&&(this.instanceObject.muted=!!a);break;case F:this.mutevol=a?0:1,this.gainNode.gain.value=X*this.volume*this.mutevol}};y.prototype.setMuted=function(a){this.is_muted=!!a;this.doSetMuted(this.is_muted||this.is_silent)};y.prototype.setSilent=function(a){this.is_silent=!!a;this.doSetMuted(this.is_muted||this.is_silent)};y.prototype.setLooping=function(a){this.looping=a;switch(this.myapi){case R:this.instanceObject.loop!==!!a&&(this.instanceObject.loop=!!a);break;case F:this.instanceObject.loop!==
!!a&&(this.instanceObject.loop=!!a)}};y.prototype.setPlaybackRate=function(a){this.playbackRate=a;this.updatePlaybackRate()};y.prototype.updatePlaybackRate=function(){var a=this.playbackRate;if(1===fa&&!this.is_music||2===fa)a*=M.timescale;switch(this.myapi){case R:this.instanceObject.playbackRate!==a&&(this.instanceObject.playbackRate=a);break;case F:this.buffer.myapi===F?this.instanceObject.playbackRate.value!==a&&(this.instanceObject.playbackRate.value=a):this.instanceObject.playbackRate!==a&&
(this.instanceObject.playbackRate=a)}};y.prototype.setSuspended=function(a){switch(this.myapi){case R:a?this.isPlaying()?(this.instanceObject.pause(),this.resume_me=!0):this.resume_me=!1:this.resume_me&&this.instanceObject.play();break;case F:a?this.isPlaying()?(this.buffer.myapi===F?(this.resume_position=this.getPlaybackTime(),this.looping&&(this.resume_position%=this.getDuration()),h(this.instanceObject)):this.instanceObject.pause(),this.resume_me=!0):this.resume_me=!1:this.resume_me&&(this.buffer.myapi===
F?(this.instanceObject=I.createBufferSource(),this.instanceObject.buffer=this.buffer.bufferObject,this.instanceObject.connect(this.gainNode),this.instanceObject.loop=this.looping,this.gainNode.gain.value=X*this.volume*this.mutevol,this.startTime=M.kahanTime.sum-this.resume_position,g(this.instanceObject,this.resume_position,this.getDuration())):this.instanceObject.play());break;case U:a?this.isPlaying()?(this.instanceObject.pause(),this.resume_me=!0):this.resume_me=!1:this.resume_me&&this.instanceObject.play()}};
C.Instance=function(a){this.type=a;M=this.runtime=a.runtime;Q=this;this.listenerTracker=null;this.listenerZ=-600;I=null;"undefined"!==typeof AudioContext?(J=F,I=new AudioContext):"undefined"!==typeof webkitAudioContext&&(J=F,I=new webkitAudioContext);this.runtime.isiOS&&J===F&&document.addEventListener("touchstart",function(){if(!na){var a=I.createBuffer(1,1,22050),b=I.createBufferSource();b.buffer=a;b.connect(I.destination);f(b);na=!0}},!0);J!==F&&(this.runtime.isPhoneGap?J=U:this.runtime.isAppMobi&&
(J=aa));J===U&&(T=location.href,a=T.lastIndexOf("/"),-1<a&&(T=T.substr(0,a+1)),T=T.replace("file://",""));if(this.runtime.isSafari&&this.runtime.isWindows&&"undefined"===typeof Audio)alert("It looks like you're using Safari for Windows without Quicktime.  Audio cannot be played until Quicktime is installed."),this.runtime.DestroyInstance(this);else{if(this.runtime.isDirectCanvas)W=this.runtime.isAndroid;else try{W=!!(new Audio).canPlayType('audio/ogg; codecs="vorbis"')}catch(b){W=!1}this.runtime.tickMe(this)}};
var ba=C.Instance.prototype;ba.onCreate=function(){fa=this.properties[0];this.saveload=this.properties[1];ha=this.properties[2];ia=this.properties[3];this.listenerZ=-this.properties[4];ka=this.properties[5];la=this.properties[6];ma=this.properties[7];this.listenerTracker=new q;J===F&&(I.listener.speedOfSound=this.properties[7],I.listener.dopplerFactor=this.properties[8],I.listener.setPosition(this.runtime.width/2,this.runtime.height/2,this.listenerZ),I.listener.setOrientation(0,0,1,0,-1,0),window.c2OnAudioMicStream=
function(a,b){ca&&ca.disconnect();ga=b.toLowerCase();ca=I.createMediaStreamSource(a);ca.connect(e(ga))});this.runtime.addSuspendCallback(function(a){Q.onSuspend(a)});var a=this;this.runtime.addDestroyCallback(function(b){a.onInstanceDestroyed(b)})};ba.onInstanceDestroyed=function(a){var b,c,d;b=0;for(c=L.length;b<c;b++)d=L[b],d.objectTracker&&d.objectTracker.obj===a&&(d.objectTracker.obj=null,d.pannerEnabled&&d.isPlaying()&&d.looping&&d.stop());this.listenerTracker.obj===a&&(this.listenerTracker.obj=
null)};ba.saveToJSON=function(){var a={silent:S,masterVolume:X,listenerZ:this.listenerZ,listenerUid:this.listenerTracker.hasObject()?this.listenerTracker.obj.uid:-1,playing:[],effects:{}},b=a.playing,c,d,e,f,g,m;c=0;for(d=L.length;c<d;c++)e=L[c],!e.isPlaying()||3===this.saveload||e.is_music&&1===this.saveload||!e.is_music&&2===this.saveload||(f=e.getPlaybackTime(),e.looping&&(f%=e.getDuration()),f={tag:e.tag,buffersrc:e.buffer.src,is_music:e.is_music,playbackTime:f,volume:e.volume,looping:e.looping,
muted:e.is_muted,playbackRate:e.playbackRate,paused:e.is_paused,resume_position:e.resume_position},e.pannerEnabled&&(f.pan={},m=f.pan,e.objectTracker&&e.objectTracker.hasObject()?m.objUid=e.objectTracker.obj.uid:(m.x=e.panX,m.y=e.panY,m.a=e.panAngle),m.ia=e.panConeInner,m.oa=e.panConeOuter,m.og=e.panConeOuterGain),b.push(f));b=a.effects;for(g in N)if(N.hasOwnProperty(g)){e=[];c=0;for(d=N[g].length;c<d;c++)e.push({type:N[g][c].type,params:N[g][c].params});b[g]=e}return a};var ea=[];ba.loadFromJSON=
function(a){var b=a.silent;X=a.masterVolume;this.listenerZ=a.listenerZ;this.listenerTracker.setObject(null);var c=a.listenerUid;-1!==c&&(this.listenerTracker.loadUid=c,ea.push(this.listenerTracker));var c=a.playing,d,e,f,g,h,l,A,G,y,w,E;if(3!==this.saveload)for(d=0,e=L.length;d<e;d++)y=L[d],y.is_music&&1===this.saveload||(y.is_music||2!==this.saveload)&&y.stop();for(h in N)if(N.hasOwnProperty(h))for(d=0,e=N[h].length;d<e;d++)N[h][d].remove();cr.wipe(N);for(h in a.effects)if(a.effects.hasOwnProperty(h))for(l=
a.effects[h],d=0,e=l.length;d<e;d++)switch(f=l[d].type,w=l[d].params,f){case "filter":D(h,new k(w[0],w[1],w[2],w[3],w[4],w[5]));break;case "delay":D(h,new n(w[0],w[1],w[2]));break;case "convolve":f=w[2];y=this.getAudioBuffer(f,!1);y.bufferObject?f=new v(y.bufferObject,w[0],w[1],f):(f=new v(null,w[0],w[1],f),y.normalizeWhenReady=w[0],y.convolveWhenReady=f);D(h,f);break;case "flanger":D(h,new u(w[0],w[1],w[2],w[3],w[4]));break;case "phaser":D(h,new p(w[0],w[1],w[2],w[3],w[4],w[5]));break;case "gain":D(h,
new t(w[0]));break;case "tremolo":D(h,new s(w[0],w[1]));break;case "ringmod":D(h,new m(w[0],w[1]));break;case "distortion":D(h,new x(w[0],w[1],w[2],w[3],w[4]));break;case "compressor":D(h,new z(w[0],w[1],w[2],w[3],w[4]));break;case "analyser":D(h,new r(w[0],w[1]))}d=0;for(e=c.length;d<e;d++)3===this.saveload||(a=c[d],f=a.buffersrc,g=a.is_music,h=a.tag,l=a.playbackTime,A=a.looping,G=a.volume,E=(w=a.pan)&&w.hasOwnProperty("objUid")?w.objUid:-1,g&&1===this.saveload)||!g&&2===this.saveload||((y=this.getAudioInstance(f,
h,g,A,G))?(y.resume_position=a.resume_position,y.setPannerEnabled(!!w),y.play(A,G,l),y.updatePlaybackRate(),y.updateVolume(),y.doSetMuted(y.is_muted||y.is_silent),a.paused&&y.pause(),a.muted&&y.mute(),w&&(-1!==E?(y.objectTracker=y.objectTracker||new q,y.objectTracker.loadUid=E,ea.push(y.objectTracker)):y.setPan(w.x,w.y,w.a,w.ia,w.oa,w.og))):(y=this.getAudioBuffer(f,g),y.seekWhenReady=l,y.pauseWhenReady=a.paused,w&&(-1!==E?y.panWhenReady.push({objUid:E,ia:w.ia,oa:w.oa,og:w.og,thistag:h}):y.panWhenReady.push({x:w.x,
y:w.y,a:w.a,ia:w.ia,oa:w.oa,og:w.og,thistag:h}))));if(b&&!S){d=0;for(e=L.length;d<e;d++)L[d].setSilent(!0);S=!0}else if(!b&&S){d=0;for(e=L.length;d<e;d++)L[d].setSilent(!1);S=!1}};ba.afterLoad=function(){var a,b,c,d;a=0;for(b=ea.length;a<b;a++)c=ea[a],d=this.runtime.getObjectByUID(c.loadUid),c.setObject(d),c.loadUid=-1,d&&(Y=d.x,Z=d.y);ea.length=0};ba.onSuspend=function(a){var b,c;b=0;for(c=L.length;b<c;b++)L[b].setSuspended(a)};ba.tick=function(){var a=this.runtime.dt,b,c,d;b=0;for(c=L.length;b<
c;b++)d=L[b],d.tick(a),d.myapi===R||d.myapi===aa||d.fresh||d.stopped||!d.hasEnded()||(d.stopped=!0,V=d.tag,M.trigger(cr.plugins_.Audio.prototype.cnds.OnEnded,Q)),0!==fa&&d.updatePlaybackRate();var e,f;for(e in N)if(N.hasOwnProperty(e))for(d=N[e],b=0,c=d.length;b<c;b++)f=d[b],f.tick&&f.tick();J===F&&this.listenerTracker.hasObject()&&(this.listenerTracker.tick(a),Y=this.listenerTracker.obj.x,Z=this.listenerTracker.obj.y,I.listener.setPosition(this.listenerTracker.obj.x,this.listenerTracker.obj.y,this.listenerZ),
I.listener.setVelocity(this.listenerTracker.getVelocityX(),this.listenerTracker.getVelocityY(),0))};ba.getAudioBuffer=function(a,b){var c,d,e,f=null,g,h,m,k;c=0;for(d=da.length;c<d;c++)if(e=da[c],e.src===a){f=e;break}f||(f=new G(a,b),da.push(f));if(f.is_music&&(M.isMobile||M.isNodeWebkit)){c=0;for(d=da.length;c<d;++c)if(e=da[c],e!==f&&e.is_music){e.bufferObject=null;h=g=0;for(m=L.length;g<m;++g)k=L[g],L[h]=k,k.buffer===e&&k.myapi===F?(k.gainNode.disconnect(),e.myapi===F&&k.instanceObject.disconnect()):
++h;L.length=h}f.decodeAudioBuffer()}return f};ba.getAudioInstance=function(a,b,c,d,e){var f,g,h;f=0;for(g=L.length;f<g;f++)if(h=L[f],h.src===a&&(h.canBeRecycled()||c))return h.tag=b,h;a=this.getAudioBuffer(a,c);if(!a.bufferObject)return"<preload>"!==b&&(a.playTagWhenReady=b,a.loopWhenReady=d,a.volumeWhenReady=e),null;h=new y(a,b);L.push(h);return h};var O=[];E.prototype.OnEnded=function(a){return cr.equals_nocase(V,a)};E.prototype.PreloadsComplete=function(){var a,b;a=0;for(b=da.length;a<b;a++)if(!da[a].isLoaded())return!1;
return!0};E.prototype.AdvancedAudioSupported=function(){return J===F};E.prototype.IsSilent=function(){return S};E.prototype.IsAnyPlaying=function(){var a,b;a=0;for(b=L.length;a<b;a++)if(L[a].isPlaying())return!0;return!1};E.prototype.IsTagPlaying=function(a){A(a);var b;a=0;for(b=O.length;a<b;a++)if(O[a].isPlaying())return!0;return!1};C.cnds=new E;B.prototype.Play=function(b,c,d,e){!S&&(d=a(d),P=this.getAudioInstance(this.runtime.files_subfolder+b[0]+(W?".ogg":".m4a"),e,b[1],0!==c,d))&&(P.setPannerEnabled(!1),
P.play(0!==c,d))};B.prototype.PlayAtPosition=function(b,c,d,e,f,g,h,m,k,p){if(!S){d=a(d);var l=b[1];b=this.runtime.files_subfolder+b[0]+(W?".ogg":".m4a");(P=this.getAudioInstance(b,p,l,0!==c,d))?(P.setPannerEnabled(!0),P.setPan(e,f,g,h,m,a(k)),P.play(0!==c,d)):this.getAudioBuffer(b,l).panWhenReady.push({x:e,y:f,a:g,ia:h,oa:m,og:a(k),thistag:p})}};B.prototype.PlayAtObject=function(b,c,d,e,f,g,h,m){if(!S&&e&&(e=e.getFirstPicked())){d=a(d);var k=b[1];b=this.runtime.files_subfolder+b[0]+(W?".ogg":".m4a");
(P=this.getAudioInstance(b,m,k,0!==c,d))?(P.setPannerEnabled(!0),m=cr.rotatePtAround(e.x,e.y,-e.layer.getAngle(),Y,Z,!0),b=cr.rotatePtAround(e.x,e.y,-e.layer.getAngle(),Y,Z,!1),P.setPan(m,b,cr.to_degrees(e.angle-e.layer.getAngle()),f,g,a(h)),P.setObject(e),P.play(0!==c,d)):this.getAudioBuffer(b,k).panWhenReady.push({obj:e,ia:f,oa:g,og:a(h),thistag:m})}};B.prototype.PlayByName=function(b,c,d,e,f){!S&&(e=a(e),b=1===b,c=this.runtime.files_subfolder+c.toLowerCase()+(W?".ogg":".m4a"),P=this.getAudioInstance(c,
f,b,0!==d,e))&&(P.setPannerEnabled(!1),P.play(0!==d,e))};B.prototype.PlayAtPositionByName=function(b,c,d,e,f,g,h,m,k,p,l){S||(e=a(e),b=1===b,c=this.runtime.files_subfolder+c.toLowerCase()+(W?".ogg":".m4a"),(P=this.getAudioInstance(c,l,b,0!==d,e))?(P.setPannerEnabled(!0),P.setPan(f,g,h,m,k,a(p)),P.play(0!==d,e)):this.getAudioBuffer(c,b).panWhenReady.push({x:f,y:g,a:h,ia:m,oa:k,og:a(p),thistag:l}))};B.prototype.PlayAtObjectByName=function(b,c,d,e,f,g,h,m,k){!S&&f&&(f=f.getFirstPicked())&&(e=a(e),b=
1===b,c=this.runtime.files_subfolder+c.toLowerCase()+(W?".ogg":".m4a"),(P=this.getAudioInstance(c,k,b,0!==d,e))?(P.setPannerEnabled(!0),k=cr.rotatePtAround(f.x,f.y,-f.layer.getAngle(),Y,Z,!0),c=cr.rotatePtAround(f.x,f.y,-f.layer.getAngle(),Y,Z,!1),P.setPan(k,c,cr.to_degrees(f.angle-f.layer.getAngle()),g,h,a(m)),P.setObject(f),P.play(0!==d,e)):this.getAudioBuffer(c,b).panWhenReady.push({obj:f,ia:g,oa:h,og:a(m),thistag:k}))};B.prototype.SetLooping=function(a,b){A(a);var c,d;c=0;for(d=O.length;c<d;c++)O[c].setLooping(0===
b)};B.prototype.SetMuted=function(a,b){A(a);var c,d;c=0;for(d=O.length;c<d;c++)O[c].setMuted(0===b)};B.prototype.SetVolume=function(b,c){A(b);var d=a(c),e,f;e=0;for(f=O.length;e<f;e++)O[e].setVolume(d)};B.prototype.Preload=function(a){if(!S){var b=a[1];a=this.runtime.files_subfolder+a[0]+(W?".ogg":".m4a");J===aa?this.runtime.isDirectCanvas?AppMobi.context.loadSound(a):AppMobi.player.loadSound(a):J!==U&&this.getAudioInstance(a,"<preload>",b,!1)}};B.prototype.PreloadByName=function(a,b){if(!S){var c=
1===a,d=this.runtime.files_subfolder+b.toLowerCase()+(W?".ogg":".m4a");J===aa?this.runtime.isDirectCanvas?AppMobi.context.loadSound(d):AppMobi.player.loadSound(d):J!==U&&this.getAudioInstance(d,"<preload>",c,!1)}};B.prototype.SetPlaybackRate=function(a,b){A(a);0>b&&(b=0);var c,d;c=0;for(d=O.length;c<d;c++)O[c].setPlaybackRate(b)};B.prototype.Stop=function(a){A(a);var b;a=0;for(b=O.length;a<b;a++)O[a].stop()};B.prototype.StopAll=function(){var a,b;a=0;for(b=L.length;a<b;a++)L[a].stop()};B.prototype.SetPaused=
function(a,b){A(a);var c,d;c=0;for(d=O.length;c<d;c++)0===b?O[c].pause():O[c].resume()};B.prototype.Seek=function(a,b){A(a);var c,d;c=0;for(d=O.length;c<d;c++)O[c].seek(b)};B.prototype.SetSilent=function(a){var b;2===a&&(a=S?1:0);if(0===a&&!S){a=0;for(b=L.length;a<b;a++)L[a].setSilent(!0);S=!0}else if(1===a&&S){a=0;for(b=L.length;a<b;a++)L[a].setSilent(!1);S=!1}};B.prototype.SetMasterVolume=function(b){X=a(b);var c;b=0;for(c=L.length;b<c;b++)L[b].updateVolume()};B.prototype.AddFilterEffect=function(a,
b,c,d,e,f,g){J!==F||0>b||b>=ja.length||(a=a.toLowerCase(),g/=100,0>g&&(g=0),1<g&&(g=1),D(a,new k(b,c,d,e,f,g)))};B.prototype.AddDelayEffect=function(b,c,d,e){J===F&&(b=b.toLowerCase(),e/=100,0>e&&(e=0),1<e&&(e=1),D(b,new n(c,a(d),e)))};B.prototype.AddFlangerEffect=function(a,b,c,d,e,f){J===F&&(a=a.toLowerCase(),f/=100,0>f&&(f=0),1<f&&(f=1),D(a,new u(b/1E3,c/1E3,d,e/100,f)))};B.prototype.AddPhaserEffect=function(a,b,c,d,e,f,g){J===F&&(a=a.toLowerCase(),g/=100,0>g&&(g=0),1<g&&(g=1),D(a,new p(b,c,d,
e,f,g)))};B.prototype.AddConvolutionEffect=function(a,b,c,d){if(J===F){c=0===c;var e=this.runtime.files_subfolder+b[0]+(W?".ogg":".m4a");b=this.getAudioBuffer(e,!1);a=a.toLowerCase();d/=100;0>d&&(d=0);1<d&&(d=1);b.bufferObject?d=new v(b.bufferObject,c,d,e):(d=new v(null,c,d,e),b.normalizeWhenReady=c,b.convolveWhenReady=d);D(a,d)}};B.prototype.AddGainEffect=function(b,c){J===F&&(b=b.toLowerCase(),D(b,new t(a(c))))};B.prototype.AddMuteEffect=function(a){J===F&&(a=a.toLowerCase(),D(a,new t(0)))};B.prototype.AddTremoloEffect=
function(a,b,c){J===F&&(a=a.toLowerCase(),c/=100,0>c&&(c=0),1<c&&(c=1),D(a,new s(b,c)))};B.prototype.AddRingModEffect=function(a,b,c){J===F&&(a=a.toLowerCase(),c/=100,0>c&&(c=0),1<c&&(c=1),D(a,new m(b,c)))};B.prototype.AddDistortionEffect=function(a,b,c,d,e,f){J===F&&(a=a.toLowerCase(),f/=100,0>f&&(f=0),1<f&&(f=1),D(a,new x(b,c,d,e,f)))};B.prototype.AddCompressorEffect=function(a,b,c,d,e,f){J===F&&(a=a.toLowerCase(),D(a,new z(b,c,d,e/1E3,f/1E3)))};B.prototype.AddAnalyserEffect=function(a,b,c){J===
F&&(a=a.toLowerCase(),D(a,new r(b,c)))};B.prototype.RemoveEffects=function(a){if(J===F){a=a.toLowerCase();var b,c,d;if(N.hasOwnProperty(a)&&(d=N[a],d.length)){b=0;for(c=d.length;b<c;b++)d[b].remove();d.length=0;w(a)}}};B.prototype.SetEffectParameter=function(a,b,c,d,e,f){J===F&&(a=a.toLowerCase(),b=Math.floor(b),N.hasOwnProperty(a)&&(a=N[a],0>b||b>=a.length||a[b].setParam(c,d,e,f)))};B.prototype.SetListenerObject=function(a){a&&J===F&&(a=a.getFirstPicked())&&(this.listenerTracker.setObject(a),Y=a.x,
Z=a.y)};B.prototype.SetListenerZ=function(a){this.listenerZ=a};C.acts=new B;H.prototype.Duration=function(a,b){A(b);O.length?a.set_float(O[0].getDuration()):a.set_float(0)};H.prototype.PlaybackTime=function(a,b){A(b);O.length?a.set_float(O[0].getPlaybackTime()):a.set_float(0)};H.prototype.Volume=function(a,c){A(c);if(O.length){var d=O[0].getVolume();a.set_float(b(d))}else a.set_float(0)};H.prototype.MasterVolume=function(a){a.set_float(X)};H.prototype.EffectCount=function(a,b){b=b.toLowerCase();var c=
null;N.hasOwnProperty(b)&&(c=N[b]);a.set_int(c?c.length:0)};H.prototype.AnalyserFreqBinCount=function(a,b,c){b=b.toLowerCase();c=Math.floor(c);b=K(b,c);a.set_int(b?b.node.frequencyBinCount:0)};H.prototype.AnalyserFreqBinAt=function(a,b,c,d){b=b.toLowerCase();c=Math.floor(c);d=Math.floor(d);(b=K(b,c))?0>d||d>=b.node.frequencyBinCount?a.set_float(0):a.set_float(b.freqBins[d]):a.set_float(0)};H.prototype.AnalyserPeakLevel=function(a,b,c){b=b.toLowerCase();c=Math.floor(c);(b=K(b,c))?a.set_float(b.peak):
a.set_float(0)};H.prototype.AnalyserRMSLevel=function(a,b,c){b=b.toLowerCase();c=Math.floor(c);(b=K(b,c))?a.set_float(b.rms):a.set_float(0)};C.exps=new H})();cr.plugins_.Browser=function(a){this.runtime=a};
(function(){function a(){}function b(){}function e(){"undefined"!==typeof jQuery&&g.setSize(jQuery(window).width(),jQuery(window).height())}function d(){}var c=cr.plugins_.Browser.prototype;c.Type=function(a){this.plugin=a;this.runtime=a.runtime};c.Type.prototype.onCreate=function(){};c.Instance=function(a){this.type=a;this.runtime=a.runtime};c.Instance.prototype.onCreate=function(){var a=this;window.addEventListener("resize",function(){a.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnResize,
a)});"undefined"!==typeof navigator.onLine&&(window.addEventListener("online",function(){a.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnOnline,a)}),window.addEventListener("offline",function(){a.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnOffline,a)}));"undefined"!==typeof window.applicationCache&&(window.applicationCache.addEventListener("updateready",function(){a.runtime.loadingprogress=1;a.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnUpdateReady,a)}),window.applicationCache.addEventListener("progress",
function(b){a.runtime.loadingprogress=b.loaded/b.total}));this.runtime.isDirectCanvas||(document.addEventListener("appMobi.device.update.available",function(){a.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnUpdateReady,a)}),document.addEventListener("menubutton",function(){a.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnMenuButton,a)}),document.addEventListener("searchbutton",function(){a.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnSearchButton,a)}),document.addEventListener("tizenhwkey",
function(b){var c;switch(b.keyName){case "back":c=a.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnBackButton,a);!c&&window.tizen&&window.tizen.application.getCurrentApplication().exit();break;case "menu":(c=a.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnMenuButton,a))||b.preventDefault()}}));this.runtime.addSuspendCallback(function(b){b?a.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnPageHidden,a):a.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnPageVisible,a)});this.is_arcade=
"undefined"!==typeof window.is_scirra_arcade;this.fullscreenOldMarginCss=""};a.prototype.CookiesEnabled=function(){return navigator?navigator.cookieEnabled:!1};a.prototype.IsOnline=function(){return navigator?navigator.onLine:!1};a.prototype.HasJava=function(){return navigator?navigator.javaEnabled():!1};a.prototype.OnOnline=function(){return!0};a.prototype.OnOffline=function(){return!0};a.prototype.IsDownloadingUpdate=function(){return"undefined"===typeof window.applicationCache?!1:window.applicationCache.status===
window.applicationCache.DOWNLOADING};a.prototype.OnUpdateReady=function(){return!0};a.prototype.PageVisible=function(){return!this.runtime.isSuspended};a.prototype.OnPageVisible=function(){return!0};a.prototype.OnPageHidden=function(){return!0};a.prototype.OnResize=function(){return!0};a.prototype.IsFullscreen=function(){return!!(document.mozFullScreen||document.webkitIsFullScreen||document.fullScreen||this.runtime.isNodeFullscreen)};a.prototype.OnBackButton=function(){return!0};a.prototype.OnMenuButton=
function(){return!0};a.prototype.OnSearchButton=function(){return!0};a.prototype.IsMetered=function(){var a=navigator.connection||navigator.mozConnection||navigator.webkitConnection;return a?a.metered:!1};a.prototype.IsCharging=function(){var a=navigator.battery||navigator.mozBattery||navigator.webkitBattery;return a?a.charging:!0};a.prototype.IsPortraitLandscape=function(a){return(window.innerWidth<=window.innerHeight?0:1)===a};c.cnds=new a;b.prototype.Alert=function(a){this.runtime.isDomFree||alert(a.toString())};
b.prototype.Close=function(){this.runtime.isCocoonJs?CocoonJS.App.forceToFinish():this.is_arcade||this.runtime.isDomFree||window.close()};b.prototype.Focus=function(){this.runtime.isNodeWebkit?window.nwgui.Window.get().focus():this.is_arcade||this.runtime.isDomFree||window.focus()};b.prototype.Blur=function(){this.runtime.isNodeWebkit?window.nwgui.Window.get().blur():this.is_arcade||this.runtime.isDomFree||window.blur()};b.prototype.GoBack=function(){this.is_arcade||this.runtime.isDomFree||!window.back||
window.back()};b.prototype.GoForward=function(){this.is_arcade||this.runtime.isDomFree||!window.forward||window.forward()};b.prototype.GoHome=function(){this.is_arcade||this.runtime.isDomFree||!window.home||window.home()};b.prototype.GoToURL=function(a){this.runtime.isCocoonJs?CocoonJS.App.openURL(a):this.is_arcade||this.runtime.isDomFree||(window.location=a)};b.prototype.GoToURLWindow=function(a,b){this.runtime.isCocoonJs?CocoonJS.App.openURL(a):this.is_arcade||this.runtime.isDomFree||window.open(a,
b)};b.prototype.Reload=function(){this.is_arcade||this.runtime.isDomFree||window.location.reload()};var f=!0,g=null;b.prototype.RequestFullScreen=function(a){this.runtime.isDomFree?cr.logexport("[Construct 2] Requesting fullscreen is not supported on this platform - the request has been ignored"):(2<=a&&(a+=1),6===a&&(a=2),this.runtime.isNodeWebkit?this.runtime.isNodeFullscreen||(window.nwgui.Window.get().enterFullscreen(),this.runtime.isNodeFullscreen=!0):document.mozFullScreen||document.webkitIsFullScreen||
document.fullScreen||(this.fullscreenOldMarginCss=jQuery(this.runtime.canvasdiv).css("margin"),jQuery(this.runtime.canvasdiv).css("margin","0"),window.c2resizestretchmode=0<a?1:0,this.runtime.fullscreen_scaling=2<=a?a:0,a=this.runtime.canvasdiv||this.runtime.canvas,f&&(f=!1,g=this.runtime,a.addEventListener("mozfullscreenerror",e),a.addEventListener("webkitfullscreenerror",e),a.addEventListener("msfullscreenerror",e),a.addEventListener("fullscreenerror",e)),cr.is_undefined(a.webkitRequestFullScreen)?
cr.is_undefined(a.mozRequestFullScreen)?cr.is_undefined(a.requestFullscreen)||a.requestFullscreen():a.mozRequestFullScreen():"undefined"!==typeof Element&&"undefined"!==typeof Element.ALLOW_KEYBOARD_INPUT?a.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT):a.webkitRequestFullScreen()))};b.prototype.CancelFullScreen=function(){this.runtime.isDomFree?cr.logexport("[Construct 2] Exiting fullscreen is not supported on this platform - the request has been ignored"):this.runtime.isNodeWebkit?this.runtime.isNodeFullscreen&&
(window.nwgui.Window.get().leaveFullscreen(),this.runtime.isNodeFullscreen=!1):(cr.is_undefined(document.webkitCancelFullScreen)||document.webkitCancelFullScreen(),cr.is_undefined(document.mozCancelFullScreen)||document.mozCancelFullScreen(),cr.is_undefined(document.exitFullscreen)||document.exitFullscreen(),jQuery(this.runtime.canvasdiv).css("margin",this.fullscreenOldMarginCss))};b.prototype.Vibrate=function(a){try{var b=a.split(","),c,d;c=0;for(d=b.length;c<d;c++)b[c]=parseInt(b[c],10);navigator.vibrate?
navigator.vibrate(b):navigator.mozVibrate?navigator.mozVibrate(b):navigator.webkitVibrate&&navigator.webkitVibrate(b)}catch(e){}};b.prototype.InvokeDownload=function(a,b){var c=document.createElement("a");if("undefined"===typeof c.download)window.open(a);else{var d=document.getElementsByTagName("body")[0];c.textContent=b;c.href=a;c.download=b;d.appendChild(c);var e=document.createEvent("MouseEvent");e.initMouseEvent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null);c.dispatchEvent(e);d.removeChild(c)}};
b.prototype.ConsoleLog=function(a,b){console&&(0===a&&console.log&&console.log(b),1===a&&console.warn&&console.warn(b),2===a&&console.error&&console.error(b))};b.prototype.ConsoleGroup=function(a){console&&console.group&&console.group(a)};b.prototype.ConsoleGroupEnd=function(){console&&console.groupEnd&&console.groupEnd()};b.prototype.ExecJs=function(a){eval&&eval(a)};c.acts=new b;d.prototype.URL=function(a){a.set_string(this.runtime.isDomFree?"":window.location.toString())};d.prototype.Protocol=
function(a){a.set_string(this.runtime.isDomFree?"":window.location.protocol)};d.prototype.Domain=function(a){a.set_string(this.runtime.isDomFree?"":window.location.hostname)};d.prototype.PathName=function(a){a.set_string(this.runtime.isDomFree?"":window.location.pathname)};d.prototype.Hash=function(a){a.set_string(this.runtime.isDomFree?"":window.location.hash)};d.prototype.Referrer=function(a){a.set_string(this.runtime.isDomFree?"":document.referrer)};d.prototype.Title=function(a){a.set_string(this.runtime.isDomFree?
"":document.title)};d.prototype.Name=function(a){a.set_string(this.runtime.isDomFree?"":navigator.appName)};d.prototype.Version=function(a){a.set_string(this.runtime.isDomFree?"":navigator.appVersion)};d.prototype.Language=function(a){navigator&&navigator.language?a.set_string(navigator.language):a.set_string("")};d.prototype.Platform=function(a){a.set_string(this.runtime.isDomFree?"":navigator.platform)};d.prototype.Product=function(a){navigator&&navigator.product?a.set_string(navigator.product):
a.set_string("")};d.prototype.Vendor=function(a){navigator&&navigator.vendor?a.set_string(navigator.vendor):a.set_string("")};d.prototype.UserAgent=function(a){a.set_string(this.runtime.isDomFree?"":navigator.userAgent)};d.prototype.QueryString=function(a){a.set_string(this.runtime.isDomFree?"":window.location.search)};d.prototype.QueryParam=function(a,b){if(this.runtime.isDomFree)a.set_string("");else{var c=RegExp("[?&]"+b+"=([^&]*)").exec(window.location.search);c?a.set_string(decodeURIComponent(c[1].replace(/\+/g,
" "))):a.set_string("")}};d.prototype.Bandwidth=function(a){var b=navigator.connection||navigator.mozConnection||navigator.webkitConnection;b?a.set_float(b.bandwidth):a.set_float(Number.POSITIVE_INFINITY)};d.prototype.BatteryLevel=function(a){var b=navigator.battery||navigator.mozBattery||navigator.webkitBattery;b?a.set_float(b.level):a.set_float(1)};d.prototype.BatteryTimeLeft=function(a){var b=navigator.battery||navigator.mozBattery||navigator.webkitBattery;b?a.set_float(b.dischargingTime):a.set_float(Number.POSITIVE_INFINITY)};
d.prototype.ExecJS=function(a,b){if(eval){var c=eval(b);"number"===typeof c?a.set_any(c):"string"===typeof c?a.set_any(c):"boolean"===typeof c?a.set_any(c?1:0):a.set_any(0)}else a.set_any(0)};d.prototype.ScreenWidth=function(a){a.set_int(screen.width)};d.prototype.ScreenHeight=function(a){a.set_int(screen.height)};d.prototype.DevicePixelRatio=function(a){a.set_float(this.runtime.devicePixelRatio)};c.exps=new d})();cr.plugins_.Button=function(a){this.runtime=a};
(function(){function a(){}function b(){}var e=cr.plugins_.Button.prototype;e.Type=function(a){this.plugin=a;this.runtime=a.runtime};e.Type.prototype.onCreate=function(){};e.Instance=function(a){this.type=a;this.runtime=a.runtime};var d=e.Instance.prototype;d.onCreate=function(){this.runtime.isDomFree?cr.logexport("[Construct 2] Button plugin not supported on this platform - the object will not be created"):(this.isCheckbox=1===this.properties[0],this.inputElem=document.createElement("input"),this.elem=
this.isCheckbox?document.createElement("label"):this.inputElem,this.labelText=null,this.inputElem.type=this.isCheckbox?"checkbox":"button",this.inputElem.id=this.properties[6],jQuery(this.elem).appendTo(this.runtime.canvasdiv?this.runtime.canvasdiv:"body"),this.isCheckbox?(jQuery(this.inputElem).appendTo(this.elem),this.labelText=document.createTextNode(this.properties[1]),jQuery(this.elem).append(this.labelText),this.inputElem.checked=0!==this.properties[7],jQuery(this.elem).css("font-family","sans-serif"),
jQuery(this.elem).css("display","inline-block"),jQuery(this.elem).css("color","black")):this.inputElem.value=this.properties[1],this.elem.title=this.properties[2],this.inputElem.disabled=0===this.properties[4],this.autoFontSize=0!==this.properties[5],this.element_hidden=!1,0===this.properties[3]&&(jQuery(this.elem).hide(),this.visible=!1,this.element_hidden=!0),this.inputElem.onclick=function(a){return function(b){b.stopPropagation();a.runtime.trigger(cr.plugins_.Button.prototype.cnds.OnClicked,a)}}(this),
this.elem.addEventListener("touchstart",function(a){a.stopPropagation()},!1),this.elem.addEventListener("touchmove",function(a){a.stopPropagation()},!1),this.elem.addEventListener("touchend",function(a){a.stopPropagation()},!1),jQuery(this.elem).mousedown(function(a){a.stopPropagation()}),jQuery(this.elem).mouseup(function(a){a.stopPropagation()}),jQuery(this.elem).keydown(function(a){a.stopPropagation()}),jQuery(this.elem).keyup(function(a){a.stopPropagation()}),this.lastWinHeight=this.lastWinWidth=
this.lastBottom=this.lastRight=this.lastTop=this.lastLeft=0,this.updatePosition(!0),this.runtime.tickMe(this))};d.saveToJSON=function(){var a={tooltip:this.elem.title,disabled:!!this.inputElem.disabled};this.isCheckbox?(a.checked=!!this.inputElem.checked,a.text=this.labelText.nodeValue):a.text=this.elem.value;return a};d.loadFromJSON=function(a){this.elem.title=a.tooltip;this.inputElem.disabled=a.disabled;this.isCheckbox?(this.inputElem.checked=a.checked,this.labelText.nodeValue=a.text):this.elem.value=
a.text};d.onDestroy=function(){this.runtime.isDomFree||(jQuery(this.elem).remove(),this.elem=null)};d.tick=function(){this.updatePosition()};d.updatePosition=function(a){if(!this.runtime.isDomFree){var b=this.layer.layerToCanvas(this.x,this.y,!0),d=this.layer.layerToCanvas(this.x,this.y,!1),e=this.layer.layerToCanvas(this.x+this.width,this.y+this.height,!0),l=this.layer.layerToCanvas(this.x+this.width,this.y+this.height,!1);if(!this.visible||!this.layer.visible||0>=e||0>=l||b>=this.runtime.width||
d>=this.runtime.height)this.element_hidden||jQuery(this.elem).hide(),this.element_hidden=!0;else{1>b&&(b=1);1>d&&(d=1);e>=this.runtime.width&&(e=this.runtime.width-1);l>=this.runtime.height&&(l=this.runtime.height-1);var k=window.innerWidth,n=window.innerHeight;a||this.lastLeft!==b||this.lastTop!==d||this.lastRight!==e||this.lastBottom!==l||this.lastWinWidth!==k||this.lastWinHeight!==n?(this.lastLeft=b,this.lastTop=d,this.lastRight=e,this.lastBottom=l,this.lastWinWidth=k,this.lastWinHeight=n,this.element_hidden&&
(jQuery(this.elem).show(),this.element_hidden=!1),a=Math.round(b)+jQuery(this.runtime.canvas).offset().left,k=Math.round(d)+jQuery(this.runtime.canvas).offset().top,jQuery(this.elem).css("position","absolute"),jQuery(this.elem).offset({left:a,top:k}),jQuery(this.elem).width(Math.round(e-b)),jQuery(this.elem).height(Math.round(l-d)),this.autoFontSize&&jQuery(this.elem).css("font-size",this.layer.getScale()/this.runtime.devicePixelRatio-0.2+"em")):this.element_hidden&&(jQuery(this.elem).show(),this.element_hidden=
!1)}}};d.draw=function(a){};d.drawGL=function(a){};a.prototype.OnClicked=function(){return!0};a.prototype.IsChecked=function(){return this.isCheckbox&&this.inputElem.checked};e.cnds=new a;b.prototype.SetText=function(a){this.runtime.isDomFree||(this.isCheckbox?this.labelText.nodeValue=a:this.elem.value=a)};b.prototype.SetTooltip=function(a){this.runtime.isDomFree||(this.elem.title=a)};b.prototype.SetVisible=function(a){this.runtime.isDomFree||(this.visible=0!==a)};b.prototype.SetEnabled=function(a){this.runtime.isDomFree||
(this.inputElem.disabled=0===a)};b.prototype.SetFocus=function(){this.runtime.isDomFree||this.inputElem.focus()};b.prototype.SetBlur=function(){this.runtime.isDomFree||this.inputElem.blur()};b.prototype.SetCSSStyle=function(a,b){this.runtime.isDomFree||jQuery(this.elem).css(a,b)};b.prototype.SetChecked=function(a){!this.runtime.isDomFree&&this.isCheckbox&&(this.inputElem.checked=1===a)};b.prototype.ToggleChecked=function(){!this.runtime.isDomFree&&this.isCheckbox&&(this.inputElem.checked=!this.inputElem.checked)};
e.acts=new b;e.exps=new function(){}})();cr.plugins_.Facebook=function(a){this.runtime=a};
(function(){function a(){l||(l=!0,p.trigger(cr.plugins_.Facebook.prototype.cnds.OnLogIn,t),FB.api("/me",function(a){n=a.name;v=a.first_name;u=a.last_name;p.trigger(cr.plugins_.Facebook.prototype.cnds.OnNameAvailable,t)}))}function b(){}function e(){}function d(){}var c=cr.plugins_.Facebook.prototype;c.Type=function(a){this.plugin=a;this.runtime=a.runtime};var f="",g="",h=!1,l=!1,k="",n="",v="",u="",p=null,t=null,s=0,m="",x=0,z=0,r=!1,q=!1,G="";c.Type.prototype.onCreate=function(){};c.Instance=function(a){this.type=
a;this.runtime=a.runtime};var y=c.Instance.prototype;y.onCreate=function(){this.runtime.isDomFree?cr.logexport("[Construct 2] Facebook plugin not supported on this platform - the object will not be created"):(f=this.properties[0],g=this.properties[1],p=this.runtime,t=this,window.fbAsyncInit=function(){var b=location.pathname;"/"!==b.substr(b.length-1)&&(b=b.substr(0,b.lastIndexOf("/")+1));FB.init({appId:f,channelURL:"//"+location.hostname+b+"channel.html",status:!0,cookie:!0,oauth:!0,xfbml:!1});h=
!0;FB.Event.subscribe("auth.login",function(b){k=b.authResponse.userID;a()});FB.Event.subscribe("auth.logout",function(a){l&&(l=!1,u=v=n="",p.trigger(cr.plugins_.Facebook.prototype.cnds.OnLogOut,t))});FB.getLoginStatus(function(b){b.authResponse&&(k=b.authResponse.userID,a())});p.trigger(cr.plugins_.Facebook.prototype.cnds.OnReady,t)},f.length&&function(a){var b;a.getElementById("facebook-jssdk")||(b=a.createElement("script"),b.id="facebook-jssdk",b.async=!0,b.src="//connect.facebook.net/en_US/all.js",
a.getElementsByTagName("head")[0].appendChild(b))}(document))};y.onLayoutChange=function(){this.runtime.isDomFree||(l&&p.trigger(cr.plugins_.Facebook.prototype.cnds.OnLogIn,t),n.length&&p.trigger(cr.plugins_.Facebook.prototype.cnds.OnNameAvailable,t))};b.prototype.IsReady=function(){return h};b.prototype.OnReady=function(){return!0};b.prototype.IsLoggedIn=function(){return l};b.prototype.OnLogIn=function(){return!0};b.prototype.OnLogOut=function(){return!0};b.prototype.OnNameAvailable=function(){return!0};
b.prototype.OnUserTopScoreAvailable=function(){return!0};b.prototype.OnHiscore=function(){return!0};b.prototype.OnScoreSubmitted=function(){return!0};c.cnds=new b;e.prototype.LogIn=function(b,c){if(!this.runtime.isDomFree&&h){r=1===b;q=1===c;var d=[];r&&d.push("publish_stream");q&&d.push("publish_actions");G=d.join();FB.login(function(b){b.authResponse&&a()},{scope:G})}};e.prototype.LogOut=function(){this.runtime.isDomFree||l&&FB.logout(function(a){})};e.prototype.PromptWallPost=function(){!this.runtime.isDomFree&&
l&&FB.ui({method:"feed"},function(a){a&&!a.error||console.error(a)})};e.prototype.PromptToShareApp=function(a,b,c,d){!this.runtime.isDomFree&&l&&FB.ui({method:"feed",link:"http://apps.facebook.com/"+f+"/",picture:d,name:a,caption:b,description:c},function(a){a&&!a.error||console.error(a)})};e.prototype.PromptToShareLink=function(a,b,c,d,e){!this.runtime.isDomFree&&l&&FB.ui({method:"feed",link:a,picture:e,name:b,caption:c,description:d},function(a){a&&!a.error||console.error(a)})};e.prototype.PublishToWall=
function(a){!this.runtime.isDomFree&&l&&FB.api("/me/feed","POST",{method:"stream.publish",message:a},function(a){a&&!a.error||console.error(a)})};e.prototype.PublishLink=function(a,b,c,d,e,f){!this.runtime.isDomFree&&l&&(a={method:"stream.publish",message:a,link:b,name:c,caption:d,description:e},f.length&&(a.picture=f),FB.api("/me/feed","POST",a,function(a){a&&!a.error||console.error(a)}))};e.prototype.PublishScore=function(a){!this.runtime.isDomFree&&l&&FB.api("/"+k+"/scores","POST",{score:Math.floor(a),
access_token:f+"|"+g},function(a){p.trigger(cr.plugins_.Facebook.prototype.cnds.OnScoreSubmitted,t);a&&!a.error||console.error(a)})};e.prototype.RequestUserHiscore=function(){!this.runtime.isDomFree&&l&&FB.api("/me/scores","GET",{},function(a){s=0;var b=a.data;if(b){var c,d;c=0;for(d=b.length;c<d;c++)b[c].score>s&&(s=b[c].score);p.trigger(cr.plugins_.Facebook.prototype.cnds.OnUserTopScoreAvailable,t);a&&!a.error||console.error(a)}else console.error("Request for user hi-score failed: "+a)})};e.prototype.RequestHiscores=
function(a){!this.runtime.isDomFree&&l&&FB.api("/"+f+"/scores","GET",{},function(b){var c=b.data;if(c){c.sort(function(a,b){return b.score-a.score});for(var d=0,e=Math.min(c.length,a);d<e;d++)s=c[d].score,m=c[d].user.name,x=c[d].user.id,z=d+1,p.trigger(cr.plugins_.Facebook.prototype.cnds.OnHiscore,t);b&&!b.error||console.error(b)}else console.error("Hi-scores request failed: "+b)})};c.acts=new e;d.prototype.FullName=function(a){a.set_string(n)};d.prototype.FirstName=function(a){a.set_string(v)};d.prototype.LastName=
function(a){a.set_string(u)};d.prototype.Score=function(a){a.set_int(s)};d.prototype.HiscoreName=function(a){a.set_string(m)};d.prototype.HiscoreUserID=function(a){a.set_int(x)};d.prototype.HiscoreRank=function(a){a.set_int(z)};d.prototype.UserID=function(a){a.set_float(parseFloat(k))};c.exps=new d})();cr.plugins_.Keyboard=function(a){this.runtime=a};
(function(){function a(){}function b(){}function e(a){a=Math.floor(a);switch(a){case 8:return"backspace";case 9:return"tab";case 13:return"enter";case 16:return"shift";case 17:return"control";case 18:return"alt";case 19:return"pause";case 20:return"capslock";case 27:return"esc";case 33:return"pageup";case 34:return"pagedown";case 35:return"end";case 36:return"home";case 37:return"\u2190";case 38:return"\u2191";case 39:return"\u2192";case 40:return"\u2193";case 45:return"insert";case 46:return"del";
case 91:return"left window key";case 92:return"right window key";case 93:return"select";case 96:return"numpad 0";case 97:return"numpad 1";case 98:return"numpad 2";case 99:return"numpad 3";case 100:return"numpad 4";case 101:return"numpad 5";case 102:return"numpad 6";case 103:return"numpad 7";case 104:return"numpad 8";case 105:return"numpad 9";case 106:return"numpad *";case 107:return"numpad +";case 109:return"numpad -";case 110:return"numpad .";case 111:return"numpad /";case 112:return"F1";case 113:return"F2";
case 114:return"F3";case 115:return"F4";case 116:return"F5";case 117:return"F6";case 118:return"F7";case 119:return"F8";case 120:return"F9";case 121:return"F10";case 122:return"F11";case 123:return"F12";case 144:return"numlock";case 145:return"scroll lock";case 186:return";";case 187:return"=";case 188:return",";case 189:return"-";case 190:return".";case 191:return"/";case 192:return"'";case 219:return"[";case 220:return"\\";case 221:return"]";case 222:return"#";case 223:return"`";default:return String.fromCharCode(a)}}
var d=cr.plugins_.Keyboard.prototype;d.Type=function(a){this.plugin=a;this.runtime=a.runtime};d.Type.prototype.onCreate=function(){};d.Instance=function(a){this.type=a;this.runtime=a.runtime;this.keyMap=Array(256);this.usedKeys=Array(256);this.triggerKey=0};var c=d.Instance.prototype;c.onCreate=function(){var a=this;this.runtime.isDomFree||(jQuery(document).keydown(function(b){a.onKeyDown(b)}),jQuery(document).keyup(function(b){a.onKeyUp(b)}))};var f=[32,33,34,35,36,37,38,39,40,44];c.onKeyDown=function(a){var b=
!1;window!=window.top&&-1<f.indexOf(a.which)&&(a.preventDefault(),b=!0,a.stopPropagation());if(this.keyMap[a.which])this.usedKeys[a.which]&&!b&&a.preventDefault();else{this.keyMap[a.which]=!0;this.triggerKey=a.which;this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnAnyKey,this);var c=this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnKey,this),d=this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnKeyCode,this);if(c||d)this.usedKeys[a.which]=!0,b||a.preventDefault()}};c.onKeyUp=
function(a){this.keyMap[a.which]=!1;this.triggerKey=a.which;this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnAnyKeyReleased,this);var b=this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnKeyReleased,this),c=this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnKeyCodeReleased,this);if(b||c||this.usedKeys[a.which])this.usedKeys[a.which]=!0,a.preventDefault()};c.saveToJSON=function(){return{triggerKey:this.triggerKey}};c.loadFromJSON=function(a){this.triggerKey=a.triggerKey};
a.prototype.IsKeyDown=function(a){return this.keyMap[a]};a.prototype.OnKey=function(a){return a===this.triggerKey};a.prototype.OnAnyKey=function(a){return!0};a.prototype.OnAnyKeyReleased=function(a){return!0};a.prototype.OnKeyReleased=function(a){return a===this.triggerKey};a.prototype.IsKeyCodeDown=function(a){a=Math.floor(a);return 0>a||a>=this.keyMap.length?!1:this.keyMap[a]};a.prototype.OnKeyCode=function(a){return a===this.triggerKey};a.prototype.OnKeyCodeReleased=function(a){return a===this.triggerKey};
d.cnds=new a;d.acts=new function(){};b.prototype.LastKeyCode=function(a){a.set_int(this.triggerKey)};b.prototype.StringFromKeyCode=function(a,b){a.set_string(e(b))};d.exps=new b})();cr.plugins_.Mouse=function(a){this.runtime=a};
(function(){function a(){}function b(){}function e(){}var d=cr.plugins_.Mouse.prototype;d.Type=function(a){this.plugin=a;this.runtime=a.runtime};d.Type.prototype.onCreate=function(){};d.Instance=function(a){this.type=a;this.runtime=a.runtime;this.buttonMap=Array(4);this.triggerDir=this.triggerType=this.triggerButton=this.mouseYcanvas=this.mouseXcanvas=0;this.handled=!1};var c=d.Instance.prototype;c.onCreate=function(){var a=this;if(!this.runtime.isDomFree){jQuery(document).mousemove(function(b){a.onMouseMove(b)});
jQuery(document).mousedown(function(b){a.onMouseDown(b)});jQuery(document).mouseup(function(b){a.onMouseUp(b)});jQuery(document).dblclick(function(b){a.onDoubleClick(b)});var b=function(b){a.onWheel(b)};document.addEventListener("mousewheel",b,!1);document.addEventListener("DOMMouseScroll",b,!1)}};var f={left:0,top:0};c.onMouseMove=function(a){var b=this.runtime.isDomFree?f:jQuery(this.runtime.canvas).offset();this.mouseXcanvas=a.pageX-b.left;this.mouseYcanvas=a.pageY-b.top};c.mouseInGame=function(){return 0<
this.runtime.fullscreen_mode?!0:0<=this.mouseXcanvas&&0<=this.mouseYcanvas&&this.mouseXcanvas<this.runtime.width&&this.mouseYcanvas<this.runtime.height};c.onMouseDown=function(a){this.mouseInGame()&&(this.runtime.had_a_click&&a.preventDefault(),this.buttonMap[a.which]=!0,this.runtime.trigger(cr.plugins_.Mouse.prototype.cnds.OnAnyClick,this),this.triggerButton=a.which-1,this.triggerType=0,this.runtime.trigger(cr.plugins_.Mouse.prototype.cnds.OnClick,this),this.runtime.trigger(cr.plugins_.Mouse.prototype.cnds.OnObjectClicked,
this))};c.onMouseUp=function(a){this.buttonMap[a.which]&&(this.runtime.had_a_click&&a.preventDefault(),this.runtime.had_a_click=!0,this.buttonMap[a.which]=!1,this.triggerButton=a.which-1,this.runtime.trigger(cr.plugins_.Mouse.prototype.cnds.OnRelease,this))};c.onDoubleClick=function(a){this.mouseInGame()&&(a.preventDefault(),this.triggerButton=a.which-1,this.triggerType=1,this.runtime.trigger(cr.plugins_.Mouse.prototype.cnds.OnClick,this),this.runtime.trigger(cr.plugins_.Mouse.prototype.cnds.OnObjectClicked,
this))};c.onWheel=function(a){this.triggerDir=0>(a.wheelDelta?a.wheelDelta:a.detail?-a.detail:0)?0:1;this.handled=!1;this.runtime.trigger(cr.plugins_.Mouse.prototype.cnds.OnWheel,this);this.handled&&a.preventDefault()};a.prototype.OnClick=function(a,b){return a===this.triggerButton&&b===this.triggerType};a.prototype.OnAnyClick=function(){return!0};a.prototype.IsButtonDown=function(a){return this.buttonMap[a+1]};a.prototype.OnRelease=function(a){return a===this.triggerButton};a.prototype.IsOverObject=
function(a){var b=this.runtime.getCurrentCondition();return cr.xor(this.runtime.testAndSelectCanvasPointOverlap(a,this.mouseXcanvas,this.mouseYcanvas,b.inverted),b.inverted)};a.prototype.OnObjectClicked=function(a,b,c){return a!==this.triggerButton||b!==this.triggerType?!1:this.runtime.testAndSelectCanvasPointOverlap(c,this.mouseXcanvas,this.mouseYcanvas,!1)};a.prototype.OnWheel=function(a){this.handled=!0;return a===this.triggerDir};d.cnds=new a;b.prototype.SetCursor=function(a){a="auto pointer text crosshair move help wait none".split(" ")[a];
this.runtime.canvas&&this.runtime.canvas.style&&(this.runtime.canvas.style.cursor=a)};b.prototype.SetCursorSprite=function(a){this.runtime.isDomFree||this.runtime.isMobile||!a||(a=a.getFirstPicked())&&a.curFrame&&(a=a.curFrame,a="url("+a.getDataUri()+") "+Math.round(a.hotspotX*a.width)+" "+Math.round(a.hotspotY*a.height)+", auto",jQuery(this.runtime.canvas).css("cursor",a))};d.acts=new b;e.prototype.X=function(a,b){var c,d,e,f,u;cr.is_undefined(b)?(c=this.runtime.getLayerByNumber(0),d=c.scale,e=c.zoomRate,
f=c.parallaxX,u=c.angle,c.scale=this.runtime.running_layout.scale,c.zoomRate=1,c.parallaxX=1,c.angle=this.runtime.running_layout.angle,a.set_float(c.canvasToLayer(this.mouseXcanvas,this.mouseYcanvas,!0)),c.scale=d,c.zoomRate=e,c.parallaxX=f,c.angle=u):(c=cr.is_number(b)?this.runtime.getLayerByNumber(b):this.runtime.getLayerByName(b))?a.set_float(c.canvasToLayer(this.mouseXcanvas,this.mouseYcanvas,!0)):a.set_float(0)};e.prototype.Y=function(a,b){var c,d,e,f,u;cr.is_undefined(b)?(c=this.runtime.getLayerByNumber(0),
d=c.scale,e=c.zoomRate,f=c.parallaxY,u=c.angle,c.scale=this.runtime.running_layout.scale,c.zoomRate=1,c.parallaxY=1,c.angle=this.runtime.running_layout.angle,a.set_float(c.canvasToLayer(this.mouseXcanvas,this.mouseYcanvas,!1)),c.scale=d,c.zoomRate=e,c.parallaxY=f,c.angle=u):(c=cr.is_number(b)?this.runtime.getLayerByNumber(b):this.runtime.getLayerByName(b))?a.set_float(c.canvasToLayer(this.mouseXcanvas,this.mouseYcanvas,!1)):a.set_float(0)};e.prototype.AbsoluteX=function(a){a.set_float(this.mouseXcanvas)};
e.prototype.AbsoluteY=function(a){a.set_float(this.mouseYcanvas)};d.exps=new e})();cr.plugins_.NodeWebkit=function(a){this.runtime=a};
(function(){function a(){}function b(){}function e(){}var d=!1,c=null,f=null,g=null,h=null,l="",k="",n="\\",v=[],u="",p="",t=cr.plugins_.NodeWebkit.prototype;t.Type=function(a){this.plugin=a;this.runtime=a.runtime};t.Type.prototype.onCreate=function(){};t.Instance=function(a){this.type=a;this.runtime=a.runtime};var s=t.Instance.prototype;s.onCreate=function(){d=this.runtime.isNodeWebkit;var a=this;d&&(c=require("path"),f=require("fs"),h=require("child_process"),"win32"!==process.platform&&(n="/"),
l=c.dirname(process.execPath)+n,k=(process.env.HOME||process.env.HOMEPATH||process.env.USERPROFILE)+n,g=require("nw.gui"),window.ondrop=function(b){b.preventDefault();for(var c=0;c<b.dataTransfer.files.length;++c)u=b.dataTransfer.files[c].path,a.runtime.trigger(cr.plugins_.NodeWebkit.prototype.cnds.OnFileDrop,a);return!1},jQuery("#c2nwOpenFileDialog").change(function(b){p=jQuery(this).val();a.runtime.trigger(cr.plugins_.NodeWebkit.prototype.cnds.OnOpenDlg,a)}),jQuery("#c2nwChooseFolderDialog").change(function(b){p=
jQuery(this).val();a.runtime.trigger(cr.plugins_.NodeWebkit.prototype.cnds.OnFolderDlg,a)}),jQuery("#c2nwSaveDialog").change(function(b){p=jQuery(this).val();a.runtime.trigger(cr.plugins_.NodeWebkit.prototype.cnds.OnSaveDlg,a)}))};s.onDestroy=function(){};s.saveToJSON=function(){return{}};s.loadFromJSON=function(a){};a.prototype.PathExists=function(a){return d?f.existsSync(a):!1};a.prototype.OnFileDrop=function(){return!0};a.prototype.OnOpenDlg=function(){return!0};a.prototype.OnFolderDlg=function(){return!0};
a.prototype.OnSaveDlg=function(){return!0};t.cnds=new a;b.prototype.WriteFile=function(a,b){if(d)try{f.writeFileSync(a,b,{encoding:"utf8"})}catch(c){}};b.prototype.RenameFile=function(a,b){if(d)try{f.renameSync(a,b)}catch(c){}};b.prototype.DeleteFile=function(a){if(d)try{f.unlinkSync(a)}catch(b){}};b.prototype.CopyFile=function(a,b){if(d&&a!==b)try{var c=f.readFileSync(a,{flags:"rb"});f.writeFileSync(b,c,{flags:"wb"})}catch(e){}};b.prototype.MoveFile=function(a,b){if(d&&a!==b)try{var c=f.readFileSync(a,
{flags:"rb"});f.writeFileSync(b,c,{flags:"wb"});f.existsSync(b)&&f.unlinkSync(a)}catch(e){}};b.prototype.RunFile=function(a){d&&h.exec(a,function(){})};b.prototype.CreateFolder=function(a){if(d)try{f.mkdirSync(a)}catch(b){}};b.prototype.AppendFile=function(a,b){if(d)try{f.appendFileSync(a,b,{encoding:"utf8"})}catch(c){}};b.prototype.ListFiles=function(a){if(d){try{v=f.readdirSync(a)}catch(b){}v||(v=[])}};b.prototype.ShowOpenDlg=function(a){if(d){var b=jQuery("#c2nwOpenFileDialog");b.attr("accept",
a);b.trigger("click")}};b.prototype.ShowFolderDlg=function(a){d&&jQuery("#c2nwChooseFolderDialog").trigger("click")};b.prototype.ShowSaveDlg=function(a){if(d){var b=jQuery("#c2nwSaveDialog");b.attr("accept",a);b.trigger("click")}};b.prototype.SetWindowX=function(a){d&&(g.Window.get().x=a)};b.prototype.SetWindowY=function(a){d&&(g.Window.get().y=a)};b.prototype.SetWindowWidth=function(a){d&&(g.Window.get().width=a)};b.prototype.SetWindowHeight=function(a){d&&(g.Window.get().height=a)};b.prototype.SetWindowTitle=
function(a){d&&(g.Window.get().title=a)};b.prototype.WindowMinimize=function(){d&&g.Window.get().minimize()};b.prototype.WindowMaximize=function(){d&&g.Window.get().maximize()};b.prototype.WindowUnmaximize=function(){d&&g.Window.get().unmaximize()};b.prototype.WindowRestore=function(){d&&g.Window.get().restore()};b.prototype.WindowRequestAttention=function(a){d&&g.Window.get().requestAttention(0===a)};b.prototype.WindowSetMaxSize=function(a,b){d&&g.Window.get().setMaximumSize(a,b)};b.prototype.WindowSetMinSize=
function(a,b){d&&g.Window.get().setMinimumSize(a,b)};b.prototype.WindowSetResizable=function(a){d&&g.Window.get().setResizable(0!==a)};b.prototype.WindowSetAlwaysOnTop=function(a){d&&g.Window.get().setAlwaysOnTop(0!==a)};b.prototype.ShowDevTools=function(){d&&g.Window.get().showDevTools()};b.prototype.SetClipboardText=function(a){d&&g.Clipboard.get().set(a)};b.prototype.ClearClipboard=function(){d&&g.Clipboard.get().clear()};t.acts=new b;e.prototype.AppFolder=function(a){a.set_string(l)};e.prototype.UserFolder=
function(a){a.set_string(k)};e.prototype.ReadFile=function(a,b){if(d){var c="";try{c=f.readFileSync(b,{encoding:"utf8"})}catch(e){}a.set_string(c)}else a.set_string("")};e.prototype.ListCount=function(a){a.set_int(v.length)};e.prototype.ListAt=function(a,b){b=Math.floor(b);0>b||b>=v.length?a.set_string(""):a.set_string(v[b])};e.prototype.DroppedFile=function(a){a.set_string(u)};e.prototype.ChosenPath=function(a){a.set_string(p)};e.prototype.WindowX=function(a){a.set_int(d?g.Window.get().x:0)};e.prototype.WindowY=
function(a){a.set_int(d?g.Window.get().y:0)};e.prototype.WindowWidth=function(a){a.set_int(d?g.Window.get().width:0)};e.prototype.WindowHeight=function(a){a.set_int(d?g.Window.get().height:0)};e.prototype.WindowTitle=function(a){a.set_string(d?g.Window.get().title||"":0)};e.prototype.ClipboardText=function(a){a.set_string(d?g.Clipboard.get().get()||"":0)};t.exps=new e})();cr.plugins_.Sprite=function(a){this.runtime=a};
(function(){function a(){if(0===this.datauri.length){var a=document.createElement("canvas");a.width=this.width;a.height=this.height;var b=a.getContext("2d");this.spritesheeted?b.drawImage(this.texture_img,this.offx,this.offy,this.width,this.height,0,0,this.width,this.height):b.drawImage(this.texture_img,0,0,this.width,this.height);this.datauri=a.toDataURL("image/png")}return this.datauri}function b(){}function e(a,b,c){var d;d=u.length?u.pop():[0,0];d[0]=b.uid;d[1]=c.uid;a.push(d)}function d(a,b,
c){b=b.uid;var d=c.uid,e=0,f,g;c=0;for(f=a.length;c<f;c++)g=a[c],g[0]===b&&g[1]===d||g[0]===d&&g[1]===b||(a[e][0]=a[c][0],a[e][1]=a[c][1],e++);for(c=e;c<f;c++)b=a[c],b[0]=0,b[1]=0,u.push(b);a.length=e}function c(a,b,c){b=b.uid;c=c.uid;var d,e,f;d=0;for(e=a.length;d<e;d++)if(f=a[d],f[0]===b&&f[1]===c||f[0]===c&&f[1]===b)return!0;return!1}function f(a,b,c){if(!a)return!1;var d=0!==b||0!==c,e,f,g=!1,h,k=this.runtime.getCurrentCondition(),n=k.type,k=k.inverted,l=a.getCurrentSol();h=this.runtime.getCurrentEventStack().current_event.orblock;
l=l.select_all?l.type.instances:h?l.else_instances:l.instances;p=a;s=n!==a&&!k;d&&(e=this.x,f=this.y,this.x+=b,this.y+=c,this.set_bbox_changed());b=0;for(c=l.length;b<c;b++)if(h=l[b],this.runtime.testOverlap(this,h)){g=!0;if(k)break;n!==a&&t.add(h)}d&&(this.x=e,this.y=f,this.set_bbox_changed());return g}function g(){}function h(){}var l=cr.plugins_.Sprite.prototype;l.Type=function(a){this.plugin=a;this.runtime=a.runtime};var k=l.Type.prototype;k.onCreate=function(){if(!this.is_family){var b,c,d,e,
f,g,h,p,k;this.all_frames=[];this.has_loaded_textures=!1;b=0;for(c=this.animations.length;b<c;b++){f=this.animations[b];h={};h.name=f[0];h.speed=f[1];h.loop=f[2];h.repeatcount=f[3];h.repeatto=f[4];h.pingpong=f[5];h.sid=f[6];h.frames=[];d=0;for(e=f[7].length;d<e;d++)g=f[7][d],p={},p.texture_file=g[0],p.texture_filesize=g[1],p.offx=g[2],p.offy=g[3],p.width=g[4],p.height=g[5],p.duration=g[6],p.hotspotX=g[7],p.hotspotY=g[8],p.image_points=g[9],p.poly_pts=g[10],p.pixelformat=g[11],p.spritesheeted=0!==
p.width,p.datauri="",p.getDataUri=a,k={left:0,top:0,right:1,bottom:1},p.sheetTex=k,p.webGL_texture=null,(k=this.runtime.findWaitingTexture(g[0]))?p.texture_img=k:(p.texture_img=new Image,p.texture_img.idtkLoadDisposed=!0,p.texture_img.src=g[0],p.texture_img.cr_src=g[0],p.texture_img.cr_filesize=g[1],p.texture_img.c2webGL_texture=null,this.runtime.wait_for_textures.push(p.texture_img)),cr.seal(p),h.frames.push(p),this.all_frames.push(p);cr.seal(h);this.animations[b]=h}}};k.updateAllCurrentTexture=
function(){var a,b,c;a=0;for(b=this.instances.length;a<b;a++)c=this.instances[a],c.curWebGLTexture=c.curFrame.webGL_texture};k.onLostWebGLContext=function(){if(!this.is_family){var a,b,c;a=0;for(b=this.all_frames.length;a<b;++a)c=this.all_frames[a],c.texture_img.c2webGL_texture=null,c.webGL_texture=null}};k.onRestoreWebGLContext=function(){if(!this.is_family&&this.instances.length){var a,b,c;a=0;for(b=this.all_frames.length;a<b;++a)c=this.all_frames[a],c.webGL_texture=this.runtime.glwrap.loadTexture(c.texture_img,
!1,this.runtime.linearSampling,c.pixelformat);this.updateAllCurrentTexture()}};k.loadTextures=function(){if(!this.is_family&&!this.has_loaded_textures&&this.runtime.glwrap){var a,b,c;a=0;for(b=this.all_frames.length;a<b;++a)c=this.all_frames[a],c.webGL_texture=this.runtime.glwrap.loadTexture(c.texture_img,!1,this.runtime.linearSampling,c.pixelformat);this.has_loaded_textures=!0}};k.unloadTextures=function(){if(!this.is_family&&!this.instances.length&&this.has_loaded_textures){var a,b,c;a=0;for(b=
this.all_frames.length;a<b;++a)c=this.all_frames[a],this.runtime.glwrap.deleteTexture(c.webGL_texture);this.has_loaded_textures=!1}};var n=[];k.preloadCanvas2D=function(a){var b,c,d;b=n.length=0;for(c=this.all_frames.length;b<c;++b)d=this.all_frames[b].texture_img,-1===n.indexOf(d)&&(a.drawImage(d,0,0),n.push(d))};l.Instance=function(a){this.type=a;this.runtime=a.runtime;a=this.type.animations[0].frames[0].poly_pts;this.recycled?this.collision_poly.set_pts(a):this.collision_poly=new cr.CollisionPoly(a)};
var v=l.Instance.prototype;v.onCreate=function(){this.visible=0===this.properties[0];this.inAnimTrigger=this.isTicking=!1;this.collisionsEnabled=0!==this.properties[3];1===this.type.animations.length&&1===this.type.animations[0].frames.length||0===this.type.animations[0].speed||(this.runtime.tickMe(this),this.isTicking=!0);this.cur_animation=this.getAnimationByName(this.properties[1])||this.type.animations[0];this.cur_frame=this.properties[2];0>this.cur_frame&&(this.cur_frame=0);this.cur_frame>=this.cur_animation.frames.length&&
(this.cur_frame=this.cur_animation.frames.length-1);var a=this.cur_animation.frames[this.cur_frame];this.collision_poly.set_pts(a.poly_pts);this.hotspotX=a.hotspotX;this.hotspotY=a.hotspotY;this.cur_anim_speed=this.cur_animation.speed;this.recycled?this.animTimer.reset():this.animTimer=new cr.KahanAdder;this.frameStart=this.getNowTime();this.animPlaying=!0;this.animRepeats=0;this.animForwards=!0;this.changeAnimName=this.animTriggerName="";this.changeAnimFrom=0;this.changeAnimFrame=-1;this.type.loadTextures();
var b,c,d,e,f,g,h,a=0;for(b=this.type.animations.length;a<b;a++)for(e=this.type.animations[a],c=0,d=e.frames.length;c<d;c++)f=e.frames[c],0===f.width&&(f.width=f.texture_img.width,f.height=f.texture_img.height),f.spritesheeted&&(h=f.texture_img,g=f.sheetTex,g.left=f.offx/h.width,g.top=f.offy/h.height,g.right=(f.offx+f.width)/h.width,g.bottom=(f.offy+f.height)/h.height,0===f.offx&&0===f.offy&&f.width===h.width&&f.height===h.height&&(f.spritesheeted=!1));this.curFrame=this.cur_animation.frames[this.cur_frame];
this.curWebGLTexture=this.curFrame.webGL_texture};v.saveToJSON=function(){var a={a:this.cur_animation.sid,f:this.cur_frame,cas:this.cur_anim_speed,fs:this.frameStart,ar:this.animRepeats,at:this.animTimer.sum};this.animPlaying||(a.ap=this.animPlaying);this.animForwards||(a.af=this.animForwards);return a};v.loadFromJSON=function(a){var b=this.getAnimationBySid(a.a);b&&(this.cur_animation=b);this.cur_frame=a.f;0>this.cur_frame&&(this.cur_frame=0);this.cur_frame>=this.cur_animation.frames.length&&(this.cur_frame=
this.cur_animation.frames.length-1);this.cur_anim_speed=a.cas;this.frameStart=a.fs;this.animRepeats=a.ar;this.animTimer.reset();this.animTimer.sum=a.at;this.animPlaying=a.hasOwnProperty("ap")?a.ap:!0;this.animForwards=a.hasOwnProperty("af")?a.af:!0;this.curFrame=this.cur_animation.frames[this.cur_frame];this.curWebGLTexture=this.curFrame.webGL_texture;this.collision_poly.set_pts(this.curFrame.poly_pts);this.hotspotX=this.curFrame.hotspotX;this.hotspotY=this.curFrame.hotspotY};v.animationFinish=function(a){this.cur_frame=
a?0:this.cur_animation.frames.length-1;this.animPlaying=!1;this.animTriggerName=this.cur_animation.name;this.inAnimTrigger=!0;this.runtime.trigger(cr.plugins_.Sprite.prototype.cnds.OnAnyAnimFinished,this);this.runtime.trigger(cr.plugins_.Sprite.prototype.cnds.OnAnimFinished,this);this.inAnimTrigger=!1;this.animRepeats=0};v.getNowTime=function(){return this.animTimer.sum};v.tick=function(){this.animTimer.add(this.runtime.getDt(this));this.changeAnimName.length&&this.doChangeAnim();0<=this.changeAnimFrame&&
this.doChangeAnimFrame();var a=this.getNowTime(),b=this.cur_animation,c=b.frames[this.cur_frame],d=c.duration/this.cur_anim_speed;this.animPlaying&&a>=this.frameStart+d&&(this.animForwards?this.cur_frame++:this.cur_frame--,this.frameStart+=d,this.cur_frame>=b.frames.length&&(b.pingpong?(this.animForwards=!1,this.cur_frame=b.frames.length-2):b.loop?this.cur_frame=b.repeatto:(this.animRepeats++,this.animRepeats>=b.repeatcount?this.animationFinish(!1):this.cur_frame=b.repeatto)),0>this.cur_frame&&(b.pingpong?
(this.cur_frame=1,this.animForwards=!0,b.loop||(this.animRepeats++,this.animRepeats>=b.repeatcount&&this.animationFinish(!0))):b.loop?this.cur_frame=b.repeatto:(this.animRepeats++,this.animRepeats>=b.repeatcount?this.animationFinish(!0):this.cur_frame=b.repeatto)),0>this.cur_frame?this.cur_frame=0:this.cur_frame>=b.frames.length&&(this.cur_frame=b.frames.length-1),a>this.frameStart+b.frames[this.cur_frame].duration/this.cur_anim_speed&&(this.frameStart=a),a=b.frames[this.cur_frame],this.OnFrameChanged(c,
a),this.runtime.redraw=!0)};v.getAnimationByName=function(a){var b,c,d;b=0;for(c=this.type.animations.length;b<c;b++)if(d=this.type.animations[b],cr.equals_nocase(d.name,a))return d;return null};v.getAnimationBySid=function(a){var b,c,d;b=0;for(c=this.type.animations.length;b<c;b++)if(d=this.type.animations[b],d.sid===a)return d;return null};v.doChangeAnim=function(){var a=this.cur_animation.frames[this.cur_frame],b=this.getAnimationByName(this.changeAnimName);this.changeAnimName="";!b||cr.equals_nocase(b.name,
this.cur_animation.name)&&this.animPlaying||(this.cur_animation=b,this.cur_anim_speed=b.speed,0>this.cur_frame&&(this.cur_frame=0),this.cur_frame>=this.cur_animation.frames.length&&(this.cur_frame=this.cur_animation.frames.length-1),1===this.changeAnimFrom&&(this.cur_frame=0),this.animPlaying=!0,this.frameStart=this.getNowTime(),this.animForwards=!0,this.OnFrameChanged(a,this.cur_animation.frames[this.cur_frame]),this.runtime.redraw=!0)};v.doChangeAnimFrame=function(){var a=this.cur_animation.frames[this.cur_frame],
b=this.cur_frame;this.cur_frame=cr.floor(this.changeAnimFrame);0>this.cur_frame&&(this.cur_frame=0);this.cur_frame>=this.cur_animation.frames.length&&(this.cur_frame=this.cur_animation.frames.length-1);b!==this.cur_frame&&(this.OnFrameChanged(a,this.cur_animation.frames[this.cur_frame]),this.frameStart=this.getNowTime(),this.runtime.redraw=!0);this.changeAnimFrame=-1};v.OnFrameChanged=function(a,b){var c=a.width,d=a.height,e=b.width,f=b.height;c!=e&&(this.width*=e/c);d!=f&&(this.height*=f/d);this.hotspotX=
b.hotspotX;this.hotspotY=b.hotspotY;this.collision_poly.set_pts(b.poly_pts);this.set_bbox_changed();this.curFrame=b;this.curWebGLTexture=b.webGL_texture;c=0;for(d=this.behavior_insts.length;c<d;c++)if(e=this.behavior_insts[c],e.onSpriteFrameChanged)e.onSpriteFrameChanged(a,b);this.runtime.trigger(cr.plugins_.Sprite.prototype.cnds.OnFrameChanged,this)};v.draw=function(a){a.globalAlpha=this.opacity;var b=this.curFrame,c=b.spritesheeted,d=b.texture_img,e=this.x,f=this.y,g=this.width,h=this.height;if(0===
this.angle&&0<=g&&0<=h)e-=this.hotspotX*g,f-=this.hotspotY*h,this.runtime.pixel_rounding&&(e=e+0.5|0,f=f+0.5|0),c?a.drawImage(d,b.offx,b.offy,b.width,b.height,e,f,g,h):a.drawImage(d,e,f,g,h);else{this.runtime.pixel_rounding&&(e=e+0.5|0,f=f+0.5|0);a.save();var p=0<g?1:-1,k=0<h?1:-1;a.translate(e,f);1===p&&1===k||a.scale(p,k);a.rotate(this.angle*p*k);e=0-this.hotspotX*cr.abs(g);f=0-this.hotspotY*cr.abs(h);c?a.drawImage(d,b.offx,b.offy,b.width,b.height,e,f,cr.abs(g),cr.abs(h)):a.drawImage(d,e,f,cr.abs(g),
cr.abs(h));a.restore()}};v.drawGL=function(a){a.setTexture(this.curWebGLTexture);a.setOpacity(this.opacity);var b=this.curFrame,c=this.bquad;if(this.runtime.pixel_rounding){var d=(this.x+0.5|0)-this.x,e=(this.y+0.5|0)-this.y;b.spritesheeted?a.quadTex(c.tlx+d,c.tly+e,c.trx+d,c.try_+e,c.brx+d,c.bry+e,c.blx+d,c.bly+e,b.sheetTex):a.quad(c.tlx+d,c.tly+e,c.trx+d,c.try_+e,c.brx+d,c.bry+e,c.blx+d,c.bly+e)}else b.spritesheeted?a.quadTex(c.tlx,c.tly,c.trx,c.try_,c.brx,c.bry,c.blx,c.bly,b.sheetTex):a.quad(c.tlx,
c.tly,c.trx,c.try_,c.brx,c.bry,c.blx,c.bly)};v.getImagePointIndexByName=function(a){var b=this.curFrame,c,d;c=0;for(d=b.image_points.length;c<d;c++)if(cr.equals_nocase(a,b.image_points[c][0]))return c;return-1};v.getImagePoint=function(a,b){var c=this.curFrame,d=c.image_points,e;e=cr.is_string(a)?this.getImagePointIndexByName(a):a-1;e=cr.floor(e);if(0>e||e>=d.length)return b?this.x:this.y;var f=(d[e][1]-c.hotspotX)*this.width,d=d[e][2],d=(d-c.hotspotY)*this.height,c=Math.cos(this.angle);e=Math.sin(this.angle);
var g=f*c-d*e,d=d*c+f*e,f=g+this.x,d=d+this.y;return b?f:d};var u=[];b.prototype.OnCollision=function(a){if(!a)return!1;var b=this.runtime,f=b.getCurrentCondition(),g=f.type;f.extra.collmemory||(f.extra.collmemory=[],b.addDestroyCallback(function(a){return function(b){var c=0,d,e,f=b.uid;b=0;for(d=a.length;b<d;b++)e=a[b],e[0]!==f&&e[1]!==f&&(a[c][0]=a[b][0],a[c][1]=a[b][1],c++);for(b=c;b<d;b++)e=a[b],e[0]=0,e[1]=0,u.push(e);a.length=c}}(f.extra.collmemory)));var h=g.getCurrentSol(),p=a.getCurrentSol(),
h=h.getObjects(),p=p.getObjects(),k,s,n,l,t,v,H=b.getCurrentEventStack().current_event;for(k=0;k<h.length;k++)for(s=h[k],n=0;n<p.length;n++)l=p[n],b.testOverlap(s,l)||b.checkRegisteredCollision(s,l)?c(f.extra.collmemory,s,l)||(e(f.extra.collmemory,s,l),b.pushCopySol(H.solModifiers),t=g.getCurrentSol(),v=a.getCurrentSol(),t.select_all=!1,v.select_all=!1,g===a?(t.instances.length=2,t.instances[0]=s,t.instances[1]=l,g.applySolToContainer()):(t.instances.length=1,v.instances.length=1,t.instances[0]=s,
v.instances[0]=l,g.applySolToContainer(),a.applySolToContainer()),H.retrigger(),b.popSol(H.solModifiers)):d(f.extra.collmemory,s,l);return!1};var p=null,t=new cr.ObjectSet,s=!1;k.finish=function(a){if(s){if(a){var b=this.runtime.getCurrentEventStack().current_event.orblock;a=p.getCurrentSol();var c=t.valuesRef(),d,e;if(a.select_all){a.select_all=!1;a.instances.length=c.length;d=0;for(e=c.length;d<e;d++)a.instances[d]=c[d];if(b)for(d=a.else_instances.length=0,e=p.instances.length;d<e;d++)b=p.instances[d],
t.contains(b)||a.else_instances.push(b)}else{var f=a.instances.length;a.instances.length=f+c.length;d=0;for(e=c.length;d<e;d++)a.instances[f+d]=c[d],b&&cr.arrayFindRemove(a.else_instances,c[d])}p.applySolToContainer()}t.clear();s=!1}};b.prototype.IsOverlapping=function(a){return f.call(this,a,0,0)};b.prototype.IsOverlappingOffset=function(a,b,c){return f.call(this,a,b,c)};b.prototype.IsAnimPlaying=function(a){return this.changeAnimName.length?cr.equals_nocase(this.changeAnimName,a):cr.equals_nocase(this.cur_animation.name,
a)};b.prototype.CompareFrame=function(a,b){return cr.do_cmp(this.cur_frame,a,b)};b.prototype.OnAnimFinished=function(a){return cr.equals_nocase(this.animTriggerName,a)};b.prototype.OnAnyAnimFinished=function(){return!0};b.prototype.OnFrameChanged=function(){return!0};b.prototype.IsMirrored=function(){return 0>this.width};b.prototype.IsFlipped=function(){return 0>this.height};b.prototype.OnURLLoaded=function(){return!0};b.prototype.IsCollisionEnabled=function(){return this.collisionsEnabled};l.cnds=
new b;g.prototype.Spawn=function(a,b,c){if(a&&b&&(b=this.runtime.createInstance(a,b,this.getImagePoint(c,!0),this.getImagePoint(c,!1)))){"undefined"!==typeof b.angle&&(b.angle=this.angle,b.set_bbox_changed());this.runtime.isInOnDestroy++;var d,e,f;this.runtime.trigger(Object.getPrototypeOf(a.plugin).cnds.OnCreated,b);if(b.is_contained)for(d=0,e=b.siblings.length;d<e;d++)f=b.siblings[d],this.runtime.trigger(Object.getPrototypeOf(f.type.plugin).cnds.OnCreated,f);this.runtime.isInOnDestroy--;d=this.runtime.getCurrentAction();
c=!1;if(cr.is_undefined(d.extra.Spawn_LastExec)||d.extra.Spawn_LastExec<this.runtime.execcount)c=!0,d.extra.Spawn_LastExec=this.runtime.execcount;if(a!=this.type&&(a=a.getCurrentSol(),a.select_all=!1,c?(a.instances.length=1,a.instances[0]=b):a.instances.push(b),b.is_contained))for(d=0,e=b.siblings.length;d<e;d++)f=b.siblings[d],a=f.type.getCurrentSol(),a.select_all=!1,c?(a.instances.length=1,a.instances[0]=f):a.instances.push(f)}};g.prototype.SetEffect=function(a){this.compositeOp=cr.effectToCompositeOp(a);
cr.setGLBlend(this,a,this.runtime.gl);this.runtime.redraw=!0};g.prototype.StopAnim=function(){this.animPlaying=!1};g.prototype.StartAnim=function(a){this.animPlaying=!0;this.frameStart=this.getNowTime();1===a&&0!==this.cur_frame&&(this.changeAnimFrame=0,this.inAnimTrigger||this.doChangeAnimFrame());this.isTicking||(this.runtime.tickMe(this),this.isTicking=!0)};g.prototype.SetAnim=function(a,b){this.changeAnimName=a;this.changeAnimFrom=b;this.isTicking||(this.runtime.tickMe(this),this.isTicking=!0);
this.inAnimTrigger||this.doChangeAnim()};g.prototype.SetAnimFrame=function(a){this.changeAnimFrame=a;this.isTicking||(this.runtime.tickMe(this),this.isTicking=!0);this.inAnimTrigger||this.doChangeAnimFrame()};g.prototype.SetAnimSpeed=function(a){this.cur_anim_speed=cr.abs(a);this.animForwards=0<=a;this.isTicking||(this.runtime.tickMe(this),this.isTicking=!0)};g.prototype.SetMirrored=function(a){a=cr.abs(this.width)*(0===a?-1:1);this.width!==a&&(this.width=a,this.set_bbox_changed())};g.prototype.SetFlipped=
function(a){a=cr.abs(this.height)*(0===a?-1:1);this.height!==a&&(this.height=a,this.set_bbox_changed())};g.prototype.SetScale=function(a){var b=this.curFrame,c=b.width*a*(0>this.width?-1:1);a=b.height*a*(0>this.height?-1:1);if(this.width!==c||this.height!==a)this.width=c,this.height=a,this.set_bbox_changed()};g.prototype.LoadURL=function(a,b){var c=new Image,d=this,e=this.curFrame;c.onload=function(){e.texture_img.src===c.src?d.runtime.glwrap&&d.curFrame===e&&(d.curWebGLTexture=e.webGL_texture):(e.texture_img=
c,e.offx=0,e.offy=0,e.width=c.width,e.height=c.height,e.spritesheeted=!1,e.datauri="",d.runtime.glwrap&&(e.webGL_texture&&d.runtime.glwrap.deleteTexture(e.webGL_texture),e.webGL_texture=d.runtime.glwrap.loadTexture(c,!1,d.runtime.linearSampling),d.curFrame===e&&(d.curWebGLTexture=e.webGL_texture),d.type.updateAllCurrentTexture()),0===b&&(d.width=c.width,d.height=c.height,d.set_bbox_changed()));d.runtime.redraw=!0;d.runtime.trigger(cr.plugins_.Sprite.prototype.cnds.OnURLLoaded,d)};"data:"!==a.substr(0,
5)&&(c.crossOrigin="anonymous");c.src=a};g.prototype.SetCollisions=function(a){this.collisionsEnabled=0!==a};l.acts=new g;h.prototype.AnimationFrame=function(a){a.set_int(this.cur_frame)};h.prototype.AnimationFrameCount=function(a){a.set_int(this.cur_animation.frames.length)};h.prototype.AnimationName=function(a){a.set_string(this.cur_animation.name)};h.prototype.AnimationSpeed=function(a){a.set_float(this.cur_anim_speed)};h.prototype.ImagePointX=function(a,b){a.set_float(this.getImagePoint(b,!0))};
h.prototype.ImagePointY=function(a,b){a.set_float(this.getImagePoint(b,!1))};h.prototype.ImagePointCount=function(a){a.set_int(this.curFrame.image_points.length)};h.prototype.ImageWidth=function(a){a.set_float(this.curFrame.width)};h.prototype.ImageHeight=function(a){a.set_float(this.curFrame.height)};l.exps=new h})();cr.plugins_.Text=function(a){this.runtime=a};
(function(){function a(){return k.length?k.pop():{}}function b(a){var b,c;b=0;for(c=a.length;b<c;b++)k.push(a[b]);a.length=0}function e(){}function d(){}function c(){}var f=cr.plugins_.Text.prototype;f.onCreate=function(){f.acts.SetWidth=function(a){this.width!==a&&(this.width=a,this.text_changed=!0,this.set_bbox_changed())}};f.Type=function(a){this.plugin=a;this.runtime=a.runtime};var g=f.Type.prototype;g.onCreate=function(){};g.onLostWebGLContext=function(){if(!this.is_family){var a,b,c;a=0;for(b=
this.instances.length;a<b;a++)c=this.instances[a],c.mycanvas=null,c.myctx=null,c.mytex=null}};f.Instance=function(a){this.type=a;this.runtime=a.runtime;this.recycled?this.lines.length=0:this.lines=[];this.text_changed=!0};var g=f.Instance.prototype,h={};g.onCreate=function(){this.text=this.properties[0];this.visible=0===this.properties[1];this.font=this.properties[2];this.color=this.properties[3];this.halign=this.properties[4];this.valign=this.properties[5];this.wrapbyword=0===this.properties[7];
this.lastwrapwidth=this.lastwidth=this.width;this.lastheight=this.height;this.line_height_offset=this.properties[8];this.fontstyle=this.facename="";this.textHeight=this.textWidth=this.ptSize=0;this.parseFont();this.mytex=this.myctx=this.mycanvas=null;this.need_text_redraw=!1;this.last_render_tick=this.runtime.tickcount;this.recycled?this.rcTex.set(0,0,1,1):this.rcTex=new cr.rect(0,0,1,1);this.runtime.glwrap&&this.runtime.tickMe(this)};g.parseFont=function(){var a=this.font.split(" "),b;for(b=0;b<
a.length;b++)if("pt"===a[b].substr(a[b].length-2,2)){this.ptSize=parseInt(a[b].substr(0,a[b].length-2));this.pxHeight=Math.ceil(96*(this.ptSize/72))+4;0<b&&(this.fontstyle=a[b-1]);this.facename=a[b+1];for(b+=2;b<a.length;b++)this.facename+=" "+a[b];break}};g.saveToJSON=function(){return{t:this.text,f:this.font,c:this.color,ha:this.halign,va:this.valign,wr:this.wrapbyword,lho:this.line_height_offset,fn:this.facename,fs:this.fontstyle,ps:this.ptSize,pxh:this.pxHeight,tw:this.textWidth,th:this.textHeight,
lrt:this.last_render_tick}};g.loadFromJSON=function(a){this.text=a.t;this.font=a.f;this.color=a.c;this.halign=a.ha;this.valign=a.va;this.wrapbyword=a.wr;this.line_height_offset=a.lho;this.facename=a.fn;this.fontstyle=a.fs;this.ptSize=a.ps;this.pxHeight=a.pxh;this.textWidth=a.tw;this.textHeight=a.th;this.last_render_tick=a.lrt;this.text_changed=!0;this.lastwrapwidth=this.lastwidth=this.width;this.lastheight=this.height};g.tick=function(){if(this.runtime.glwrap&&this.mytex&&300<=this.runtime.tickcount-
this.last_render_tick){var a=this.layer;this.update_bbox();var b=this.bbox;if(b.right<a.viewLeft||b.bottom<a.viewTop||b.left>a.viewRight||b.top>a.viewBottom)this.runtime.glwrap.deleteTexture(this.mytex),this.mycanvas=this.myctx=this.mytex=null}};g.onDestroy=function(){this.mycanvas=this.myctx=null;this.runtime.glwrap&&this.mytex&&this.runtime.glwrap.deleteTexture(this.mytex);this.mytex=null};g.updateFont=function(){this.font=this.fontstyle+" "+this.ptSize.toString()+"pt "+this.facename;this.text_changed=
!0;this.runtime.redraw=!0};g.draw=function(a,b){a.font=this.font;a.textBaseline="top";a.fillStyle=this.color;a.globalAlpha=b?1:this.opacity;var c=1;b&&(c=this.layer.getScale(),a.save(),a.scale(c,c));if(this.text_changed||this.width!==this.lastwrapwidth)this.type.plugin.WordWrap(this.text,this.lines,a,this.width,this.wrapbyword),this.text_changed=!1,this.lastwrapwidth=this.width;this.update_bbox();var c=b?0:this.bquad.tlx,d=b?0:this.bquad.tly;this.runtime.pixel_rounding&&(c=c+0.5|0,d=d+0.5|0);0===
this.angle||b||(a.save(),a.translate(c,d),a.rotate(this.angle),d=c=0);var e=d+this.height,f=this.pxHeight,f=f+this.line_height_offset*this.runtime.devicePixelRatio,g,h;1===this.valign?d+=Math.max(this.height/2-this.lines.length*f/2,0):2===this.valign&&(d+=Math.max(this.height-this.lines.length*f-2,0));for(h=0;h<this.lines.length&&!(g=c,1===this.halign?g=c+(this.width-this.lines[h].width)/2:2===this.halign&&(g=c+(this.width-this.lines[h].width)),a.fillText(this.lines[h].text,g,d),d+=f,d>=e-f);h++);
(0!==this.angle||b)&&a.restore();this.last_render_tick=this.runtime.tickcount};g.drawGL=function(a){if(!(1>this.width||1>this.height)){var b=this.text_changed||this.need_text_redraw;this.need_text_redraw=!1;var c=this.layer.getScale(),d=this.layer.getAngle(),e=this.rcTex,f=c*this.width,g=c*this.height,h=Math.ceil(f),k=Math.ceil(g),l=this.runtime.width/2,q=this.runtime.height/2;this.myctx||(this.mycanvas=document.createElement("canvas"),this.mycanvas.width=h,this.mycanvas.height=k,this.lastwidth=h,
this.lastheight=k,b=!0,this.myctx=this.mycanvas.getContext("2d"));if(h!==this.lastwidth||k!==this.lastheight)this.mycanvas.width=h,this.mycanvas.height=k,this.mytex&&(a.deleteTexture(this.mytex),this.mytex=null),b=!0;b&&(this.myctx.clearRect(0,0,h,k),this.draw(this.myctx,!0),this.mytex||(this.mytex=a.createEmptyTexture(h,k,this.runtime.linearSampling,this.runtime.isMobile)),a.videoToTexture(this.mycanvas,this.mytex,this.runtime.isMobile));this.lastwidth=h;this.lastheight=k;a.setTexture(this.mytex);
a.setOpacity(this.opacity);a.resetModelView();a.translate(-l,-q);a.updateModelView();var G=this.bquad,b=this.layer.layerToCanvas(G.tlx,G.tly,!0),l=this.layer.layerToCanvas(G.tlx,G.tly,!1),q=this.layer.layerToCanvas(G.trx,G.try_,!0),y=this.layer.layerToCanvas(G.trx,G.try_,!1),A=this.layer.layerToCanvas(G.brx,G.bry,!0),w=this.layer.layerToCanvas(G.brx,G.bry,!1),D=this.layer.layerToCanvas(G.blx,G.bly,!0),G=this.layer.layerToCanvas(G.blx,G.bly,!1);if(this.runtime.pixel_rounding||0===this.angle&&0===d)var E=
(b+0.5|0)-b,B=(l+0.5|0)-l,b=b+E,l=l+B,q=q+E,y=y+B,A=A+E,w=w+B,D=D+E,G=G+B;0===this.angle&&0===d?(q=b+h,y=l,A=q,w=l+k,D=b,G=w,e.right=1,e.bottom=1):(e.right=f/h,e.bottom=g/k);a.quadTex(b,l,q,y,A,w,D,G,e);a.resetModelView();a.scale(c,c);a.rotateZ(-this.layer.getAngle());a.translate((this.layer.viewLeft+this.layer.viewRight)/-2,(this.layer.viewTop+this.layer.viewBottom)/-2);a.updateModelView();this.last_render_tick=this.runtime.tickcount}};var l=[];f.TokeniseWords=function(a){l.length=0;for(var b="",
c,d=0;d<a.length;)if(c=a.charAt(d),"\n"===c)b.length&&(l.push(b),b=""),l.push("\n"),++d;else if(" "===c||"\t"===c||"-"===c){do b+=a.charAt(d),d++;while(d<a.length&&(" "===a.charAt(d)||"\t"===a.charAt(d)));l.push(b);b=""}else d<a.length&&(b+=c,d++);b.length&&l.push(b)};var k=[];f.WordWrap=function(c,d,e,f,g){if(c&&c.length)if(2>=f)b(d);else{if(100>=c.length&&-1===c.indexOf("\n")){var h=e.measureText(c).width;if(h<=f){b(d);d.push(a());d[0].text=c;d[0].width=h;return}}this.WrapText(c,d,e,f,g)}else b(d)};
f.WrapText=function(b,c,d,e,f){f&&(this.TokeniseWords(b),b=l);var g="",h,x,z,r=0;for(z=0;z<b.length;z++)"\n"===b[z]?(r>=c.length&&c.push(a()),x=c[r],x.text=g,x.width=d.measureText(g).width,r++,g=""):(h=g,g+=b[z],x=d.measureText(g).width,x>=e&&(r>=c.length&&c.push(a()),x=c[r],x.text=h,x.width=d.measureText(h).width,r++,g=b[z],f||" "!==g||(g="")));g.length&&(r>=c.length&&c.push(a()),x=c[r],x.text=g,x.width=d.measureText(g).width,r++);for(z=r;z<c.length;z++)k.push(c[z]);c.length=r};e.prototype.CompareText=
function(a,b){return b?this.text==a:cr.equals_nocase(this.text,a)};f.cnds=new e;d.prototype.SetText=function(a){cr.is_number(a)&&1E9>a&&(a=Math.round(1E10*a)/1E10);a=a.toString();this.text!==a&&(this.text=a,this.text_changed=!0,this.runtime.redraw=!0)};d.prototype.AppendText=function(a){cr.is_number(a)&&(a=Math.round(1E10*a)/1E10);if(a=a.toString())this.text+=a,this.text_changed=!0,this.runtime.redraw=!0};d.prototype.SetFontFace=function(a,b){var c="";switch(b){case 1:c="bold";break;case 2:c="italic";
break;case 3:c="bold italic"}if(a!==this.facename||c!==this.fontstyle)this.facename=a,this.fontstyle=c,this.updateFont()};d.prototype.SetFontSize=function(a){this.ptSize!==a&&(this.ptSize=a,this.pxHeight=Math.ceil(96*(this.ptSize/72))+4,this.updateFont())};d.prototype.SetFontColor=function(a){a="rgb("+cr.GetRValue(a).toString()+","+cr.GetGValue(a).toString()+","+cr.GetBValue(a).toString()+")";a!==this.color&&(this.color=a,this.need_text_redraw=!0,this.runtime.redraw=!0)};d.prototype.SetWebFont=function(a,
b){if(this.runtime.isDomFree)cr.logexport("[Construct 2] Text plugin: 'Set web font' not supported on this platform - the action has been ignored");else{var c=this,d=function(){c.runtime.redraw=!0;c.text_changed=!0};if(h.hasOwnProperty(b)){var e="'"+a+"'";if(this.facename!==e)for(this.facename=e,this.updateFont(),e=1;10>e;e++)setTimeout(d,100*e),setTimeout(d,1E3*e)}else for(e=document.createElement("link"),e.href=b,e.rel="stylesheet",e.type="text/css",e.onload=d,document.getElementsByTagName("head")[0].appendChild(e),
h[b]=!0,this.facename="'"+a+"'",this.updateFont(),e=1;10>e;e++)setTimeout(d,100*e),setTimeout(d,1E3*e)}};d.prototype.SetEffect=function(a){this.compositeOp=cr.effectToCompositeOp(a);cr.setGLBlend(this,a,this.runtime.gl);this.runtime.redraw=!0};f.acts=new d;c.prototype.Text=function(a){a.set_string(this.text)};c.prototype.FaceName=function(a){a.set_string(this.facename)};c.prototype.FaceSize=function(a){a.set_int(this.ptSize)};c.prototype.TextWidth=function(a){var b=0,c,d,e;c=0;for(d=this.lines.length;c<
d;c++)e=this.lines[c].width,b<e&&(b=e);a.set_int(b)};c.prototype.TextHeight=function(a){a.set_int(this.lines.length*(this.pxHeight+this.line_height_offset)-this.line_height_offset)};f.exps=new c})();cr.plugins_.TiledBg=function(a){this.runtime=a};
(function(){function a(){}function b(){}function e(){}var d=cr.plugins_.TiledBg.prototype;d.Type=function(a){this.plugin=a;this.runtime=a.runtime};var c=d.Type.prototype;c.onCreate=function(){this.is_family||(this.texture_img=new Image,this.texture_img.idtkLoadDisposed=!0,this.texture_img.src=this.texture_file,this.texture_img.cr_filesize=this.texture_filesize,this.runtime.wait_for_textures.push(this.texture_img),this.webGL_texture=this.pattern=null)};c.onLostWebGLContext=function(){this.is_family||
(this.webGL_texture=null)};c.onRestoreWebGLContext=function(){if(!this.is_family&&this.instances.length){this.webGL_texture||(this.webGL_texture=this.runtime.glwrap.loadTexture(this.texture_img,!0,this.runtime.linearSampling,this.texture_pixelformat));var a,b;a=0;for(b=this.instances.length;a<b;a++)this.instances[a].webGL_texture=this.webGL_texture}};c.loadTextures=function(){this.is_family||this.webGL_texture||!this.runtime.glwrap||(this.webGL_texture=this.runtime.glwrap.loadTexture(this.texture_img,
!0,this.runtime.linearSampling,this.texture_pixelformat))};c.unloadTextures=function(){this.is_family||this.instances.length||!this.webGL_texture||(this.runtime.glwrap.deleteTexture(this.webGL_texture),this.webGL_texture=null)};c.preloadCanvas2D=function(a){a.drawImage(this.texture_img,0,0)};d.Instance=function(a){this.type=a;this.runtime=a.runtime};c=d.Instance.prototype;c.onCreate=function(){this.visible=0===this.properties[0];this.rcTex=new cr.rect(0,0,0,0);this.has_own_texture=!1;this.texture_img=
this.type.texture_img;this.runtime.glwrap?(this.type.loadTextures(),this.webGL_texture=this.type.webGL_texture):(this.type.pattern||(this.type.pattern=this.runtime.ctx.createPattern(this.type.texture_img,"repeat")),this.pattern=this.type.pattern)};c.afterLoad=function(){this.has_own_texture=!1;this.texture_img=this.type.texture_img};c.onDestroy=function(){this.runtime.glwrap&&this.has_own_texture&&this.webGL_texture&&(this.runtime.glwrap.deleteTexture(this.webGL_texture),this.webGL_texture=null)};
c.draw=function(a){a.globalAlpha=this.opacity;a.save();a.fillStyle=this.pattern;var b=this.x,c=this.y;this.runtime.pixel_rounding&&(b=b+0.5|0,c=c+0.5|0);var d=-(this.hotspotX*this.width),e=-(this.hotspotY*this.height),n=d%this.texture_img.width,v=e%this.texture_img.height;0>n&&(n+=this.texture_img.width);0>v&&(v+=this.texture_img.height);a.translate(b,c);a.rotate(this.angle);a.translate(n,v);a.fillRect(d-n,e-v,this.width,this.height);a.restore()};c.drawGL=function(a){a.setTexture(this.webGL_texture);
a.setOpacity(this.opacity);var b=this.rcTex;b.right=this.width/this.texture_img.width;b.bottom=this.height/this.texture_img.height;var c=this.bquad;if(this.runtime.pixel_rounding){var d=(this.x+0.5|0)-this.x,e=(this.y+0.5|0)-this.y;a.quadTex(c.tlx+d,c.tly+e,c.trx+d,c.try_+e,c.brx+d,c.bry+e,c.blx+d,c.bly+e,b)}else a.quadTex(c.tlx,c.tly,c.trx,c.try_,c.brx,c.bry,c.blx,c.bly,b)};a.prototype.OnURLLoaded=function(){return!0};d.cnds=new a;b.prototype.SetEffect=function(a){this.compositeOp=cr.effectToCompositeOp(a);
cr.setGLBlend(this,a,this.runtime.gl);this.runtime.redraw=!0};b.prototype.LoadURL=function(a){var b=new Image,c=this;b.onload=function(){c.texture_img=b;c.runtime.glwrap?(c.has_own_texture&&c.webGL_texture&&c.runtime.glwrap.deleteTexture(c.webGL_texture),c.webGL_texture=c.runtime.glwrap.loadTexture(b,!0,c.runtime.linearSampling)):c.pattern=c.runtime.ctx.createPattern(b,"repeat");c.has_own_texture=!0;c.runtime.redraw=!0;c.runtime.trigger(cr.plugins_.TiledBg.prototype.cnds.OnURLLoaded,c)};"data:"!==
a.substr(0,5)&&(b.crossOrigin="anonymous");b.src=a};d.acts=new b;e.prototype.ImageWidth=function(a){a.set_float(this.texture_img.width)};e.prototype.ImageHeight=function(a){a.set_float(this.texture_img.height)};d.exps=new e})();cr.plugins_.Touch=function(a){this.runtime=a};
(function(){function a(a){h=a.x;l=a.y;k=a.z}function b(a){n=a.x;v=a.y;u=a.z}function e(){}function d(){}var c=cr.plugins_.Touch.prototype;c.Type=function(a){this.plugin=a;this.runtime=a.runtime};c.Type.prototype.onCreate=function(){};c.Instance=function(a){this.type=a;this.runtime=a.runtime;this.touches=[];this.mouseDown=!1};var f=c.Instance.prototype,g={left:0,top:0};f.findTouch=function(a){var b,c;b=0;for(c=this.touches.length;b<c;b++)if(this.touches[b].id===a)return b;return-1};var h=0,l=0,k=0,
n=0,v=0,u=0;f.onCreate=function(){this.isWindows8=!("undefined"===typeof window.c2isWindows8||!window.c2isWindows8);this.trigger_id=this.trigger_index=this.curTouchY=this.curTouchX=this.acc_z=this.acc_y=this.acc_x=this.acc_g_z=this.acc_g_y=this.acc_g_x=this.orient_gamma=this.orient_beta=this.orient_alpha=0;this.useMouseInput=0!==this.properties[0];var c=0<this.runtime.fullscreen_mode?document:this.runtime.canvas,d=document;this.runtime.isDirectCanvas?d=c=window.Canvas:this.runtime.isCocoonJs&&(d=
c=window);var e=this;window.navigator.msPointerEnabled?(c.addEventListener("MSPointerDown",function(a){e.onPointerStart(a)},!1),c.addEventListener("MSPointerMove",function(a){e.onPointerMove(a)},!1),d.addEventListener("MSPointerUp",function(a){e.onPointerEnd(a)},!1),d.addEventListener("MSPointerCancel",function(a){e.onPointerEnd(a)},!1),this.runtime.canvas&&(this.runtime.canvas.addEventListener("MSGestureHold",function(a){a.preventDefault()},!1),document.addEventListener("MSGestureHold",function(a){a.preventDefault()},
!1))):(c.addEventListener("touchstart",function(a){e.onTouchStart(a)},!1),c.addEventListener("touchmove",function(a){e.onTouchMove(a)},!1),d.addEventListener("touchend",function(a){e.onTouchEnd(a)},!1),d.addEventListener("touchcancel",function(a){e.onTouchEnd(a)},!1));if(this.isWindows8){var f=function(a){a=a.reading;e.acc_x=a.accelerationX;e.acc_y=a.accelerationY;e.acc_z=a.accelerationZ},g=function(a){a=a.reading;e.orient_alpha=a.yawDegrees;e.orient_beta=a.pitchDegrees;e.orient_gamma=a.rollDegrees},
h=Windows.Devices.Sensors.Accelerometer.getDefault();h&&(h.reportInterval=Math.max(h.minimumReportInterval,16),h.addEventListener("readingchanged",f));var k=Windows.Devices.Sensors.Inclinometer.getDefault();k&&(k.reportInterval=Math.max(k.minimumReportInterval,16),k.addEventListener("readingchanged",g));document.addEventListener("visibilitychange",function(a){document.hidden||document.msHidden?(h&&h.removeEventListener("readingchanged",f),k&&k.removeEventListener("readingchanged",g)):(h&&h.addEventListener("readingchanged",
f),k&&k.addEventListener("readingchanged",g))},!1)}else window.addEventListener("deviceorientation",function(a){e.orient_alpha=a.alpha||0;e.orient_beta=a.beta||0;e.orient_gamma=a.gamma||0},!1),window.addEventListener("devicemotion",function(a){a.accelerationIncludingGravity&&(e.acc_g_x=a.accelerationIncludingGravity.x,e.acc_g_y=a.accelerationIncludingGravity.y,e.acc_g_z=a.accelerationIncludingGravity.z);a.acceleration&&(e.acc_x=a.acceleration.x,e.acc_y=a.acceleration.y,e.acc_z=a.acceleration.z)},
!1);this.useMouseInput&&!this.runtime.isDomFree&&(jQuery(document).mousemove(function(a){e.onMouseMove(a)}),jQuery(document).mousedown(function(a){e.onMouseDown(a)}),jQuery(document).mouseup(function(a){e.onMouseUp(a)}));this.runtime.isAppMobi&&!this.runtime.isDirectCanvas&&AppMobi.accelerometer.watchAcceleration(a,{frequency:40,adjustForRotation:!0});this.runtime.isPhoneGap&&navigator.accelerometer.watchAcceleration(b,null,{frequency:40});this.runtime.tick2Me(this)};f.onPointerMove=function(a){if(a.pointerType!==
a.MSPOINTER_TYPE_MOUSE){a.preventDefault&&a.preventDefault();var b=this.findTouch(a.pointerId),c=cr.performance_now();if(0<=b){var d=this.runtime.isDomFree?g:jQuery(this.runtime.canvas).offset(),b=this.touches[b];2>c-b.time||(b.lasttime=b.time,b.lastx=b.x,b.lasty=b.y,b.time=c,b.x=a.pageX-d.left,b.y=a.pageY-d.top)}}};f.onPointerStart=function(a){if(a.pointerType!==a.MSPOINTER_TYPE_MOUSE){a.preventDefault&&a.preventDefault();var b=this.runtime.isDomFree?g:jQuery(this.runtime.canvas).offset(),c=a.pageX-
b.left,b=a.pageY-b.top,d=cr.performance_now();this.trigger_index=this.touches.length;this.trigger_id=a.pointerId;this.touches.push({time:d,x:c,y:b,lasttime:d,lastx:c,lasty:b,id:a.pointerId,startindex:this.trigger_index});this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnNthTouchStart,this);this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnTouchStart,this);this.curTouchX=c;this.curTouchY=b;this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnTouchObject,this)}};f.onPointerEnd=function(a){a.pointerType!==
a.MSPOINTER_TYPE_MOUSE&&(a.preventDefault&&a.preventDefault(),a=this.findTouch(a.pointerId),this.trigger_index=0<=a?this.touches[a].startindex:-1,this.trigger_id=0<=a?this.touches[a].id:-1,this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnNthTouchEnd,this),this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnTouchEnd,this),0<=a&&this.touches.splice(a,1))};f.onTouchMove=function(a){a.preventDefault&&a.preventDefault();var b=cr.performance_now(),c,d,e,f;c=0;for(d=a.changedTouches.length;c<
d;c++)if(e=a.changedTouches[c],f=this.findTouch(e.identifier),0<=f){var h=this.runtime.isDomFree?g:jQuery(this.runtime.canvas).offset();f=this.touches[f];2>b-f.time||(f.lasttime=f.time,f.lastx=f.x,f.lasty=f.y,f.time=b,f.x=e.pageX-h.left,f.y=e.pageY-h.top)}};f.onTouchStart=function(a){a.preventDefault&&a.preventDefault();var b=this.runtime.isDomFree?g:jQuery(this.runtime.canvas).offset(),c=cr.performance_now(),d,e,f,h;d=0;for(e=a.changedTouches.length;d<e;d++)if(f=a.changedTouches[d],h=this.findTouch(f.identifier),
-1===h){h=f.pageX-b.left;var k=f.pageY-b.top;this.trigger_index=this.touches.length;this.trigger_id=f.identifier;this.touches.push({time:c,x:h,y:k,lasttime:c,lastx:h,lasty:k,id:f.identifier,startindex:this.trigger_index});this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnNthTouchStart,this);this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnTouchStart,this);this.curTouchX=h;this.curTouchY=k;this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnTouchObject,this)}};f.onTouchEnd=function(a){a.preventDefault&&
a.preventDefault();var b,c,d;b=0;for(c=a.changedTouches.length;b<c;b++)d=a.changedTouches[b],d=this.findTouch(d.identifier),0<=d&&(this.trigger_index=this.touches[d].startindex,this.trigger_id=this.touches[d].id,this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnNthTouchEnd,this),this.runtime.trigger(cr.plugins_.Touch.prototype.cnds.OnTouchEnd,this),this.touches.splice(d,1))};f.getAlpha=function(){return this.runtime.isAppMobi&&0===this.orient_alpha&&0!==k?90*k:this.runtime.isPhoneGap&&0===this.orient_alpha&&
0!==u?90*u:this.orient_alpha};f.getBeta=function(){return this.runtime.isAppMobi&&0===this.orient_beta&&0!==l?-90*l:this.runtime.isPhoneGap&&0===this.orient_beta&&0!==v?-90*v:this.orient_beta};f.getGamma=function(){return this.runtime.isAppMobi&&0===this.orient_gamma&&0!==h?90*h:this.runtime.isPhoneGap&&0===this.orient_gamma&&0!==n?90*n:this.orient_gamma};f.onMouseDown=function(a){a.preventDefault&&this.runtime.had_a_click&&a.preventDefault();this.onTouchStart({changedTouches:[{pageX:a.pageX,pageY:a.pageY,
identifier:0}]});this.mouseDown=!0};f.onMouseMove=function(a){a.preventDefault&&this.runtime.had_a_click&&a.preventDefault();if(this.mouseDown)this.onTouchMove({changedTouches:[{pageX:a.pageX,pageY:a.pageY,identifier:0}]})};f.onMouseUp=function(a){a.preventDefault&&this.runtime.had_a_click&&a.preventDefault();this.runtime.had_a_click=!0;this.onTouchEnd({changedTouches:[{pageX:a.pageX,pageY:a.pageY,identifier:0}]});this.mouseDown=!1};f.tick2=function(){var a,b,c,d=cr.performance_now();a=0;for(b=this.touches.length;a<
b;a++)c=this.touches[a],c.time<=d-50&&(c.lasttime=d)};e.prototype.OnTouchStart=function(){return!0};e.prototype.OnTouchEnd=function(){return!0};e.prototype.IsInTouch=function(){return this.touches.length};e.prototype.OnTouchObject=function(a){return a?this.runtime.testAndSelectCanvasPointOverlap(a,this.curTouchX,this.curTouchY,!1):!1};e.prototype.IsTouchingObject=function(a){if(!a)return!1;a=a.getCurrentSol();var b=a.getObjects(),c,d,e=[],f,g,h,k;f=0;for(g=b.length;f<g;f++){var l=b[f];l.update_bbox();
h=0;for(k=this.touches.length;h<k;h++)if(d=this.touches[h],c=l.layer.canvasToLayer(d.x,d.y,!0),d=l.layer.canvasToLayer(d.x,d.y,!1),l.contains_pt(c,d)){e.push(l);break}}return e.length?(a.select_all=!1,a.instances=e,!0):!1};e.prototype.CompareTouchSpeed=function(a,b,c){a=Math.floor(a);if(0>a||a>=this.touches.length)return!1;var d=this.touches[a];a=cr.distanceTo(d.x,d.y,d.lastx,d.lasty);var d=(d.time-d.lasttime)/1E3,e=0;0<d&&(e=a/d);return cr.do_cmp(e,b,c)};e.prototype.OrientationSupported=function(){return"undefined"!==
typeof window.DeviceOrientationEvent};e.prototype.MotionSupported=function(){return"undefined"!==typeof window.DeviceMotionEvent};e.prototype.CompareOrientation=function(a,b,c){var d=0,d=0===a?this.getAlpha():1===a?this.getBeta():this.getGamma();return cr.do_cmp(d,b,c)};e.prototype.CompareAcceleration=function(a,b,c){var d=0;0===a?d=this.acc_g_x:1===a?d=this.acc_g_y:2===a?d=this.acc_g_z:3===a?d=this.acc_x:4===a?d=this.acc_y:5===a&&(d=this.acc_z);return cr.do_cmp(d,b,c)};e.prototype.OnNthTouchStart=
function(a){a=Math.floor(a);return a===this.trigger_index};e.prototype.OnNthTouchEnd=function(a){a=Math.floor(a);return a===this.trigger_index};e.prototype.HasNthTouch=function(a){a=Math.floor(a);return this.touches.length>=a+1};c.cnds=new e;d.prototype.TouchCount=function(a){a.set_int(this.touches.length)};d.prototype.X=function(a,b){if(this.touches.length){var c,d,e,f,g;cr.is_undefined(b)?(c=this.runtime.getLayerByNumber(0),d=c.scale,e=c.zoomRate,f=c.parallaxX,g=c.angle,c.scale=this.runtime.running_layout.scale,
c.zoomRate=1,c.parallaxX=1,c.angle=this.runtime.running_layout.angle,a.set_float(c.canvasToLayer(this.touches[0].x,this.touches[0].y,!0)),c.scale=d,c.zoomRate=e,c.parallaxX=f,c.angle=g):(c=cr.is_number(b)?this.runtime.getLayerByNumber(b):this.runtime.getLayerByName(b))?a.set_float(c.canvasToLayer(this.touches[0].x,this.touches[0].y,!0)):a.set_float(0)}else a.set_float(0)};d.prototype.XAt=function(a,b,c){b=Math.floor(b);if(0>b||b>=this.touches.length)a.set_float(0);else{var d,e,f,g;cr.is_undefined(c)?
(c=this.runtime.getLayerByNumber(0),d=c.scale,e=c.zoomRate,f=c.parallaxX,g=c.angle,c.scale=this.runtime.running_layout.scale,c.zoomRate=1,c.parallaxX=1,c.angle=this.runtime.running_layout.angle,a.set_float(c.canvasToLayer(this.touches[b].x,this.touches[b].y,!0)),c.scale=d,c.zoomRate=e,c.parallaxX=f,c.angle=g):(c=cr.is_number(c)?this.runtime.getLayerByNumber(c):this.runtime.getLayerByName(c))?a.set_float(c.canvasToLayer(this.touches[b].x,this.touches[b].y,!0)):a.set_float(0)}};d.prototype.XForID=function(a,
b,c){b=this.findTouch(b);if(0>b)a.set_float(0);else{b=this.touches[b];var d,e,f,g;cr.is_undefined(c)?(c=this.runtime.getLayerByNumber(0),d=c.scale,e=c.zoomRate,f=c.parallaxX,g=c.angle,c.scale=this.runtime.running_layout.scale,c.zoomRate=1,c.parallaxX=1,c.angle=this.runtime.running_layout.angle,a.set_float(c.canvasToLayer(b.x,b.y,!0)),c.scale=d,c.zoomRate=e,c.parallaxX=f,c.angle=g):(c=cr.is_number(c)?this.runtime.getLayerByNumber(c):this.runtime.getLayerByName(c))?a.set_float(c.canvasToLayer(b.x,b.y,
!0)):a.set_float(0)}};d.prototype.Y=function(a,b){if(this.touches.length){var c,d,e,f,g;cr.is_undefined(b)?(c=this.runtime.getLayerByNumber(0),d=c.scale,e=c.zoomRate,f=c.parallaxY,g=c.angle,c.scale=this.runtime.running_layout.scale,c.zoomRate=1,c.parallaxY=1,c.angle=this.runtime.running_layout.angle,a.set_float(c.canvasToLayer(this.touches[0].x,this.touches[0].y,!1)),c.scale=d,c.zoomRate=e,c.parallaxY=f,c.angle=g):(c=cr.is_number(b)?this.runtime.getLayerByNumber(b):this.runtime.getLayerByName(b))?
a.set_float(c.canvasToLayer(this.touches[0].x,this.touches[0].y,!1)):a.set_float(0)}else a.set_float(0)};d.prototype.YAt=function(a,b,c){b=Math.floor(b);if(0>b||b>=this.touches.length)a.set_float(0);else{var d,e,f,g;cr.is_undefined(c)?(c=this.runtime.getLayerByNumber(0),d=c.scale,e=c.zoomRate,f=c.parallaxY,g=c.angle,c.scale=this.runtime.running_layout.scale,c.zoomRate=1,c.parallaxY=1,c.angle=this.runtime.running_layout.angle,a.set_float(c.canvasToLayer(this.touches[b].x,this.touches[b].y,!1)),c.scale=
d,c.zoomRate=e,c.parallaxY=f,c.angle=g):(c=cr.is_number(c)?this.runtime.getLayerByNumber(c):this.runtime.getLayerByName(c))?a.set_float(c.canvasToLayer(this.touches[b].x,this.touches[b].y,!1)):a.set_float(0)}};d.prototype.YForID=function(a,b,c){b=this.findTouch(b);if(0>b)a.set_float(0);else{b=this.touches[b];var d,e,f,g;cr.is_undefined(c)?(c=this.runtime.getLayerByNumber(0),d=c.scale,e=c.zoomRate,f=c.parallaxY,g=c.angle,c.scale=this.runtime.running_layout.scale,c.zoomRate=1,c.parallaxY=1,c.angle=
this.runtime.running_layout.angle,a.set_float(c.canvasToLayer(b.x,b.y,!1)),c.scale=d,c.zoomRate=e,c.parallaxY=f,c.angle=g):(c=cr.is_number(c)?this.runtime.getLayerByNumber(c):this.runtime.getLayerByName(c))?a.set_float(c.canvasToLayer(b.x,b.y,!1)):a.set_float(0)}};d.prototype.AbsoluteX=function(a){this.touches.length?a.set_float(this.touches[0].x):a.set_float(0)};d.prototype.AbsoluteXAt=function(a,b){b=Math.floor(b);0>b||b>=this.touches.length?a.set_float(0):a.set_float(this.touches[b].x)};d.prototype.AbsoluteXForID=
function(a,b){var c=this.findTouch(b);0>c?a.set_float(0):a.set_float(this.touches[c].x)};d.prototype.AbsoluteY=function(a){this.touches.length?a.set_float(this.touches[0].y):a.set_float(0)};d.prototype.AbsoluteYAt=function(a,b){b=Math.floor(b);0>b||b>=this.touches.length?a.set_float(0):a.set_float(this.touches[b].y)};d.prototype.AbsoluteYForID=function(a,b){var c=this.findTouch(b);0>c?a.set_float(0):a.set_float(this.touches[c].y)};d.prototype.SpeedAt=function(a,b){b=Math.floor(b);if(0>b||b>=this.touches.length)a.set_float(0);
else{var c=this.touches[b],d=cr.distanceTo(c.x,c.y,c.lastx,c.lasty),c=(c.time-c.lasttime)/1E3;0===c?a.set_float(0):a.set_float(d/c)}};d.prototype.SpeedForID=function(a,b){var c=this.findTouch(b);if(0>c)a.set_float(0);else{var d=this.touches[c],c=cr.distanceTo(d.x,d.y,d.lastx,d.lasty),d=(d.time-d.lasttime)/1E3;0===d?a.set_float(0):a.set_float(c/d)}};d.prototype.AngleAt=function(a,b){b=Math.floor(b);if(0>b||b>=this.touches.length)a.set_float(0);else{var c=this.touches[b];a.set_float(cr.to_degrees(cr.angleTo(c.lastx,
c.lasty,c.x,c.y)))}};d.prototype.AngleForID=function(a,b){var c=this.findTouch(b);0>c?a.set_float(0):(c=this.touches[c],a.set_float(cr.to_degrees(cr.angleTo(c.lastx,c.lasty,c.x,c.y))))};d.prototype.Alpha=function(a){a.set_float(this.getAlpha())};d.prototype.Beta=function(a){a.set_float(this.getBeta())};d.prototype.Gamma=function(a){a.set_float(this.getGamma())};d.prototype.AccelerationXWithG=function(a){a.set_float(this.acc_g_x)};d.prototype.AccelerationYWithG=function(a){a.set_float(this.acc_g_y)};
d.prototype.AccelerationZWithG=function(a){a.set_float(this.acc_g_z)};d.prototype.AccelerationX=function(a){a.set_float(this.acc_x)};d.prototype.AccelerationY=function(a){a.set_float(this.acc_y)};d.prototype.AccelerationZ=function(a){a.set_float(this.acc_z)};d.prototype.TouchIndex=function(a){a.set_int(this.trigger_index)};d.prototype.TouchID=function(a){a.set_float(this.trigger_id)};c.exps=new d})();cr.behaviors.EightDir=function(a){this.runtime=a};
(function(){function a(){}function b(){}function e(){}var d=cr.behaviors.EightDir.prototype;d.Type=function(a,b){this.behavior=a;this.objtype=b;this.runtime=a.runtime};d.Type.prototype.onCreate=function(){};d.Instance=function(a,b){this.type=a;this.behavior=a.behavior;this.inst=b;this.runtime=a.runtime;this.simright=this.simleft=this.simdown=this.simup=this.ignoreInput=this.rightkey=this.leftkey=this.downkey=this.upkey=!1;this.lastrighttick=this.lastlefttick=this.lastdowntick=this.lastuptick=-1;this.dy=
this.dx=0};var c=d.Instance.prototype;c.onCreate=function(){this.maxspeed=this.properties[0];this.acc=this.properties[1];this.dec=this.properties[2];this.directions=this.properties[3];this.angleMode=this.properties[4];this.defaultControls=1===this.properties[5];this.enabled=0!==this.properties[6];this.defaultControls&&!this.runtime.isDomFree&&(jQuery(document).keydown(function(a){return function(b){a.onKeyDown(b)}}(this)),jQuery(document).keyup(function(a){return function(b){a.onKeyUp(b)}}(this)))};
c.saveToJSON=function(){return{dx:this.dx,dy:this.dy,enabled:this.enabled,maxspeed:this.maxspeed,acc:this.acc,dec:this.dec,ignoreInput:this.ignoreInput}};c.loadFromJSON=function(a){this.dx=a.dx;this.dy=a.dy;this.enabled=a.enabled;this.maxspeed=a.maxspeed;this.acc=a.acc;this.dec=a.dec;this.ignoreInput=a.ignoreInput;this.simright=this.simleft=this.simdown=this.simup=this.rightkey=this.leftkey=this.downkey=this.upkey=!1;this.lastrighttick=this.lastlefttick=this.lastdowntick=this.lastuptick=-1};c.onKeyDown=
function(a){var b=this.runtime.tickcount;switch(a.which){case 37:a.preventDefault();this.lastlefttick<b&&(this.leftkey=!0);break;case 38:a.preventDefault();this.lastuptick<b&&(this.upkey=!0);break;case 39:a.preventDefault();this.lastrighttick<b&&(this.rightkey=!0);break;case 40:a.preventDefault(),this.lastdowntick<b&&(this.downkey=!0)}};c.onKeyUp=function(a){var b=this.runtime.tickcount;switch(a.which){case 37:a.preventDefault();this.leftkey=!1;this.lastlefttick=b;break;case 38:a.preventDefault();
this.upkey=!1;this.lastuptick=b;break;case 39:a.preventDefault();this.rightkey=!1;this.lastrighttick=b;break;case 40:a.preventDefault(),this.downkey=!1,this.lastdowntick=b}};c.tick=function(){var a=this.runtime.getDt(this.inst),b=this.leftkey||this.simleft,c=this.rightkey||this.simright,d=this.upkey||this.simup,e=this.downkey||this.simdown;this.simdown=this.simup=this.simright=this.simleft=!1;if(this.enabled){var n=this.runtime.testOverlapSolid(this.inst);if(n&&(this.runtime.registerCollision(this.inst,
n),!this.runtime.pushOutSolidNearest(this.inst)))return;this.ignoreInput&&(e=d=c=b=!1);0===this.directions?c=b=!1:1===this.directions&&(e=d=!1);2===this.directions&&(d||e)&&(c=b=!1);b==c&&(0>this.dx?(this.dx+=this.dec*a,0<this.dx&&(this.dx=0)):0<this.dx&&(this.dx-=this.dec*a,0>this.dx&&(this.dx=0)));d==e&&(0>this.dy?(this.dy+=this.dec*a,0<this.dy&&(this.dy=0)):0<this.dy&&(this.dy-=this.dec*a,0>this.dy&&(this.dy=0)));b&&!c&&(this.dx=0<this.dx?this.dx-(this.acc+this.dec)*a:this.dx-this.acc*a);c&&!b&&
(this.dx=0>this.dx?this.dx+(this.acc+this.dec)*a:this.dx+this.acc*a);d&&!e&&(this.dy=0<this.dy?this.dy-(this.acc+this.dec)*a:this.dy-this.acc*a);e&&!d&&(this.dy=0>this.dy?this.dy+(this.acc+this.dec)*a:this.dy+this.acc*a);if(0!==this.dx||0!==this.dy){Math.sqrt(this.dx*this.dx+this.dy*this.dy)>this.maxspeed&&(n=Math.atan2(this.dy,this.dx),this.dx=this.maxspeed*Math.cos(n),this.dy=this.maxspeed*Math.sin(n));c=this.inst.x;d=this.inst.y;b=this.inst.angle;this.inst.x+=this.dx*a;this.inst.set_bbox_changed();
if(n=this.runtime.testOverlapSolid(this.inst))this.inst.x=c,this.dx=0,this.inst.set_bbox_changed(),this.runtime.registerCollision(this.inst,n);this.inst.y+=this.dy*a;this.inst.set_bbox_changed();if(n=this.runtime.testOverlapSolid(this.inst))this.inst.y=d,this.dy=0,this.inst.set_bbox_changed(),this.runtime.registerCollision(this.inst,n);a=cr.round6dp(this.dx);n=cr.round6dp(this.dy);if(0!==a||0!==n)1===this.angleMode?this.inst.angle=cr.to_clamped_radians(90*Math.round(cr.to_degrees(Math.atan2(n,a))/
90)):2===this.angleMode?this.inst.angle=cr.to_clamped_radians(45*Math.round(cr.to_degrees(Math.atan2(n,a))/45)):3===this.angleMode&&(this.inst.angle=Math.atan2(n,a));this.inst.set_bbox_changed();this.inst.angle!=b&&(n=this.runtime.testOverlapSolid(this.inst))&&(this.inst.angle=b,this.inst.set_bbox_changed(),this.runtime.registerCollision(this.inst,n))}}};a.prototype.IsMoving=function(){return 0!==this.dx||0!==this.dy};a.prototype.CompareSpeed=function(a,b){var c=Math.sqrt(this.dx*this.dx+this.dy*
this.dy);return cr.do_cmp(c,a,b)};d.cnds=new a;b.prototype.Stop=function(){this.dy=this.dx=0};b.prototype.Reverse=function(){this.dx*=-1;this.dy*=-1};b.prototype.SetIgnoreInput=function(a){this.ignoreInput=a};b.prototype.SetSpeed=function(a){0>a&&(a=0);a>this.maxspeed&&(a=this.maxspeed);var b=Math.atan2(this.dy,this.dx);this.dx=a*Math.cos(b);this.dy=a*Math.sin(b)};b.prototype.SetMaxSpeed=function(a){this.maxspeed=a;0>this.maxspeed&&(this.maxspeed=0)};b.prototype.SetAcceleration=function(a){this.acc=
a;0>this.acc&&(this.acc=0)};b.prototype.SetDeceleration=function(a){this.dec=a;0>this.dec&&(this.dec=0)};b.prototype.SimulateControl=function(a){switch(a){case 0:this.simleft=!0;break;case 1:this.simright=!0;break;case 2:this.simup=!0;break;case 3:this.simdown=!0}};b.prototype.SetEnabled=function(a){this.enabled=1===a};b.prototype.SetVectorX=function(a){this.dx=a};b.prototype.SetVectorY=function(a){this.dy=a};d.acts=new b;e.prototype.Speed=function(a){a.set_float(Math.sqrt(this.dx*this.dx+this.dy*
this.dy))};e.prototype.MaxSpeed=function(a){a.set_float(this.maxspeed)};e.prototype.Acceleration=function(a){a.set_float(this.acc)};e.prototype.Deceleration=function(a){a.set_float(this.dec)};e.prototype.MovingAngle=function(a){a.set_float(cr.to_degrees(Math.atan2(this.dy,this.dx)))};e.prototype.VectorX=function(a){a.set_float(this.dx)};e.prototype.VectorY=function(a){a.set_float(this.dy)};d.exps=new e})();cr.behaviors.Fade=function(a){this.runtime=a};
(function(){function a(){}function b(){}var e=cr.behaviors.Fade.prototype;e.Type=function(a,b){this.behavior=a;this.objtype=b;this.runtime=a.runtime};e.Type.prototype.onCreate=function(){};e.Instance=function(a,b){this.type=a;this.behavior=a.behavior;this.inst=b;this.runtime=a.runtime};var d=e.Instance.prototype;d.onCreate=function(){var a=1===this.properties[0];this.fadeInTime=this.properties[1];this.waitTime=this.properties[2];this.fadeOutTime=this.properties[3];this.destroy=this.properties[4];
this.stage=a?0:3;this.recycled?this.stageTime.reset():this.stageTime=new cr.KahanAdder;this.maxOpacity=this.inst.opacity?this.inst.opacity:1;a&&(0===this.fadeInTime?(this.stage=1,0===this.waitTime&&(this.stage=2)):(this.inst.opacity=0,this.runtime.redraw=!0))};d.saveToJSON=function(){return{fit:this.fadeInTime,wt:this.waitTime,fot:this.fadeOutTime,s:this.stage,st:this.stageTime.sum,mo:this.maxOpacity}};d.loadFromJSON=function(a){this.fadeInTime=a.fit;this.waitTime=a.wt;this.fadeOutTime=a.fot;this.stage=
a.s;this.stageTime.reset();this.stageTime.sum=a.st;this.maxOpacity=a.mo};d.tick=function(){this.stageTime.add(this.runtime.getDt(this.inst));0===this.stage&&(this.inst.opacity=this.stageTime.sum/this.fadeInTime*this.maxOpacity,this.runtime.redraw=!0,this.inst.opacity>=this.maxOpacity&&(this.inst.opacity=this.maxOpacity,this.stage=1,this.stageTime.reset()));1===this.stage&&this.stageTime.sum>=this.waitTime&&(this.stage=2,this.stageTime.reset());2===this.stage&&0!==this.fadeOutTime&&(this.inst.opacity=
this.maxOpacity-this.stageTime.sum/this.fadeOutTime*this.maxOpacity,this.runtime.redraw=!0,0>this.inst.opacity&&(this.inst.opacity=0,this.stage=3,this.stageTime.reset(),this.runtime.trigger(cr.behaviors.Fade.prototype.cnds.OnFadeOutEnd,this.inst),1===this.destroy&&this.runtime.DestroyInstance(this.inst)))};d.doStart=function(){this.stage=0;this.stageTime.reset();0===this.fadeInTime?(this.stage=1,0===this.waitTime&&(this.stage=2)):(this.inst.opacity=0,this.runtime.redraw=!0)};a.prototype.OnFadeOutEnd=
function(){return!0};e.cnds=new a;b.prototype.StartFade=function(){3===this.stage&&this.doStart()};b.prototype.RestartFade=function(){this.doStart()};e.acts=new b})();cr.behaviors.Flash=function(a){this.runtime=a};
(function(){function a(){}function b(){}var e=cr.behaviors.Flash.prototype;e.Type=function(a,b){this.behavior=a;this.objtype=b;this.runtime=a.runtime};e.Type.prototype.onCreate=function(){};e.Instance=function(a,b){this.type=a;this.behavior=a.behavior;this.inst=b;this.runtime=a.runtime};var d=e.Instance.prototype;d.onCreate=function(){this.timeleft=this.stagetimeleft=this.stage=this.offtime=this.ontime=0};d.saveToJSON=function(){return{ontime:this.ontime,offtime:this.offtime,stage:this.stage,stagetimeleft:this.stagetimeleft,
timeleft:this.timeleft}};d.loadFromJSON=function(a){this.ontime=a.ontime;this.offtime=a.offtime;this.stage=a.stage;this.stagetimeleft=a.stagetimeleft;this.timeleft=a.timeleft};d.tick=function(){if(!(0>=this.timeleft)){var a=this.runtime.getDt(this.inst);this.timeleft-=a;0>=this.timeleft?(this.timeleft=0,this.inst.visible=!0,this.runtime.redraw=!0,this.runtime.trigger(cr.behaviors.Flash.prototype.cnds.OnFlashEnded,this.inst)):(this.stagetimeleft-=a,0>=this.stagetimeleft&&(0===this.stage?(this.inst.visible=
!1,this.stage=1,this.stagetimeleft+=this.offtime):(this.inst.visible=!0,this.stage=0,this.stagetimeleft+=this.ontime),this.runtime.redraw=!0))}};a.prototype.IsFlashing=function(){return 0<this.timeleft};a.prototype.OnFlashEnded=function(){return!0};e.cnds=new a;b.prototype.Flash=function(a,b,d){this.ontime=a;this.offtime=b;this.stage=1;this.stagetimeleft=b;this.timeleft=d;this.inst.visible=!1;this.runtime.redraw=!0};b.prototype.StopFlashing=function(){this.timeleft=0;this.inst.visible=!0;this.runtime.redraw=
!0};e.acts=new b;e.exps=new function(){}})();cr.behaviors.Pin=function(a){this.runtime=a};
(function(){function a(){}function b(){}function e(){}var d=cr.behaviors.Pin.prototype;d.Type=function(a,b){this.behavior=a;this.objtype=b;this.runtime=a.runtime};d.Type.prototype.onCreate=function(){};d.Instance=function(a,b){this.type=a;this.behavior=a.behavior;this.inst=b;this.runtime=a.runtime};var c=d.Instance.prototype;c.onCreate=function(){this.pinObject=null;this.pinObjectUid=-1;this.mode=this.lastKnownAngle=this.theirStartAngle=this.myStartAngle=this.pinDist=this.pinAngle=0;var a=this;this.recycled||
(this.myDestroyCallback=function(b){a.onInstanceDestroyed(b)});this.runtime.addDestroyCallback(this.myDestroyCallback)};c.saveToJSON=function(){return{uid:this.pinObject?this.pinObject.uid:-1,pa:this.pinAngle,pd:this.pinDist,msa:this.myStartAngle,tsa:this.theirStartAngle,lka:this.lastKnownAngle,m:this.mode}};c.loadFromJSON=function(a){this.pinObjectUid=a.uid;this.pinAngle=a.pa;this.pinDist=a.pd;this.myStartAngle=a.msa;this.theirStartAngle=a.tsa;this.lastKnownAngle=a.lka;this.mode=a.m};c.afterLoad=
function(){this.pinObject=-1===this.pinObjectUid?null:this.runtime.getObjectByUID(this.pinObjectUid);this.pinObjectUid=-1};c.onInstanceDestroyed=function(a){this.pinObject==a&&(this.pinObject=null)};c.onDestroy=function(){this.pinObject=null;this.runtime.removeDestroyCallback(this.myDestroyCallback)};c.tick=function(){};c.tick2=function(){if(this.pinObject){this.lastKnownAngle!==this.inst.angle&&(this.myStartAngle=cr.clamp_angle(this.myStartAngle+(this.inst.angle-this.lastKnownAngle)));var a=this.inst.x,
b=this.inst.y;if(3===this.mode||4===this.mode){var c=cr.distanceTo(this.inst.x,this.inst.y,this.pinObject.x,this.pinObject.y);if(c>this.pinDist||4===this.mode&&c<this.pinDist)b=cr.angleTo(this.pinObject.x,this.pinObject.y,this.inst.x,this.inst.y),a=this.pinObject.x+Math.cos(b)*this.pinDist,b=this.pinObject.y+Math.sin(b)*this.pinDist}else a=this.pinObject.x+Math.cos(this.pinObject.angle+this.pinAngle)*this.pinDist,b=this.pinObject.y+Math.sin(this.pinObject.angle+this.pinAngle)*this.pinDist;this.lastKnownAngle=
c=cr.clamp_angle(this.myStartAngle+(this.pinObject.angle-this.theirStartAngle));0!==this.mode&&1!==this.mode&&3!==this.mode&&4!==this.mode||this.inst.x===a&&this.inst.y===b||(this.inst.x=a,this.inst.y=b,this.inst.set_bbox_changed());0!==this.mode&&2!==this.mode||this.inst.angle===c||(this.inst.angle=c,this.inst.set_bbox_changed())}};a.prototype.IsPinned=function(){return!!this.pinObject};d.cnds=new a;b.prototype.Pin=function(a,b){if(a){var c=a.getFirstPicked(this.inst);c&&(this.pinObject=c,this.pinAngle=
cr.angleTo(c.x,c.y,this.inst.x,this.inst.y)-c.angle,this.pinDist=cr.distanceTo(c.x,c.y,this.inst.x,this.inst.y),this.lastKnownAngle=this.myStartAngle=this.inst.angle,this.theirStartAngle=c.angle,this.mode=b)}};b.prototype.Unpin=function(){this.pinObject=null};d.acts=new b;e.prototype.PinnedUID=function(a){a.set_int(this.pinObject?this.pinObject.uid:-1)};d.exps=new e})();cr.behaviors.bound=function(a){this.runtime=a};
(function(){var a=cr.behaviors.bound.prototype;a.Type=function(a,e){this.behavior=a;this.objtype=e;this.runtime=a.runtime};a.Type.prototype.onCreate=function(){};a.Instance=function(a,e){this.type=a;this.behavior=a.behavior;this.inst=e;this.runtime=a.runtime;this.mode=0};a=a.Instance.prototype;a.onCreate=function(){this.mode=this.properties[0]};a.tick=function(){};a.tick2=function(){this.inst.update_bbox();var a=this.inst.bbox,e=this.inst.layer.layout,d=!1;0===this.mode?(0>this.inst.x&&(this.inst.x=
0,d=!0),0>this.inst.y&&(this.inst.y=0,d=!0),this.inst.x>e.width&&(this.inst.x=e.width,d=!0),this.inst.y>e.height&&(this.inst.y=e.height,d=!0)):(0>a.left&&(this.inst.x-=a.left,d=!0),0>a.top&&(this.inst.y-=a.top,d=!0),a.right>e.width&&(this.inst.x-=a.right-e.width,d=!0),a.bottom>e.height&&(this.inst.y-=a.bottom-e.height,d=!0));d&&this.inst.set_bbox_changed()}})();cr.behaviors.custom=function(a){this.runtime=a};
(function(){function a(){}function b(){}function e(){}var d=cr.behaviors.custom.prototype;d.Type=function(a,b){this.behavior=a;this.objtype=b;this.runtime=a.runtime};d.Type.prototype.onCreate=function(){};d.Instance=function(a,b){this.type=a;this.behavior=a.behavior;this.inst=b;this.runtime=a.runtime;this.cancelStep=this.dy=this.dx=0};var c=d.Instance.prototype;c.onCreate=function(){this.stepMode=this.properties[0];this.pxPerStep=this.properties[1];this.enabled=0!==this.properties[2]};c.saveToJSON=
function(){return{dx:this.dx,dy:this.dy,cancelStep:this.cancelStep,enabled:this.enabled,stepMode:this.stepMode,pxPerStep:this.pxPerStep}};c.loadFromJSON=function(a){this.dx=a.dx;this.dy=a.dy;this.cancelStep=a.cancelStep;this.enabled=a.enabled;this.stepMode=a.stepMode;this.pxPerStep=a.pxPerStep};c.getSpeed=function(){return Math.sqrt(this.dx*this.dx+this.dy*this.dy)};c.getAngle=function(){return Math.atan2(this.dy,this.dx)};c.step=function(a,b,c){if(0!==a||0!==b){var d=this.inst.x,e=this.inst.y,n,
v=Math.round(Math.sqrt(a*a+b*b)/this.pxPerStep);0===v&&(v=1);var u;for(u=1;u<=v;u++)if(n=u/v,this.inst.x=d+a*n,this.inst.y=e+b*n,this.inst.set_bbox_changed(),this.runtime.trigger(c,this.inst),1===this.cancelStep){u--;n=u/v;this.inst.x=d+a*n;this.inst.y=e+b*n;this.inst.set_bbox_changed();break}else if(2===this.cancelStep)break}};c.tick=function(){var a=this.runtime.getDt(this.inst),b=this.dx*a,a=this.dy*a;0===this.dx&&0===this.dy||!this.enabled||(this.cancelStep=0,0===this.stepMode?(this.inst.x+=b,
this.inst.y+=a):1===this.stepMode?this.step(b,a,cr.behaviors.custom.prototype.cnds.OnCMStep):2===this.stepMode?(this.step(b,0,cr.behaviors.custom.prototype.cnds.OnCMHorizStep),this.cancelStep=0,this.step(0,a,cr.behaviors.custom.prototype.cnds.OnCMVertStep)):3===this.stepMode&&(this.step(0,a,cr.behaviors.custom.prototype.cnds.OnCMVertStep),this.cancelStep=0,this.step(b,0,cr.behaviors.custom.prototype.cnds.OnCMHorizStep)),this.inst.set_bbox_changed())};a.prototype.IsMoving=function(){return 0!=this.dx||
0!=this.dy};a.prototype.CompareSpeed=function(a,b,c){var d;switch(a){case 0:d=this.getSpeed();break;case 1:d=this.dx;break;case 2:d=this.dy}return cr.do_cmp(d,b,c)};a.prototype.OnCMStep=function(){return!0};a.prototype.OnCMHorizStep=function(){return!0};a.prototype.OnCMVertStep=function(){return!0};d.cnds=new a;b.prototype.Stop=function(){this.dy=this.dx=0};b.prototype.Reverse=function(a){switch(a){case 0:this.dx*=-1;this.dy*=-1;break;case 1:this.dx*=-1;break;case 2:this.dy*=-1}};b.prototype.SetSpeed=
function(a,b){var c;switch(a){case 0:c=this.getAngle();this.dx=Math.cos(c)*b;this.dy=Math.sin(c)*b;break;case 1:this.dx=b;break;case 2:this.dy=b}};b.prototype.Accelerate=function(a,b){var c=this.runtime.getDt(this.inst),c=b*c,d;switch(a){case 0:d=this.getAngle();this.dx+=Math.cos(d)*c;this.dy+=Math.sin(d)*c;break;case 1:this.dx+=c;break;case 2:this.dy+=c}};b.prototype.AccelerateAngle=function(a,b){var c=this.runtime.getDt(this.inst),c=a*c,d=cr.to_radians(b);this.dx+=Math.cos(d)*c;this.dy+=Math.sin(d)*
c};b.prototype.AcceleratePos=function(a,b,c){var d=this.runtime.getDt(this.inst);a*=d;b=Math.atan2(c-this.inst.y,b-this.inst.x);this.dx+=Math.cos(b)*a;this.dy+=Math.sin(b)*a};b.prototype.SetAngleOfMotion=function(a){a=cr.to_radians(a);var b=this.getSpeed();this.dx=Math.cos(a)*b;this.dy=Math.sin(a)*b};b.prototype.RotateAngleOfMotionClockwise=function(a){a=this.getAngle()+cr.to_radians(a);var b=this.getSpeed();this.dx=Math.cos(a)*b;this.dy=Math.sin(a)*b};b.prototype.RotateAngleOfMotionCounterClockwise=
function(a){a=this.getAngle()-cr.to_radians(a);var b=this.getSpeed();this.dx=Math.cos(a)*b;this.dy=Math.sin(a)*b};b.prototype.StopStepping=function(a){this.cancelStep=a+1};b.prototype.PushOutSolid=function(a){var b;switch(a){case 0:b=this.getAngle();a=Math.cos(b);b=Math.sin(b);this.runtime.pushOutSolid(this.inst,-a,-b,Math.max(3*this.getSpeed(),100));break;case 1:this.runtime.pushOutSolidNearest(this.inst);break;case 2:this.runtime.pushOutSolid(this.inst,0,-1,Math.max(3*Math.abs(this.dy),100));break;
case 3:this.runtime.pushOutSolid(this.inst,0,1,Math.max(3*Math.abs(this.dy),100));break;case 4:this.runtime.pushOutSolid(this.inst,-1,0,Math.max(3*Math.abs(this.dx),100));break;case 5:this.runtime.pushOutSolid(this.inst,1,0,Math.max(3*Math.abs(this.dx),100))}};b.prototype.PushOutSolidAngle=function(a){a=cr.to_radians(a);var b=Math.cos(a);a=Math.sin(a);this.runtime.pushOutSolid(this.inst,b,a,Math.max(3*this.getSpeed(),100))};b.prototype.SetEnabled=function(a){this.enabled=1===a};d.acts=new b;e.prototype.Speed=
function(a){a.set_float(this.getSpeed())};e.prototype.MovingAngle=function(a){a.set_float(cr.to_degrees(this.getAngle()))};e.prototype.dx=function(a){a.set_float(this.dx)};e.prototype.dy=function(a){a.set_float(this.dy)};d.exps=new e})();cr.behaviors.destroy=function(a){this.runtime=a};
(function(){var a=cr.behaviors.destroy.prototype;a.Type=function(a,e){this.behavior=a;this.objtype=e;this.runtime=a.runtime};a.Type.prototype.onCreate=function(){};a.Instance=function(a,e){this.type=a;this.behavior=a.behavior;this.inst=e;this.runtime=a.runtime};a=a.Instance.prototype;a.onCreate=function(){};a.tick=function(){this.inst.update_bbox();var a=this.inst.bbox,e=this.inst.layer.layout;(0>a.right||0>a.bottom||a.left>e.width||a.top>e.height)&&this.runtime.DestroyInstance(this.inst)}})();
cr.behaviors.scrollto=function(a){this.runtime=a;this.shakeMode=this.shakeEnd=this.shakeStart=this.shakeMag=0};
(function(){function a(){}var b=cr.behaviors.scrollto.prototype;b.Type=function(a,b){this.behavior=a;this.objtype=b;this.runtime=a.runtime};b.Type.prototype.onCreate=function(){};b.Instance=function(a,b){this.type=a;this.behavior=a.behavior;this.inst=b;this.runtime=a.runtime};var e=b.Instance.prototype;e.onCreate=function(){};e.saveToJSON=function(){return{smg:this.behavior.shakeMag,ss:this.behavior.shakeStart,se:this.behavior.shakeEnd,smd:this.behavior.shakeMode}};e.loadFromJSON=function(a){this.behavior.shakeMag=
a.smg;this.behavior.shakeStart=a.ss;this.behavior.shakeEnd=a.se;this.behavior.shakeMode=a.smd};e.tick=function(){};e.tick2=function(){var a=this.behavior.my_instances.values(),b=0,e=0,g,h;g=0;for(h=a.length;g<h;g++)b+=a[g].x,e+=a[g].y;g=this.inst.layer.layout;var l=this.runtime.kahanTime.sum,k=h=0;l>=this.behavior.shakeStart&&l<this.behavior.shakeEnd&&(h=this.behavior.shakeMag*Math.min(this.runtime.timescale,1),0===this.behavior.shakeMode&&(h*=1-(l-this.behavior.shakeStart)/(this.behavior.shakeEnd-
this.behavior.shakeStart)),l=2*Math.random()*Math.PI,k=Math.random()*h,h=Math.cos(l)*k,k*=Math.sin(l));g.scrollToX(b/a.length+h);g.scrollToY(e/a.length+k)};a.prototype.Shake=function(a,b,e){this.behavior.shakeMag=a;this.behavior.shakeStart=this.runtime.kahanTime.sum;this.behavior.shakeEnd=this.behavior.shakeStart+b;this.behavior.shakeMode=e};b.acts=new a})();cr.behaviors.solid=function(a){this.runtime=a};
(function(){function a(){}function b(){}var e=cr.behaviors.solid.prototype;e.Type=function(a,b){this.behavior=a;this.objtype=b;this.runtime=a.runtime};e.Type.prototype.onCreate=function(){};e.Instance=function(a,b){this.type=a;this.behavior=a.behavior;this.inst=b;this.runtime=a.runtime};var d=e.Instance.prototype;d.onCreate=function(){this.inst.extra.solidEnabled=0!==this.properties[0]};d.tick=function(){};a.prototype.IsEnabled=function(){return this.inst.extra.solidEnabled};e.cnds=new a;b.prototype.SetEnabled=
function(a){this.inst.extra.solidEnabled=!!a};e.acts=new b})();
cr.getProjectModel=function(){return[null,null,[[cr.plugins_.Browser,!0,!1,!1,!1,!1,!1,!1,!1,!1],[cr.plugins_.Button,!1,!0,!0,!0,!1,!1,!1,!1,!1],[cr.plugins_.Facebook,!0,!1,!1,!1,!1,!1,!1,!1,!1],[cr.plugins_.Keyboard,!0,!1,!1,!1,!1,!1,!1,!1,!1],[cr.plugins_.Touch,!0,!1,!1,!1,!1,!1,!1,!1,!1],[cr.plugins_.TiledBg,!1,!0,!0,!0,!0,!0,!0,!0,!0],[cr.plugins_.Sprite,!1,!0,!0,!0,!0,!0,!0,!0,!1],[cr.plugins_.Mouse,!0,!1,!1,!1,!1,!1,!1,!1,!1],[cr.plugins_.NodeWebkit,!0,!1,!1,!1,!1,!1,!1,!1,!1],[cr.plugins_.Text,
!1,!0,!0,!0,!0,!0,!0,!0,!1],[cr.plugins_.Audio,!0,!1,!1,!1,!1,!1,!1,!1,!1]],[["t0",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",10,!0,1,0,!1,9802370165285292,[["sprite1-sheet0.png",49458,1,1,120,120,1,0.5,0.5,[],[-0.341667,-0.5,0.45,-0.483333,0.408333,0.483333,-0.316667,0.5],0],["sprite1-sheet0.png",49458,122,1,120,120,1,0.5,0.5,[],[-0.341667,-0.5,0.45,-0.483333,0.408333,0.483333,-0.316667,0.5],0],["sprite1-sheet0.png",49458,1,122,120,120,1,0.5,0.5,[],[-0.341667,-0.5,0.45,-0.483333,0.408333,0.483333,
-0.316667,0.5],0],["sprite1-sheet0.png",49458,122,122,120,120,1,0.5,0.5,[],[-0.341667,-0.5,0.45,-0.483333,0.408333,0.483333,-0.316667,0.5],0],["sprite1-sheet1.png",25297,1,1,120,120,1,0.5,0.5,[],[-0.341667,-0.5,0.45,-0.483333,0.408333,0.483333,-0.316667,0.5],0],["sprite1-sheet1.png",25297,122,1,120,120,1,0.5,0.5,[],[-0.341667,-0.5,0.45,-0.483333,0.408333,0.483333,-0.316667,0.5],0]]]],[["DestroyOutsideLayout",cr.behaviors.destroy,9550423683034416]],!1,!1,8367308011215737,[]],["t1",cr.plugins_.Sprite,
!1,[],1,0,null,[["Default",5,!1,1,0,!1,8206051208505546,[["solido-sheet0.png",20034,0,0,330,346,1,0,0,[],[0.0545455,0.352601,0.621212,0.0231214,0.936364,0.283237,0.990909,0.601156,0.712121,0.791907,0.387879,0.985549,0.0272727,0.650289],0]]]],[["Solid",cr.behaviors.solid,6018923241690463]],!1,!1,0xab3d2c8c75e18,[]],["t2",cr.plugins_.TiledBg,!1,[],0,0,["tiledbackground.png",53654,1],null,[],!1,!1,713087966060305,[]],["t3",cr.plugins_.Sprite,!1,[],2,0,null,[["Default",5,!1,1,0,!1,7298543273957387,[["sprite-sheet0.png",
2362,0,0,74,64,1,0.5,0.5,[],[-0.27027,-0.234375,0,-0.484375,0.22973,-0.1875,0.432432,0,0.324324,0.296875,0,0.484375,-0.283784,0.25,-0.297297,0],0],["sprite-sheet1.png",2348,0,0,74,64,1,0.5,0.5,[],[0.297297,0,0.283784,0.25,0,0.484375,-0.324324,0.296875,-0.432432,0,-0.22973,-0.1875,0,-0.484375,0.27027,-0.234375],0]]]],[["BoundToLayout",cr.behaviors.bound,6580017898097506],["CustomMovement",cr.behaviors.custom,0xb2665c526b157]],!1,!1,0xdf2f61e16b50a,[]],["t4",cr.plugins_.Keyboard,!1,[],0,0,null,null,
[],!1,!1,9282626102629664,[],[]],["t5",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,0xde91b7be830a3,[["sprite3-sheet0.png",3651,0,0,108,207,1,0.5,0.502415,[],[-0.092593,-0.289855,0,-0.405797,0.296296,-0.396135,0.027778,-0.00483048,0.203704,0.342996,0,0.449275,-0.240741,0.362319,-0.101852,-0.00483048],0]]]],[["8Direction",cr.behaviors.EightDir,0xcdbecb9dfdb7b]],!1,!1,0x58a369305e808,[]],["t6",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,5390207057593589,[["sprite4-sheet0.png",
3461,0,0,207,108,1,0.502415,0.5,[],[-0.367149,-0.240741,-0.00483048,-0.101852,0.285025,-0.092593,0.400967,0,0.391304,0.296296,-0.00483048,0.027778,-0.347826,0.203704,-0.454106,0],0]]]],[["8Direction",cr.behaviors.EightDir,8202258724198344]],!1,!1,884322294822705,[]],["t7",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,9604458663434548,[["sprite5-sheet0.png",3467,0,0,207,108,1,0.502415,0.5,[],[-0.289855,-0.092593,-0.00483048,-0.101852,0.342996,-0.203704,0.400967,0,0.318841,0.157407,-0.00483048,
0.027778,-0.256038,0.027778,-0.454106,0],0]]]],[["8Direction",cr.behaviors.EightDir,0x4579b4456968e]],!1,!1,6986517052871078,[]],["t8",cr.plugins_.Sprite,!1,[],2,0,null,[["Default",5,!1,1,0,!1,6006919024961927,[["sprite-sheet0.png",2362,0,0,74,64,1,0.5,0.5,[],[-0.27027,-0.234375,0,-0.484375,0.22973,-0.1875,0.432432,0,0.324324,0.296875,0,0.484375,-0.283784,0.25,-0.297297,0],0],["sprite-sheet1.png",2348,0,0,74,64,1,0.5,0.5,[],[0.297297,0,0.283784,0.25,0,0.484375,-0.324324,0.296875,-0.432432,0,-0.22973,
-0.1875,0,-0.484375,0.27027,-0.234375],0]]]],[["8Direction",cr.behaviors.EightDir,6048995267086869],["BoundToLayout",cr.behaviors.bound,7225242269356171]],!1,!1,883616490821704,[]],["t9",cr.plugins_.TiledBg,!1,[],0,0,["tiledbackground2.png",12090,1],null,[],!1,!1,0xfe745b2e2f0de,[]],["t10",cr.plugins_.Sprite,!1,[],3,0,null,[["andando",5,!0,1,0,!1,5610542909513018,[["sprite7-sheet0.png",317686,1,1,200,187,1,0.5,0.502674,[["Imagepoint 1",0.905,1.29412],["Imagepoint 2",0.455,1.25134],["Imagepoint 3",
-0.09,1.08021],["Imagepoint 4",-0.25,0.57754],["Imagepoint 5",1.185,0.55615]],[-0.19,-0.385027,0.21,-0.374332,0.37,-0.256685,0.485,0.0106952,0.12,0.454545,-0.085,0.44385,-0.27,0.347593,-0.465,-0.106952],0],["sprite7-sheet0.png",317686,202,1,200,187,1,0.5,0.502674,[],[-0.19,-0.385027,0.21,-0.374332,0.37,-0.256685,0.485,0.0106952,0.12,0.454545,-0.085,0.44385,-0.27,0.347593,-0.465,-0.106952],0],["sprite7-sheet0.png",317686,403,1,200,187,1,0.5,0.502674,[],[-0.19,-0.385027,0.21,-0.374332,0.37,-0.256685,
0.485,0.0106952,0.12,0.454545,-0.085,0.44385,-0.27,0.347593,-0.465,-0.106952],0],["sprite7-sheet0.png",317686,604,1,200,187,1,0.5,0.502674,[],[-0.19,-0.385027,0.21,-0.374332,0.37,-0.256685,0.485,0.0106952,0.12,0.454545,-0.085,0.44385,-0.27,0.347593,-0.465,-0.106952],0],["sprite7-sheet0.png",317686,805,1,200,187,1,0.5,0.502674,[],[-0.19,-0.385027,0.21,-0.374332,0.37,-0.256685,0.485,0.0106952,0.12,0.454545,-0.085,0.44385,-0.27,0.347593,-0.465,-0.106952],0],["sprite7-sheet0.png",317686,1,189,200,187,
1,0.5,0.502674,[],[-0.19,-0.385027,0.21,-0.374332,0.37,-0.256685,0.485,0.0106952,0.12,0.454545,-0.085,0.44385,-0.27,0.347593,-0.465,-0.106952],0],["sprite7-sheet0.png",317686,202,189,200,187,1,0.5,0.502674,[],[-0.19,-0.385027,0.21,-0.374332,0.37,-0.256685,0.485,0.0106952,0.12,0.454545,-0.085,0.44385,-0.27,0.347593,-0.465,-0.106952],0],["sprite7-sheet0.png",317686,403,189,200,187,1,0.5,0.502674,[],[-0.19,-0.385027,0.21,-0.374332,0.37,-0.256685,0.485,0.0106952,0.12,0.454545,-0.085,0.44385,-0.27,0.347593,
-0.465,-0.106952],0],["sprite7-sheet0.png",317686,604,189,200,187,1,0.5,0.502674,[],[-0.19,-0.385027,0.21,-0.374332,0.37,-0.256685,0.485,0.0106952,0.12,0.454545,-0.085,0.44385,-0.27,0.347593,-0.465,-0.106952],0],["sprite7-sheet0.png",317686,805,189,200,187,1,0.5,0.502674,[],[-0.19,-0.385027,0.21,-0.374332,0.37,-0.256685,0.485,0.0106952,0.12,0.454545,-0.085,0.44385,-0.27,0.347593,-0.465,-0.106952],0]]],["deCostas",10,!0,1,0,!1,5521262019961256,[["sprite7-sheet0.png",317686,1,377,200,187,1,0.5,0.502674,
[["Imagepoint 1",1.035,1.19251],["Imagepoint 2",0.59,1.19251],["Imagepoint 3",0.185,1.19786],["Imagepoint 4",-0.19,0.705882],["Imagepoint 5",1.165,0.566845]],[],0],["sprite7-sheet0.png",317686,202,377,200,187,1,0.5,0.502674,[],[],0],["sprite7-sheet0.png",317686,403,377,200,187,1,0.5,0.502674,[],[],0],["sprite7-sheet0.png",317686,604,377,200,187,1,0.5,0.502674,[],[],0],["sprite7-sheet0.png",317686,805,377,200,187,1,0.5,0.502674,[],[],0],["sprite7-sheet0.png",317686,1,565,200,187,1,0.5,0.502674,[],
[],0],["sprite7-sheet0.png",317686,202,565,200,187,1,0.5,0.502674,[],[],0],["sprite7-sheet0.png",317686,403,565,200,187,1,0.5,0.502674,[],[],0],["sprite7-sheet0.png",317686,604,565,200,187,1,0.5,0.502674,[],[],0],["sprite7-sheet0.png",317686,805,565,200,187,1,0.5,0.502674,[],[],0],["sprite7-sheet0.png",317686,1,753,200,187,1,0.5,0.502674,[],[],0],["sprite7-sheet0.png",317686,202,753,200,187,1,0.5,0.502674,[],[],0],["sprite7-sheet0.png",317686,403,753,200,187,1,0.5,0.502674,[],[],0],["sprite7-sheet0.png",
317686,604,753,200,187,1,0.5,0.502674,[],[],0],["sprite7-sheet0.png",317686,805,753,200,187,1,0.5,0.502674,[],[],0],["sprite7-sheet1.png",225378,1,1,200,187,1,0.5,0.502674,[],[],0],["sprite7-sheet1.png",225378,202,1,200,187,1,0.5,0.502674,[],[],0],["sprite7-sheet1.png",225378,403,1,200,187,1,0.5,0.502674,[],[],0],["sprite7-sheet1.png",225378,604,1,200,187,1,0.5,0.502674,[],[],0],["sprite7-sheet1.png",225378,805,1,200,187,1,0.5,0.502674,[],[],0]]],["beijandoGal",5,!0,1,0,!1,5831186941261031,[["sprite7-sheet1.png",
225378,1,189,200,187,1,0.5,0.502674,[["Imagepoint 1",0.99,1.19251],["Imagepoint 2",0.44,1.21925],["Imagepoint 3",0.005,1.19251],["Imagepoint 4",-0.2,0.631016],["Imagepoint 5",1.175,0.497326]],[],0],["sprite7-sheet1.png",225378,202,189,200,187,1,0.5,0.502674,[],[],0],["sprite7-sheet1.png",225378,403,189,200,187,1,0.5,0.502674,[],[],0]]],["maluco",20,!0,1,0,!1,9409373310477834,[["sprite7-sheet1.png",225378,604,189,200,187,1,0.5,0.502674,[],[],0],["sprite7-sheet1.png",225378,805,189,200,187,1,0.5,0.502674,
[],[],0],["sprite7-sheet1.png",225378,1,377,200,187,1,0.5,0.502674,[],[],0]]]],[["8Direction",cr.behaviors.EightDir,7332671641260385],["BoundToLayout",cr.behaviors.bound,6791742340693424],["ScrollTo",cr.behaviors.scrollto,0x7f2ce15492c0b]],!1,!1,7651489879466313,[]],["t11",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",10,!0,1,0,!1,896732613046353,[["sprite8-sheet0.png",91025,1,1,150,141,1,0.5,0.503546,[],[-0.426667,-0.478723,0.373333,-0.5,0.353333,0.485816,-0.413333,0.496454],0],["sprite8-sheet0.png",
91025,152,1,150,141,1,0.5,0.503546,[],[-0.426667,-0.478723,0.373333,-0.5,0.353333,0.485816,-0.413333,0.496454],0],["sprite8-sheet0.png",91025,303,1,150,141,1,0.5,0.503546,[],[-0.426667,-0.478723,0.373333,-0.5,0.353333,0.485816,-0.413333,0.496454],0],["sprite8-sheet0.png",91025,1,143,150,141,1,0.5,0.503546,[],[-0.426667,-0.478723,0.373333,-0.5,0.353333,0.485816,-0.413333,0.496454],0],["sprite8-sheet0.png",91025,152,143,150,141,1,0.5,0.503546,[],[-0.426667,-0.478723,0.373333,-0.5,0.353333,0.485816,
-0.413333,0.496454],0],["sprite8-sheet0.png",91025,303,143,150,141,1,0.5,0.503546,[],[-0.426667,-0.478723,0.373333,-0.5,0.353333,0.485816,-0.413333,0.496454],0],["sprite8-sheet0.png",91025,1,285,150,141,1,0.5,0.503546,[],[-0.426667,-0.478723,0.373333,-0.5,0.353333,0.485816,-0.413333,0.496454],0],["sprite8-sheet0.png",91025,152,285,150,141,1,0.5,0.503546,[],[-0.426667,-0.478723,0.373333,-0.5,0.353333,0.485816,-0.413333,0.496454],0],["sprite8-sheet0.png",91025,303,285,150,141,1,0.5,0.503546,[],[-0.426667,
-0.478723,0.373333,-0.5,0.353333,0.485816,-0.413333,0.496454],0],["sprite8-sheet1.png",62471,1,1,150,141,1,0.5,0.503546,[],[-0.426667,-0.478723,0.373333,-0.5,0.353333,0.485816,-0.413333,0.496454],0],["sprite8-sheet1.png",62471,152,1,150,141,1,0.5,0.503546,[],[-0.426667,-0.478723,0.373333,-0.5,0.353333,0.485816,-0.413333,0.496454],0],["sprite8-sheet1.png",62471,303,1,150,141,1,0.5,0.503546,[],[-0.426667,-0.478723,0.373333,-0.5,0.353333,0.485816,-0.413333,0.496454],0],["sprite8-sheet1.png",62471,1,
143,150,141,1,0.5,0.503546,[],[-0.426667,-0.478723,0.373333,-0.5,0.353333,0.485816,-0.413333,0.496454],0],["sprite8-sheet1.png",62471,152,143,150,141,1,0.5,0.503546,[],[-0.426667,-0.478723,0.373333,-0.5,0.353333,0.485816,-0.413333,0.496454],0]]]],[["DestroyOutsideLayout",cr.behaviors.destroy,0xa86ed244b3738]],!1,!1,0x968b6fca32484,[]],["t12",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",9,!0,1,0,!1,4706288200423363,[["timba2-sheet0.png",87169,1,1,200,200,1,0.5,0.5,[],[0.275,0.5,-0.3,0.5,-0.375,-0.5,
0.335,-0.5],0],["timba2-sheet0.png",87169,202,1,200,200,1,0.5,0.5,[],[0.275,0.5,-0.3,0.5,-0.375,-0.5,0.335,-0.5],0],["timba2-sheet0.png",87169,1,202,200,200,1,0.5,0.5,[],[0.275,0.5,-0.3,0.5,-0.375,-0.5,0.335,-0.5],0],["timba2-sheet0.png",87169,202,202,200,200,1,0.5,0.5,[],[0.275,0.5,-0.3,0.5,-0.375,-0.5,0.335,-0.5],0],["timba2-sheet1.png",33425,1,1,200,200,1,0.5,0.5,[],[0.275,0.5,-0.3,0.5,-0.375,-0.5,0.335,-0.5],0],["timba2-sheet1.png",33425,202,1,200,200,1,0.5,0.5,[],[0.275,0.5,-0.3,0.5,-0.375,-0.5,
0.335,-0.5],0]]]],[["DestroyOutsideLayout",cr.behaviors.destroy,0x6ff40688d554d]],!1,!1,0x9df13c289f17c,[]],["t13",cr.plugins_.Sprite,!1,[],1,0,null,[["Default",5,!1,1,0,!1,9602435638870772,[["sprite2-sheet0.png",1548,0,0,53,60,1,0.509434,0.5,[],[-0.188679,-0.316667,-0.018868,-0.45,0.396227,-0.141667,0.40566,0.208333,0.207547,0.366666,-0.018868,0.483333,-0.415094,0.225,-0.443396,-0.191667],0]]]],[["Solid",cr.behaviors.solid,0xa75993b179853]],!1,!1,627036711919899,[]],["t14",cr.plugins_.Sprite,!1,
[],1,0,null,[["Default",5,!1,1,0,!1,4797369636081668,[["sprite9-sheet0.png",7591,0,0,144,144,1,0.5,0.5,[],[-0.145833,-0.270833,0.152777,-0.430556,0.298611,-0.298611,0.486111,-0.111111,0.493056,0.180556,-0.055556,0.479167,-0.388889,0.222222,-0.4375,-0.145833],0]]]],[["Solid",cr.behaviors.solid,7080492466878863]],!1,!1,9595820882345666,[]],["t15",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,4967717162242784,[["sprite10-sheet0.png",5399,0,0,356,179,1,0.5,0.502793,[],[-0.457865,-0.418994,
0,-0.385475,0.441011,-0.385475,0.396067,-0.00558633,0.396067,0.290503,0,0.446928,-0.398876,0.29609,-0.460674,-0.00558633],0]]]],[],!1,!1,8158914478614271,[]],["t16",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,8532619479384364,[["sprite11-sheet0.png",1554,0,0,200,59,1,0.5,0.508475,[],[-0.44,-0.305085,0,-0.508475,0.5,-0.508475,0.495,-0.0169496,0.445,0.305084,0,0.322033,-0.445,0.305084,-0.5,-0.0169496],0]]]],[],!1,!1,9710626671413116,[]],["t17",cr.plugins_.Sprite,!1,[],2,0,null,[["Default",
5,!0,1,0,!1,0x3aa3234c42258,[["gal-sheet0.png",27771,0,0,200,233,1,0.5,0.502146,[],[-0.355,-0.377682,0,-0.463519,0.34,-0.364807,0.415,-0.00429195,0.27,0.300429,0,0.433476,-0.32,0.343348,-0.42,-0.00429195],0],["gal-sheet1.png",33876,0,0,200,233,1,0.5,0.502146,[],[-0.355,-0.377682,0,-0.463519,0.34,-0.364807,0.415,-0.00429195,0.27,0.300429,0,0.433476,-0.32,0.343348,-0.42,-0.00429195],0],["gal-sheet2.png",33181,0,0,200,233,1,0.5,0.502146,[],[-0.355,-0.377682,0,-0.463519,0.34,-0.364807,0.415,-0.00429195,
0.27,0.300429,0,0.433476,-0.32,0.343348,-0.42,-0.00429195],0]]]],[["Flash",cr.behaviors.Flash,7063054111634813],["Pin",cr.behaviors.Pin,0x4b2ed2b87cce5]],!1,!1,5680537601025498,[]],["t18",cr.plugins_.Sprite,!1,[],2,0,null,[["Default",5,!1,1,0,!1,6050052015928716,[["coracao-sheet0.png",976,0,0,50,48,1,0.5,0.5,[],[-0.36,-0.354167,0,-0.3125,0.36,-0.354167,0.42,0,0.28,0.270833,0,0.395833,-0.24,0.229167,-0.44,0],0]]]],[["Fade",cr.behaviors.Fade,6937695287492751],["Pin",cr.behaviors.Pin,6489354272239064]],
!1,!1,6726937862742277,[]],["t19",cr.plugins_.Sprite,!1,[303394686353073],3,0,null,[["Default",7,!0,1,0,!1,6417352373554614,[["gal-sheet0.png",27771,0,0,200,233,1,0.505,0.27897,[["Imagepoint 1",0.45,-0.248927]],[],0],["gal-sheet1.png",33876,0,0,200,233,1,0.555,0.300429,[],[],0],["gal-sheet2.png",33181,0,0,200,233,1,0.455,0.304721,[],[],0]]]],[["Pin",cr.behaviors.Pin,9230967222917600],["Flash",cr.behaviors.Flash,0xbbe144d6cfd5a],["Fade",cr.behaviors.Fade,0x978a25510e0a5]],!1,!1,7322672652394977,[]],
["t20",cr.plugins_.Text,!1,[],0,0,null,null,[],!1,!1,5707570755811389,[]],["t21",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,0x8060322f28135,[["sprite12-sheet0.png",483598,0,0,512,512,1,0.5,0.5,[],[],1]]]],[],!1,!1,7134656274701598,[]],["t22",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,0x9162f3ee906b7,[["sprite13-sheet0.png",146,0,0,200,200,1,0.5,0.5,[],[],3]]]],[],!1,!1,652640905848524,[]],["t23",cr.plugins_.Mouse,!1,[],0,0,null,null,[],!1,!1,7617201362521483,[],[]],["t24",
cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,6383373715231523,[["sprite14-sheet0.png",20727,0,0,250,133,1,0.5,0.503759,[],[-0.22,0.0225566,0,-0.503759,0.22,0.0225566,0.484,0.466166,0,0.496241,-0.484,0.466166],0]]]],[],!1,!1,0xe8103b85ee023,[]],["t25",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,8349230463018414,[["sprite15-sheet0.png",17717,0,0,250,103,1,0.5,0.504854,[],[-0.496,-0.495146,0,-0.466019,0.416,-0.300971,0.392,0.23301,0,0.291263,-0.484,0.456311],0]]]],[],!1,!1,
0x4aaef60e3972e,[]],["t26",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,9272493734425740,[["sprite16-sheet0.png",7887,0,0,205,131,1,0.502439,0.503817,[],[-0.463415,-0.442748,-0.00487801,-0.503817,0.458537,-0.442748,0.497561,-0.00763378,0.458537,0.435114,-0.00487801,0.496183,-0.463415,0.435114,-0.502439,-0.00763378],0]]]],[],!1,!1,5761679649828936,[]],["t27",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,6448226567519001,[["sprite17-sheet0.png",4062,0,0,102,82,1,0.5,0.5,[],
[-0.45098,-0.439024,0,-0.5,0.45098,-0.439024,0.5,0,0.45098,0.439024,0,0.5,-0.45098,0.439024,-0.5,0],0]]]],[],!1,!1,0xee8f54e74d989,[]],["t28",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,9914283125230024,[["sprite18-sheet0.png",10528,0,0,250,60,1,0.5,0.5,[],[-0.496,-0.483333,0,0.166667,0.364,0.066667,0.372,0,0.412,0.133333,0,0.2,-0.496,0.483333,-0.3,0],0]]]],[],!1,!1,776697498001049,[]],["t29",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,7827167602484699,[["sprite19-sheet0.png",
814,0,0,97,97,1,0.505155,0.505155,[],[-0.505155,-0.505155,-0.0103096,-0.371134,0.206185,-0.216495,0.360824,-0.0103096,0.494845,0.494845,-0.505155,0.494845],0]]]],[],!1,!1,962994376601716,[]],["t30",cr.plugins_.Touch,!1,[],0,0,null,null,[],!1,!1,7097982676349649,[],[0]],["t31",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,0x859289113a01d,[["sprite20-sheet0.png",9716,0,0,218,219,1,0.5,0.502283,[],[0,-0.461187,0.463303,-0.0045661,0,0.456621,-0.458716,-0.0045661],0]]]],[],!1,!1,0xe8b8fb2902c50,
[]],["t32",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,5325514964891699,[["setashift-sheet0.png",729,0,0,66,114,1,0.5,0.5,[],[-0.181818,-0.315789,0,-0.491228,0.19697,-0.324561,0.287879,0,0.287879,0.377193,0,0.5,-0.287879,0.377193,-0.287879,0],0]]]],[],!1,!1,348396093790738,[]],["t33",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,6985332197937554,[["top_t-sheet0.png",641,0,0,64,64,1,0.5,0.5,[],[],0]]]],[],!1,!1,0xa6b33cacca421,[]],["t34",cr.plugins_.Sprite,!1,[],0,0,null,
[["Default",5,!1,1,0,!1,0xdf07309549b73,[["top_t-sheet0.png",641,0,0,64,64,1,0.5,0.5,[],[],0]]]],[],!1,!1,0xf2930151be91c,[]],["t35",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,0x6c427e39afbb7,[["top_t-sheet0.png",641,0,0,64,64,1,0.5,0.5,[],[],0]]]],[],!1,!1,0x7ab8ce7c947b3,[]],["t36",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,0xb9d33e8369472,[["top_t-sheet0.png",641,0,0,64,64,1,0.5,0.5,[],[],0]]]],[],!1,!1,0x99adaf4b2e98f,[]],["t37",cr.plugins_.Sprite,!1,[],0,0,null,
[["Default",5,!1,1,0,!1,0xc937a3253a779,[["setashift-sheet0.png",729,0,0,66,114,1,0.5,0.5,[],[-0.181818,-0.315789,0,-0.491228,0.19697,-0.324561,0.287879,0,0.287879,0.377193,0,0.5,-0.287879,0.377193,-0.287879,0],0]]]],[],!1,!1,6388638260985907,[]],["t38",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",10,!0,1,0,!1,0xaf9ad86641ee5,[["sprite7-sheet0.png",317686,1,1,200,187,1,0.525,0.705882,[],[],0],["sprite7-sheet0.png",317686,1,1,200,187,1,0.525,0.705882,[],[],0],["sprite7-sheet0.png",317686,202,1,200,
187,1,0.525,0.705882,[],[],0],["sprite7-sheet0.png",317686,403,1,200,187,1,0.525,0.705882,[],[],0],["sprite7-sheet0.png",317686,604,1,200,187,1,0.525,0.705882,[],[],0],["sprite7-sheet0.png",317686,805,1,200,187,1,0.525,0.705882,[],[],0],["sprite7-sheet0.png",317686,1,189,200,187,1,0.525,0.705882,[],[],0],["sprite7-sheet0.png",317686,1,189,200,187,1,0.525,0.705882,[],[],0],["sprite7-sheet0.png",317686,202,189,200,187,1,0.525,0.705882,[],[],0],["sprite7-sheet0.png",317686,403,189,200,187,1,0.525,0.705882,
[],[],0],["sprite7-sheet0.png",317686,604,189,200,187,1,0.525,0.705882,[],[],0],["sprite7-sheet0.png",317686,805,189,200,187,1,0.525,0.705882,[],[],0]]]],[],!1,!1,8419046555767928,[]],["t39",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,8619955657354507,[["sprite22-sheet0.png",19455,0,0,713,199,1,0.500701,0.502513,[],[-0.497896,-0.492462,-0.00140226,-0.311558,0.420758,-0.221106,0.24404,-0.00502557,0.392707,0.115577,-0.00140226,0.41206,-0.479663,0.42211,-0.256662,-0.00502557],0]]]],[],
!1,!1,9785454769280364,[]],["t40",cr.plugins_.Audio,!1,[],0,0,null,null,[],!1,!1,0x539cb32d74461,[],[0,0,1,1,600,600,1E4,1,5E3,1]],["t41",cr.plugins_.Text,!1,[],0,0,null,null,[],!1,!1,9331559759759744,[]],["t42",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,0xbb5d7072875b,[["sprite24-sheet0.png",8520,0,0,313,104,1,0.501597,0.5,[],[-0.485623,-0.451923,-0.00319445,-0.5,0.482429,-0.451923,0.498403,0,0.482429,0.451923,-0.00319445,0.5,-0.485623,0.451923,-0.501597,0],0]]]],[],!1,!1,9419370834029254,
[]],["t43",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,6711246098997961,[["sprite25-sheet0.png",13222,0,0,300,76,1,0.5,0.5,[],[-0.49,-0.460526,0,-0.368421,0.463333,-0.355263,0.493333,0,0.423333,0.197368,0,0.210526,-0.463333,0.355263,-0.493333,0],0]]]],[],!1,!1,9968608443875806,[]],["t44",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,532601366846163,[["som1-sheet0.png",6948,0,0,128,128,1,0.5,0.5,[],[-0.28125,-0.28125,0.28125,-0.28125,0.5,0,0.28125,0.28125,-0.28125,0.28125,
-0.5,0],0]]]],[],!1,!1,0x837af877060f6,[]],["t45",cr.plugins_.Text,!1,[],0,0,null,null,[],!1,!1,0x9be20d9123537,[]],["t46",cr.plugins_.Sprite,!1,[8660390427728781],0,0,null,[["Default",5,!0,1,0,!1,8192713222137087,[["policia-sheet2.png",33714,1,1,288,757,1,0.5,0.50066,[],[-0.225694,-0.5,0.5,-0.50066,0.177083,0.49934,-0.5,0.49934],0],["policia-sheet2.png",33714,290,1,288,757,1,0.5,0.50066,[],[-0.225694,-0.5,0.5,-0.50066,0.177083,0.49934,-0.5,0.49934],0],["policia-sheet2.png",33714,579,1,288,757,1,
0.5,0.50066,[],[-0.225694,-0.5,0.5,-0.50066,0.177083,0.49934,-0.5,0.49934],0],["policia-sheet3.png",11462,0,0,288,757,1,0.5,0.50066,[],[-0.225694,-0.5,0.5,-0.50066,0.177083,0.49934,-0.5,0.49934],0]]],["prende",2,!1,1,0,!1,8096746811146116,[["policia-sheet0.png",62664,1,1,590,757,1,0.5,0.50066,[],[-0.049153,-0.50066,0.235593,-0.50066,0.042373,0.49868,-0.255932,0.493396],0],["policia-sheet0.png",62664,592,1,590,757,1,0.5,0.50066,[],[-0.049153,-0.50066,0.235593,-0.50066,0.042373,0.49868,-0.255932,0.493396],
0],["policia-sheet0.png",62664,1183,1,590,757,1,0.5,0.50066,[],[-0.049153,-0.50066,0.235593,-0.50066,0.042373,0.49868,-0.255932,0.493396],0],["policia-sheet0.png",62664,1,759,590,757,1,0.5,0.50066,[],[-0.049153,-0.50066,0.235593,-0.50066,0.042373,0.49868,-0.255932,0.493396],0],["policia-sheet0.png",62664,592,759,590,757,1,0.5,0.50066,[],[-0.049153,-0.50066,0.235593,-0.50066,0.042373,0.49868,-0.255932,0.493396],0],["policia-sheet0.png",62664,1183,759,590,757,1,0.5,0.50066,[],[-0.049153,-0.50066,0.235593,
-0.50066,0.042373,0.49868,-0.255932,0.493396],0]]],["prendesus",5,!0,1,0,!1,0x666198f88948e,[["policia-sheet1.png",71999,1,1,590,757,1,0.5,0.50066,[],[],0],["policia-sheet1.png",71999,592,1,590,757,1,0.5,0.50066,[],[],0],["policia-sheet1.png",71999,1183,1,590,757,1,0.5,0.50066,[],[],0],["policia-sheet1.png",71999,1,759,590,757,1,0.5,0.50066,[],[],0]]],["solta",5,!0,1,0,!1,0xf2b98b21012f4,[["policia-sheet1.png",71999,592,759,590,757,1,0.5,0.50066,[],[],0],["policia-sheet1.png",71999,1183,759,590,757,
1,0.5,0.50066,[],[],0]]]],[],!1,!1,8687080632689889,[]],["t47",cr.plugins_.Sprite,!1,[],2,0,null,[["abertura",5,!1,1,0,!1,7759496154192402,[["policia-sheet0.png",62664,1183,759,590,757,1,0.5,0.50066,[],[],0],["policia-sheet0.png",62664,1,759,590,757,1,0.5,0.50066,[],[],0],["policia-sheet1.png",71999,1,1,590,757,1,0.5,0.50066,[],[],0],["policia-sheet1.png",71999,592,1,590,757,1,0.5,0.50066,[],[],0],["policia-sheet1.png",71999,1183,1,590,757,1,0.5,0.50066,[],[],0],["policia-sheet1.png",71999,1,759,
590,757,1,0.5,0.50066,[],[],0]]],["prisao",5,!0,1,0,!1,8805994274809638,[["policia-sheet1.png",71999,1,1,590,757,1,0.5,0.50066,[],[],0],["policia-sheet1.png",71999,592,1,590,757,1,0.5,0.50066,[],[],0],["policia-sheet1.png",71999,1183,1,590,757,1,0.5,0.50066,[],[],0],["policia-sheet1.png",71999,1,759,590,757,1,0.5,0.50066,[],[],0]]],["soltando",5,!1,1,0,!1,7945948160694749,[["policia-sheet1.png",71999,1,1,590,757,1,0.5,0.50066,[],[],0],["policia-sheet1.png",71999,592,1,590,757,1,0.5,0.50066,[],[],
0],["policia-sheet1.png",71999,1183,1,590,757,1,0.5,0.50066,[],[],0],["policia-sheet1.png",71999,1,759,590,757,1,0.5,0.50066,[],[],0],["policia-sheet0.png",62664,1,759,590,757,1,0.5,0.50066,[],[],0],["policia-sheet0.png",62664,1183,759,590,757,1,0.5,0.50066,[],[],0]]]],[["Solid",cr.behaviors.solid,8936328748628839],["Fade",cr.behaviors.Fade,0x7905b078f4207]],!1,!1,0x78f4596f8551d,[]],["t48",cr.plugins_.Facebook,!1,[],0,0,null,null,[],!1,!1,382624257378007,[],["281089965290430","1d2adc8f338785b064c4fb7bb310e0ce"]],
["t49",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,0xdeb1ca20b5f3a,[["sprite13-sheet0.png",146,0,0,200,200,1,0.5,0.5,[],[],3]]]],[],!1,!1,0x6ffd9e7c9375c,[]],["t50",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,0xc6a6388f1d017,[["loginface-sheet0.png",12641,0,0,100,84,1,0.5,0.511905,[],[],1]]]],[],!1,!1,6321613377360592,[]],["t51",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,0xed76932ffe035,[["top10-sheet0.png",2130,0,0,100,38,1,0.5,0.5,[],[],1]]]],[],!1,!1,
0xb7323563cad86,[]],["t52",cr.plugins_.Text,!1,[],0,0,null,null,[],!1,!1,0xa7771f0445611,[]],["t53",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,0xac37995be992b,[["facescore-sheet0.png",2553,0,0,100,38,1,0.5,0.5,[],[],1]]]],[],!1,!1,5718375726459218,[]],["t54",cr.plugins_.Text,!1,[],0,0,null,null,[],!1,!1,8667575357836815,[]],["t55",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,6969828802845539,[["sprite27-sheet0.png",15512,0,0,240,129,1,0.5,0.813953,[],[],0]]]],[],!1,!1,
378759538122879,[]],["t56",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,9819220594905732,[["compartilhar-sheet0.png",48203,0,0,300,190,1,0.5,0.5,[],[],1]]]],[],!1,!1,4749793291540429,[]],["t57",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,0x852ea1529fccd,[["sprite28-sheet0.png",2519,0,0,189,26,1,0.502645,0.5,[],[],1]]]],[],!1,!1,0xa137cf80dc0a3,[]],["t58",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,81863336226249,[["loginfaceabert-sheet0.png",14824,0,0,200,
113,1,0.5,0.504425,[],[],1]]]],[],!1,!1,6898016221717134,[]],["t59",cr.plugins_.Text,!1,[],0,0,null,null,[],!1,!1,0xe1704127ba98a,[]],["t60",cr.plugins_.Text,!1,[],2,0,null,null,[["Fade",cr.behaviors.Fade,6733315975168462],["Flash",cr.behaviors.Flash,6942409179164368]],!1,!1,4879802104542369,[]],["t61",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,5397046453573783,[["sprite29-sheet0.png",45959,0,0,656,106,1,0.5,0.5,[],[-0.452744,-0.207547,0,-0.433962,0.471037,-0.320755,0.484756,0,0.477134,
0.358491,0,0.320755,-0.487805,0.424528],0]]]],[],!1,!1,0xf301279514520,[]],["t62",cr.plugins_.Button,!1,[],0,0,null,null,[],!1,!1,6916016190528705,[]],["t63",cr.plugins_.NodeWebkit,!1,[],0,0,null,null,[],!1,!1,6363286327633837,[],[]],["t64",cr.plugins_.Sprite,!1,[],0,0,null,[["Default",5,!1,1,0,!1,836351606002425,[["sprite30-sheet0.png",168,0,0,250,250,1,0.5,0.5,[],[],0]]]],[],!1,!1,5423960735317747,[]],["t65",cr.plugins_.Browser,!1,[],0,0,null,null,[],!1,!1,600898029245839,[],[]],["t66",cr.plugins_.Sprite,
!1,[],0,0,null,[["Default",5,!1,1,0,!1,0x6b3e3694ba429,[["fechar-sheet0.png",945,0,0,22,22,1,0.5,0.5,[],[-0.35567,-0.35567,-0.005155,-0.5,0.35567,-0.35567,0.5,-0.005155,0.35567,0.35567,-0.005155,0.5,-0.35567,0.35567,-0.5,-0.005155],0]]]],[],!1,!1,5574149275055707,[]]],[],[["abertura empresa",1165,635,!1,"loginface_ sheet 1",8090245894414762,[["Layer 0",0,0x607527fc0fff3,!0,[255,255,255],!1,1,1,1,!1,1,0,0,[[[587,321,0,1174,642,0,0,1,0.5,0.5,0,0,[]],64,64,[],[],[0,"Default",0,1]],[[1430,355,0,143.264,
87.2237,0,0,1,0.5,0.502793,0,0,[]],15,0,[],[],[0,"Default",0,1]],[[1433,461,0,200,113,0,0,1,0.5,0.504425,0,0,[]],58,1,[],[],[0,"Default",0,1]],[[1336,523,0,191,69,0,0,1,0,0,0,0,[]],59,2,[],[],["Clique aqui para permitir que o Facebook salve sua pontua\u00e7\u00e3o no ranking.",0,"12pt Arial","rgb(0,0,0)",0,0,0,0,0]],[[1427,131,0,190.588,107.812,0,0,1,0.5,0.813953,0,0,[]],55,3,[],[],[0,"Default",0,1]],[[1091,626,0,147.888,20.3444,0,0,1,0.502645,0.5,0,0,[]],57,4,[],[],[0,"Default",0,1]],[[573,318,0,
656,106,0,0,1,0.5,0.5,0,0,[]],61,5,[],[],[0,"Default",0,1]]],[]]],[],[]],["abertura",1165,635,!1,"Abertura  sheet 2",8903159895799975,[["Layer 0",0,7350259850515509,!0,[255,255,255],!1,0,0,1,!1,0,0,0,[[[409,281,0,59,68,0,0,1,0.5,0.502146,0,0,[]],17,6,[],[[],[]],[0,"Default",0,1]],[[580,282,0,91,83,0,0,1,0.5,0.5,0,0,[]],12,7,[],[[]],[0,"Default",0,1]],[[658,278,0,93,86,0,0,1,0.5,0.503546,0,0,[]],11,8,[],[[]],[0,"Default",0,1]],[[721,274,0,94,94,0,0,1,0.5,0.5,0,0,[]],0,9,[],[[]],[0,"Default",0,1]],
[[570,149,0,255.998,155.86,0,0,1,0.5,0.502793,0,0,[]],15,10,[],[],[0,"Default",0,1]],[[710.135,374.93,0,121,77,0,0,1,0.5,0.503759,0,0,[]],24,11,[],[],[0,"Default",0,1]],[[492,296,0,96.1201,93.0901,0,0,1,0.525,0.705882,0,0,[]],38,12,[],[],[0,"Default",0,1]],[[527,375,0,268.269,74.8744,0,0,1,0.500701,0.502513,0,0,[]],39,13,[],[],[0,"Default",0,1]],[[-290,986,0,401,331,0,0,1,0.5,0.5,0,0,[]],21,14,[],[],[0,"Default",0,1]],[[570,524,0,189.447,126.7,0,0,1,0.502439,0.503817,0,0,[]],26,15,[],[],[0,"Default",
0,1]],[[1146,18,0,22,22,0,0,1,0.5,0.5,0,0,[]],66,66,[],[],[0,"Default",0,1]]],[]]],[],[]],["jogo",1280,900,!1,"Jogo sheet 1",0x74dd852783cd2,[["Layer 1",0,5145387066810412,!0,[255,255,255],!1,1,1,1,!1,1,0,0,[[[102,-531,0,1696,1571,0,0.349066,1,0,0,0,0,[]],9,16,[],[],[0,0]],[[107,351,0,85,91,0,0,1,0.5,0.5,0,0,[]],14,17,[],[[1]],[0,"Default",0,1]],[[627,866,0,85,91,0,0,1,0.5,0.5,0,0,[]],14,18,[],[[1]],[0,"Default",0,1]],[[257,726,0,53,60,0,0,1,0.509434,0.5,0,0,[]],13,19,[],[[1]],[0,"Default",0,1]],
[[945,573,0,53,60,0,0,1,0.509434,0.5,0,0,[]],13,20,[],[[1]],[0,"Default",0,1]],[[372,142,0,345.373,198.666,0,-0.002493,1,0.5,0.502793,0,0,[]],15,21,[],[],[0,"Default",0,1]],[[27.7335,-158.6,0,41.7062,40.4831,0,0,1,0.5,0.5,0,0,[]],18,22,[],[[1,0,0,3,1],[]],[0,"Default",0,1]]],[]],["personagens",1,4551225168446653,!0,[255,255,255],!0,1,1,1,!1,0.7,0,0,[[[238,125,0,93.2132,90.2245,0,0,1,0.5,0.502674,0,0,[]],10,23,[],[[300,2E3,500,2,0,1,1],[1],[]],[0,"Default",0,1]],[[841,-71,0,-97,95,0,0,1,0.5,0.5,0,
0,[]],0,24,[],[[]],[0,"Default",0,1]],[[1210,-79,0,-100,97,0,0,1,0.5,0.5,0,0,[]],0,25,[],[[]],[0,"Default",0,1]],[[198,-161,0,-101,89,0,0,1,0.5,0.5,0,0,[]],0,26,[],[[]],[0,"Default",0,1]],[[477.5,-65.5,0,-100,95,0,0,1,0.5,0.5,0,0,[]],0,27,[],[[]],[0,"Default",0,1]],[[383,56,0,98,95,0,0,1,0.5,0.503546,0,0,[]],11,28,[],[[]],[0,"Default",0,1]],[[651,251,0,98,95,0,0,1,0.5,0.503546,0,0,[]],11,29,[],[[]],[0,"Default",0,1]],[[597.996,-69.6527,0,96.9703,91.5431,0,-0.0215793,1,0.5,0.5,0,0,[]],12,30,[],[[]],
[0,"Default",0,1]],[[1124,178,0,-251,253,0,-0.0357483,1,0,0,0,0,[]],1,31,[],[[1]],[0,"Default",0,1]],[[284.972,355.463,0,216,210,0,-0.0357483,1,0,0,0,0,[]],1,32,[],[[1]],[0,"Default",0,1]],[[702.428,-66.4035,0,65.1769,77.3539,0,0,1,0.5,0.502146,0,0,[]],17,33,[],[[],[]],[0,"Default",0,1]],[[235.469,-70.6467,0,65.3264,76.087,0,0,1,0.505,0.27897,0,0,[]],19,34,[[0]],[[],[],[1,0,0,1,1]],[0,"Default",0,1]],[[1393,-147,0,104,264,0,0,1,0.5,0.50066,0,0,[]],46,35,[[0]],[],[0,"Default",0,1]],[[1047.74,-193.795,
0,215,259,0,0,1,0.5,0.50066,0,0,[]],47,36,[],[[1],[1,0,4,1,1]],[0,"Default",0,1]]],[]],["HUD",2,0x3bec08256ccd1,!0,[255,255,255],!0,0,0,1,!1,0,0,0,[[[989.867,-24,0,209,184,0,0,0.7,0.5,0.5,0,0,[]],21,37,[],[],[0,"Default",0,1]],[[1011,-3,0,73,92,0,0,1,0,0,0,0,[]],20,38,[],[],["10",0,"bold 48pt Arial Narrow","rgb(204,0,0)",1,0,0,0,0]],[[-185,104,0,86.824,51.2919,0,-0.002493,1,0.5,0.502793,0,0,[]],15,39,[],[],[0,"Default",0,1]],[[851,13,0,138,53,0,0,1,0,0,0,0,[]],41,40,[],[],["0",0,"bold 26pt Arial",
"rgb(0,0,0)",2,0,0,0,0]],[[0,18,0,64.405,64.405,0,0,1,0.5,0.5,0,0,[]],44,41,[],[],[0,"Default",0,1]],[[557,584,0,64,64,0,0,1,0.5,0.5,0,0,[]],35,42,[],[],[1,"Default",0,1]],[[736,582,0,64,64,0,0,1,0.5,0.5,0,0,[]],36,43,[],[],[1,"Default",0,1]],[[645,505,0,64,64,0,0,1,0.5,0.5,0,0,[]],33,44,[],[],[1,"Default",0,1]],[[648,583,0,64,64,0,0,1,0.5,0.5,0,0,[]],34,45,[],[],[1,"Default",0,1]],[[1144,15,0,22,22,0,0,1,0.5,0.5,0,0,[]],66,67,[],[],[0,"Default",0,1]]],[]]],[],[]],["game over",1165,635,!1,"Fim do jogo  sheet 3",
5131360432347359,[["Layer 0",0,7937973468658224,!0,[255,255,255],!1,1,1,1,!1,1,0,0,[[[564.096,207.815,0,267,160,0,0,1,0.5,0.502793,0,0,[]],15,46,[],[],[0,"Default",0,1]],[[-414,794,0,480,295,0,0,1,0.5,0.5,0,0,[]],21,47,[],[],[0,"Default",0,1]],[[393,318,0,352,53,0,0,1,0,0,0,0,[]],41,48,[],[],["0",0,"bold 22pt Arial","rgb(0,0,0)",1,0,0,0,0]],[[-166,573,0,100,38,0,0,1,0.5,0.5,0,0,[]],51,49,[],[],[0,"Default",0,1]],[[-206,245,0,122,44,0,0,1,0,0,0,0,[]],52,50,[],[],["0",0,"bold 22pt Arial","rgb(0,0,0)",
0,0,0,0,0]],[[-159,220,0,100,38,0,0,1,0.5,0.5,0,0,[]],53,51,[],[],[0,"Default",0,1]],[[574,482,0,285.625,106.657,0,0,1,0.501597,0.5,0,0,[]],42,52,[],[],[0,"Default",0,1]],[[837,168,0,281,270,0,0,1,0,0,0,0,[]],54,53,[],[],["",0,"10pt Arial","rgb(0,0,0)",0,0,0,0,0]],[[570,100,0,125,34,0,0,1,0.5,0.5,0,0,[]],43,54,[],[],[0,"Default",0,1]],[[-136,349,0,149.023,94.3813,0,0,1,0.5,0.5,0,0,[]],56,55,[],[],[0,"Default",0,1]],[[480,407,0,104,99,0,0,1,0.525,0.705882,0,0,[]],38,56,[],[],[0,"Default",0,1]],[[-236,
607,0,148,30,0,0,1,0,0,0,0,[]],60,57,[],[[1,0,3,1,1],[]],["Loading Ranking",0,"bold 12pt Arial","rgb(0,0,0)",0,0,0,0,0]],[[1141,22,0,22,22,0,0,1,0.5,0.5,0,0,[]],66,68,[],[],[0,"Default",0,1]]],[]]],[],[]]],[["Jogo sheet 1",[[1,"colisaopolicia",0,0,!1,!1,366498052424205,!1],[1,"score",0,0,!1,!1,0x520dbc05bc99c,!1],[1,"desktop2",0,0,!1,!1,4931973940191587,!1],[1,"touchscreen2",0,0,!1,!1,7287722105020182,!1],[1,"Minutes",0,0,!1,!1,6243428087826761,!1],[1,"Seconds",0,0,!1,!1,6795141676946968,!1],[1,"Subtractor",
0,0,!1,!1,0x3ac807b4e748d,!1],[0,null,!1,null,9368362300949808,[[-1,cr.system_object.prototype.cnds.OnLayoutStart,null,1,!1,!1,!1,5084335766676391,!1]],[[40,cr.plugins_.Audio.prototype.acts.Play,null,9074873894482664,!1,[[2,["escola de ax",!0]],[3,1],[0,[0,0]],[1,[2,"original"]]]],[40,cr.plugins_.Audio.prototype.acts.SetVolume,null,0xf2857dc43db67,!1,[[1,[2,"original"]],[0,[0,-2]]]],[40,cr.plugins_.Audio.prototype.acts.SetLooping,null,0x75c0414ba3e55,!1,[[1,[2,"original"]],[3,0]]]]],[0,[!0,"CREATE CHARACTERS"],
!1,null,387978242545558,[[-1,cr.system_object.prototype.cnds.IsGroupActive,null,0,!1,!1,!1,387978242545558,!1,[[1,[2,"CREATE CHARACTERS"]]]]],[],[[0,null,!1,null,7815287729968138,[[-1,cr.system_object.prototype.cnds.EveryTick,null,0,!1,!1,!1,307619933165843,!1]],[[0,cr.plugins_.Sprite.prototype.acts.MoveAtAngle,null,4960076016322843,!1,[[0,[0,90]],[0,[0,2]]]],[11,cr.plugins_.Sprite.prototype.acts.MoveAtAngle,null,5776747038481606,!1,[[0,[0,70]],[0,[0,2]]]],[12,cr.plugins_.Sprite.prototype.acts.MoveAtAngle,
null,5363552909178016,!1,[[0,[0,80]],[0,[0,2]]]],[17,cr.plugins_.Sprite.prototype.acts.MoveAtAngle,null,0xe5bca18d8dd3d,!1,[[0,[0,80]],[0,[0,2]]]],[46,cr.plugins_.Sprite.prototype.acts.MoveAtAngle,null,0x6d199542399cf,!1,[[0,[0,90]],[0,[0,2]]]],[20,cr.plugins_.Text.prototype.acts.SetText,null,4936230253654407,!1,[[7,[10,[2,""],[23,"score"]]]]]],[[0,null,!1,null,0x5a847d4e20e49,[[-1,cr.system_object.prototype.cnds.Every,null,0,!1,!1,!1,600969806415674,!1,[[0,[0,2]]]]],[[-1,cr.system_object.prototype.acts.CreateObject,
null,6412035883365322,!1,[[4,0],[5,[0,0]],[0,[19,cr.system_object.prototype.exps.random,[[0,1200]]]],[0,[19,cr.system_object.prototype.exps.random,[[1,100.4]]]]]],[-1,cr.system_object.prototype.acts.CreateObject,null,0x6ae578503d097,!1,[[4,11],[5,[0,0]],[0,[19,cr.system_object.prototype.exps.random,[[0,1200]]]],[0,[0,0]]]],[-1,cr.system_object.prototype.acts.CreateObject,null,0xa2930b0b2de99,!1,[[4,12],[5,[0,0]],[0,[19,cr.system_object.prototype.exps.random,[[0,1200]]]],[0,[0,0]]]]]],[0,null,!1,null,
0xe961331d922fa,[[-1,cr.system_object.prototype.cnds.Every,null,0,!1,!1,!1,0x5fbb233af27af,!1,[[0,[0,6]]]]],[[-1,cr.system_object.prototype.acts.CreateObject,null,8099112116763182,!1,[[4,17],[5,[0,0]],[0,[19,cr.system_object.prototype.exps.random,[[0,1200]]]],[0,[19,cr.system_object.prototype.exps.random,[[0,600]]]]]],[-1,cr.system_object.prototype.acts.CreateObject,null,8708061255997082,!1,[[4,46],[5,[0,0]],[0,[19,cr.system_object.prototype.exps.random,[[0,1200]]]],[0,[19,cr.system_object.prototype.exps.random,
[[0,100]]]]]]]],[0,null,!1,null,425245599325856,[[-1,cr.system_object.prototype.cnds.Every,null,0,!1,!1,!1,0xd19f3f9146293,!1,[[0,[0,1]]]]],[[-1,cr.system_object.prototype.acts.AddVar,null,683730664067325,!1,[[11,"Seconds"],[7,[0,1]]]],[-1,cr.system_object.prototype.acts.SetVar,null,8621445134720761,!1,[[11,"Minutes"],[7,[19,cr.system_object.prototype.exps.floor,[[7,[23,"Seconds"],[0,60]]]]]]],[-1,cr.system_object.prototype.acts.SetVar,null,0x5d15be4c0fd5b,!1,[[11,"Subtractor"],[7,[6,[23,"Minutes"],
[0,60]]]]],[41,cr.plugins_.Text.prototype.acts.SetText,null,6991465053093831,!1,[[7,[10,[10,[10,[2," "],[19,cr.system_object.prototype.exps.floor,[[23,"Minutes"]]]],[2,":"]],[5,[23,"Seconds"],[23,"Subtractor"]]]]]]]],[0,null,!1,null,9011409276013360,[[-1,cr.system_object.prototype.cnds.CompareVar,null,0,!1,!1,!1,0x52c35c4e54812,!1,[[11,"Minutes"],[8,0],[7,[0,2]]]]],[[-1,cr.system_object.prototype.acts.GoToLayout,null,795540130611192,!1,[[6,"game over"]]]]],[0,null,!1,null,4873545705908074,[[1,cr.plugins_.Sprite.prototype.cnds.OnCollision,
null,0,!1,!1,!0,8713741092356107,!1,[[4,12]]]],[[12,cr.plugins_.Sprite.prototype.acts.MoveAtAngle,null,7770824080499605,!1,[[0,[0,120]],[0,[0,-70]]]]]],[0,null,!1,null,7567410482093514,[[1,cr.plugins_.Sprite.prototype.cnds.OnCollision,null,0,!1,!1,!0,5511419253200687,!1,[[4,11]]]],[[11,cr.plugins_.Sprite.prototype.acts.MoveAtAngle,null,4888583872764343,!1,[[0,[19,cr.system_object.prototype.exps.random,[[0,30],[0,120]]]],[0,[0,-100]]]]]],[0,null,!1,null,0xcc5fa9385d354,[],[]],[0,null,!1,null,0xdc88375ef1f23,
[],[]],[0,null,!1,null,0xb71c9257297ac,[[1,cr.plugins_.Sprite.prototype.cnds.OnCollision,null,0,!1,!1,!0,8184217392889513,!1,[[4,46]]]],[[46,cr.plugins_.Sprite.prototype.acts.MoveAtAngle,null,4616971922394397,!1,[[0,[0,120]],[0,[0,-70]]]]]],[0,null,!1,null,93320391447222,[[46,cr.plugins_.Sprite.prototype.cnds.OnCollision,null,0,!1,!1,!0,6627298941945886,!1,[[4,12]]]],[[12,cr.plugins_.Sprite.prototype.acts.MoveAtAngle,null,5798781615168256,!1,[[0,[0,120]],[0,[0,-70]]]]]],[0,null,!1,null,0xa801b7cf28fc9,
[[46,cr.plugins_.Sprite.prototype.cnds.IsOverlapping,null,0,!1,!1,!1,0x91f88dbb20b2,!1,[[4,17]]]],[[17,cr.plugins_.Sprite.prototype.acts.MoveAtAngle,null,5046949383994142,!1,[[0,[0,120]],[0,[0,-20]]]]]],[0,null,!1,null,683114889364666,[[46,cr.plugins_.Sprite.prototype.cnds.IsOverlapping,null,0,!1,!1,!1,5163026267272175,!1,[[4,10]]]],[[10,cr.behaviors.EightDir.prototype.acts.Stop,"8Direction",8971811406936286,!1],[10,cr.plugins_.Sprite.prototype.acts.SetAnim,null,7384717045878477,!1,[[1,[2,"maluco"]],
[3,1]]]]],[0,null,!1,null,5744972229558268,[[46,cr.plugins_.Sprite.prototype.cnds.OnCollision,null,0,!1,!1,!0,919323682566069,!1,[[4,10]]]],[[-1,cr.system_object.prototype.acts.AddVar,null,7004329176678622,!1,[[11,"colisaopolicia"],[7,[0,1]]]],[46,cr.plugins_.Sprite.prototype.acts.SetAnim,null,4525330295442659,!1,[[1,[2,"prende"]],[3,0]]],[40,cr.plugins_.Audio.prototype.acts.Play,null,6234546191096388,!1,[[2,["napaz",!0]],[3,0],[0,[0,0]],[1,[2,""]]]]]],[0,null,!1,null,0xdc52f84675566,[[46,cr.plugins_.Sprite.prototype.cnds.OnAnyAnimFinished,
null,1,!1,!1,!1,517401553707323,!1]],[[46,cr.plugins_.Sprite.prototype.acts.SetAnim,null,8323527274509289,!1,[[1,[2,"default"]],[3,1]]]]],[0,null,!1,null,5431910307923955,[[-1,cr.system_object.prototype.cnds.CompareVar,null,0,!1,!1,!1,0x96d92f1b992a6,!1,[[11,"colisaopolicia"],[8,0],[7,[0,3]]]],[-1,cr.system_object.prototype.cnds.TriggerOnce,null,0,!1,!1,!1,8457165510499125,!1]],[[46,cr.plugins_.Sprite.prototype.acts.Destroy,null,0x723affaa648b2,!1],[10,cr.behaviors.EightDir.prototype.acts.SetIgnoreInput,
"8Direction",9703109160642372,!1,[[3,1]]],[10,cr.plugins_.Sprite.prototype.acts.SetAnim,null,0x491767e3aa043,!1,[[1,[2,"maluco"]],[3,1]]],[10,cr.plugins_.Sprite.prototype.acts.Spawn,null,0x49aeb6c4e67de,!1,[[4,47],[5,[0,0]],[7,[0,0]]]],[10,cr.plugins_.Sprite.prototype.acts.Spawn,null,7704242669497667,!1,[[4,38],[5,[0,0]],[7,[0,0]]]],[10,cr.plugins_.Sprite.prototype.acts.Destroy,null,7094408441043339,!1],[-1,cr.system_object.prototype.acts.SetVar,null,6296299647877614,!1,[[11,"colisaopolicia"],[7,
[0,0]]]]]],[0,null,!1,null,0xd15a28e403a8d,[[47,cr.plugins_.Sprite.prototype.cnds.OnAnimFinished,null,1,!1,!1,!1,0x80bd011c0d1fb,!1,[[1,[2,"abertura"]]]]],[[47,cr.plugins_.Sprite.prototype.acts.SetAnim,null,0xed85217533a75,!1,[[1,[2,"prisao"]],[3,1]]]]],[0,null,!1,null,8335094425026755,[[47,cr.plugins_.Sprite.prototype.cnds.IsVisible,null,0,!1,!1,!1,0xc644eb18d391f,!1]],[[-1,cr.system_object.prototype.acts.Wait,null,6094090980343127,!1,[[0,[0,5]]]],[47,cr.plugins_.Sprite.prototype.acts.Destroy,null,
5654815471193174,!1],[38,cr.plugins_.Sprite.prototype.acts.Spawn,null,4707034133933821,!1,[[4,10],[5,[0,0]],[7,[0,0]]]],[38,cr.plugins_.Sprite.prototype.acts.Destroy,null,0xc50e407714ffa,!1],[10,cr.behaviors.EightDir.prototype.acts.SetIgnoreInput,"8Direction",0x93c5dc37eb582,!1,[[3,0]]]]],[0,null,!1,null,5600714664476006,[[46,cr.plugins_.Sprite.prototype.cnds.IsOverlapping,null,0,!1,!1,!1,0x9acd085b8d796,!1,[[4,11]]]],[[11,cr.plugins_.Sprite.prototype.acts.MoveAtAngle,null,8728357946358223,!1,[[0,
[0,120]],[0,[0,-20]]]]]],[0,null,!1,null,9588919781006224,[[46,cr.plugins_.Sprite.prototype.cnds.IsOverlapping,null,0,!1,!1,!1,5015957831276181,!1,[[4,0]]]],[[0,cr.plugins_.Sprite.prototype.acts.MoveAtAngle,null,0xc5f49e31d1e4e,!1,[[0,[0,120]],[0,[0,-20]]]]]],[0,null,!1,null,6921707216076925,[[46,cr.plugins_.Sprite.prototype.cnds.IsOverlapping,null,0,!1,!1,!1,6843192230278032,!1,[[4,12]]]],[[12,cr.plugins_.Sprite.prototype.acts.MoveAtAngle,null,6597949525856858,!1,[[0,[0,30]],[0,[0,-20]]]]]]]]]],
[0,[!0,"player"],!1,null,5962153083185267,[[-1,cr.system_object.prototype.cnds.IsGroupActive,null,0,!1,!1,!1,5962153083185267,!1,[[1,[2,"player"]]]]],[]],[0,null,!1,null,9945832376190428,[],[]],[0,null,!1,null,6956753537687705,[[11,cr.plugins_.Sprite.prototype.cnds.IsOverlapping,null,0,!1,!1,!1,5407706644736902,!1,[[4,10]]]],[[11,cr.plugins_.Sprite.prototype.acts.MoveAtAngle,null,7274184999050595,!1,[[0,[19,cr.system_object.prototype.exps.random,[[0,30],[0,120]]]],[0,[0,10]]]]]],[0,null,!1,null,0x8565b65394a51,
[[0,cr.plugins_.Sprite.prototype.cnds.IsOverlapping,null,0,!1,!1,!1,5967186500536293,!1,[[4,10]]]],[[10,cr.behaviors.EightDir.prototype.acts.Reverse,"8Direction",0xeecb05462449d,!1],[0,cr.plugins_.Sprite.prototype.acts.MoveAtAngle,null,6990371528972716,!1,[[0,[19,cr.system_object.prototype.exps.random,[[0,30],[0,120]]]],[0,[0,17]]]]]],[0,null,!1,null,9754558473120844,[[12,cr.plugins_.Sprite.prototype.cnds.OnCollision,null,0,!1,!1,!0,0xa98b64e5ed914,!1,[[4,10]]]],[[12,cr.plugins_.Sprite.prototype.acts.MoveAtAngle,
null,8868361167337182,!1,[[0,[19,cr.system_object.prototype.exps.random,[[0,30]]]],[0,[19,cr.system_object.prototype.exps.random,[[0,-30],[0,30]]]]]]]],[0,null,!1,null,5327009236261432,[],[]],[0,null,!1,null,5543642040048837,[[4,cr.plugins_.Keyboard.prototype.cnds.IsKeyDown,null,0,!1,!1,!1,0x65a54838dfe1a,!1,[[9,38]]]],[[10,cr.plugins_.Sprite.prototype.acts.SetAnim,null,6781622937316577,!1,[[1,[2,"deCostas"]],[3,1]]]]],[0,null,!1,null,0x3b7211b565ee8,[[4,cr.plugins_.Keyboard.prototype.cnds.IsKeyDown,
null,0,!1,!1,!1,9640066259862340,!1,[[9,40]]]],[[10,cr.plugins_.Sprite.prototype.acts.SetAnim,null,8300767817640252,!1,[[1,[2,"andando"]],[3,1]]]]],[0,null,!1,null,4571929340494545,[[10,cr.plugins_.Sprite.prototype.cnds.IsOverlapping,null,0,!1,!1,!1,8452910080113995,!1,[[4,17]]]],[[10,cr.plugins_.Sprite.prototype.acts.Spawn,null,8067185314109543,!1,[[4,18],[5,[0,0]],[7,[0,5]]]],[17,cr.plugins_.Sprite.prototype.acts.Spawn,null,6631105134403336,!1,[[4,18],[5,[0,0]],[7,[0,0]]]],[18,cr.behaviors.Pin.prototype.acts.Pin,
"Pin",0x904209a717329,!1,[[4,10],[3,0]]],[10,cr.behaviors.scrollto.prototype.acts.Shake,"ScrollTo",9398641736561196,!1,[[0,[0,10]],[0,[1,0.8]],[3,1]]],[10,cr.behaviors.EightDir.prototype.acts.Stop,"8Direction",0x8296f657e1e2a,!1],[10,cr.plugins_.Sprite.prototype.acts.SetAnim,null,8153956021662742,!1,[[1,[2,"beijandoGal"]],[3,1]]],[10,cr.plugins_.Sprite.prototype.acts.Spawn,null,7379546157897104,!1,[[4,19],[5,[0,0]],[7,[19,cr.system_object.prototype.exps.random,[[0,1],[0,5]]]]]],[17,cr.plugins_.Sprite.prototype.acts.Destroy,
null,0xfcdd9f712145b,!1],[-1,cr.system_object.prototype.acts.AddVar,null,8757810350940877,!1,[[11,"score"],[7,[0,1]]]],[19,cr.behaviors.Pin.prototype.acts.Pin,"Pin",0x622af96d694dd,!1,[[4,10],[3,0]]],[40,cr.plugins_.Audio.prototype.acts.Play,null,6522799465978987,!1,[[2,["smuack",!0]],[3,0],[0,[0,0]],[1,[2,""]]]]]],[0,null,!1,null,7742461082825926,[[19,cr.behaviors.Pin.prototype.cnds.IsPinned,"Pin",0,!1,!1,!1,0x73caf61f3f577,!1]],[[-1,cr.system_object.prototype.acts.Wait,null,7849682434706138,!1,
[[0,[0,10]]]],[19,cr.behaviors.Flash.prototype.acts.Flash,"Flash",9621082578061844,!1,[[0,[1,0.1]],[0,[1,0.1]],[0,[1,1]]]],[19,cr.plugins_.Sprite.prototype.acts.Destroy,null,0x4376b148f2b8f,!1]]],[0,null,!1,null,5395469482783808,[[30,cr.plugins_.Touch.prototype.cnds.IsTouchingObject,null,0,!1,!1,!1,0x6604bffa442b6,!1,[[4,33]]]],[[10,cr.behaviors.EightDir.prototype.acts.SimulateControl,"8Direction",6201037663899364,!1,[[3,2]]],[10,cr.plugins_.Sprite.prototype.acts.SetAnim,null,688097366611005,!1,[[1,
[2,"deCostas"]],[3,1]]]]],[0,null,!1,null,6842695584782211,[[30,cr.plugins_.Touch.prototype.cnds.IsTouchingObject,null,0,!1,!1,!1,0xb9a38fccf8bad,!1,[[4,35]]]],[[10,cr.behaviors.EightDir.prototype.acts.SimulateControl,"8Direction",6476336091040847,!1,[[3,0]]]]],[0,null,!1,null,4811719497151586,[[30,cr.plugins_.Touch.prototype.cnds.IsTouchingObject,null,0,!1,!1,!1,5809256814308665,!1,[[4,36]]]],[[10,cr.behaviors.EightDir.prototype.acts.SimulateControl,"8Direction",5678549870383955,!1,[[3,1]]]]],[0,
null,!1,null,8026604817654936,[[30,cr.plugins_.Touch.prototype.cnds.IsTouchingObject,null,0,!1,!1,!1,0xfe0027bbd859d,!1,[[4,34]]]],[[10,cr.behaviors.EightDir.prototype.acts.SimulateControl,"8Direction",8867349612534554,!1,[[3,3]]],[10,cr.plugins_.Sprite.prototype.acts.SetAnim,null,503216464066051,!1,[[1,[2,"andando"]],[3,1]]]]],[0,null,!1,null,750810306036375,[[23,cr.plugins_.Mouse.prototype.cnds.OnObjectClicked,null,1,!1,!1,!1,0xe773df8cfa108,!1,[[3,0],[3,0],[4,44]]]],[[40,cr.plugins_.Audio.prototype.acts.SetMuted,
null,0xfbd26776ed807,!1,[[1,[2,""]],[3,0]]]]],[0,null,!1,null,0xcb943419655ef,[[23,cr.plugins_.Mouse.prototype.cnds.OnObjectClicked,null,1,!1,!1,!1,5181879903114596,!1,[[3,0],[3,1],[4,44]]]],[[40,cr.plugins_.Audio.prototype.acts.SetMuted,null,0xf142b20759659,!1,[[1,[2,""]],[3,1]]]]],[0,null,!1,null,6962954455113624,[[4,cr.plugins_.Keyboard.prototype.cnds.IsKeyDown,null,0,!1,!1,!1,0xe6c93528570d7,!1,[[9,40]]]],[[-1,cr.system_object.prototype.acts.ScrollToObject,null,0x63cc70639b157,!1,[[4,10]]]]],
[0,null,!1,null,0x521a76c425fd4,[[23,cr.plugins_.Mouse.prototype.cnds.OnObjectClicked,null,1,!1,!1,!1,0x798a90b3ea9f,!1,[[3,0],[3,0],[4,66]]]],[[65,cr.plugins_.Browser.prototype.acts.Close,null,4810944731314206,!1]]],[0,null,!1,null,8858595980746077,[[30,cr.plugins_.Touch.prototype.cnds.OnTouchObject,null,1,!1,!1,!1,451612009433674,!1,[[4,66]]]],[[65,cr.plugins_.Browser.prototype.acts.Close,null,9576520524366476,!1]]],[0,[!0,"CONTROLES TOUCH E DESKTOP"],!1,null,0xe9f1c6c1adb2f,[[-1,cr.system_object.prototype.cnds.IsGroupActive,
null,0,!1,!1,!1,0xe9f1c6c1adb2f,!1,[[1,[2,"CONTROLES TOUCH E DESKTOP"]]]]],[],[[0,null,!1,null,9251757913785612,[[-1,cr.system_object.prototype.cnds.CompareVar,null,0,!1,!1,!1,6595572406420486,!1,[[11,"desktop2"],[8,0],[7,[0,1]]]]],[[33,cr.plugins_.Sprite.prototype.acts.SetVisible,null,0xb9decba1ec203,!1,[[3,0]]],[36,cr.plugins_.Sprite.prototype.acts.SetVisible,null,5070500665826655,!1,[[3,0]]],[35,cr.plugins_.Sprite.prototype.acts.SetVisible,null,8766231393262488,!1,[[3,0]]],[34,cr.plugins_.Sprite.prototype.acts.SetVisible,
null,9631779383106744,!1,[[3,0]]]]],[0,null,!1,null,9434105121372644,[[-1,cr.system_object.prototype.cnds.CompareVar,null,0,!1,!1,!1,8298990440214376,!1,[[11,"touchscreen2"],[8,0],[7,[0,1]]]]],[[33,cr.plugins_.Sprite.prototype.acts.SetVisible,null,0x70bf5aeab11eb,!1,[[3,1]]],[36,cr.plugins_.Sprite.prototype.acts.SetVisible,null,963850674007619,!1,[[3,1]]],[35,cr.plugins_.Sprite.prototype.acts.SetVisible,null,5432073837300676,!1,[[3,1]]],[34,cr.plugins_.Sprite.prototype.acts.SetVisible,null,0xf5dae18e566c4,
!1,[[3,1]]]]]]]]],["Abertura  sheet 2",[[0,null,!1,null,0xd96993794303d,[[23,cr.plugins_.Mouse.prototype.cnds.OnObjectClicked,null,1,!1,!1,!1,0x425dfc153d69e,!1,[[3,0],[3,0],[4,26]]]],[[-1,cr.system_object.prototype.acts.SetVar,null,454491852795838,!1,[[11,"desktop2"],[7,[0,1]]]]]],[0,null,!1,null,5007595896387256,[[-1,cr.system_object.prototype.cnds.CompareVar,null,0,!1,!1,!1,0x5bc2c5ff0110c,!1,[[11,"desktop2"],[8,0],[7,[0,1]]]]],[[-1,cr.system_object.prototype.acts.GoToLayout,null,5371464150312704,
!1,[[6,"jogo"]]]]],[0,null,!1,null,0x45637c9151bcf,[[30,cr.plugins_.Touch.prototype.cnds.OnTouchStart,null,1,!1,!1,!1,0xae151e674aac3,!1]],[[-1,cr.system_object.prototype.acts.SetVar,null,0x6cb89bfabeae,!1,[[11,"touchscreen2"],[7,[0,1]]]]]],[0,null,!1,null,9313082406782660,[[-1,cr.system_object.prototype.cnds.CompareVar,null,0,!1,!1,!1,6983704966039113,!1,[[11,"touchscreen2"],[8,0],[7,[0,1]]]]],[[-1,cr.system_object.prototype.acts.GoToLayout,null,0xfc70fa5e6c507,!1,[[6,"jogo"]]]]],[0,null,!1,null,
9944210939826728,[[30,cr.plugins_.Touch.prototype.cnds.OnTouchObject,null,1,!1,!1,!1,8145578798233537,!1,[[4,66]]]],[[65,cr.plugins_.Browser.prototype.acts.Close,null,9080187521067978,!1]]],[0,null,!1,null,9906520612678464,[[23,cr.plugins_.Mouse.prototype.cnds.OnObjectClicked,null,1,!1,!1,!1,0xd556e576189bb,!1,[[3,0],[3,0],[4,66]]]],[[65,cr.plugins_.Browser.prototype.acts.Close,null,6392852367894052,!1]]]]],["Fim do jogo  sheet 3",[[0,null,!1,null,4883345487107396,[[23,cr.plugins_.Mouse.prototype.cnds.OnObjectClicked,
null,1,!1,!1,!1,4869021926215455,!1,[[3,0],[3,0],[4,42]]]],[[-1,cr.system_object.prototype.acts.GoToLayout,null,0x5da74a9c964e6,!1,[[6,"jogo"]]],[-1,cr.system_object.prototype.acts.ResetGlobals,null,0xae3cab7c84f96,!1]]],[0,null,!1,null,5474443003030198,[[30,cr.plugins_.Touch.prototype.cnds.OnTouchObject,null,1,!1,!1,!1,6985977224968712,!1,[[4,42]]]],[[-1,cr.system_object.prototype.acts.GoToLayout,null,9127745049645944,!1,[[6,"abertura"]]],[-1,cr.system_object.prototype.acts.ResetGlobals,null,9113650296422272,
!1]]],[0,null,!1,null,0xc4fc2e758150d,[[-1,cr.system_object.prototype.cnds.OnLayoutStart,null,1,!1,!1,!1,7623298123265043,!1]],[[40,cr.plugins_.Audio.prototype.acts.Stop,null,0x43944d949184d,!1,[[1,[2,""]]]]]],[0,null,!1,null,392445320891245,[[-1,cr.system_object.prototype.cnds.EveryTick,null,0,!1,!1,!1,0x779ddc76c275e,!1]],[[41,cr.plugins_.Text.prototype.acts.SetText,null,732016623867618,!1,[[7,[10,[2,"Pontua\u00e7\u00e3o:"],[23,"score"]]]]]]],[0,null,!1,null,0x54b3a26abd188,[[23,cr.plugins_.Mouse.prototype.cnds.OnObjectClicked,
null,1,!1,!1,!1,0xffa4655479f63,!1,[[3,0],[3,0],[4,66]]]],[[65,cr.plugins_.Browser.prototype.acts.Close,null,9553484054285320,!1]]],[0,null,!1,null,7503260245718059,[[30,cr.plugins_.Touch.prototype.cnds.OnTouchObject,null,1,!1,!1,!1,0xa1ffed83bf5d,!1,[[4,66]]]],[[65,cr.plugins_.Browser.prototype.acts.Close,null,53684429572018,!1]]]]],["loginface_ sheet 1",[[0,null,!1,null,0x8d554d3fd966d,[],[]],[0,null,!1,null,0xfa199f1956f74,[[23,cr.plugins_.Mouse.prototype.cnds.OnObjectClicked,null,1,!1,!1,!1,6770717895198913,
!1,[[3,0],[3,0],[4,55]]]],[[-1,cr.system_object.prototype.acts.GoToLayout,null,9040261861864148,!1,[[6,"abertura"]]]]],[0,null,!1,null,0x5f27c0a65a163,[[-1,cr.system_object.prototype.cnds.CompareTime,null,0,!1,!1,!1,4665240692088036,!1,[[8,0],[0,[0,5]]]]],[[-1,cr.system_object.prototype.acts.GoToLayout,null,8154111326617975,!1,[[6,"abertura"]]]]],[0,null,!1,null,7110708029499678,[[-1,cr.system_object.prototype.cnds.OnLayoutStart,null,1,!1,!1,!1,0xed839160a486f,!1]],[[65,cr.plugins_.Browser.prototype.acts.RequestFullScreen,
null,955544995663917,!1,[[3,3]]]]]]]],"",!0,1165,635,4,!0,!0,!0,"1.0",1,!1,0,!1,69,!1,[]]};

createCocoonJSRuntime();

})();
