/*
HTTP Host: static.ak.fbcdn.net
Generated: March 20th 2010 2:31:12 AM PDT
Machine: 10.16.139.110
Locale: nu_ll
Path: js/support/FABridge.js
*/

if (window.CavalryLogger) { CavalryLogger.start_js(["js\/support\/FABridge.js"]); }

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(a){var c=[];for(var b=0;b<a.length;b++)c[b]=a[b];return c;};function instanceFactory(a){this.fb_instance_id=a;return this;}function FABridge__invokeJSFunction(a){var c=a[0];var d=a.concat();d.shift();var b=FABridge.extractBridgeFromID(c);return b.invokeLocalFunction(c,d);}FABridge.addInitializationCallback=function(a,b){var d=FABridge.instances[a];if(d!=undefined){b.call(d);return;}var c=FABridge.initCallbacks[a];if(c==null)FABridge.initCallbacks[a]=c=[];c.push(b);};function FABridge__bridgeInitialized(a){var j="bridgeName="+a;if(/Explorer/.test(navigator.appName)||/Konqueror|Safari|KHTML/.test(navigator.appVersion)){var b=document.getElementsByTagName("object");if(b.length==1){FABridge.attachBridge(b[0],a);}else for(var e=0;e<b.length;e++){var f=b[e];var i=f.childNodes;var d=false;for(var g=0;g<i.length;g++){var h=i[g];if(h.nodeType==1&&h.tagName.toLowerCase()=="param")if(h.name.toLowerCase()=="flashvars"&&h.value.indexOf(j)>=0){FABridge.attachBridge(f,a);d=true;break;}}if(d)break;}}else{var b=document.getElementsByTagName("embed");if(b.length==1){FABridge.attachBridge(b[0],a);}else for(var e=0;e<b.length;e++){var f=b[e];var c=f.attributes.getNamedItem("flashVars").nodeValue;if(c.indexOf(j)>=0)FABridge.attachBridge(f,a);}}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(d,a){var e=new FABridge(d,a);FABridge[a]=e;var b=FABridge.initCallbacks[a];if(b==null)return;for(var c=0;c<b.length;c++)b[c].call(e);delete FABridge.initCallbacks[a];};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(a,b){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++;retVal=this.target.getPropFromAS(a,b);retVal=this.handleError(retVal);FABridge.refCount--;return retVal;}},setPropertyInAS:function(a,b,c){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++;retVal=this.target.setPropInAS(a,b,this.serialize(c));retVal=this.handleError(retVal);FABridge.refCount--;return retVal;}},callASFunction:function(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++;retVal=this.target.invokeASFunction(b,this.serialize(a));retVal=this.handleError(retVal);FABridge.refCount--;return retVal;}},callASMethod:function(c,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++;a=this.serialize(a);retVal=this.target.invokeASMethod(c,b,a);retVal=this.handleError(retVal);FABridge.refCount--;return retVal;}},invokeLocalFunction:function(c,a){var d;var b=this.localFunctionCache[c];if(b!=undefined)d=this.serialize(b.apply(null,this.deserialize(a)));return d;},getUserTypeDescriptor:function(b){var d=b.replace(/^([^:]*)\:\:([^:]*)$/,"$2");var a=((typeof window[d]=="function")&&(typeof FABridge.userTypes[d]!="undefined"));var c=false;if(a)c=FABridge.userTypes[d].enriched;var e={simpleType:d,isUserProto:a,protoEnriched:c};return e;},getTypeFromName:function(a){var c=this.getUserTypeDescriptor(a);var b=this.remoteTypeCache[a];if(c.isUserProto)if(!c.protoEnriched){for(i in window[c.simpleType].prototype)b[i]=window[c.simpleType].prototype[i];window[c.simpleType].prototype=b;this.remoteTypeCache[a]=b;FABridge.userTypes[c.simpleType].enriched=true;}return b;},createProxy:function(c,e){var f=this.getUserTypeDescriptor(e);var d=this.getTypeFromName(e);if(f.isUserProto){var a=window[f.simpleType];var b=new a(this.name,c);b.fb_instance_id=c;}else{instanceFactory.prototype=d;var b=new instanceFactory(c);}this.remoteInstanceCache[c]=b;return b;},getProxy:function(a){return this.remoteInstanceCache[a];},addTypeDataToCache:function(d){newType=new ASProxy(this,d.name);var a=d.accessors;for(var b=0;b<a.length;b++)this.addPropertyToType(newType,a[b]);var c=d.methods;for(var b=0;b<c.length;b++)if(FABridge.blockedMethods[c[b]]==undefined)this.addMethodToType(newType,c[b]);this.remoteTypeCache[newType.typeName]=newType;return newType;},addPropertyToType:function(e,c){var a=c.charAt(0);var d;var b;if(a>="a"&&a<="z"){b="get"+a.toUpperCase()+c.substr(1);d="set"+a.toUpperCase()+c.substr(1);}else{b="get"+c;d="set"+c;}e[d]=function(f){this.bridge.setPropertyInAS(this.fb_instance_id,c,f);};e[b]=function(){return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id,c));};},addMethodToType:function(b,a){b[a]=function(){return this.bridge.deserialize(this.bridge.callASMethod(this.fb_instance_id,a,FABridge.argsToArray(arguments)));};},getFunctionProxy:function(b){var a=this;if(this.remoteFunctionCache[b]==null)this.remoteFunctionCache[b]=function(){a.callASFunction(b,FABridge.argsToArray(arguments));};return this.remoteFunctionCache[b];},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 b={};var c=typeof(d);if(c=="number"||c=="string"||c=="boolean"||c==null||c==undefined){b=d;}else if(d instanceof Array||typeof(d.sort)=="function"){b=[];for(var a=0;a<d.length;a++)b[a]=this.serialize(d[a]);}else if(c=="function"){b.type=FABridge.TYPE_JSFUNCTION;b.value=this.getFunctionID(d);}else if(d instanceof ASProxy){b.type=FABridge.TYPE_ASINSTANCE;b.value=d.fb_instance_id;}else{b.type=FABridge.TYPE_ANONYMOUS;b.value=d;}return b;},deserialize:function(c){var d;var e=typeof(c);if(e=="number"||e=="string"||e=="boolean"||c==null||c==undefined){d=this.handleError(c);}else if(c instanceof Array){d=[];for(var b=0;b<c.length;b++)d[b]=this.deserialize(c[b]);}else if(e=="object"){for(var b=0;b<c.newTypes.length;b++)this.addTypeDataToCache(c.newTypes[b]);for(var a in c.newRefs)this.createProxy(a,c.newRefs[a]);if(c.type==FABridge.TYPE_PRIMITIVE){d=c.value;}else if(c.type==FABridge.TYPE_ASFUNCTION){d=this.getFunctionProxy(c.value);}else if(c.type==FABridge.TYPE_ASINSTANCE){d=this.getProxy(c.value);}else if(c.type==FABridge.TYPE_ANONYMOUS)d=c.value;}return d;},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;}};ASProxy=function(a,b){this.bridge=a;this.typeName=b;return this;};ASProxy.prototype={get:function(a){return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id,a));},set:function(a,b){this.bridge.setPropertyInAS(this.fb_instance_id,a,b);},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);}};

if (window.Bootloader) { Bootloader.done(["js\/support\/FABridge.js"]); }