You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by mt...@apache.org on 2007/03/14 20:37:27 UTC

svn commit: r518313 [12/43] - in /incubator/xap/trunk/codebase/src/dojo: ./ src/ src/animation/ src/cal/ src/charting/ src/charting/svg/ src/charting/vml/ src/collections/ src/crypto/ src/data/ src/data/core/ src/data/old/ src/data/old/format/ src/data...

Added: incubator/xap/trunk/codebase/src/dojo/src/event/common.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/event/common.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/event/common.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/event/common.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,885 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.event.common");
+
+dojo.require("dojo.lang.array");
+dojo.require("dojo.lang.extras");
+dojo.require("dojo.lang.func");
+
+// TODO: connection filter functions
+//			these are functions that accept a method invocation (like around
+//			advice) and return a boolean based on it. That value determines
+//			whether or not the connection proceeds. It could "feel" like around
+//			advice for those who know what it is (calling proceed() or not),
+//			but I think presenting it as a "filter" and/or calling it with the
+//			function args and not the MethodInvocation might make it more
+//			palletable to "normal" users than around-advice currently is
+// TODO: execution scope mangling
+//			YUI's event facility by default executes listeners in the context
+//			of the source object. This is very odd, but should probably be
+//			supported as an option (both for the source and for the dest). It
+//			can be thought of as a connection-specific hitch().
+// TODO: more resiliency for 4+ arguments to connect()
+
+dojo.event = new function(){
+	this._canTimeout = dojo.lang.isFunction(dj_global["setTimeout"])||dojo.lang.isAlien(dj_global["setTimeout"]);
+
+	// FIXME: where should we put this method (not here!)?
+	function interpolateArgs(args, searchForNames){
+		var dl = dojo.lang;
+		var ao = {
+			srcObj: dj_global,
+			srcFunc: null,
+			adviceObj: dj_global,
+			adviceFunc: null,
+			aroundObj: null,
+			aroundFunc: null,
+			adviceType: (args.length>2) ? args[0] : "after",
+			precedence: "last",
+			once: false,
+			delay: null,
+			rate: 0,
+			adviceMsg: false
+		};
+
+		switch(args.length){
+			case 0: return;
+			case 1: return;
+			case 2:
+				ao.srcFunc = args[0];
+				ao.adviceFunc = args[1];
+				break;
+			case 3:
+				if((dl.isObject(args[0]))&&(dl.isString(args[1]))&&(dl.isString(args[2]))){
+					ao.adviceType = "after";
+					ao.srcObj = args[0];
+					ao.srcFunc = args[1];
+					ao.adviceFunc = args[2];
+				}else if((dl.isString(args[1]))&&(dl.isString(args[2]))){
+					ao.srcFunc = args[1];
+					ao.adviceFunc = args[2];
+				}else if((dl.isObject(args[0]))&&(dl.isString(args[1]))&&(dl.isFunction(args[2]))){
+					ao.adviceType = "after";
+					ao.srcObj = args[0];
+					ao.srcFunc = args[1];
+					var tmpName  = dl.nameAnonFunc(args[2], ao.adviceObj, searchForNames);
+					ao.adviceFunc = tmpName;
+				}else if((dl.isFunction(args[0]))&&(dl.isObject(args[1]))&&(dl.isString(args[2]))){
+					ao.adviceType = "after";
+					ao.srcObj = dj_global;
+					var tmpName  = dl.nameAnonFunc(args[0], ao.srcObj, searchForNames);
+					ao.srcFunc = tmpName;
+					ao.adviceObj = args[1];
+					ao.adviceFunc = args[2];
+				}
+				break;
+			case 4:
+				if((dl.isObject(args[0]))&&(dl.isObject(args[2]))){
+					// we can assume that we've got an old-style "connect" from
+					// the sigslot school of event attachment. We therefore
+					// assume after-advice.
+					ao.adviceType = "after";
+					ao.srcObj = args[0];
+					ao.srcFunc = args[1];
+					ao.adviceObj = args[2];
+					ao.adviceFunc = args[3];
+				}else if((dl.isString(args[0]))&&(dl.isString(args[1]))&&(dl.isObject(args[2]))){
+					ao.adviceType = args[0];
+					ao.srcObj = dj_global;
+					ao.srcFunc = args[1];
+					ao.adviceObj = args[2];
+					ao.adviceFunc = args[3];
+				}else if((dl.isString(args[0]))&&(dl.isFunction(args[1]))&&(dl.isObject(args[2]))){
+					ao.adviceType = args[0];
+					ao.srcObj = dj_global;
+					var tmpName  = dl.nameAnonFunc(args[1], dj_global, searchForNames);
+					ao.srcFunc = tmpName;
+					ao.adviceObj = args[2];
+					ao.adviceFunc = args[3];
+				}else if((dl.isString(args[0]))&&(dl.isObject(args[1]))&&(dl.isString(args[2]))&&(dl.isFunction(args[3]))){
+					ao.srcObj = args[1];
+					ao.srcFunc = args[2];
+					var tmpName  = dl.nameAnonFunc(args[3], dj_global, searchForNames);
+					ao.adviceObj = dj_global;
+					ao.adviceFunc = tmpName;
+				}else if(dl.isObject(args[1])){
+					ao.srcObj = args[1];
+					ao.srcFunc = args[2];
+					ao.adviceObj = dj_global;
+					ao.adviceFunc = args[3];
+				}else if(dl.isObject(args[2])){
+					ao.srcObj = dj_global;
+					ao.srcFunc = args[1];
+					ao.adviceObj = args[2];
+					ao.adviceFunc = args[3];
+				}else{
+					ao.srcObj = ao.adviceObj = ao.aroundObj = dj_global;
+					ao.srcFunc = args[1];
+					ao.adviceFunc = args[2];
+					ao.aroundFunc = args[3];
+				}
+				break;
+			case 6:
+				ao.srcObj = args[1];
+				ao.srcFunc = args[2];
+				ao.adviceObj = args[3]
+				ao.adviceFunc = args[4];
+				ao.aroundFunc = args[5];
+				ao.aroundObj = dj_global;
+				break;
+			default:
+				ao.srcObj = args[1];
+				ao.srcFunc = args[2];
+				ao.adviceObj = args[3]
+				ao.adviceFunc = args[4];
+				ao.aroundObj = args[5];
+				ao.aroundFunc = args[6];
+				ao.once = args[7];
+				ao.delay = args[8];
+				ao.rate = args[9];
+				ao.adviceMsg = args[10];
+				break;
+		}
+
+		if(dl.isFunction(ao.aroundFunc)){
+			var tmpName  = dl.nameAnonFunc(ao.aroundFunc, ao.aroundObj, searchForNames);
+			ao.aroundFunc = tmpName;
+		}
+
+		if(dl.isFunction(ao.srcFunc)){
+			ao.srcFunc = dl.getNameInObj(ao.srcObj, ao.srcFunc);
+		}
+
+		if(dl.isFunction(ao.adviceFunc)){
+			ao.adviceFunc = dl.getNameInObj(ao.adviceObj, ao.adviceFunc);
+		}
+
+		if((ao.aroundObj)&&(dl.isFunction(ao.aroundFunc))){
+			ao.aroundFunc = dl.getNameInObj(ao.aroundObj, ao.aroundFunc);
+		}
+
+		if(!ao.srcObj){
+			dojo.raise("bad srcObj for srcFunc: "+ao.srcFunc);
+		}
+		if(!ao.adviceObj){
+			dojo.raise("bad adviceObj for adviceFunc: "+ao.adviceFunc);
+		}
+		
+		if(!ao.adviceFunc){
+			dojo.debug("bad adviceFunc for srcFunc: "+ao.srcFunc);
+			dojo.debugShallow(ao);
+		} 
+		
+		return ao;
+	}
+
+	this.connect = function(/*...*/){
+		// summary:
+		//		dojo.event.connect is the glue that holds most Dojo-based
+		//		applications together. Most combinations of arguments are
+		//		supported, with the connect() method attempting to disambiguate
+		//		the implied types of positional parameters. The following will
+		//		all work:
+		//			dojo.event.connect("globalFunctionName1", "globalFunctionName2");
+		//			dojo.event.connect(functionReference1, functionReference2);
+		//			dojo.event.connect("globalFunctionName1", functionReference2);
+		//			dojo.event.connect(functionReference1, "globalFunctionName2");
+		//			dojo.event.connect(scope1, "functionName1", "globalFunctionName2");
+		//			dojo.event.connect("globalFunctionName1", scope2, "functionName2");
+		//			dojo.event.connect(scope1, "functionName1", scope2, "functionName2");
+		//			dojo.event.connect("after", scope1, "functionName1", scope2, "functionName2");
+		//			dojo.event.connect("before", scope1, "functionName1", scope2, "functionName2");
+		//			dojo.event.connect("around", 	scope1, "functionName1", 
+		//											scope2, "functionName2",
+		//											aroundFunctionReference);
+		//			dojo.event.connect("around", 	scope1, "functionName1", 
+		//											scope2, "functionName2",
+		//											scope3, "aroundFunctionName");
+		//			dojo.event.connect("before-around", 	scope1, "functionName1", 
+		//													scope2, "functionName2",
+		//													aroundFunctionReference);
+		//			dojo.event.connect("after-around", 		scope1, "functionName1", 
+		//													scope2, "functionName2",
+		//													aroundFunctionReference);
+		//			dojo.event.connect("after-around", 		scope1, "functionName1", 
+		//													scope2, "functionName2",
+		//													scope3, "aroundFunctionName");
+		//			dojo.event.connect("around", 	scope1, "functionName1", 
+		//											scope2, "functionName2",
+		//											scope3, "aroundFunctionName", true, 30);
+		//			dojo.event.connect("around", 	scope1, "functionName1", 
+		//											scope2, "functionName2",
+		//											scope3, "aroundFunctionName", null, null, 10);
+		// adviceType: 
+		//		Optional. String. One of "before", "after", "around",
+		//		"before-around", or "after-around". FIXME
+		// srcObj:
+		//		the scope in which to locate/execute the named srcFunc. Along
+		//		with srcFunc, this creates a way to dereference the function to
+		//		call. So if the function in question is "foo.bar", the
+		//		srcObj/srcFunc pair would be foo and "bar", where "bar" is a
+		//		string and foo is an object reference.
+		// srcFunc:
+		//		the name of the function to connect to. When it is executed,
+		//		the listener being registered with this call will be called.
+		//		The adviceType defines the call order between the source and
+		//		the target functions.
+		// adviceObj:
+		//		the scope in which to locate/execute the named adviceFunc.
+		// adviceFunc:
+		//		the name of the function being conected to srcObj.srcFunc
+		// aroundObj:
+		//		the scope in which to locate/execute the named aroundFunc.
+		// aroundFunc:
+		//		the name of, or a reference to, the function that will be used
+		//		to mediate the advice call. Around advice requires a special
+		//		unary function that will be passed a "MethodInvocation" object.
+		//		These objects have several important properties, namely:
+		//			- args
+		//				a mutable array of arguments to be passed into the
+		//				wrapped function
+		//			- proceed
+		//				a function that "continues" the invocation. The result
+		//				of this function is the return of the wrapped function.
+		//				You can then manipulate this return before passing it
+		//				back out (or take further action based on it).
+		// once:
+		//		boolean that determines whether or not this connect() will
+		//		create a new connection if an identical connect() has already
+		//		been made. Defaults to "false".
+		// delay:
+		//		an optional delay (in ms), as an integer, for dispatch of a
+		//		listener after the source has been fired.
+		// rate:
+		//		an optional rate throttling parameter (integer, in ms). When
+		//		specified, this particular connection will not fire more than
+		//		once in the interval specified by the rate
+		// adviceMsg:
+		//		boolean. Should the listener have all the parameters passed in
+		//		as a single argument?
+
+		/*
+				ao.adviceType = args[0];
+				ao.srcObj = args[1];
+				ao.srcFunc = args[2];
+				ao.adviceObj = args[3]
+				ao.adviceFunc = args[4];
+				ao.aroundObj = args[5];
+				ao.aroundFunc = args[6];
+				ao.once = args[7];
+				ao.delay = args[8];
+				ao.rate = args[9];
+				ao.adviceMsg = args[10];
+		*/
+		if(arguments.length == 1){
+			var ao = arguments[0];
+		}else{
+			var ao = interpolateArgs(arguments, true);
+		}
+		if(dojo.lang.isString(ao.srcFunc) && (ao.srcFunc.toLowerCase() == "onkey") ){
+			if(dojo.render.html.ie){
+				ao.srcFunc = "onkeydown";
+				this.connect(ao);
+			}
+			ao.srcFunc = "onkeypress";
+		}
+
+
+		if(dojo.lang.isArray(ao.srcObj) && ao.srcObj!=""){
+			var tmpAO = {};
+			for(var x in ao){
+				tmpAO[x] = ao[x];
+			}
+			var mjps = [];
+			dojo.lang.forEach(ao.srcObj, function(src){
+				if((dojo.render.html.capable)&&(dojo.lang.isString(src))){
+					src = dojo.byId(src);
+					// dojo.debug(src);
+				}
+				tmpAO.srcObj = src;
+				// dojo.debug(tmpAO.srcObj, tmpAO.srcFunc);
+				// dojo.debug(tmpAO.adviceObj, tmpAO.adviceFunc);
+				mjps.push(dojo.event.connect.call(dojo.event, tmpAO));
+			});
+			return mjps;
+		}
+
+		// FIXME: just doing a "getForMethod()" seems to be enough to put this into infinite recursion!!
+		var mjp = dojo.event.MethodJoinPoint.getForMethod(ao.srcObj, ao.srcFunc);
+		if(ao.adviceFunc){
+			var mjp2 = dojo.event.MethodJoinPoint.getForMethod(ao.adviceObj, ao.adviceFunc);
+		}
+
+		mjp.kwAddAdvice(ao);
+
+		// advanced users might want to fsck w/ the join point manually
+		return mjp; // a MethodJoinPoint object
+	}
+
+	this.log = function(/*object or funcName*/ a1, /*funcName*/ a2){
+		// summary:
+		//		a function that will wrap and log all calls to the specified
+		//		a1.a2() function. If only a1 is passed, it'll be used as a
+		//		function or function name on the global context. Logging will
+		//		be sent to dojo.debug
+		// a1:
+		//		if a2 is passed, this should be an object. If not, it can be a
+		//		function or function name.
+		// a2:
+		//		a function name
+		var kwArgs;
+		if((arguments.length == 1)&&(typeof a1 == "object")){
+			kwArgs = a1;
+		}else{
+			kwArgs = {
+				srcObj: a1,
+				srcFunc: a2
+			};
+		}
+		kwArgs.adviceFunc = function(){
+			var argsStr = [];
+			for(var x=0; x<arguments.length; x++){
+				argsStr.push(arguments[x]);
+			}
+			dojo.debug("("+kwArgs.srcObj+")."+kwArgs.srcFunc, ":", argsStr.join(", "));
+		}
+		this.kwConnect(kwArgs);
+	}
+
+	this.connectBefore = function(){
+		// summary:
+		//	 	takes the same parameters as dojo.event.connect(), except that
+		//	 	the advice type will always be "before"
+		var args = ["before"];
+		for(var i = 0; i < arguments.length; i++){ args.push(arguments[i]); }
+		return this.connect.apply(this, args); // a MethodJoinPoint object
+	}
+
+	this.connectAround = function(){
+		// summary:
+		//	 	takes the same parameters as dojo.event.connect(), except that
+		//	 	the advice type will always be "around"
+		var args = ["around"];
+		for(var i = 0; i < arguments.length; i++){ args.push(arguments[i]); }
+		return this.connect.apply(this, args); // a MethodJoinPoint object
+	}
+
+	this.connectOnce = function(){
+		// summary:
+		//	 	takes the same parameters as dojo.event.connect(), except that
+		//	 	the "once" flag will always be set to "true"
+		var ao = interpolateArgs(arguments, true);
+		ao.once = true;
+		return this.connect(ao); // a MethodJoinPoint object
+	}
+
+	this._kwConnectImpl = function(kwArgs, disconnect){
+		var fn = (disconnect) ? "disconnect" : "connect";
+		if(typeof kwArgs["srcFunc"] == "function"){
+			kwArgs.srcObj = kwArgs["srcObj"]||dj_global;
+			var tmpName  = dojo.lang.nameAnonFunc(kwArgs.srcFunc, kwArgs.srcObj, true);
+			kwArgs.srcFunc = tmpName;
+		}
+		if(typeof kwArgs["adviceFunc"] == "function"){
+			kwArgs.adviceObj = kwArgs["adviceObj"]||dj_global;
+			var tmpName  = dojo.lang.nameAnonFunc(kwArgs.adviceFunc, kwArgs.adviceObj, true);
+			kwArgs.adviceFunc = tmpName;
+		}
+		kwArgs.srcObj = kwArgs["srcObj"]||dj_global;
+		kwArgs.adviceObj = kwArgs["adviceObj"]||kwArgs["targetObj"]||dj_global;
+		kwArgs.adviceFunc = kwArgs["adviceFunc"]||kwArgs["targetFunc"];
+		// pass kwargs to avoid unrolling/repacking
+		return dojo.event[fn](kwArgs);
+	}
+
+	this.kwConnect = function(/*Object*/ kwArgs){
+		// summary:
+		//		A version of dojo.event.connect() that takes a map of named
+		//		parameters instead of the positional parameters that
+		//		dojo.event.connect() uses. For many advanced connection types,
+		//		this can be a much more readable (and potentially faster)
+		//		alternative.
+		// kwArgs:
+		// 		An object that can have the following properties:
+		//			- adviceType
+		//			- srcObj
+		//			- srcFunc
+		//			- adviceObj
+		//			- adviceFunc 
+		//			- aroundObj
+		//			- aroundFunc
+		//			- once
+		//			- delay
+		//			- rate
+		//			- adviceMsg
+		//		As with connect, only srcFunc and adviceFunc are generally
+		//		required
+
+		return this._kwConnectImpl(kwArgs, false); // a MethodJoinPoint object
+
+	}
+
+	this.disconnect = function(){
+		// summary:
+		//		Takes the same parameters as dojo.event.connect() but destroys
+		//		an existing connection instead of building a new one. For
+		//		multiple identical connections, multiple disconnect() calls
+		//		will unroll one each time it's called.
+		if(arguments.length == 1){
+			var ao = arguments[0];
+		}else{
+			var ao = interpolateArgs(arguments, true);
+		}
+		if(!ao.adviceFunc){ return; } // nothing to disconnect
+		if(dojo.lang.isString(ao.srcFunc) && (ao.srcFunc.toLowerCase() == "onkey") ){
+			if(dojo.render.html.ie){
+				ao.srcFunc = "onkeydown";
+				this.disconnect(ao);
+			}
+			ao.srcFunc = "onkeypress";
+		}
+		if(!ao.srcObj[ao.srcFunc]){ return null; } // prevent un-necessaray joinpoint creation
+		var mjp = dojo.event.MethodJoinPoint.getForMethod(ao.srcObj, ao.srcFunc, true);
+		mjp.removeAdvice(ao.adviceObj, ao.adviceFunc, ao.adviceType, ao.once); // a MethodJoinPoint object
+		return mjp;
+	}
+
+	this.kwDisconnect = function(kwArgs){
+		// summary:
+		//		Takes the same parameters as dojo.event.kwConnect() but
+		//		destroys an existing connection instead of building a new one.
+		return this._kwConnectImpl(kwArgs, true);
+	}
+}
+
+// exactly one of these is created whenever a method with a joint point is run,
+// if there is at least one 'around' advice.
+dojo.event.MethodInvocation = function(/*dojo.event.MethodJoinPoint*/join_point, /*Object*/obj, /*Array*/args){
+	// summary:
+	//		a class the models the call into a function. This is used under the
+	//		covers for all method invocations on both ends of a
+	//		connect()-wrapped function dispatch. This allows us to "pickle"
+	//		calls, such as in the case of around advice.
+	// join_point:
+	//		a dojo.event.MethodJoinPoint object that represents a connection
+	// obj:
+	//		the scope the call will execute in
+	// args:
+	//		an array of parameters that will get passed to the callee
+	this.jp_ = join_point;
+	this.object = obj;
+	this.args = [];
+	// make sure we don't lock into a mutable object which can change under us.
+	// It's ok if the individual items change, though.
+	for(var x=0; x<args.length; x++){
+		this.args[x] = args[x];
+	}
+	// the index of the 'around' that is currently being executed.
+	this.around_index = -1;
+}
+
+dojo.event.MethodInvocation.prototype.proceed = function(){
+	// summary:
+	//		proceed with the method call that's represented by this invocation
+	//		object
+	this.around_index++;
+	if(this.around_index >= this.jp_.around.length){
+		return this.jp_.object[this.jp_.methodname].apply(this.jp_.object, this.args);
+		// return this.jp_.run_before_after(this.object, this.args);
+	}else{
+		var ti = this.jp_.around[this.around_index];
+		var mobj = ti[0]||dj_global;
+		var meth = ti[1];
+		return mobj[meth].call(mobj, this);
+	}
+} 
+
+
+dojo.event.MethodJoinPoint = function(/*Object*/obj, /*String*/funcName){
+	this.object = obj||dj_global;
+	this.methodname = funcName;
+	this.methodfunc = this.object[funcName];
+	this.squelch = false;
+	// this.before = [];
+	// this.after = [];
+	// this.around = [];
+}
+
+dojo.event.MethodJoinPoint.getForMethod = function(/*Object*/obj, /*String*/funcName){
+	// summary:
+	//		"static" class function for returning a MethodJoinPoint from a
+	//		scoped function. If one doesn't exist, one is created.
+	// obj:
+	//		the scope to search for the function in
+	// funcName:
+	//		the name of the function to return a MethodJoinPoint for
+	if(!obj){ obj = dj_global; }
+	if(!obj[funcName]){
+		// supply a do-nothing method implementation
+		obj[funcName] = function(){};
+		if(!obj[funcName]){
+			// e.g. cannot add to inbuilt objects in IE6
+			dojo.raise("Cannot set do-nothing method on that object "+funcName);
+		}
+	}else if((!dojo.lang.isFunction(obj[funcName]))&&(!dojo.lang.isAlien(obj[funcName]))){
+		// FIXME: should we throw an exception here instead?
+		return null; 
+	}
+	// we hide our joinpoint instance in obj[funcName + '$joinpoint']
+	var jpname = funcName + "$joinpoint";
+	var jpfuncname = funcName + "$joinpoint$method";
+	var joinpoint = obj[jpname];
+	if(!joinpoint){
+		var isNode = false;
+		if(dojo.event["browser"]){
+			if( (obj["attachEvent"])||
+				(obj["nodeType"])||
+				(obj["addEventListener"]) ){
+				isNode = true;
+				dojo.event.browser.addClobberNodeAttrs(obj, [jpname, jpfuncname, funcName]);
+			}
+		}
+		var origArity = obj[funcName].length;
+		obj[jpfuncname] = obj[funcName];
+		// joinpoint = obj[jpname] = new dojo.event.MethodJoinPoint(obj, funcName);
+		joinpoint = obj[jpname] = new dojo.event.MethodJoinPoint(obj, jpfuncname);
+		obj[funcName] = function(){ 
+			var args = [];
+
+			if((isNode)&&(!arguments.length)){
+				var evt = null;
+				try{
+					if(obj.ownerDocument){
+						evt = obj.ownerDocument.parentWindow.event;
+					}else if(obj.documentElement){
+						evt = obj.documentElement.ownerDocument.parentWindow.event;
+					}else if(obj.event){ //obj is a window
+						evt = obj.event;
+					}else{
+						evt = window.event;
+					}
+				}catch(e){
+					evt = window.event;
+				}
+
+				if(evt){
+					args.push(dojo.event.browser.fixEvent(evt, this));
+				}
+			}else{
+				for(var x=0; x<arguments.length; x++){
+					if((x==0)&&(isNode)&&(dojo.event.browser.isEvent(arguments[x]))){
+						args.push(dojo.event.browser.fixEvent(arguments[x], this));
+					}else{
+						args.push(arguments[x]);
+					}
+				}
+			}
+			// return joinpoint.run.apply(joinpoint, arguments); 
+			return joinpoint.run.apply(joinpoint, args); 
+		}
+		obj[funcName].__preJoinArity = origArity;
+	}
+	return joinpoint; // dojo.event.MethodJoinPoint
+}
+
+dojo.lang.extend(dojo.event.MethodJoinPoint, {
+	unintercept: function(){
+		// summary: 
+		//		destroy the connection to all listeners that may have been
+		//		registered on this joinpoint
+		this.object[this.methodname] = this.methodfunc;
+		this.before = [];
+		this.after = [];
+		this.around = [];
+	},
+
+	disconnect: dojo.lang.forward("unintercept"),
+
+	run: function(){
+		// summary:
+		//		execute the connection represented by this join point. The
+		//		arguments passed to run() will be passed to the function and
+		//		its listeners.
+		var obj = this.object||dj_global;
+		var args = arguments;
+
+		// optimization. We only compute once the array version of the arguments
+		// pseudo-arr in order to prevent building it each time advice is unrolled.
+		var aargs = [];
+		for(var x=0; x<args.length; x++){
+			aargs[x] = args[x];
+		}
+
+		var unrollAdvice  = function(marr){ 
+			if(!marr){
+				dojo.debug("Null argument to unrollAdvice()");
+				return;
+			}
+		  
+			var callObj = marr[0]||dj_global;
+			var callFunc = marr[1];
+			
+			if(!callObj[callFunc]){
+				dojo.raise("function \"" + callFunc + "\" does not exist on \"" + callObj + "\"");
+			}
+			
+			var aroundObj = marr[2]||dj_global;
+			var aroundFunc = marr[3];
+			var msg = marr[6];
+			var undef;
+
+			var to = {
+				args: [],
+				jp_: this,
+				object: obj,
+				proceed: function(){
+					return callObj[callFunc].apply(callObj, to.args);
+				}
+			};
+			to.args = aargs;
+
+			var delay = parseInt(marr[4]);
+			var hasDelay = ((!isNaN(delay))&&(marr[4]!==null)&&(typeof marr[4] != "undefined"));
+			if(marr[5]){
+				var rate = parseInt(marr[5]);
+				var cur = new Date();
+				var timerSet = false;
+				if((marr["last"])&&((cur-marr.last)<=rate)){
+					if(dojo.event._canTimeout){
+						if(marr["delayTimer"]){
+							clearTimeout(marr.delayTimer);
+						}
+						var tod = parseInt(rate*2); // is rate*2 naive?
+						var mcpy = dojo.lang.shallowCopy(marr);
+						marr.delayTimer = setTimeout(function(){
+							// FIXME: on IE at least, event objects from the
+							// browser can go out of scope. How (or should?) we
+							// deal with it?
+							mcpy[5] = 0;
+							unrollAdvice(mcpy);
+						}, tod);
+					}
+					return;
+				}else{
+					marr.last = cur;
+				}
+			}
+
+			// FIXME: need to enforce rates for a connection here!
+
+			if(aroundFunc){
+				// NOTE: around advice can't delay since we might otherwise depend
+				// on execution order!
+				aroundObj[aroundFunc].call(aroundObj, to);
+			}else{
+				// var tmjp = dojo.event.MethodJoinPoint.getForMethod(obj, methname);
+				if((hasDelay)&&((dojo.render.html)||(dojo.render.svg))){  // FIXME: the render checks are grotty!
+					dj_global["setTimeout"](function(){
+						if(msg){
+							callObj[callFunc].call(callObj, to); 
+						}else{
+							callObj[callFunc].apply(callObj, args); 
+						}
+					}, delay);
+				}else{ // many environments can't support delay!
+					if(msg){
+						callObj[callFunc].call(callObj, to); 
+					}else{
+						callObj[callFunc].apply(callObj, args); 
+					}
+				}
+			}
+		}
+
+		var unRollSquelch = function(){
+			if(this.squelch){
+				try{
+					return unrollAdvice.apply(this, arguments);
+				}catch(e){ 
+					dojo.debug(e);
+				}
+			}else{
+				return unrollAdvice.apply(this, arguments);
+			}
+		}
+
+		if((this["before"])&&(this.before.length>0)){
+			// pass a cloned array, if this event disconnects this event forEach on this.before wont work
+			dojo.lang.forEach(this.before.concat(new Array()), unRollSquelch);
+		}
+
+		var result;
+		try{
+			if((this["around"])&&(this.around.length>0)){
+				var mi = new dojo.event.MethodInvocation(this, obj, args);
+				result = mi.proceed();
+			}else if(this.methodfunc){
+				result = this.object[this.methodname].apply(this.object, args);
+			}
+		}catch(e){ 
+			if(!this.squelch){ 
+				dojo.debug(e,"when calling",this.methodname,"on",this.object,"with arguments",args);
+				dojo.raise(e);
+			} 
+		}
+
+		if((this["after"])&&(this.after.length>0)){
+			// see comment on this.before above
+			dojo.lang.forEach(this.after.concat(new Array()), unRollSquelch);
+		}
+
+		return (this.methodfunc) ? result : null;
+	},
+
+	getArr: function(/*String*/kind){
+		// summary: return a list of listeners of the past "kind"
+		// kind:
+		//		can be one of: "before", "after", "around", "before-around", or
+		//		"after-around"
+		var type = "after";
+		// FIXME: we should be able to do this through props or Array.in()
+		if((typeof kind == "string")&&(kind.indexOf("before")!=-1)){
+			type = "before";
+		}else if(kind=="around"){
+			type = "around";
+		}
+		if(!this[type]){ this[type] = []; }
+		return this[type]; // Array
+	},
+
+	kwAddAdvice: function(/*Object*/args){
+		// summary:
+		//		adds advice to the joinpoint with arguments in a map
+		// args:
+		// 		An object that can have the following properties:
+		//			- adviceType
+		//			- adviceObj
+		//			- adviceFunc 
+		//			- aroundObj
+		//			- aroundFunc
+		//			- once
+		//			- delay
+		//			- rate
+		//			- adviceMsg
+		this.addAdvice(	args["adviceObj"], args["adviceFunc"], 
+						args["aroundObj"], args["aroundFunc"], 
+						args["adviceType"], args["precedence"], 
+						args["once"], args["delay"], args["rate"], 
+						args["adviceMsg"]);
+	},
+
+	addAdvice: function(	thisAdviceObj, thisAdvice, 
+							thisAroundObj, thisAround, 
+							adviceType, precedence, 
+							once, delay, rate, asMessage){
+		// summary:
+		//		add advice to this joinpoint using positional parameters
+		// thisAdviceObj:
+		//		the scope in which to locate/execute the named adviceFunc.
+		// thisAdviceFunc:
+		//		the name of the function being conected
+		// thisAroundObj:
+		//		the scope in which to locate/execute the named aroundFunc.
+		// thisAroundFunc:
+		//		the name of the function that will be used to mediate the
+		//		advice call.
+		// adviceType: 
+		//		Optional. String. One of "before", "after", "around",
+		//		"before-around", or "after-around". FIXME
+		// once:
+		//		boolean that determines whether or not this advice will create
+		//		a new connection if an identical advice set has already been
+		//		provided. Defaults to "false".
+		// delay:
+		//		an optional delay (in ms), as an integer, for dispatch of a
+		//		listener after the source has been fired.
+		// rate:
+		//		an optional rate throttling parameter (integer, in ms). When
+		//		specified, this particular connection will not fire more than
+		//		once in the interval specified by the rate
+		// adviceMsg:
+		//		boolean. Should the listener have all the parameters passed in
+		//		as a single argument?
+		var arr = this.getArr(adviceType);
+		if(!arr){
+			dojo.raise("bad this: " + this);
+		}
+
+		var ao = [thisAdviceObj, thisAdvice, thisAroundObj, thisAround, delay, rate, asMessage];
+		
+		if(once){
+			if(this.hasAdvice(thisAdviceObj, thisAdvice, adviceType, arr) >= 0){
+				return;
+			}
+		}
+
+		if(precedence == "first"){
+			arr.unshift(ao);
+		}else{
+			arr.push(ao);
+		}
+	},
+
+	hasAdvice: function(thisAdviceObj, thisAdvice, adviceType, arr){
+		// summary:
+		//		returns the array index of the first existing connection
+		//		betweened the passed advice and this joinpoint. Will be -1 if
+		//		none exists.
+		// thisAdviceObj:
+		//		the scope in which to locate/execute the named adviceFunc.
+		// thisAdviceFunc:
+		//		the name of the function being conected
+		// adviceType: 
+		//		Optional. String. One of "before", "after", "around",
+		//		"before-around", or "after-around". FIXME
+		// arr:
+		//		Optional. The list of advices to search. Will be found via
+		//		adviceType if not passed
+		if(!arr){ arr = this.getArr(adviceType); }
+		var ind = -1;
+		for(var x=0; x<arr.length; x++){
+			var aao = (typeof thisAdvice == "object") ? (new String(thisAdvice)).toString() : thisAdvice;
+			var a1o = (typeof arr[x][1] == "object") ? (new String(arr[x][1])).toString() : arr[x][1];
+			if((arr[x][0] == thisAdviceObj)&&(a1o == aao)){
+				ind = x;
+			}
+		}
+		return ind; // Integer
+	},
+
+	removeAdvice: function(thisAdviceObj, thisAdvice, adviceType, once){
+		// summary:
+		//		returns the array index of the first existing connection
+		//		betweened the passed advice and this joinpoint. Will be -1 if
+		//		none exists.
+		// thisAdviceObj:
+		//		the scope in which to locate/execute the named adviceFunc.
+		// thisAdviceFunc:
+		//		the name of the function being conected
+		// adviceType: 
+		//		Optional. String. One of "before", "after", "around",
+		//		"before-around", or "after-around". FIXME
+		// once:
+		//		Optional. Should this only remove the first occurance of the
+		//		connection?
+		var arr = this.getArr(adviceType);
+		var ind = this.hasAdvice(thisAdviceObj, thisAdvice, adviceType, arr);
+		if(ind == -1){
+			return false;
+		}
+		while(ind != -1){
+			arr.splice(ind, 1);
+			if(once){ break; }
+			ind = this.hasAdvice(thisAdviceObj, thisAdvice, adviceType, arr);
+		}
+		return true;
+	}
+});

Added: incubator/xap/trunk/codebase/src/dojo/src/event/topic.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/event/topic.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/event/topic.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/event/topic.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,201 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.require("dojo.event.common");
+dojo.provide("dojo.event.topic");
+
+dojo.event.topic = new function(){
+	this.topics = {};
+
+	this.getTopic = function(/*String*/topic){
+		// summary:
+		//		returns a topic implementation object of type
+		//		dojo.event.topic.TopicImpl
+		// topic:
+		//		a unique, opaque string that names the topic
+		if(!this.topics[topic]){
+			this.topics[topic] = new this.TopicImpl(topic);
+		}
+		return this.topics[topic]; // a dojo.event.topic.TopicImpl object
+	}
+
+	this.registerPublisher = function(/*String*/topic, /*Object*/obj, /*String*/funcName){
+		// summary:
+		//		registers a function as a publisher on a topic. Subsequent
+		//		calls to the function will cause a publish event on the topic
+		//		with the arguments passed to the function passed to registered
+		//		listeners.
+		// topic: 
+		//		a unique, opaque string that names the topic
+		// obj:
+		//		the scope to locate the function in
+		// funcName:
+		//		the name of the function to register
+		var topic = this.getTopic(topic);
+		topic.registerPublisher(obj, funcName);
+	}
+
+	this.subscribe = function(/*String*/topic, /*Object*/obj, /*String*/funcName){
+		// summary:
+		//		susbscribes the function to the topic. Subsequent events
+		//		dispached to the topic will create a function call for the
+		//		obj.funcName() function.
+		// topic: 
+		//		a unique, opaque string that names the topic
+		// obj:
+		//		the scope to locate the function in
+		// funcName:
+		//		the name of the function to being registered as a listener
+		var topic = this.getTopic(topic);
+		topic.subscribe(obj, funcName);
+	}
+
+	this.unsubscribe = function(/*String*/topic, /*Object*/obj, /*String*/funcName){
+		// summary:
+		//		unsubscribes the obj.funcName() from the topic
+		// topic: 
+		//		a unique, opaque string that names the topic
+		// obj:
+		//		the scope to locate the function in
+		// funcName:
+		//		the name of the function to being unregistered as a listener
+		var topic = this.getTopic(topic);
+		topic.unsubscribe(obj, funcName);
+	}
+
+	this.destroy = function(/*String*/topic){
+		// summary: 
+		//		destroys the topic and unregisters all listeners
+		// topic:
+		//		a unique, opaque string that names the topic
+		this.getTopic(topic).destroy();
+		delete this.topics[topic];
+	}
+
+	this.publishApply = function(/*String*/topic, /*Array*/args){
+		// summary: 
+		//		dispatches an event to the topic using the args array as the
+		//		source for the call arguments to each listener. This is similar
+		//		to JavaScript's built-in Function.apply()
+		// topic:
+		//		a unique, opaque string that names the topic
+		// args:
+		//		the arguments to be passed into listeners of the topic
+		var topic = this.getTopic(topic);
+		topic.sendMessage.apply(topic, args);
+	}
+
+	this.publish = function(/*String*/topic, /*Object*/message){
+		// summary: 
+		//		manually "publish" to the passed topic
+		// topic:
+		//		a unique, opaque string that names the topic
+		// message:
+		//		can be an array of parameters (similar to publishApply), or
+		//		will be treated as one of many arguments to be passed along in
+		//		a "flat" unrolling
+		var topic = this.getTopic(topic);
+		// if message is an array, we treat it as a set of arguments,
+		// otherwise, we just pass on the arguments passed in as-is
+		var args = [];
+		// could we use concat instead here?
+		for(var x=1; x<arguments.length; x++){
+			args.push(arguments[x]);
+		}
+		topic.sendMessage.apply(topic, args);
+	}
+}
+
+dojo.event.topic.TopicImpl = function(topicName){
+	// summary: a class to represent topics
+
+	this.topicName = topicName;
+
+	this.subscribe = function(/*Object*/listenerObject, /*Function or String*/listenerMethod){
+		// summary:
+		//		use dojo.event.connect() to attach the passed listener to the
+		//		topic represented by this object
+		// listenerObject:
+		//		if a string and listenerMethod is ommitted, this is treated as
+		//		the name of a function in the global namespace. If
+		//		listenerMethod is provided, this is the scope to find/execute
+		//		the function in.
+		// listenerMethod:
+		//		Optional. The function to register.
+		var tf = listenerMethod||listenerObject;
+		var to = (!listenerMethod) ? dj_global : listenerObject;
+		return dojo.event.kwConnect({ // dojo.event.MethodJoinPoint
+			srcObj:		this, 
+			srcFunc:	"sendMessage", 
+			adviceObj:	to,
+			adviceFunc: tf
+		});
+	}
+
+	this.unsubscribe = function(/*Object*/listenerObject, /*Function or String*/listenerMethod){
+		// summary:
+		//		use dojo.event.disconnect() to attach the passed listener to the
+		//		topic represented by this object
+		// listenerObject:
+		//		if a string and listenerMethod is ommitted, this is treated as
+		//		the name of a function in the global namespace. If
+		//		listenerMethod is provided, this is the scope to find the
+		//		function in.
+		// listenerMethod:
+		//		Optional. The function to unregister.
+		var tf = (!listenerMethod) ? listenerObject : listenerMethod;
+		var to = (!listenerMethod) ? null : listenerObject;
+		return dojo.event.kwDisconnect({ // dojo.event.MethodJoinPoint
+			srcObj:		this, 
+			srcFunc:	"sendMessage", 
+			adviceObj:	to,
+			adviceFunc: tf
+		});
+	}
+
+	this._getJoinPoint = function(){
+		return dojo.event.MethodJoinPoint.getForMethod(this, "sendMessage");
+	}
+
+	this.setSquelch = function(/*Boolean*/shouldSquelch){
+		// summary: 
+		//		determine whether or not exceptions in the calling of a
+		//		listener in the chain should stop execution of the chain.
+		this._getJoinPoint().squelch = shouldSquelch;
+	}
+
+	this.destroy = function(){
+		// summary: disconnects all listeners from this topic
+		this._getJoinPoint().disconnect();
+	}
+
+	this.registerPublisher = function(	/*Object*/publisherObject, 
+										/*Function or String*/publisherMethod){
+		// summary:
+		//		registers the passed function as a publisher on this topic.
+		//		Each time the function is called, an event will be published on
+		//		this topic.
+		// publisherObject:
+		//		if a string and listenerMethod is ommitted, this is treated as
+		//		the name of a function in the global namespace. If
+		//		listenerMethod is provided, this is the scope to find the
+		//		function in.
+		// publisherMethod:
+		//		Optional. The function to register.
+		dojo.event.connect(publisherObject, publisherMethod, this, "sendMessage");
+	}
+
+	this.sendMessage = function(message){
+		// summary: a stub to be called when a message is sent to the topic.
+
+		// The message has been propagated
+	}
+}
+

Added: incubator/xap/trunk/codebase/src/dojo/src/experimental.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/experimental.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/experimental.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/experimental.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,30 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.experimental");
+
+dojo.experimental = function(/* String */ moduleName, /* String? */ extra){
+	// summary: Marks code as experimental.
+	// description: 
+	//    This can be used to mark a function, file, or module as experimental.
+	//    Experimental code is not ready to be used, and the APIs are subject
+	//    to change without notice.  Experimental code may be completed deleted
+	//    without going through the normal deprecation process.
+	// moduleName: The name of a module, or the name of a module file or a specific function
+	// extra: some additional message for the user
+	
+	// examples:
+	//    dojo.experimental("dojo.data.Result");
+	//    dojo.experimental("dojo.weather.toKelvin()", "PENDING approval from NOAA");
+	var message = "EXPERIMENTAL: " + moduleName;
+	message += " -- Not yet ready for use.  APIs subject to change without notice.";
+	if(extra){ message += " " + extra; }
+	dojo.debug(message);
+}

Added: incubator/xap/trunk/codebase/src/dojo/src/flash.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/flash.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/flash.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/flash.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,1257 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.flash");
+
+dojo.require("dojo.string.*");
+dojo.require("dojo.uri.*");
+dojo.require("dojo.html.common");
+
+dojo.flash = function(){
+	// summary:
+	//	The goal of dojo.flash is to make it easy to extend Flash's capabilities
+	//	into an AJAX/DHTML environment.
+	// description:  
+	//	The goal of dojo.flash is to make it easy to extend Flash's capabilities
+	//	into an AJAX/DHTML environment. Robust, performant, reliable 
+	//	JavaScript/Flash communication is harder than most realize when they
+	//	delve into the topic, especially if you want it
+	//	to work on Internet Explorer, Firefox, and Safari, and to be able to
+	//	push around hundreds of K of information quickly. Dojo.flash makes it
+	//	possible to support these platforms; you have to jump through a few
+	//	hoops to get its capabilites, but if you are a library writer 
+	//	who wants to bring Flash's storage or streaming sockets ability into
+	//	DHTML, for example, then dojo.flash is perfect for you.
+	//  
+	//	Dojo.flash provides an easy object for interacting with the Flash plugin. 
+	//	This object provides methods to determine the current version of the Flash
+	//	plugin (dojo.flash.info); execute Flash instance methods 
+	//	independent of the Flash version
+	//	being used (dojo.flash.comm); write out the necessary markup to 
+	//	dynamically insert a Flash object into the page (dojo.flash.Embed; and 
+	//	do dynamic installation and upgrading of the current Flash plugin in 
+	//	use (dojo.flash.Install).
+	//		
+	//	To use dojo.flash, you must first wait until Flash is finished loading 
+	//	and initializing before you attempt communication or interaction. 
+	//	To know when Flash is finished use dojo.event.connect:
+	//		
+	//	dojo.event.connect(dojo.flash, "loaded", myInstance, "myCallback");
+	//		
+	//	Then, while the page is still loading provide the file name
+	//	and the major version of Flash that will be used for Flash/JavaScript
+	//	communication (see "Flash Communication" below for information on the 
+	//	different kinds of Flash/JavaScript communication supported and how they 
+	//	depend on the version of Flash installed):
+	//		
+	//	dojo.flash.setSwf({flash6: "src/storage/storage_flash6.swf",
+	//										 flash8: "src/storage/storage_flash8.swf"});
+	//		
+	//	This will cause dojo.flash to pick the best way of communicating
+	//	between Flash and JavaScript based on the platform.
+	//		
+	//	If no SWF files are specified, then Flash is not initialized.
+	//		
+	//	Your Flash must use DojoExternalInterface to expose Flash methods and
+	//	to call JavaScript; see "Flash Communication" below for details.
+	//		
+	//	setSwf can take an optional 'visible' attribute to control whether
+	//	the Flash object is visible or not on the page; the default is visible:
+	//		
+	//	dojo.flash.setSwf({flash6: "src/storage/storage_flash6.swf",
+	//										 flash8: "src/storage/storage_flash8.swf",
+	//										 visible: false});
+	//		
+	//	Once finished, you can query Flash version information:
+	//		
+	//	dojo.flash.info.version
+	//		
+	//	Or can communicate with Flash methods that were exposed:
+	//		
+	//	var results = dojo.flash.comm.sayHello("Some Message");
+	//		
+	//	Only string values are currently supported for both arguments and
+	//	for return results. Everything will be cast to a string on both
+	//	the JavaScript and Flash sides.
+	//		
+	//	-------------------
+	//	Flash Communication
+	//	-------------------
+	//		
+	//	dojo.flash allows Flash/JavaScript communication in 
+	//	a way that can pass large amounts of data back and forth reliably and
+	//	very fast. The dojo.flash
+	//	framework encapsulates the specific way in which this communication occurs,
+	//	presenting a common interface to JavaScript irrespective of the underlying
+	//	Flash version.
+	//		
+	//	There are currently three major ways to do Flash/JavaScript communication
+	//	in the Flash community:
+	//		
+	//	1) Flash 6+ - Uses Flash methods, such as SetVariable and TCallLabel,
+	//	and the fscommand handler to do communication. Strengths: Very fast,
+	//	mature, and can send extremely large amounts of data; can do
+	//	synchronous method calls. Problems: Does not work on Safari; works on 
+	//	Firefox/Mac OS X only if Flash 8 plugin is installed; cryptic to work with.
+	//		
+	//	2) Flash 8+ - Uses ExternalInterface, which provides a way for Flash
+	//	methods to register themselves for callbacks from JavaScript, and a way
+	//	for Flash to call JavaScript. Strengths: Works on Safari; elegant to
+	//	work with; can do synchronous method calls. Problems: Extremely buggy 
+	//	(fails if there are new lines in the data, for example); performance
+	//	degrades drastically in O(n^2) time as data grows; locks up the browser while
+	//	it is communicating; does not work in Internet Explorer if Flash
+	//	object is dynamically added to page with document.writeln, DOM methods,
+	//	or innerHTML.
+	//		
+	//	3) Flash 6+ - Uses two seperate Flash applets, one that we 
+	//	create over and over, passing input data into it using the PARAM tag, 
+	//	which then uses a Flash LocalConnection to pass the data to the main Flash
+	//	applet; communication back to Flash is accomplished using a getURL
+	//	call with a javascript protocol handler, such as "javascript:myMethod()".
+	//	Strengths: the most cross browser, cross platform pre-Flash 8 method
+	//	of Flash communication known; works on Safari. Problems: Timing issues;
+	//	clunky and complicated; slow; can only send very small amounts of
+	//	data (several K); all method calls are asynchronous.
+	//		
+	//	dojo.flash.comm uses only the first two methods. This framework
+	//	was created primarily for dojo.storage, which needs to pass very large
+	//	amounts of data synchronously and reliably across the Flash/JavaScript
+	//	boundary. We use the first method, the Flash 6 method, on all platforms
+	//	that support it, while using the Flash 8 ExternalInterface method
+	//	only on Safari with some special code to help correct ExternalInterface's
+	//	bugs.
+	//		
+	//	Since dojo.flash needs to have two versions of the Flash
+	//	file it wants to generate, a Flash 6 and a Flash 8 version to gain
+	//	true cross-browser compatibility, several tools are provided to ease
+	//	development on the Flash side.
+	//		
+	//	In your Flash file, if you want to expose Flash methods that can be
+	//	called, use the DojoExternalInterface class to register methods. This
+	//	class is an exact API clone of the standard ExternalInterface class, but
+	//	can work in Flash 6+ browsers. Under the covers it uses the best
+	//	mechanism to do communication:
+	//		
+	//	class HelloWorld{
+	//		function HelloWorld(){
+	//			// Initialize the DojoExternalInterface class
+	//			DojoExternalInterface.initialize();
+	//			
+	//			// Expose your methods
+	//			DojoExternalInterface.addCallback("sayHello", this, this.sayHello);
+	//				
+	//			// Tell JavaScript that you are ready to have method calls
+	//			DojoExternalInterface.loaded();
+	//				
+	//			// Call some JavaScript
+	//			var resultsReady = function(results){
+	//				trace("Received the following results from JavaScript: " + results);
+	//			}
+	//			DojoExternalInterface.call("someJavaScriptMethod", resultsReady, 
+	//																	 someParameter);
+	//		}
+	//			
+	//		function sayHello(){ ... }
+	//			
+	//		static main(){ ... }
+	//	}
+	//		
+	//	DojoExternalInterface adds two new functions to the ExternalInterface
+	//	API: initialize() and loaded(). initialize() must be called before
+	//	any addCallback() or call() methods are run, and loaded() must be
+	//	called after you are finished adding your callbacks. Calling loaded()
+	//	will fire the dojo.flash.loaded() event, so that JavaScript can know that
+	//	Flash has finished loading and adding its callbacks, and can begin to
+	//	interact with the Flash file.
+	//		
+	//	To generate your SWF files, use the ant task
+	//	"buildFlash". You must have the open source Motion Twin ActionScript 
+	//	compiler (mtasc) installed and in your path to use the "buildFlash"
+	//	ant task; download and install mtasc from http://www.mtasc.org/.
+	//		
+	//		
+	//		
+	//	buildFlash usage:
+	//		
+	//	ant buildFlash -Ddojo.flash.file=../tests/flash/HelloWorld.as
+	//		
+	//	where "dojo.flash.file" is the relative path to your Flash 
+	//	ActionScript file.
+	//		
+	//	This will generate two SWF files, one ending in _flash6.swf and the other
+	//	ending in _flash8.swf in the same directory as your ActionScript method:
+	//		
+	//	HelloWorld_flash6.swf
+	//	HelloWorld_flash8.swf
+	//		
+	//	Initialize dojo.flash with the filename and Flash communication version to
+	//	use during page load; see the documentation for dojo.flash for details:
+	//		
+	//	dojo.flash.setSwf({flash6: "tests/flash/HelloWorld_flash6.swf",
+	//					 flash8: "tests/flash/HelloWorld_flash8.swf"});
+	//		
+	//	Now, your Flash methods can be called from JavaScript as if they are native
+	//	Flash methods, mirrored exactly on the JavaScript side:
+	//		
+	//	dojo.flash.comm.sayHello();
+	//		
+	//	Only Strings are supported being passed back and forth currently.
+	//		
+	//	JavaScript to Flash communication is synchronous; i.e., results are returned
+	//	directly from the method call:
+	//		
+	//	var results = dojo.flash.comm.sayHello();
+	//		
+	//	Flash to JavaScript communication is asynchronous due to limitations in
+	//	the underlying technologies; you must use a results callback to handle
+	//	results returned by JavaScript in your Flash AS files:
+	//		
+	//	var resultsReady = function(results){
+	//		trace("Received the following results from JavaScript: " + results);
+	//	}
+	//	DojoExternalInterface.call("someJavaScriptMethod", resultsReady);
+	//		
+	//		
+	//		
+	//	-------------------
+	//	Notes
+	//	-------------------
+	//		
+	//	If you have both Flash 6 and Flash 8 versions of your file:
+	//		
+	//	dojo.flash.setSwf({flash6: "tests/flash/HelloWorld_flash6.swf",
+	//					 flash8: "tests/flash/HelloWorld_flash8.swf"});
+	//											 
+	//	but want to force the browser to use a certain version of Flash for
+	//	all platforms (for testing, for example), use the djConfig
+	//	variable 'forceFlashComm' with the version number to force:
+	//		
+	//	var djConfig = { forceFlashComm: 6 };
+	//		
+	//	Two values are currently supported, 6 and 8, for the two styles of
+	//	communication described above. Just because you force dojo.flash
+	//	to use a particular communication style is no guarantee that it will
+	//	work; for example, Flash 8 communication doesn't work in Internet
+	//	Explorer due to bugs in Flash, and Flash 6 communication does not work
+	//	in Safari. It is best to let dojo.flash determine the best communication
+	//	mechanism, and to use the value above only for debugging the dojo.flash
+	//	framework itself.
+	//		
+	//	Also note that dojo.flash can currently only work with one Flash object
+	//	on the page; it and the API do not yet support multiple Flash objects on
+	//	the same page.
+	//		
+	//	We use some special tricks to get decent, linear performance
+	//	out of Flash 8's ExternalInterface on Safari; see the blog
+	//	post 
+	//	http://codinginparadise.org/weblog/2006/02/how-to-speed-up-flash-8s.html
+	//	for details.
+	//		
+	//	Your code can detect whether the Flash player is installing or having
+	//	its version revved in two ways. First, if dojo.flash detects that
+	//	Flash installation needs to occur, it sets dojo.flash.info.installing
+	//	to true. Second, you can detect if installation is necessary with the
+	//	following callback:
+	//		
+	//	dojo.event.connect(dojo.flash, "installing", myInstance, "myCallback");
+	//		
+	//	You can use this callback to delay further actions that might need Flash;
+	//	when installation is finished the full page will be refreshed and the
+	//	user will be placed back on your page with Flash installed.
+	//		
+	//	Two utility methods exist if you want to add loading and installing
+	//	listeners without creating dependencies on dojo.event; these are
+	//	'addLoadingListener' and 'addInstallingListener'.
+	//		
+	//	-------------------
+	//	Todo/Known Issues
+	//	-------------------
+	//
+	//	There are several tasks I was not able to do, or did not need to fix
+	//	to get dojo.storage out:		
+	//		
+	//	* When using Flash 8 communication, Flash method calls to JavaScript
+	//	are not working properly; serialization might also be broken for certain
+	//	invalid characters when it is Flash invoking JavaScript methods.
+	//	The Flash side needs to have more sophisticated serialization/
+	//	deserialization mechanisms like JavaScript currently has. The
+	//	test_flash2.html unit tests should also be updated to have much more
+	//	sophisticated Flash to JavaScript unit tests, including large
+	//	amounts of data.
+	//		
+	//	* On Internet Explorer, after doing a basic install, the page is
+	//	not refreshed or does not detect that Flash is now available. The way
+	//	to fix this is to create a custom small Flash file that is pointed to
+	//	during installation; when it is finished loading, it does a callback
+	//	that says that Flash installation is complete on IE, and we can proceed
+	//	to initialize the dojo.flash subsystem.
+	//		
+	//	Author- Brad Neuberg, bkn3@columbia.edu
+}
+
+dojo.flash = {
+	flash6_version: null,
+	flash8_version: null,
+	ready: false,
+	_visible: true,
+	_loadedListeners: new Array(),
+	_installingListeners: new Array(),
+	
+	setSwf: function(/* Object */ fileInfo){
+		// summary: Sets the SWF files and versions we are using.
+		// fileInfo: Object
+		//	An object that contains two attributes, 'flash6' and 'flash8',
+		//	each of which contains the path to our Flash 6 and Flash 8 versions
+		//	of the file we want to script.
+		//
+		//	Example-
+		//		var swfloc6 = dojo.uri.dojoUri("Storage_version6.swf").toString();
+		//		var swfloc8 = dojo.uri.dojoUri("Storage_version8.swf").toString();
+		//		dojo.flash.setSwf({flash6: swfloc6, flash8: swfloc8, visible: false}); 	
+		
+		if(fileInfo == null || dojo.lang.isUndefined(fileInfo)){
+			return;
+		}
+		
+		if(fileInfo.flash6 != null && !dojo.lang.isUndefined(fileInfo.flash6)){
+			this.flash6_version = fileInfo.flash6;
+		}
+		
+		if(fileInfo.flash8 != null && !dojo.lang.isUndefined(fileInfo.flash8)){
+			this.flash8_version = fileInfo.flash8;
+		}
+		
+		if(!dojo.lang.isUndefined(fileInfo.visible)){
+			this._visible = fileInfo.visible;
+		}
+		
+		// initialize ourselves		
+		this._initialize();
+	},
+	
+	useFlash6: function(){ /* Boolean */
+		// summary: Returns whether we are using Flash 6 for communication on this platform.
+		
+		if(this.flash6_version == null){
+			return false;
+		}else if (this.flash6_version != null && dojo.flash.info.commVersion == 6){
+			// if we have a flash 6 version of this SWF, and this browser supports 
+			// communicating using Flash 6 features...
+			return true;
+		}else{
+			return false;
+		}
+	},
+	
+	useFlash8: function(){ /* Boolean */
+		// summary: Returns whether we are using Flash 8 for communication on this platform.
+		
+		if(this.flash8_version == null){
+			return false;
+		}else if (this.flash8_version != null && dojo.flash.info.commVersion == 8){
+			// if we have a flash 8 version of this SWF, and this browser supports
+			// communicating using Flash 8 features...
+			return true;
+		}else{
+			return false;
+		}
+	},
+	
+	addLoadedListener: function(/* Function */ listener){
+		// summary:
+		//	Adds a listener to know when Flash is finished loading. 
+		//	Useful if you don't want a dependency on dojo.event.
+		// listener: Function
+		//	A function that will be called when Flash is done loading.
+		
+		this._loadedListeners.push(listener);
+	},
+
+	addInstallingListener: function(/* Function */ listener){
+		// summary:
+		//	Adds a listener to know if Flash is being installed. 
+		//	Useful if you don't want a dependency on dojo.event.
+		// listener: Function
+		//	A function that will be called if Flash is being
+		//	installed
+		
+		this._installingListeners.push(listener);
+	},	
+	
+	loaded: function(){
+		// summary: Called back when the Flash subsystem is finished loading.
+		// description:
+		//	A callback when the Flash subsystem is finished loading and can be
+		//	worked with. To be notified when Flash is finished loading, connect
+		//	your callback to this method using the following:
+		//	
+		//	dojo.event.connect(dojo.flash, "loaded", myInstance, "myCallback");
+		
+		//dojo.debug("dojo.flash.loaded");
+		dojo.flash.ready = true;
+		if(dojo.flash._loadedListeners.length > 0){
+			for(var i = 0;i < dojo.flash._loadedListeners.length; i++){
+				dojo.flash._loadedListeners[i].call(null);
+			}
+		}
+	},
+	
+	installing: function(){
+		// summary: Called if Flash is being installed.
+		// description:
+		//	A callback to know if Flash is currently being installed or
+		//	having its version revved. To be notified if Flash is installing, connect
+		//	your callback to this method using the following:
+		//	
+		//	dojo.event.connect(dojo.flash, "installing", myInstance, "myCallback");
+		 
+		//dojo.debug("installing");
+		if(dojo.flash._installingListeners.length > 0){
+			for(var i = 0; i < dojo.flash._installingListeners.length; i++){
+				dojo.flash._installingListeners[i].call(null);
+			}
+		}
+	},
+	
+	// Initializes dojo.flash.
+	_initialize: function(){
+		//dojo.debug("dojo.flash._initialize");
+		// see if we need to rev or install Flash on this platform
+		var installer = new dojo.flash.Install();
+		dojo.flash.installer = installer;
+
+		if(installer.needed() == true){		
+			installer.install();
+		}else{
+			//dojo.debug("Writing object out");
+			// write the flash object into the page
+			dojo.flash.obj = new dojo.flash.Embed(this._visible);
+			dojo.flash.obj.write(dojo.flash.info.commVersion);
+			
+			// initialize the way we do Flash/JavaScript communication
+			dojo.flash.comm = new dojo.flash.Communicator();
+		}
+	}
+};
+
+
+dojo.flash.Info = function(){
+	// summary: A class that helps us determine whether Flash is available.
+	// description:
+	//	A class that helps us determine whether Flash is available,
+	//	it's major and minor versions, and what Flash version features should
+	//	be used for Flash/JavaScript communication. Parts of this code
+	//	are adapted from the automatic Flash plugin detection code autogenerated 
+	//	by the Macromedia Flash 8 authoring environment. 
+	//	
+	//	An instance of this class can be accessed on dojo.flash.info after
+	//	the page is finished loading.
+	//	
+	//	This constructor must be called before the page is finished loading.	
+	
+	// Visual basic helper required to detect Flash Player ActiveX control 
+	// version information on Internet Explorer
+	if(dojo.render.html.ie){
+		document.writeln('<script language="VBScript" type="text/vbscript"\>');
+		document.writeln('Function VBGetSwfVer(i)');
+		document.writeln('  on error resume next');
+		document.writeln('  Dim swControl, swVersion');
+		document.writeln('  swVersion = 0');
+		document.writeln('  set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))');
+		document.writeln('  if (IsObject(swControl)) then');
+		document.writeln('    swVersion = swControl.GetVariable("$version")');
+		document.writeln('  end if');
+		document.writeln('  VBGetSwfVer = swVersion');
+		document.writeln('End Function');
+		document.writeln('</script\>');
+	}
+	
+	this._detectVersion();
+	this._detectCommunicationVersion();
+}
+
+dojo.flash.Info.prototype = {
+	// version: String
+	//		The full version string, such as "8r22".
+	version: -1,
+	
+	// versionMajor, versionMinor, versionRevision: String
+	//		The major, minor, and revisions of the plugin. For example, if the
+	//		plugin is 8r22, then the major version is 8, the minor version is 0,
+	//		and the revision is 22. 
+	versionMajor: -1,
+	versionMinor: -1,
+	versionRevision: -1,
+	
+	// capable: Boolean
+	//		Whether this platform has Flash already installed.
+	capable: false,
+	
+	// commVersion: int
+	//		The major version number for how our Flash and JavaScript communicate.
+	//		This can currently be the following values:
+	//		6 - We use a combination of the Flash plugin methods, such as SetVariable
+	//		and TCallLabel, along with fscommands, to do communication.
+	//		8 - We use the ExternalInterface API. 
+	//		-1 - For some reason neither method is supported, and no communication
+	//		is possible. 
+	commVersion: 6,
+	
+	// installing: Boolean
+	//	Set if we are in the middle of a Flash installation session.
+	installing: false,
+	
+	isVersionOrAbove: function(
+							/* int */ reqMajorVer, 
+							/* int */ reqMinorVer, 
+							/* int */ reqVer){ /* Boolean */
+		// summary: 
+		//	Asserts that this environment has the given major, minor, and revision
+		//	numbers for the Flash player.
+		// description:
+		//	Asserts that this environment has the given major, minor, and revision
+		//	numbers for the Flash player. 
+		//	
+		//	Example- To test for Flash Player 7r14:
+		//	
+		//	dojo.flash.info.isVersionOrAbove(7, 0, 14)
+		// returns:
+		//	Returns true if the player is equal
+		//	or above the given version, false otherwise.
+		
+		// make the revision a decimal (i.e. transform revision 14 into
+		// 0.14
+		reqVer = parseFloat("." + reqVer);
+		
+		if(this.versionMajor >= reqMajorVer && this.versionMinor >= reqMinorVer
+			 && this.versionRevision >= reqVer){
+			return true;
+		}else{
+			return false;
+		}
+	},
+	
+	_detectVersion: function(){
+		var versionStr;
+		
+		// loop backwards through the versions until we find the newest version	
+		for(var testVersion = 25; testVersion > 0; testVersion--){
+			if(dojo.render.html.ie){
+				versionStr = VBGetSwfVer(testVersion);
+			}else{
+				versionStr = this._JSFlashInfo(testVersion);		
+			}
+				
+			if(versionStr == -1 ){
+				this.capable = false; 
+				return;
+			}else if(versionStr != 0){
+				var versionArray;
+				if(dojo.render.html.ie){
+					var tempArray = versionStr.split(" ");
+					var tempString = tempArray[1];
+					versionArray = tempString.split(",");
+				}else{
+					versionArray = versionStr.split(".");
+				}
+					
+				this.versionMajor = versionArray[0];
+				this.versionMinor = versionArray[1];
+				this.versionRevision = versionArray[2];
+				
+				// 7.0r24 == 7.24
+				var versionString = this.versionMajor + "." + this.versionRevision;
+				this.version = parseFloat(versionString);
+				
+				this.capable = true;
+				
+				break;
+			}
+		}
+	},
+	 
+	// JavaScript helper required to detect Flash Player PlugIn version 
+	// information. Internet Explorer uses a corresponding Visual Basic
+	// version to interact with the Flash ActiveX control. 
+	_JSFlashInfo: function(testVersion){
+		// NS/Opera version >= 3 check for Flash plugin in plugin array
+		if(navigator.plugins != null && navigator.plugins.length > 0){
+			if(navigator.plugins["Shockwave Flash 2.0"] || 
+				 navigator.plugins["Shockwave Flash"]){
+				var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
+				var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
+				var descArray = flashDescription.split(" ");
+				var tempArrayMajor = descArray[2].split(".");
+				var versionMajor = tempArrayMajor[0];
+				var versionMinor = tempArrayMajor[1];
+				if(descArray[3] != ""){
+					var tempArrayMinor = descArray[3].split("r");
+				}else{
+					var tempArrayMinor = descArray[4].split("r");
+				}
+				var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
+				var version = versionMajor + "." + versionMinor + "." 
+											+ versionRevision;
+											
+				return version;
+			}
+		}
+		
+		return -1;
+	},
+	
+	// Detects the mechanisms that should be used for Flash/JavaScript 
+	// communication, setting 'commVersion' to either 6 or 8. If the value is
+	// 6, we use Flash Plugin 6+ features, such as GetVariable, TCallLabel,
+	// and fscommand, to do Flash/JavaScript communication; if the value is
+	// 8, we use the ExternalInterface API for communication. 
+	_detectCommunicationVersion: function(){
+		if(this.capable == false){
+			this.commVersion = null;
+			return;
+		}
+		
+		// detect if the user has over-ridden the default flash version
+		if (typeof djConfig["forceFlashComm"] != "undefined" &&
+				typeof djConfig["forceFlashComm"] != null){
+			this.commVersion = djConfig["forceFlashComm"];
+			return;
+		}
+		
+		// we prefer Flash 6 features over Flash 8, because they are much faster
+		// and much less buggy
+		
+		// at this point, we don't have a flash file to detect features on,
+		// so we need to instead look at the browser environment we are in
+		if(dojo.render.html.safari == true || dojo.render.html.opera == true){
+			this.commVersion = 8;
+		}else{
+			this.commVersion = 6;
+		}
+	}
+};
+
+dojo.flash.Embed = function(visible){
+	// summary: A class that is used to write out the Flash object into the page.
+	
+	this._visible = visible;
+}
+
+dojo.flash.Embed.prototype = {
+	// width: int
+	//	The width of this Flash applet. The default is the minimal width
+	//	necessary to show the Flash settings dialog. Current value is 
+	//  215 pixels.
+	width: 215,
+	
+	// height: int 
+	//	The height of this Flash applet. The default is the minimal height
+	//	necessary to show the Flash settings dialog. Current value is
+	// 138 pixels.
+	height: 138,
+	
+	// id: String
+	// 	The id of the Flash object. Current value is 'flashObject'.
+	id: "flashObject",
+	
+	// Controls whether this is a visible Flash applet or not.
+	_visible: true,
+
+	protocol: function(){
+		switch(window.location.protocol){
+			case "https:":
+				return "https";
+				break;
+			default:
+				return "http";
+				break;
+		}
+	},
+	
+	write: function(/* String */ flashVer, /* Boolean? */ doExpressInstall){
+		// summary: Writes the Flash into the page.
+		// description:
+		//	This must be called before the page
+		//	is finished loading. 
+		// flashVer: String
+		//	The Flash version to write.
+		// doExpressInstall: Boolean
+		//	Whether to write out Express Install
+		//	information. Optional value; defaults to false.
+		
+		//dojo.debug("write");
+		if(dojo.lang.isUndefined(doExpressInstall)){
+			doExpressInstall = false;
+		}
+		
+		// determine our container div's styling
+		var containerStyle = new dojo.string.Builder();
+		containerStyle.append("width: " + this.width + "px; ");
+		containerStyle.append("height: " + this.height + "px; ");
+		if(this._visible == false){
+			containerStyle.append("position: absolute; ");
+			containerStyle.append("z-index: 10000; ");
+			containerStyle.append("top: -1000px; ");
+			containerStyle.append("left: -1000px; ");
+		}
+		containerStyle = containerStyle.toString();
+
+		// figure out the SWF file to get and how to write out the correct HTML
+		// for this Flash version
+		var objectHTML;
+		var swfloc;
+		// Flash 6
+		if(flashVer == 6){
+			swfloc = dojo.flash.flash6_version;
+			var dojoPath = djConfig.baseRelativePath;
+			swfloc = swfloc + "?baseRelativePath=" + escape(dojoPath);
+			objectHTML = 
+						  '<embed id="' + this.id + '" src="' + swfloc + '" '
+						+ '    quality="high" bgcolor="#ffffff" '
+						+ '    width="' + this.width + '" height="' + this.height + '" '
+						+ '    name="' + this.id + '" '
+						+ '    align="middle" allowScriptAccess="sameDomain" '
+						+ '    type="application/x-shockwave-flash" swLiveConnect="true" '
+						+ '    pluginspage="'
+						+ this.protocol()
+						+ '://www.macromedia.com/go/getflashplayer">';
+		}else{ // Flash 8
+			swfloc = dojo.flash.flash8_version;
+			var swflocObject = swfloc;
+			var swflocEmbed = swfloc;
+			var dojoPath = djConfig.baseRelativePath;
+			if(doExpressInstall){
+				// the location to redirect to after installing
+				var redirectURL = escape(window.location);
+				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
+				var docTitle = escape(document.title);
+				swflocObject += "?MMredirectURL=" + redirectURL
+				                + "&MMplayerType=ActiveX"
+				                + "&MMdoctitle=" + docTitle
+								+ "&baseRelativePath=" + escape(dojoPath);
+				swflocEmbed += "?MMredirectURL=" + redirectURL 
+								+ "&MMplayerType=PlugIn"
+								+ "&baseRelativePath=" + escape(dojoPath);
+			}
+
+			if(swflocEmbed.indexOf("?") == -1){
+				swflocEmbed +=  "?baseRelativePath="+escape(dojoPath)+"' ";
+			}
+			
+			objectHTML =
+				'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
+				  + 'codebase="'
+					+ this.protocol()
+					+ '://fpdownload.macromedia.com/pub/shockwave/cabs/flash/'
+					+ 'swflash.cab#version=8,0,0,0" '
+				  + 'width="' + this.width + '" '
+				  + 'height="' + this.height + '" '
+				  + 'id="' + this.id + '" '
+				  + 'align="middle"> '
+				  + '<param name="allowScriptAccess" value="sameDomain" /> '
+				  + '<param name="movie" value="' + swflocObject + '" /> '
+				  + '<param name="quality" value="high" /> '
+				  + '<param name="bgcolor" value="#ffffff" /> '
+				  + '<embed src="' + swflocEmbed + "' "
+				  + 'quality="high" '
+				  + 'bgcolor="#ffffff" '
+				  + 'width="' + this.width + '" '
+				  + 'height="' + this.height + '" '
+				  + 'id="' + this.id + '" '
+				  + 'name="' + this.id + '" '
+				  + 'swLiveConnect="true" '
+				  + 'align="middle" '
+				  + 'allowScriptAccess="sameDomain" '
+				  + 'type="application/x-shockwave-flash" '
+				  + 'pluginspage="'
+					+ this.protocol()
+					+'://www.macromedia.com/go/getflashplayer" />'
+				+ '</object>';
+		}
+
+		// now write everything out
+		objectHTML = '<div id="' + this.id + 'Container" style="' + containerStyle + '"> '
+						+ objectHTML
+					 + '</div>';
+		document.writeln(objectHTML);
+	},  
+	
+	get: function(){ /* Object */
+		// summary: Gets the Flash object DOM node.
+		
+		//return (dojo.render.html.ie) ? window[this.id] : document[this.id];
+		
+		// more robust way to get Flash object; version above can break
+		// communication on IE sometimes
+		return document.getElementById(this.id);
+	},
+	
+	setVisible: function(/* Boolean */ visible){
+		// summary: Sets the visibility of this Flash object.
+		
+		var container = dojo.byId(this.id + "Container");
+		if(visible == true){
+			container.style.visibility = "visible";
+		}else{
+			container.style.position = "absolute";
+			container.style.x = "-1000px";
+			container.style.y = "-1000px";
+			container.style.visibility = "hidden";
+		}
+	},
+	
+	center: function(){
+		// summary: Centers the flash applet on the page.
+		
+		var elementWidth = this.width;
+		var elementHeight = this.height;
+
+		var scroll_offset = dojo.html.getScroll().offset;
+		var viewport_size = dojo.html.getViewport();
+
+		// compute the centered position    
+		var x = scroll_offset.x + (viewport_size.width - elementWidth) / 2;
+		var y = scroll_offset.y + (viewport_size.height - elementHeight) / 2; 
+
+		// set the centered position
+		var container = dojo.byId(this.id + "Container");
+		container.style.top = y + "px";
+		container.style.left = x + "px";
+	}
+};
+
+
+dojo.flash.Communicator = function(){
+	// summary:
+	//	A class that is used to communicate between Flash and JavaScript in 
+	//	a way that can pass large amounts of data back and forth reliably,
+	//	very fast, and with synchronous method calls.
+	// description: 
+	//	A class that is used to communicate between Flash and JavaScript in 
+	//	a way that can pass large amounts of data back and forth reliably,
+	//	very fast, and with synchronous method calls. This class encapsulates the 
+	//	specific way in which this communication occurs,
+	//	presenting a common interface to JavaScript irrespective of the underlying
+	//	Flash version.
+
+	if(dojo.flash.useFlash6()){
+		this._writeFlash6();
+	}else if (dojo.flash.useFlash8()){
+		this._writeFlash8();
+	}
+}
+
+dojo.flash.Communicator.prototype = {
+	_writeFlash6: function(){
+		var id = dojo.flash.obj.id;
+		
+		// global function needed for Flash 6 callback;
+		// we write it out as a script tag because the VBScript hook for IE
+		// callbacks does not work properly if this function is evalled() from
+		// within the Dojo system
+		document.writeln('<script language="JavaScript">');
+		document.writeln('  function ' + id + '_DoFSCommand(command, args){ ');
+		document.writeln('    dojo.flash.comm._handleFSCommand(command, args); ');
+		document.writeln('}');
+		document.writeln('</script>');
+		
+		// hook for Internet Explorer to receive FSCommands from Flash
+		if(dojo.render.html.ie){
+			document.writeln('<SCRIPT LANGUAGE=VBScript\> ');
+			document.writeln('on error resume next ');
+			document.writeln('Sub ' + id + '_FSCommand(ByVal command, ByVal args)');
+			document.writeln(' call ' + id + '_DoFSCommand(command, args)');
+			document.writeln('end sub');
+			document.writeln('</SCRIPT\> ');
+		}
+	},
+	
+	_writeFlash8: function(){
+		// nothing needs to be written out for Flash 8 communication; 
+		// happens automatically
+	},
+	
+	//Flash 6 communication.
+	
+	// Handles fscommand's from Flash to JavaScript. Flash 6 communication.
+	_handleFSCommand: function(command, args){
+		//dojo.debug("fscommand, command="+command+", args="+args);
+		// Flash 8 on Mac/Firefox precedes all commands with the string "FSCommand:";
+		// strip it off if it is present
+		if(command != null && !dojo.lang.isUndefined(command)
+			&& /^FSCommand:(.*)/.test(command) == true){
+			command = command.match(/^FSCommand:(.*)/)[1];
+		}
+		 
+		if(command == "addCallback"){ // add Flash method for JavaScript callback
+			this._fscommandAddCallback(command, args);
+		}else if(command == "call"){ // Flash to JavaScript method call
+			this._fscommandCall(command, args);
+		}else if(command == "fscommandReady"){ // see if fscommands are ready
+			this._fscommandReady();
+		}
+	},
+	
+	// Handles registering a callable Flash function. Flash 6 communication.
+	_fscommandAddCallback: function(command, args){
+		var functionName = args;
+			
+		// do a trick, where we link this function name to our wrapper
+		// function, _call, that does the actual JavaScript to Flash call
+		var callFunc = function(){
+			return dojo.flash.comm._call(functionName, arguments);
+		};			
+		dojo.flash.comm[functionName] = callFunc;
+		
+		// indicate that the call was successful
+		dojo.flash.obj.get().SetVariable("_succeeded", true);
+	},
+	
+	// Handles Flash calling a JavaScript function. Flash 6 communication.
+	_fscommandCall: function(command, args){
+		var plugin = dojo.flash.obj.get();
+		var functionName = args;
+		
+		// get the number of arguments to this method call and build them up
+		var numArgs = parseInt(plugin.GetVariable("_numArgs"));
+		var flashArgs = new Array();
+		for(var i = 0; i < numArgs; i++){
+			var currentArg = plugin.GetVariable("_" + i);
+			flashArgs.push(currentArg);
+		}
+		
+		// get the function instance; we technically support more capabilities
+		// than ExternalInterface, which can only call global functions; if
+		// the method name has a dot in it, such as "dojo.flash.loaded", we
+		// eval it so that the method gets run against an instance
+		var runMe;
+		if(functionName.indexOf(".") == -1){ // global function
+			runMe = window[functionName];
+		}else{
+			// instance function
+			runMe = eval(functionName);
+		}
+		
+		// make the call and get the results
+		var results = null;
+		if(!dojo.lang.isUndefined(runMe) && runMe != null){
+			results = runMe.apply(null, flashArgs);
+		}
+		
+		// return the results to flash
+		plugin.SetVariable("_returnResult", results);
+	},
+	
+	// Reports that fscommands are ready to run if executed from Flash.
+	_fscommandReady: function(){
+		var plugin = dojo.flash.obj.get();
+		plugin.SetVariable("fscommandReady", "true");
+	},
+	
+	// The actual function that will execute a JavaScript to Flash call; used
+	// by the Flash 6 communication method. 
+	_call: function(functionName, args){
+		// we do JavaScript to Flash method calls by setting a Flash variable
+		// "_functionName" with the function name; "_numArgs" with the number
+		// of arguments; and "_0", "_1", etc for each numbered argument. Flash
+		// reads these, executes the function call, and returns the result
+		// in "_returnResult"
+		var plugin = dojo.flash.obj.get();
+		plugin.SetVariable("_functionName", functionName);
+		plugin.SetVariable("_numArgs", args.length);
+		for(var i = 0; i < args.length; i++){
+			// unlike Flash 8's ExternalInterface, Flash 6 has no problem with
+			// any special characters _except_ for the null character \0; double
+			// encode this so the Flash side never sees it, but we can get it 
+			// back if the value comes back to JavaScript
+			var value = args[i];
+			value = value.replace(/\0/g, "\\0");
+			
+			plugin.SetVariable("_" + i, value);
+		}
+		
+		// now tell Flash to execute this method using the Flash Runner
+		plugin.TCallLabel("/_flashRunner", "execute");
+		
+		// get the results
+		var results = plugin.GetVariable("_returnResult");
+		
+		// we double encoded all null characters as //0 because Flash breaks
+		// if they are present; turn the //0 back into /0
+		results = results.replace(/\\0/g, "\0");
+		
+		return results;
+	},
+	
+	// Flash 8 communication.
+	
+	// Registers the existence of a Flash method that we can call with
+	// JavaScript, using Flash 8's ExternalInterface. 
+	_addExternalInterfaceCallback: function(methodName){
+		var wrapperCall = function(){
+			// some browsers don't like us changing values in the 'arguments' array, so
+			// make a fresh copy of it
+			var methodArgs = new Array(arguments.length);
+			for(var i = 0; i < arguments.length; i++){
+				methodArgs[i] = arguments[i];
+			}
+			return dojo.flash.comm._execFlash(methodName, methodArgs);
+		};
+		
+		dojo.flash.comm[methodName] = wrapperCall;
+	},
+	
+	// Encodes our data to get around ExternalInterface bugs.
+	// Flash 8 communication.
+	_encodeData: function(data){
+		// double encode all entity values, or they will be mis-decoded
+		// by Flash when returned
+		var entityRE = /\&([^;]*)\;/g;
+		data = data.replace(entityRE, "&amp;$1;");
+		
+		// entity encode XML-ish characters, or Flash's broken XML serializer
+		// breaks
+		data = data.replace(/</g, "&lt;");
+		data = data.replace(/>/g, "&gt;");
+		
+		// transforming \ into \\ doesn't work; just use a custom encoding
+		data = data.replace("\\", "&custom_backslash;&custom_backslash;");
+		
+		data = data.replace(/\n/g, "\\n");
+		data = data.replace(/\r/g, "\\r");
+		data = data.replace(/\f/g, "\\f");
+		data = data.replace(/\0/g, "\\0"); // null character
+		data = data.replace(/\'/g, "\\\'");
+		data = data.replace(/\"/g, '\\\"');
+		
+		return data;
+	},
+	
+	// Decodes our data to get around ExternalInterface bugs.
+	// Flash 8 communication.
+	_decodeData: function(data){
+		if(data == null || typeof data == "undefined"){
+			return data;
+		}
+		
+		// certain XMLish characters break Flash's wire serialization for
+		// ExternalInterface; these are encoded on the 
+		// DojoExternalInterface side into a custom encoding, rather than
+		// the standard entity encoding, because otherwise we won't be able to
+		// differentiate between our own encoding and any entity characters
+		// that are being used in the string itself
+		data = data.replace(/\&custom_lt\;/g, "<");
+		data = data.replace(/\&custom_gt\;/g, ">");
+		
+		// Unfortunately, Flash returns us our String with special characters
+		// like newlines broken into seperate characters. So if \n represents
+		// a new line, Flash returns it as "\" and "n". This means the character
+		// is _not_ a newline. This forces us to eval() the string to cause
+		// escaped characters to turn into their real special character values.
+		data = eval('"' + data + '"');
+		
+		return data;
+	},
+	
+	// Sends our method arguments over to Flash in chunks in order to
+	// have ExternalInterface's performance not be O(n^2).
+	// Flash 8 communication.
+	_chunkArgumentData: function(value, argIndex){
+		var plugin = dojo.flash.obj.get();
+		
+		// cut up the string into pieces, and push over each piece one
+		// at a time
+		var numSegments = Math.ceil(value.length / 1024);
+		for(var i = 0; i < numSegments; i++){
+			var startCut = i * 1024;
+			var endCut = i * 1024 + 1024;
+			if(i == (numSegments - 1)){
+				endCut = i * 1024 + value.length;
+			}
+			
+			var piece = value.substring(startCut, endCut);
+			
+			// encode each piece seperately, rather than the entire
+			// argument data, because ocassionally a special 
+			// character, such as an entity like &foobar;, will fall between
+			// piece boundaries, and we _don't_ want to encode that value if
+			// it falls between boundaries, or else we will end up with incorrect
+			// data when we patch the pieces back together on the other side
+			piece = this._encodeData(piece);
+			
+			// directly use the underlying CallFunction method used by
+			// ExternalInterface, which is vastly faster for large strings
+			// and lets us bypass some Flash serialization bugs
+			plugin.CallFunction('<invoke name="chunkArgumentData" '
+														+ 'returntype="javascript">'
+														+ '<arguments>'
+														+ '<string>' + piece + '</string>'
+														+ '<number>' + argIndex + '</number>'
+														+ '</arguments>'
+														+ '</invoke>');
+		}
+	},
+	
+	// Gets our method return data in chunks for better performance.
+	// Flash 8 communication.
+	_chunkReturnData: function(){
+		var plugin = dojo.flash.obj.get();
+		
+		var numSegments = plugin.getReturnLength();
+		var resultsArray = new Array();
+		for(var i = 0; i < numSegments; i++){
+			// directly use the underlying CallFunction method used by
+			// ExternalInterface, which is vastly faster for large strings
+			var piece = 
+					plugin.CallFunction('<invoke name="chunkReturnData" '
+															+ 'returntype="javascript">'
+															+ '<arguments>'
+															+ '<number>' + i + '</number>'
+															+ '</arguments>'
+															+ '</invoke>');
+															
+			// remove any leading or trailing JavaScript delimiters, which surround
+			// our String when it comes back from Flash since we bypass Flash's
+			// deserialization routines by directly calling CallFunction on the
+			// plugin
+			if(piece == '""' || piece == "''"){
+				piece = "";
+			}else{
+				piece = piece.substring(1, piece.length-1);
+			}
+		
+			resultsArray.push(piece);
+		}
+		var results = resultsArray.join("");
+		
+		return results;
+	},
+	
+	// Executes a Flash method; called from the JavaScript wrapper proxy we
+	// create on dojo.flash.comm.
+	// Flash 8 communication.
+	_execFlash: function(methodName, methodArgs){
+		var plugin = dojo.flash.obj.get();
+				
+		// begin Flash method execution
+		plugin.startExec();
+		
+		// set the number of arguments
+		plugin.setNumberArguments(methodArgs.length);
+		
+		// chunk and send over each argument
+		for(var i = 0; i < methodArgs.length; i++){
+			this._chunkArgumentData(methodArgs[i], i);
+		}
+		
+		// execute the method
+		plugin.exec(methodName);
+														
+		// get the return result
+		var results = this._chunkReturnData();
+		
+		// decode the results
+		results = this._decodeData(results);
+		
+		// reset everything
+		plugin.endExec();
+		
+		return results;
+	}
+}
+
+dojo.flash.Install = function(){
+	// summary: Helps install Flash plugin if needed.
+	// description:
+	//	Figures out the best way to automatically install the Flash plugin
+	//	for this browser and platform. Also determines if installation or
+	//	revving of the current plugin is needed on this platform.
+}
+
+dojo.flash.Install.prototype = {
+	needed: function(){ /* Boolean */
+		// summary:
+		//	Determines if installation or revving of the current plugin is 
+		//	needed. 
+	
+		// do we even have flash?
+		if(dojo.flash.info.capable == false){
+			return true;
+		}
+
+		// are we on the Mac? Safari needs Flash version 8 to do Flash 8
+		// communication, while Firefox/Mac needs Flash 8 to fix bugs it has
+		// with Flash 6 communication
+		if(dojo.render.os.mac == true && !dojo.flash.info.isVersionOrAbove(8, 0, 0)){
+			return true;
+		}
+
+		// other platforms need at least Flash 6 or above
+		if(!dojo.flash.info.isVersionOrAbove(6, 0, 0)){
+			return true;
+		}
+
+		// otherwise we don't need installation
+		return false;
+	},
+
+	install: function(){
+		// summary: Performs installation or revving of the Flash plugin.
+		
+		//dojo.debug("install");
+		// indicate that we are installing
+		dojo.flash.info.installing = true;
+		dojo.flash.installing();
+		
+		if(dojo.flash.info.capable == false){ // we have no Flash at all
+			//dojo.debug("Completely new install");
+			// write out a simple Flash object to force the browser to prompt
+			// the user to install things
+			var installObj = new dojo.flash.Embed(false);
+			installObj.write(8); // write out HTML for Flash 8 version+
+		}else if(dojo.flash.info.isVersionOrAbove(6, 0, 65)){ // Express Install
+			//dojo.debug("Express install");
+			var installObj = new dojo.flash.Embed(false);
+			installObj.write(8, true); // write out HTML for Flash 8 version+
+			installObj.setVisible(true);
+			installObj.center();
+		}else{ // older Flash install than version 6r65
+			alert("This content requires a more recent version of the Macromedia "
+						+" Flash Player.");
+			window.location.href = + dojo.flash.Embed.protocol() +
+						"://www.macromedia.com/go/getflashplayer";
+		}
+	},
+	
+	// Called when the Express Install is either finished, failed, or was
+	// rejected by the user.
+	_onInstallStatus: function(msg){
+		if (msg == "Download.Complete"){
+			// Installation is complete.
+			dojo.flash._initialize();
+		}else if(msg == "Download.Cancelled"){
+			alert("This content requires a more recent version of the Macromedia "
+						+" Flash Player.");
+			window.location.href = dojo.flash.Embed.protocol() +
+						"://www.macromedia.com/go/getflashplayer";
+		}else if (msg == "Download.Failed"){
+			// The end user failed to download the installer due to a network failure
+			alert("There was an error downloading the Flash Player update. "
+						+ "Please try again later, or visit macromedia.com to download "
+						+ "the latest version of the Flash plugin.");
+		}	
+	}
+}
+
+// find out if Flash is installed
+dojo.flash.info = new dojo.flash.Info();
+
+// vim:ts=4:noet:tw=0: