/*
/*
Copyright 2006 Adobe Systems Incorporated

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.


THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

*/
function FABridge(B,A){this.target=B;this.remoteTypeCache={};this.remoteInstanceCache={};this.remoteFunctionCache={};this.localFunctionCache={};this.bridgeID=FABridge.nextBridgeID++;this.name=A;this.nextLocalFuncID=0;FABridge.instances[this.name]=this;FABridge.idMap[this.bridgeID]=this;return this}FABridge.TYPE_ASINSTANCE=1;FABridge.TYPE_ASFUNCTION=2;FABridge.TYPE_JSFUNCTION=3;FABridge.TYPE_ANONYMOUS=4;FABridge.initCallbacks={};FABridge.userTypes={};FABridge.addToUserTypes=function(){for(var A=0;A<arguments.length;A++){FABridge.userTypes[arguments[A]]={typeName:arguments[A],enriched:false}}};FABridge.argsToArray=function(B){var A=[];for(var C=0;C<B.length;C++){A[C]=B[C]}return A};function instanceFactory(A){this.fb_instance_id=A;return this}function FABridge__invokeJSFunction(A){var C=A[0];var B=A.concat();B.shift();var D=FABridge.extractBridgeFromID(C);return D.invokeLocalFunction(C,B)}FABridge.addInitializationCallback=function(B,D){var C=FABridge.instances[B];if(C!=undefined){D.call(C);return }var A=FABridge.initCallbacks[B];if(A==null){FABridge.initCallbacks[B]=A=[]}A.push(D)};function FABridge__bridgeInitialized(D){var A="bridgeName="+D;if(/Explorer/.test(navigator.appName)||/Konqueror|Safari|KHTML/.test(navigator.appVersion)){var J=document.getElementsByTagName("object");if(J.length==1){FABridge.attachBridge(J[0],D)}else{for(var F=0;F<J.length;F++){var H=J[F];var C=H.childNodes;var G=false;for(var E=0;E<C.length;E++){var B=C[E];if(B.nodeType==1&&B.tagName.toLowerCase()=="param"){if(B.name.toLowerCase()=="flashvars"&&B.value.indexOf(A)>=0){FABridge.attachBridge(H,D);G=true;break}}}if(G){break}}}}else{var J=document.getElementsByTagName("embed");if(J.length==1){FABridge.attachBridge(J[0],D)}else{for(var F=0;F<J.length;F++){var H=J[F];var I=H.attributes.getNamedItem("flashVars").nodeValue;if(I.indexOf(A)>=0){FABridge.attachBridge(H,D)}}}}return true}FABridge.nextBridgeID=0;FABridge.instances={};FABridge.idMap={};FABridge.refCount=0;FABridge.extractBridgeFromID=function(B){var A=(B>>16);return FABridge.idMap[A]};FABridge.attachBridge=function(A,C){var B=new FABridge(A,C);FABridge[C]=B;var E=FABridge.initCallbacks[C];if(E==null){return }for(var D=0;D<E.length;D++){E[D].call(B)}delete FABridge.initCallbacks[C]};FABridge.blockedMethods={toString:true,get:true,set:true,call:true};FABridge.prototype={root:function(){return this.deserialize(this.target.getRoot())},releaseASObjects:function(){return this.target.releaseASObjects()},releaseNamedASObject:function(B){if(typeof (B)!="object"){return false}else{var A=this.target.releaseNamedASObject(B.fb_instance_id);return A}},create:function(A){return this.deserialize(this.target.create(A))},makeID:function(A){return(this.bridgeID<<16)+A},getPropertyFromAS:function(C,A){if(FABridge.refCount>0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.")}else{FABridge.refCount++;var B=this.target.getPropFromAS(C,A);B=this.handleError(B);FABridge.refCount--;return B}},setPropertyInAS:function(D,B,A){if(FABridge.refCount>0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.")}else{FABridge.refCount++;var C=this.target.setPropInAS(D,B,this.serialize(A));C=this.handleError(C);FABridge.refCount--;return C}},callASFunction:function(C,A){if(FABridge.refCount>0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.")}else{FABridge.refCount++;var B=this.target.invokeASFunction(C,this.serialize(A));B=this.handleError(B);FABridge.refCount--;return B}},callASMethod:function(B,D,A){if(FABridge.refCount>0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.")}else{FABridge.refCount++;A=this.serialize(A);var C=this.target.invokeASMethod(B,D,A);C=this.handleError(C);FABridge.refCount--;return C}},invokeLocalFunction:function(D,B){var A;var C=this.localFunctionCache[D];if(C!=undefined){A=this.serialize(C.apply(null,this.deserialize(B)))}return A},getUserTypeDescriptor:function(B){var C=B.replace(/^([^:]*)\:\:([^:]*)$/,"$2");var E=((typeof window[C]=="function")&&(typeof FABridge.userTypes[C]!="undefined"));var D=false;if(E){D=FABridge.userTypes[C].enriched}var A={simpleType:C,isUserProto:E,protoEnriched:D};return A},getTypeFromName:function(B){var C=this.getUserTypeDescriptor(B);var A=this.remoteTypeCache[B];if(C.isUserProto){if(!C.protoEnriched){for(i in window[C.simpleType].prototype){A[i]=window[C.simpleType].prototype[i]}window[C.simpleType].prototype=A;this.remoteTypeCache[B]=A;FABridge.userTypes[C.simpleType].enriched=true}}return A},createProxy:function(C,B){var D=this.getUserTypeDescriptor(B);var F=this.getTypeFromName(B);if(D.isUserProto){var E=window[D.simpleType];var A=new E(this.name,C);A.fb_instance_id=C}else{instanceFactory.prototype=F;var A=new instanceFactory(C)}this.remoteInstanceCache[C]=A;return A},getProxy:function(A){return this.remoteInstanceCache[A]},addTypeDataToCache:function(E){var C=new ASProxy(this,E.name);var B=E.accessors;for(var D=0;D<B.length;D++){this.addPropertyToType(C,B[D])}var A=E.methods;for(var D=0;D<A.length;D++){if(FABridge.blockedMethods[A[D]]==undefined){this.addMethodToType(C,A[D])}}this.remoteTypeCache[C.typeName]=C;return C},addPropertyToType:function(A,D){var E=D.charAt(0);var B;var C;if(E>="a"&&E<="z"){C="get"+E.toUpperCase()+D.substr(1);B="set"+E.toUpperCase()+D.substr(1)}else{C="get"+D;B="set"+D}A[B]=function(F){this.bridge.setPropertyInAS(this.fb_instance_id,D,F)};A[C]=function(){return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id,D))}},addMethodToType:function(A,B){A[B]=function(){return this.bridge.deserialize(this.bridge.callASMethod(this.fb_instance_id,B,FABridge.argsToArray(arguments)))}},getFunctionProxy:function(A){var B=this;if(this.remoteFunctionCache[A]==null){this.remoteFunctionCache[A]=function(){B.callASFunction(A,FABridge.argsToArray(arguments))}}return this.remoteFunctionCache[A]},getFunctionID:function(A){if(A.__bridge_id__==undefined){A.__bridge_id__=this.makeID(this.nextLocalFuncID++);this.localFunctionCache[A.__bridge_id__]=A}return A.__bridge_id__},serialize:function(D){var A={};var C=typeof (D);if(C=="number"||C=="string"||C=="boolean"||C==null||C==undefined){A=D}else{if(D instanceof Array){A=[];for(var B=0;B<D.length;B++){A[B]=this.serialize(D[B])}}else{if(C=="function"){A.type=FABridge.TYPE_JSFUNCTION;A.value=this.getFunctionID(D)}else{if(D instanceof ASProxy){A.type=FABridge.TYPE_ASINSTANCE;A.value=D.fb_instance_id}else{A.type=FABridge.TYPE_ANONYMOUS;A.value=D}}}}return A},deserialize:function(E){var A;var C=typeof (E);if(C=="number"||C=="string"||C=="boolean"||E==null||E==undefined){A=this.handleError(E)}else{if(E instanceof Array){A=[];for(var B=0;B<E.length;B++){A[B]=this.deserialize(E[B])}}else{if(C=="object"){for(var B=0;B<E.newTypes.length;B++){this.addTypeDataToCache(E.newTypes[B])}for(var D in E.newRefs){this.createProxy(D,E.newRefs[D])}if(E.type==FABridge.TYPE_PRIMITIVE){A=E.value}else{if(E.type==FABridge.TYPE_ASFUNCTION){A=this.getFunctionProxy(E.value)}else{if(E.type==FABridge.TYPE_ASINSTANCE){A=this.getProxy(E.value)}else{if(E.type==FABridge.TYPE_ANONYMOUS){A=E.value}}}}}}}return A},addRef:function(A){this.target.incRef(A.fb_instance_id)},release:function(A){this.target.releaseRef(A.fb_instance_id)},handleError:function(B){if(typeof (B)=="string"&&B.indexOf("__FLASHERROR")==0){var A=B.split("||");if(FABridge.refCount>0){FABridge.refCount--}throw new Error(A[1]);return B}else{return B}}};var ASProxy=function(B,A){this.bridge=B;this.typeName=A;return this};ASProxy.prototype={get:function(A){return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id,A))},set:function(B,A){this.bridge.setPropertyInAS(this.fb_instance_id,B,A)},call:function(B,A){this.bridge.callASMethod(this.fb_instance_id,B,A)},addRef:function(){this.bridge.addRef(this)},release:function(){this.bridge.release(this)}};
