/*
 * document compressed to userplane.js using Yahoo YUI Compressor
 * http://developer.yahoo.com/yui/compressor/
 *
 * java -jar yuicompressor-2.4.2.jar --type js --verbose --preserve-semi -o userplane.js userplane_src.js
 *
 * Compressor will remove all comments EXCEPT C-Style comments (/*!)
*/

/*!
 * USERPLANE APPLICATION SCRIPT
 * Copyright (c) 2008 Userplane.
 * All Rights Reserved!
 * version 1.0.6
 
 1.0.4 - Added automatic rendering of ads to applications.
 1.0.5 - Added code to allow the end user to pass in an optional adContainer value.  
 * 			If passed in, we'll display the ad in that container.
 *			If not, we'll create our own.
 * 		ALSO added code to validate the ad container on simple checks and render the default adframe if any fail.
 1.0.6 - Included Adobe history files that were previously missing. Disabled ads on MediaPlayer for test.
 * 		ALSO added a missing include to a history.js file.
 *      ALSO added handling for including css files as well as js files in the require function.
 */


/*
 * USERPLANE
 * Core JS Object holding all Userplane scoped variables for the script.
 */
if (typeof USERPLANE == "undefined" || !USERPLANE) {
    /**
     * The USERPLANE global namespace object.  If USERPLANE is already defined, the
     * existing YAHOO object will not be overwritten so that defined
     * namespaces are preserved.
     */
    var USERPLANE = {};
}
/*
 * USERPLANE.app
 * Class instantiations for each application.
 * i.e. USERPLANE.app.Board();
 */
if (typeof USERPLANE.app == "undefined" || !USERPLANE.app) {
    USERPLANE.app = {};
}
/*
 * USERPLANE.config
 * Configuration objects used by each application class.
 * i.e. USERPLANE.config.Board { }
 */
if (typeof USERPLANE.config == "undefined" || !USERPLANE.config) {
    USERPLANE.config = {};
}
/*
 * USERPLANE.ui
 */
if (typeof USERPLANE.lang  == "undefined" || !USERPLANE.lang) {
	USERPLANE.lang = {};
}

/*
 * USERPLANE.log
 * Helper function that determines if a console is available and logs information to the console.
 * Usage: USERPLANE.log(message:string);
 */
USERPLANE.log = function(msg) {
	if (typeof console != 'undefined' && typeof console.log != "undefined") {
		console.log(msg);
	}
	else if (USERPLANE.ua.opera && typeof opera != 'undefined') {
		opera.postError(msg);
	}
};

/*
 * USERPLANE.createGUID
 * Helper function to create a standard GUID string.
 * Usage: var myGUID = USERPLANE.createGUID();
 */
USERPLANE.createGUID = function() {
	var result, i, j;
	result = '';
	for(j=0; j<32; j++) {
		if( j == 8 || j == 12|| j == 16|| j == 20)
			result = result + '-';
		i = Math.floor(Math.random()*16).toString(16).toUpperCase();
		result = result + i;
	}
	return result
};

// configuration constants shared across applications
USERPLANE.config = {
	COMSCORE : { id : "userplane_comscore_iframe", src : "comscore.html" },
	SWF_EXPRESS_INSTALL : "http://cache.static.userplane.com/CommunicationSuite/assets/js/expressinstall.swf",
	FLASHOBJECT_URL : "http://cache.static.userplane.com/CommunicationSuite/assets/js/flashobject.js",
	ADOBE_AC_OETAGS : "http://cache.static.userplane.com/CommunicationSuite/assets/js/flex/AC_OETags.js",
	ADOBE_HISTORY : "http://cache.static.userplane.com/CommunicationSuite/assets/js/flex/history.js",
	ADOBE_HISTORY_CSS : "http://cache.static.userplane.com/CommunicationSuite/assets/js/flex/history.css"
	// ADOBE_AC_OETAGS : "http://swf.m.userplane.com/CommunicationSuite/assets/js/flex/AC_OETags_src.js",
	// ADOBE_HISTORY : "http://swf.m.userplane.com/CommunicationSuite/assets/js/flex/history_src.js",
	// ADOBE_HISTORY_CSS : "http://swf.m.userplane.com/CommunicationSuite/assets/js/flex/history.css"
}

USERPLANE.ua = function() {
	var ua=navigator.userAgent,m,o;
	o={

        /**
         * Internet Explorer version number or 0.  Example: 6
         * @property ie
         * @type float
         */
        ie:0,

        /**
         * Opera version number or 0.  Example: 9.2
         * @property opera
         * @type float
         */
        opera:0,

        /**
         * Gecko engine revision number.  Will evaluate to 1 if Gecko
         * is detected but the revision could not be found. Other browsers
         * will be 0.  Example: 1.8
         * <pre>
         * Firefox 1.0.0.4: 1.7.8   <-- Reports 1.7
         * Firefox 1.5.0.9: 1.8.0.9 <-- Reports 1.8
         * Firefox 2.0.0.3: 1.8.1.3 <-- Reports 1.8
         * Firefox 3 alpha: 1.9a4   <-- Reports 1.9
         * </pre>
         * @property gecko
         * @type float
         */
        gecko:0,

        /**
         * AppleWebKit version.  KHTML browsers that are not WebKit browsers
         * will evaluate to 1, other browsers 0.  Example: 418.9.1
         * <pre>
         * Safari 1.3.2 (312.6): 312.8.1 <-- Reports 312.8 -- currently the
         *                                   latest available for Mac OSX 10.3.
         * Safari 2.0.2:         416     <-- hasOwnProperty introduced
         * Safari 2.0.4:         418     <-- preventDefault fixed
         * Safari 2.0.4 (419.3): 418.9.1 <-- One version of Safari may run
         *                                   different versions of webkit
         * Safari 2.0.4 (419.3): 419     <-- Tiger installations that have been
         *                                   updated, but not updated
         *                                   to the latest patch.
         * Webkit 212 nightly:   522+    <-- Safari 3.0 precursor (with native SVG
         *                                   and many major issues fixed).
         * 3.x yahoo.com, flickr:422     <-- Safari 3.x hacks the user agent
         *                                   string when hitting yahoo.com and
         *                                   flickr.com.
         * Safari 3.0.4 (523.12):523.12  <-- First Tiger release - automatic update
         *                                   from 2.x via the 10.4.11 OS patch
         * Webkit nightly 1/2008:525+    <-- Supports DOMContentLoaded event.
         *                                   yahoo.com user agent hack removed.
         *
         * </pre>
         * http://developer.apple.com/internet/safari/uamatrix.html
         * @property webkit
         * @type float
         */
        webkit: 0,

        /**
         * The mobile property will be set to a string containing any relevant
         * user agent information when a modern mobile browser is detected.
         * Currently limited to Safari on the iPhone/iPod Touch, Nokia N-series
         * devices with the WebKit-based browser, and Opera Mini.
         * @property mobile
         * @type string
         */
        mobile: null,

        /**
         * Adobe AIR version number or 0.  Only populated if webkit is detected.
         * Example: 1.0
         * @property air
         * @type float
         */
        air: 0,

        mode : null,

        os : null

    };

    // Modern KHTML browsers should qualify as Safari X-Grade
    if ((/KHTML/).test(ua)) {
        o.webkit=1;
    }
    // Modern WebKit browsers are at least X-Grade
    m=ua.match(/AppleWebKit\/([^\s]*)/);
    if (m&&m[1]) {
        o.webkit=parseFloat(m[1]);

        // Mobile browser check
        if (/ Mobile\//.test(ua)) {
            o.mobile = "Apple"; // iPhone or iPod Touch
        } else {
            m=ua.match(/NokiaN[^\/]*/);
            if (m) {
                o.mobile = m[0]; // Nokia N-series, ex: NokiaN95
            }
        }

        m=ua.match(/AdobeAIR\/([^\s]*)/);
        if (m) {
            o.air = m[0]; // Adobe AIR 1.0 or better
        }

    }

    if (!o.webkit) { // not webkit
        // @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr)
        m=ua.match(/Opera[\s\/]([^\s]*)/);
        if (m&&m[1]) {
            o.opera=parseFloat(m[1]);
            m=ua.match(/Opera Mini[^;]*/);
            if (m) {
                o.mobile = m[0]; // ex: Opera Mini/2.0.4509/1316
            }
        } else { // not opera or webkit
            m=ua.match(/MSIE\s([^;]*)/);
            if (m&&m[1]) {
                o.ie=parseFloat(m[1]);
            } else { // not opera, webkit, or ie
                m=ua.match(/Gecko\/([^\s]*)/);
                if (m) {
                    o.gecko=1; // Gecko detected, look for revision
                    m=ua.match(/rv:([^\s\)]*)/);
                    if (m&&m[1]) {
                        o.gecko=parseFloat(m[1]);
                    }
                }
            }
        }
    }

    // test for the os
    if (ua.match(/Mac\s([^;]*)/)) {
    	o.os = "mac";
    }
    else if (ua.match(/Windows\s([^;]*)/)) {
    	o.os = "win";
    }
    else if (ua.match(/Linux\s([^;]*)/)) {
    	o.os = "linux";
    }
    else {
    	o.os = "unknown";
    }

    // add mode to the object
    o.mode = (document.compatMode == 'BackCompat') ? 'quirks' : 'standards';

	return o;
}();

/*
 * USERPLANE.lang
 * general userplane functions needed
 */
USERPLANE.lang = {
	/**
     * Determines whether or not the provided object is a function
     * @method isFunction
     * @param {any} o The object being testing
     * @return {boolean} the result
     */
    isFunction: function(o) {
        return typeof o === 'function';
    },
	isString: function(o) {
        return typeof o === 'string';
    },
	isUndefined: function(o) {
        return typeof o === 'undefined';
    },
    isObject: function(o) {
		return (o && (typeof o === 'object' || USERPLANE.lang.isFunction(o))) || false;
    },
    isBoolean: function(o) {
        return typeof o === 'boolean';
    },
    isNumber: function(o) {
        return typeof o === 'number' && isFinite(o);
    },
    isNull: function(o) {
        return o === null;
    },
    
	toCamel : function(property) {
        if ( !/(-[a-z])/i.test(property) ) {
            return property; // no hyphens
        }
        
        if (propertyCache[property]) { // already converted
            return propertyCache[property];
        }
       
        var converted = property;
 
        while( /(-[a-z])/i.exec(converted) ) {
            converted = converted.replace(RegExp.$1, RegExp.$1.substr(1).toUpperCase());
        }
        
        propertyCache[property] = converted;
        return converted;
	},
	
	/**
	 * IE will not enumerate native functions in a derived object even if the
	 * function was overridden.  This is a workaround for specific functions
	 * we care about on the Object prototype.
	 * @property _IEEnumFix
	 * @param {Function} r  the object to receive the augmentation
	 * @param {Function} s  the object that supplies the properties to augment
	 * @static
	 * @private
	 */

	_IEEnumFix: function(r, s) {
	    if (USERPLANE.ua.ie) {
	    	var add, fname, i=0, f;
	        add=["toString", "valueOf"], i;
	        for (i=0;i<add.length;i=i+1) {
	            fname=add[i],f=s[fname];
	            if (USERPLANE.lang.isFunction(f) && f!=Object.prototype[fname]) {
	                r[fname]=f;
	            }
	        }
	    }
	},



	/*
	 * USERPLANE.require
	 * Helper function to require another script library at runtime.
	 * Usage: USERPLANE.require('http;//path/to/your/script.js');
	 */
	require : function(lib) {
		USERPLANE.log("Requiring Library: " + lib);
		document.write('<scr' + 'ipt type="text/javascript" src="' + lib + '"></scr' + 'ipt>');
	},
	
	
	extend : function(subc, superc, overrides) {
		if (!superc||!subc) {
	    	throw new Error("USERPLANE.lang.extend failed, please check that " +
	        	"all dependencies are included.");
	  	}
	  	var F, i;
	  	F = function() {};
	    F.prototype=superc.prototype;
        subc.prototype=new F();
        subc.prototype.constructor=subc;
        subc.superclass=superc.prototype;
        
        if (superc.prototype.constructor == Object.prototype.constructor) {
            superc.prototype.constructor=superc;
        }
    	if (overrides) {
	        for (i in overrides) {
	        	// console.log(i + " OVERRIDES " + overrides[i]);
	            subc.prototype[i]=overrides[i];
	        }

	        USERPLANE.lang._IEEnumFix(subc.prototype, overrides);
	    }
	}

}

USERPLANE.dom = {
	/**
     * Returns the current width of the viewport.
     * @method getViewportWidth
     * @return {Int} The width of the viewable area of the page (excludes scrollbars).
     */
     getViewportHeight: function() {
        var height = self.innerHeight; // Safari, Opera
        var mode = USERPLANE.ua.mode

        if ( (mode || USERPLANE.ua.ie) && !USERPLANE.ua.opera ) { // IE, Gecko
            height = (mode == 'standards') ?
                    document.documentElement.clientHeight : // Standards
                    document.body.clientHeight; // Quirks
        }

        return height;
    },

	/**
     * Returns the current width of the viewport.
     * @method getViewportWidth
     * @return {Int} The width of the viewable area of the page (excludes scrollbars).
     */
    getViewportWidth: function() {
       var width = self.innerWidth;  // Safari
       var mode = USERPLANE.ua.mode

        if (mode || USERPLANE.ua.ie) { // IE, Gecko, Opera
            width = (mode == 'standards') ?
                    document.documentElement.clientWidth : // Standards
                    document.body.clientWidth; // Quirks
        }
        return width;
    },

    /**
 	* Returns a region that is occupied by the DOM element
	 * @method getRegion
	 * @param  {HTMLElement} el The element
	 * @return {Region}         The region that the element occupies
	 * @static
	 */
	getRegion : function(el) {
		var p, region;

	    p = USERPLANE.dom.getXY(el);
	    region = {
	    	top : p[1],
	    	right : p[0] + el.offsetWidth,
	    	bottom: p[1] + el.offsetHeight,
	    	left : p[0]
	    };

	    return region;
	},


     /**
     * Returns the left scroll value of the document
     * @method getDocumentScrollLeft
     * @param {HTMLDocument} document (optional) The document to get the scroll value of
     * @return {Int}  The amount that the document is scrolled to the left
     */
    getDocumentScrollLeft: function(doc) {
        doc = doc || document;
        return Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft);
    },

    /**
     * Returns the top scroll value of the document
     * @method getDocumentScrollTop
     * @param {HTMLDocument} document (optional) The document to get the scroll value of
     * @return {Int}  The amount that the document is scrolled to the top
     */
    getDocumentScrollTop: function(doc) {
        doc = doc || document;
        return Math.max(doc.documentElement.scrollTop, doc.body.scrollTop);
    },
    
     setStyle : function(el, property, val) {
     	if (USERPLANE.ua.ie) {
            switch (property) {
                case 'opacity':
                    if ( USERPLANE.lang.isString(el.style.filter) ) { // in case not appended
                        el.style.filter = 'alpha(opacity=' + val * 100 + ')';
                        
                        if (!el.currentStyle || !el.currentStyle.hasLayout) {
                            el.style.zoom = 1; // when no layout or cant tell
                        }
                    }
                    break;
                case 'float':
                    property = 'styleFloat';
                default:
                el.style[property] = val;
            }
	    } 
	    else {
	            if (property == 'float') {
	                property = 'cssFloat';
	            }
	            el.style[property] = val;
	    }
     },
    
    
    getStyle : function(el, property) {
   		if (document.defaultView && document.defaultView.getComputedStyle) { // W3C DOM method
   			var value = null;
            
            if (property == 'float') { // fix reserved word
                property = 'cssFloat';
            }

            var computed = el.ownerDocument.defaultView.getComputedStyle(el, '');
            if (computed) { // test computed before touching for safari
                value = computed[USERPLANE.lang.toCamel(property)];
            }
            
            return el.style[property] || value; 	
    	 
    	} 
    	else if (document.documentElement.currentStyle && USERPLANE.ua.ie) { // IE method
            switch( USERPLANE.lang.toCamel(property) ) {
                case 'opacity' :// IE opacity uses filter
                    var val = 100;
                    try { // will error if no DXImageTransform
                        val = el.filters['DXImageTransform.Microsoft.Alpha'].opacity;

                    } catch(e) {
                        try { // make sure its in the document
                            val = el.filters('alpha').opacity;
                        } catch(e) {
                            USERPLANE.log('getStyle: IE filter failed');
                        }
                    }
                    return val / 100;
                case 'float': // fix reserved word
                    property = 'styleFloat'; // fall through
                default: 
                    // test currentStyle before touching
                    var value = el.currentStyle ? el.currentStyle[property] : null;
                    return ( el.style[property] || value );
            }
	    } 
	    else { // default to inline only
	        getStyle = function(el, property) { return el.style[property]; };
	    }
    },

    getXY : function(el) {
        if (document.documentElement.getBoundingClientRect) { // IE
        	var box, rootNode;
        	box = el.getBoundingClientRect();
        	rootNode = el.ownerDocument;
            return [box.left + USERPLANE.dom.getDocumentScrollLeft(rootNode), box.top + USERPLANE.dom.getDocumentScrollTop(rootNode)];
        } else {
        	var pos, parentNode, accountForBody;
            pos = [el.offsetLeft, el.offsetTop];
            parentNode = el.offsetParent;

            // safari: subtract body offsets if el is abs (or any offsetParent), unless body is offsetParent
            accountForBody = (USERPLANE.ua.webkit &&   el.style.position == 'absolute' &&   el.offsetParent == el.ownerDocument.body);
			if (parentNode != el) {
                while (parentNode) {
                    pos[0] += parentNode.offsetLeft;
                    pos[1] += parentNode.offsetTop;
                    if (!accountForBody && USERPLANE.ua.webkit && parentNode.style.position == 'absolute' ) {
                        accountForBody = true;
                    }
                    parentNode = parentNode.offsetParent;
                }
            }

            if (accountForBody) { //safari doubles in this case
                pos[0] -= el.ownerDocument.body.offsetLeft;
                pos[1] -= el.ownerDocument.body.offsetTop;
            }
            parentNode = el.parentNode;

            // account for any scrolled ancestors
            while ( parentNode.tagName && !/^body|html$/i.test(parentNode.tagName) )
            {
                if (parentNode.scrollTop || parentNode.scrollLeft) {
                    // work around opera inline/table scrollLeft/Top bug (false reports offset as scroll)
                    if (!/^(?:inline|table-row)$/i.test(USERPLANE.dom.getStyle(parentNode, 'display'))) {
                        if (!isOpera || USERPLANE.dom.getStyle(parentNode, 'overflow') !== 'visible') { // opera inline-block misreports when visible
                            pos[0] -= parentNode.scrollLeft;
                            pos[1] -= parentNode.scrollTop;
                        }
                    }
                }

                parentNode = parentNode.parentNode;
            }

            return pos;
        }
    }
}

USERPLANE.event = { 
	on : function(el, type, fx, obj, capture) {
		var localFx = function(e) {
			if (obj) {
				return fx.apply(this, obj);
			}
			else {
				return fx.apply(this);
			}
		};
		
		if (USERPLANE.ua.ie) {
			el.attachEvent('on' + type, localFx, this);
		}
		else {
			el.addEventListener(type, localFx, (capture));
		}
	},
	
	remove : function(el, type, fx, capture) {
		if (USERPLANE.ua.ie) { 
			el.detachEvent("on" + type, fx);
		} 
		else {
			el.removeEventListener(type, fx, (capture));
		}
	}
}

// all applications will require flashobject
if (typeof deconcept == 'undefined') {
	USERPLANE.lang.require(USERPLANE.config.FLASHOBJECT_URL);
}

USERPLANE.app.Application = function(options) {
	this.init(options);
}

/* USERPLANE.app PROTOTYPE
 * This prototype defines the general structure of a Userplane Application JS Class.
 * Can (and should) be extended and overridden as needed by the Application being defined.
 */
USERPLANE.app.Application.prototype = {
	DEFAULT_SWF_URL : null,
	DEFAULT_STYLE_SWF_URL : null,
	DEFAULT_CONTAINER : "userplane_app_container",
	SWF_EXPRESS_INSTALL : "",

	options : {},
	parentElement : null,
	adElement : null,
	adContainerInDom : false,
	adElement : null,
	adContainerInDom : false,
	swfURL : null,
	styleSwfURL : null,
	requireDiv : false,
	appCode : '',
	adFrameWidth : 0,
	adFrameHeight : 0,
	adSource : '',
	debug : false,
	ident : USERPLANE.createGUID(),

	initObject : function() {
		var args = arguments, property=null;

		if (!args[1]) args = [this, args[0]];

		// loop over the args coming in from the client
		for (property in args[1]) {
			// if this value is not in the ones expected from the class, add it to the class options
			if (typeof args[0][property] == 'undefined') {
				args[0][property] = args[1][property];
			}
		}
		// this loops over all the items we are expecting (as defined by  each classes options)
		for (property in args[0]) {
			if (typeof args[1][property] != "undefined") {
				args[0][property] = args[1][property];
			}
		}
		
		if (this.debug) {
			USERPLANE.log("------- POST SET OPTIONS ---------");
			for (property in args[0]) {
				USERPLANE.log(property + ":" + args[0][property]);
			}
		}
		
		return args[0];
	},

	init : function(o) {
		if (o) {
			this.options = this.setOptions(o);
		}
		if(typeof this.requireDiv == 'undefined') {
			this.requireDiv = false;
		}
		
		// determine the parentElement
		if (typeof this.options.container == 'string') {
			this.parentElement = document.getElementById(this.options.container);
		}
		else if (typeof this.options.container == 'object' && this.options.container != null) {
			this.parentElement = this.options.container;
			// reset the container back to id of the parent element.
			this.options.container = this.parentElement.id;
		}

		// if options.container is null, create an element on the page
		if (!this.options.container || !this.parentElement) {
			if (this.requireDiv) {
				USERPLANE.log("ERROR - Container with id '" + this.options.container + "' was not found.  In order for this application to function properly, this container must be present in the DOM before rendering the application.");
				// create an 'error' div
				var oErrorDiv = document.createElement("div");
				oErrorDiv.style.textAlign = 'center';
				oErrorDiv.style.fontFamily = 'arial';
				oErrorDiv.style.fontSize = '12px';
				oErrorDiv.style.color = 'red';
				oErrorDiv.style.background = 'white';
				oErrorDiv.style.padding = '10px';
				oErrorDiv.innerHTML = '<h3 style="font-size:16px; font-weight:bold; color:red;">Error Rendering Application</h3>If you are the site owner, please check your code.<br>A container with the id of \'' + this.options.container + '\' must be available on your page before rendering the application.';
				document.body.appendChild(oErrorDiv);
				return;
			}
			else {
				USERPLANE.log("WARNING - Container with id '" + this.options.container + "' was not found.  Defaulting to " + this.DEFAULT_CONTAINER + " and placing in body");
				this.options.container = this.DEFAULT_CONTAINER;
				this.parentElement = document.createElement("div");
				this.parentElement.id = this.options.container;
				document.body.appendChild(this.parentElement);
			}
		}

		// if invalid characters are found in the container warn.
		if (this.options.container.match(/[^a-zA-Z_]/gi) != null) {
			USERPLANE.log("WARNING - Illegal character(s) found in your container name.  Userplane cannot support containers with invalid ids.  Valid IDs are strictly alphabetical.");
		}


		// setup swfurl
		// we need to call a runtime function in the event the swf is load balanced
		// for instance - boards will override getSWFURL() to perform an AJAX loadbalance call.
		this.swfURL = this.getSWFURL();
		// just in case we want to override the URL for the StyleSwfURL per app, we'll do the same.
		this.styleSwfURL = this.getStyleSWFURL();
	},

	// sets the options AND defaults anything not passed in.
	setOptions : function(o){
		var options = this.initObject(this.options, o || {});
		return options;
	},

	getSWFURL : function() {
		// later on this will make an AJAX call to get the load balanced url for the swf.
		// right now we allow a swfURL to be passed into the config object
		// this is for developers to be able to load the swf on their local box.
		if (this.debug) {
			USERPLANE.log("this.options.swfURL " + this.options.swfURL)
		}
		return (this.options.swfURL) ? this.options.swfURL : this.DEFAULT_SWF_URL;
	},

	getStyleSWFURL : function() {
		if (this.debug) {
			USERPLANE.log("this.options.styleSwfURL " + this.options.styleSwfURL)
		}
		return (this.options.styleSwfURL) ? this.options.styleSwfURL : this.DEFAULT_STYLE_SWF_URL;
	},
	
	render : function() {
		if ((this.requireDiv) && (! this.parentElement)) {
			return;
		}
		
		var renderIt = function(o) {
			var args = arguments;
			var o = args[0];
			o.doRender(o);
		}
		
		
		// create the flashobject
		try {
			var args = Array();
			args[0] = this;
			if (this.debug) { 
				USERPLANE.log('*********** this *************');
				USERPLANE.log(this);
				USERPLANE.log('*********** end this *************');
			}
			
			USERPLANE.event.on(window, "load", renderIt, args);
			//USERPLANE.event.on(window, "resize", this.resizeAppForAd, args);
		}
		catch (e) {
			USERPLANE.log("Error Trapped Loading This Userplane Application");
			for (item in e)
				USERPLANE.log(item + " : " + e[item]);
		}
		
		//this.doRender(this);
	},
	
	addOptionalArgs : function(fo, args) {
		var item;
		for (item in args) {
			//USERPLANE.log("adding " + item + " [" + args[item] + "] to fo");
			fo.addVariable(item, args[item]);
		}
	},

	doRender : function(o) {
		var fo, item;
		
		// create the flashobject
		try {
			fo = new FlashObject(o.swfURL, "bd", o.options.width, o.options.height, "9", o.options.bg, false, "best");
			fo.addParam("wmode", "transparent");
			fo.addParam("scale", "noscale");
			fo.addParam("menu", "false");
			fo.addParam("align", "LT");
			fo.addParam("salign", "LT");
			fo.addParam("allowScriptAccess", "always");
			fo.addVariable("strDomainID", o.options.domainID);
			fo.addVariable("strInstanceID", o.options.instanceID);
			fo.addVariable("strSessionGUID", o.options.sessionGUID);
			fo.addVariable("strKey", o.options.key);
			fo.addVariable("strCSS", o.styleSwfURL);
			
			o.addOptionalArgs(fo, o.optionalArgs);
			
			fo.useExpressInstall(o.SWF_EXPRESS_INSTALL);
	  		fo.setAttribute('xiRedirectUrl', o.options.redirectURL);
			fo.write(o.parentElement);
			o.parentElement.style.display = "block";
		}
		catch (e) {
			USERPLANE.log("Error Trapped Loading This Userplane Application");
			for (item in e)
				USERPLANE.log(item + " : " + e[item]);
			
		}
	},
	
	/*
	 * resizeAppForAd
	 * Determines if an appplication needs to be resized in order to have the adFrame
	 * displayed properly.
	 * This function should only be present if the ad container was built by us ( ! o.adContainerInDom) 
	 * 
	 * IF they are controlling the adContainer - this will do some checks against it to make sure they aren't 
	 * screwing around with hiding ads.
	 */
	resizeAppForAd : function() {
		var appHeight = 0, viewportHeight = 0, adFrameHeight = 0;
		if (! this.adContainerInDom) {
			viewportHeight = USERPLANE.dom.getViewportHeight();
			
			if (this.adFrameWidth && this.adFrameHeight) {
				
				// if the height of the app is greater than viewport height - adFrameHeight then we need to shrink the app down a bit
				appHeight = USERPLANE.dom.getStyle(this.parentElement, "height");
				
				// cover IE which turns 100% to auto
				if (appHeight == 'auto') {
					appHeight = '100%';
				}
				adFrameHeight = this.adFrameHeight;
				
				if (adFrameHeight.substr((adFrameHeight.length - 2), 2) == 'px') {
					adFrameHeight = adFrameHeight.substr(0, (adFrameHeight.length - 2));
				}
				
				if (appHeight.substr((appHeight.length - 1), 1) == '%') {
					appHeight = appHeight.substr(appHeight.length - 1);
					appRegion = USERPLANE.dom.getRegion(this.parentElement);
					appHeight = parseInt(appRegion.bottom) - parseInt(appRegion.top);
					// appHeight = viewportHeight * (appHeight - 1);
					// appHeight = appHeight * (appHeight - 1);
				}
				else {
					appHeight = appHeight.substr(0, appHeight.length - 2);
				}
				
				if (appHeight > viewportHeight) {
					appHeight = viewportHeight;
				}
				
				USERPLANE.log("adFrameHeight: " + adFrameHeight + " appHeight: " + appHeight);
				USERPLANE.log(viewportHeight);
				
				if ((parseInt(appHeight) + parseInt(adFrameHeight)) > viewportHeight ) {
					USERPLANE.log("we're resizing!");
					USERPLANE.log((appHeight - adFrameHeight) + 'px');
					var oApp = document.getElementById('userplane_' + this.appCode);
					USERPLANE.dom.setStyle(oApp, 'height', (appHeight - adFrameHeight) + 'px');
				}
			}
		}
	},
	
	/*
	 * renderAd
	 * checks to see if an ad needs to be rendered for this app 
	 * (strictly based on a value populated for the adFrameWidth and adFrameHeight options)
	 * If an ad needs to be rendered, should determine if an adContainer is present in DOM.
	 * If not, will create ad container, else uses existing adContainer.
	 * Creates the ad iFrame and renders it.
	 */
	renderAd : function() {
		var oAd = null, oAdContainer = null, asl = '', appHeight = 0, adFrameHeight = 0;
		
		
		if (this.adFrameWidth && this.adFrameHeight) {
			oAdContainer = document.getElementById(this.options.adContainer);
			USERPLANE.log("adContainer: " + this.options.adContainer);
			USERPLANE.log(oAdContainer);
			
			// check for the ad container. If not found, create one.
			if (!this.options.adContainer || !oAdContainer ) {
				this.adElement = document.createElement("div");
				this.adElement.id = "userplane_" + this.appCode + "_adContainer";
				this.parentElement.appendChild(this.adElement)
			}
			else {
				USERPLANE.log("Found AdContainer in DOM");
				// set adContainerInDom to true. This tells us that they are using their own adContainer. We didn't build it
				this.adContainerInDom = true;
				
				// if the adContainer is a string value - turn it into the DOM object.
				if (typeof this.options.adContainer == "string") {
					this.adElement = document.getElementById(this.options.adContainer);
				}
				else {
					this.adElement = this.options.adContainer;
				}
				
				// if not a valid container - just make one.  
				if (! this.isValidAdContainer()) {
					USERPLANE.log("Invalid Container Found");
					this.adElement = document.createElement("div");
					this.adElement.id = "userplane_" + this.appCode + "_adContainer";
					this.parentElement.appendChild(this.adElement)
				}
				
			}
			
			if (this.options.viewerAge) {
				asl += 'a_' + this.options.viewerAge + '|';
			}
			if (this.options.viewerGender) {
				asl += 'g_' + this.options.viewerGender;
			}
			
			this.resizeAppForAd();
			
			oAd = document.createElement('iframe');
			oAd.id = "userplane_" + this.appCode + "_ad";
			USERPLANE.dom.setStyle(oAd, 'display', 'block');
			USERPLANE.dom.setStyle(oAd, 'clear', 'both');
			USERPLANE.dom.setStyle(oAd, 'width', this.adFrameWidth);
			USERPLANE.dom.setStyle(oAd, 'height', this.adFrameHeight);
			USERPLANE.dom.setStyle(oAd, 'border', '0px solid white');
			oAd.src =  this.adSource + '?userplane=false&app=' + this.appCode + '&zoneID=' + this.adZoneID + '&textZoneID=' + this.textAdZoneID + '&domainID=' + this.options.domainID + '&asl=' + asl;
			
			this.adElement.appendChild(oAd);

		}
	},
	
	/*
	 * isValidAdContainer
	 * checks to see if an ad container that was passed in from the client is valid. 
	 * Having negative margin, padding, top, left values or being hidden or display none invalidates the container.
	 */
	isValidAdContainer : function() {
		var marginLeft = 0, marginTop = 0, paddingLeft = 0, paddingTop = 0, left = 0, top = 0, width=0, height=0;
		
		// if the adElement is not displayed - display it
		if ( USERPLANE.dom.getStyle(this.adElement, 'display') == 'none' ) {
			return false;
		}
		if ( USERPLANE.dom.getStyle(this.adElement, 'visibility') == 'hidden' ) {
			return false;
		}
		
		
		paddingLeft = USERPLANE.dom.getStyle(this.adElement, 'paddingLeft');
		paddingTop = USERPLANE.dom.getStyle(this.adElement, 'paddingTop');
		marginLeft = USERPLANE.dom.getStyle(this.adElement, 'marginLeft');
		marginTop = USERPLANE.dom.getStyle(this.adElement, 'marginTop');
		left = USERPLANE.dom.getStyle(this.adElement, 'left');
		top = USERPLANE.dom.getStyle(this.adElement, 'top');
		width = USERPLANE.dom.getStyle(this.adElement, 'width');
		height = USERPLANE.dom.getStyle(this.adElement, 'height');
		
		if ( paddingLeft.substr(0, (paddingLeft.length - 2)) < 0 ) {
			return false;
		}
		if ( paddingTop.substr(0, (paddingTop.length - 2)) < 0 ) {
			return false;
		}
		if ( marginLeft.substr(0, (marginLeft.length - 2)) < 0 ) {
			return false;
		}
		if ( marginTop.substr(0, (marginTop.length - 2)) < 0 ) {
			return false;
		}
		if ( top.substr(0, (top.length - 2)) < 0 ) {
			return false;
		}
		if ( left.substr(0, (left.length - 2)) < 0 ) {
			return false;
		}
		
		// if the adElement is less than the minimum size of the ad unit, we need to resize
		if ( height.substr(0, (width.length - 2)) < this.adFrameHeight ) {
			USERPLANE.log("height is too small. Resizing");
			USERPLANE.dom.setStyle(this.adElement, 'height', this.adFrameHeight);
		}
		if ( width.substr(0, (width.length - 2)) < this.adFrameWidth ) {
			USERPLANE.log("width is too small. Resizing");
			USERPLANE.dom.setStyle(this.adElement, 'width', this.adFrameWidth);
		}
		
		return true;
	},
		
	loadAd : function(o, oAd) {
		var asl = '';
		if (o.options.viewerAge) {
			asl += 'a_' + o.options.viewerAge + '|';
		}
		if (o.options.viewerGender) {
			asl += 'g_' + o.options.viewerGender;
		}
		// USERPLANE.log("looking for ad frame at: " + 'userplane_' + o.appCode + '_ad');
		
		if (oAd) {
			USERPLANE.log("ad: " + oAd.id);
			oAd.src =  o.adSource + '?userplane=false&app=' + o.appCode + '&zoneID=' + o.adZoneID + '&textZoneID=' + o.textAdZoneID + '&domainID=' + o.options.domainID + '&asl=' + asl;
			USERPLANE.log("ad: " + oAd.src);
		}
	},
	
	dumpOptions : function() {
		USERPLANE.log("------------------------");
		USERPLANE.log("OPTIONS DUMP");
		USERPLANE.log("------------------------");
		for (property in this.options) {
			USERPLANE.log(property + ":" + this.options[property]);
		}
		USERPLANE.log("------------------------");
		USERPLANE.log("END OPTIONS DUMP");
		USERPLANE.log("------------------------");
		
		
	},
	
	dump : function() {
		USERPLANE.log("------------------------");
		USERPLANE.log("DUMP");
		USERPLANE.log("------------------------");
		for (property in this) {
			if (!USERPLANE.lang.isFunction(this[property]))
				USERPLANE.log(property + ":" + this[property]);
		}
		USERPLANE.log("------------------------");
		USERPLANE.log("END DUMP");
		USERPLANE.log("------------------------");
		
		
	}
}

/*
 * USERPLANE.app.Board
 * instantiation of the Userplane Boards Class
 * This class creates a Userplane Board object
 */
USERPLANE.app.Board = function(options) {
	// BOARDS SPECIFIC CONSTANTS HERE
	this.DEFAULT_SWF_URL = "http://cache.static.userplane.com/CommunicationSuite/bd.swf";
	this.DEFAULT_STYLE_SWF_URL = "http://cache.static.userplane.com/CommunicationSuite/assets/styles/bd_style.swf";
	this.DEFAULT_CONTAINER = "userplane_board_container";

	// initialize the board.
	this.init(options);
}

USERPLANE.lang.extend(USERPLANE.app.Board, USERPLANE.app.Application, {

	options : {
				container : '',
				adContainer:null,
				domainID : '',
				instanceID : '',
				sessionGUID : '',
				key : '',
				environment : '',
				width : '100%',
				height : '100%',
				bg : '#ffffff',
				comscoreURL : 'comscore.html',
				redirectURL : '',
				styleSwfURL : '',
				swfURL : '',
				alt: '',
				viewerAge : '',
				viewerGender : '',
				viewerIP : '',
				optionalArgs : null
			},
	
	comScoreIframe: null,
	debug : false,
	adZoneID : 4345,
	textAdZoneID : 4346,
	appCode : 'bd',
	adFrameWidth : '100%',
	adFrameHeight : '130px',
	adSource : 'http://cache.static.userplane.com/subtracts/adframes/int_frameset.html',
	requireDiv : true,
	
	init : function(o) {
		USERPLANE.app.Board.superclass.init.apply(this, [o]);

		// Boards need deeplinking ability
		// which is supplied by these adobe files...
		USERPLANE.lang.require(USERPLANE.config.ADOBE_HISTORY);
		USERPLANE.lang.require(USERPLANE.config.ADOBE_HISTORY_CSS);
		USERPLANE.lang.require(USERPLANE.config.ADOBE_AC_OETAGS);
				
		// we need to set this because it's going to be used on a csEvent call outside of the scope of this.
		USERPLANE.config.COMSCORE.src = this.options.comscoreURL;
		if (!this.options.comscoreURL.length) {
			this.options.comscoreURL = null;
			USERPLANE.config.COMSCORE.src = null;
		}
		if (this.options.comscoreURL.match(/[^a-zA-Z_:.//]/gi) != null) {
			USERPLANE.log("WARNING - Illegal character(s) found in your comscoreURL file name.  Userplane cannot support comscore files with invalid names.  Valid names are strictly alphabetical.");
		}
	},

	doRender : function() {
		var fo, item;
		// create the flashobject
		try {
			fo = new FlashObject(this.swfURL, 'userplane_' + this.appCode, this.options.width, this.options.height, "9", this.options.bg, false, "best");
			fo.addParam("wmode", "transparent");
			fo.addParam("scale", "noscale");
			fo.addParam("menu", "false");
			fo.addParam("align", "LT");
			fo.addParam("salign", "LT");
			fo.addParam("allowFullScreen", "true");
			fo.addParam("allowScriptAccess", "always");
			fo.addVariable("strDomainID", this.options.domainID);
			fo.addVariable("strInstanceID", this.options.instanceID);
			fo.addVariable("strSessionGUID", this.options.sessionGUID);
			fo.addVariable("strKey", this.options.key);
			fo.addVariable("strCSS", this.styleSwfURL);
			fo.addVariable("strCssID", this.options.container);
			fo.addVariable("strEnvironment", this.options.environment);
			
			USERPLANE.log("----------------------------------");
			this.addOptionalArgs(fo, this.options.optionalArgs);
			
			fo.useExpressInstall(this.SWF_EXPRESS_INSTALL);
	  		fo.setAttribute('xiRedirectUrl', this.options.redirectURL);
			fo.write(this.parentElement);
			// in the event we have the parentElement hidden, render it.
			this.parentElement.style.display = "block";
			
			// build the comScore iframe
			if (this.options.comscoreURL) {
				this.comScoreIframe = document.createElement('iframe');
				this.comScoreIframe.id = USERPLANE.config.COMSCORE.id;
				this.comScoreIframe.src = this.options.comscoreURL;
				if (this.debug) {
					this.comScoreIframe.style.borderTop = "1px solid #3c3c3c";
					this.comScoreIframe.style.borderBottom = "1px solid #3c3c3c";
					this.comScoreIframe.style.width = "100%";
					this.comScoreIframe.style.height = "15px";
				}
				else {
					this.comScoreIframe.style.border = "0px solid #fff";
					this.comScoreIframe.style.height = "0px";
				}
				this.parentElement.appendChild(this.comScoreIframe);
			}

			// turn ads off if asked to do so
			if (!this.options.turnOffAds)
			{
				// render an ad!
				this.renderAd();
			}
		}
		catch (e) {
			USERPLANE.log("Error Trapped Loading Boards");
			for (item in e)
				USERPLANE.log(item + " : " + e[item]);
		}
	}

});



/*
 * USERPLANE.app.Mediaplayer
 * instantiation of the Userplane MediaPlayer Class
 * This class creates a Userplane MediaPlaye Object
 */
USERPLANE.app.Mediaplayer = function(options) {
	// BOARDS SPECIFIC CONSTANTS HERE

	// REMOVE THIS / CHANGE THIS ONCE WE GET LOAD BALANCED BOARDS AND NEED AJAX CALL
	this.DEFAULT_SWF_URL = "http://cache.static.userplane.com/CommunicationSuite/mp.swf";
	this.DEFAULT_STYLE_SWF_URL = "http://cache.static.userplane.com/CommunicationSuite/assets/styles/mp_style.swf";
	this.DEFAULT_CONTAINER = "userplane_mediaplayer_container";
	
	// initialize the board.
	// USERPLANE.app.Mediaplayer.superclass.init.call(this, options);
	this.init(options);
	
}

USERPLANE.lang.extend(USERPLANE.app.Mediaplayer, USERPLANE.app.Application, {

	options : {
				container:this.DEFAULT_CONTAINER,
				domainID: '',
				instanceID: '',
				sessionGUID : '',
				key : '',
				videoID : '',
				videoUserID : '',
				status : 'approved',
				environment : '',
				width : '100%',
				height : '100%',
				bg : '#ffffff',
				redirectURL : '',
				styleSwfURL : this.DEFAULT_STYLE_SWF_URL,
				swfURL : this.DEFAULT_SWF_URL,
				alt: '',
				viewerAge : '',
				viewerGender : '',
				viewerIP : ''
			},
	optionalArgs : {},		
	adZoneID : 4209,
	textAdZoneID : 4210,
	appCode : 'mp',
	adFrameWidth :  null, //'500px',
	adFrameHeight : null, //'90px',
	adSource : 'http://cache.static.userplane.com/subtracts/adframes/int_frameset.html',
	requireDiv : false,

	
	doRender : function(o) {
		var fo, item;
		// create the flashobject
		try {
			
			if (this.debug) {  
				/*
				USERPLANE.log('*********** doRender options *************');
				USERPLANE.log(o);
				USERPLANE.log('*********** end doRender options *************');
				*/
			}

			fo = new FlashObject(o.swfURL, "userplane_" + o.appCode, o.options.width, o.options.height, "9", o.options.bg, false, "best");
			fo.addParam("wmode", "transparent");
			fo.addParam("scale", "noscale");
			fo.addParam("menu", "false");
			fo.addParam("align", "LT");
			fo.addParam("salign", "LT");
			fo.addParam("allowFullScreen", "true");
			fo.addParam("allowScriptAccess", "always");
			fo.addVariable("strDomainID", o.options.domainID);
			fo.addVariable("strInstanceID", o.options.instanceID);
			fo.addVariable("strSessionGUID", o.options.sessionGUID);
			fo.addVariable("strKey", o.options.key);
			fo.addVariable("strVideoID", o.options.videoID);
			fo.addVariable("strVideoUserID", o.options.videoUserID);
			fo.addVariable("strStatus", o.options.status);
			fo.addVariable("strCSS", o.styleSwfURL);
			fo.addVariable("styleSkin", o.styleSwfURL); 	// this is legacy flashvar, should go bye bye.  Passing strCSS as well since that's the new var.
			fo.addVariable("strCssID", o.options.container);
			fo.addVariable("strEnvironment", o.options.environment);
			
			o.addOptionalArgs(fo, o.optionalArgs);
			
			fo.useExpressInstall(o.SWF_EXPRESS_INSTALL);
	  		fo.setAttribute('xiRedirectUrl', o.options.redirectURL);
			fo.write(o.parentElement);
			// in the event we have the parentElement hidden, render it.
			o.parentElement.style.display = "block";
			
			// turn ads off if asked to do so
			if (!o.options.turnOffAds)
			{
				// render an ad!
				o.renderAd();
			}
		}
		catch (e) {
			USERPLANE.log("Error Trapped Loading Mediaplayer");
			for (item in e)
				USERPLANE.log(item + " : " + e[item]);
		}
	}
});



/*
 * USERPLANE.app.MediaplayerUploaer
 * instantiation of the Userplane MediaPlayer Class
 * This class creates a Userplane MediaPlaye Object
 */
USERPLANE.app.MediaplayerUploader = function(options) {
	// MEDIAUPLOADER SPECIFIC CONSTANTS HERE

	// REMOVE THIS / CHANGE THIS ONCE WE GET LOAD BALANCED BOARDS AND NEED AJAX CALL
	this.DEFAULT_SWF_URL = "http://cache.static.userplane.com/CommunicationSuite/mu.swf";
	this.DEFAULT_STYLE_SWF_URL = "http://cache.static.userplane.com/CommunicationSuite/assets/styles/mu_style.swf";
	this.DEFAULT_CONTAINER = "userplane_mediaplayerUploader_container";


	// require tos
	USERPLANE.lang.require("http://cache.static.userplane.com/CommunicationSuite/assets/js/mediaplayerTOSModal.js");
	//USERPLANE.lang.require("http://graphjam.mashedupapps.com/userplane/js/mediaplayerTOSModal.js");
	// initialize the board.
	this.init(options);
}

USERPLANE.lang.extend(USERPLANE.app.MediaplayerUploader, USERPLANE.app.Application, {
	options : {
				container:this.DEFAULT_CONTAINER,
				domainID : '',
				instanceID : '',
				sessionGUID : '',
				key : '',
				videoID : '',
				environment : '',
				width : '100%',
				height : '100%',
				bg : '#ffffff',
				redirectURL : '',
				styleSwfURL : this.DEFAULT_STYLE_SWF_URL,
				swfURL : this.DEFAULT_SWF_URL,
				alt: '',
				viewerAge : '',
				viewerGender : '',
				viewerIP : ''
			},
	optionalArgs : {},
	adZoneID : 4209,
	textAdZoneID : 4210,
	appCode : 'mu',
	adFrameWidth : null,
	adFrameHeight : null,
	adSource : 'http://cache.static.userplane.com/subtracts/adframes/int_frameset.html',
	requireDiv : false,

	doRender : function(o) {
		var fo, item;
		// create the flashobject
		try {
			fo = new FlashObject(o.swfURL, "userplane_" + o.appCode, o.options.width, o.options.height, "9", o.options.bg, false, "best");
			fo.addParam("wmode", "transparent");
			fo.addParam("scale", "noscale");
			fo.addParam("menu", "false");
			fo.addParam("align", "LT");
			fo.addParam("salign", "LT");
			fo.addParam("allowFullScreen", "true");
			fo.addParam("allowScriptAccess", "always");
			fo.addVariable("strDomainID", o.options.domainID);
			fo.addVariable("strInstanceID", o.options.instanceID);
			fo.addVariable("strSessionGUID", o.options.sessionGUID);
			fo.addVariable("strKey", o.options.key);
			fo.addVariable("strVideoID", o.options.videoID);
			fo.addVariable("strCSS", o.styleSwfURL);
			fo.addVariable("strCssID", o.options.container);
			fo.addVariable("strEnvironment", o.options.environment);
			
			o.addOptionalArgs(fo, o.optionalArgs);
			
			fo.useExpressInstall(o.SWF_EXPRESS_INSTALL);
	  		fo.setAttribute('xiRedirectUrl', o.options.redirectURL);
			fo.write(o.parentElement);
			// in the event we have the parentElement hidden, render it.
			o.parentElement.style.display = "block";
		}
		catch (e) {
			USERPLANE.log("Error Trapped Loading Mediaplayer Uploader");
			for (item in e)
				USERPLANE.log(item + " : " + e[item]);
		}

	}
});


/*
 * USERPLANE.app.Minichat
 * instantiation of the Userplane Minichat Class
 * This class creates a Userplane Minichat Object
 */
USERPLANE.app.Minichat = function(options) {
	// MINICHAT SPECIFIC CONSTANTS HERE

	// REMOVE THIS / CHANGE THIS ONCE WE GET LOAD BALANCED BOARDS AND NEED AJAX CALL
	this.DEFAULT_SWF_URL = "http://cache.static.userplane.com/CommunicationSuite/mc.swf";
	this.DEFAULT_STYLE_SWF_URL = "http://cache.static.userplane.com/CommunicationSuite/assets/styles/mc.swf";
	this.DEFAULT_CONTAINER = "userplane_mediaplayerUploader_container";

	// initialize the board.
	this.init(options);
}

USERPLANE.lang.extend(USERPLANE.app.Minichat, USERPLANE.app.Application, {
	options : {
				container:this.DEFAULT_CONTAINER,
				flashcomServer : '',
				domainID : '',
				instanceID : '',
				sessionGUID : '',
				key : '',
				environment : '',
				width : '100%',
				height : '100%',
				bg : '#ffffff',
				redirectURL : '',
				styleSwfURL : this.DEFAULT_STYLE_SWF_URL,
				swfURL : this.DEFAULT_SWF_URL,
				alt : '',
				viewerAge : '',
				viewerGender : '',
				viewerIP : ''
			},
	optionalArgs : {},
	adZoneID : 4209,
	textAdZoneID : 4210,
	appCode : 'mc',
	adFrameWidth : null,
	adFrameHeight : null,
	adSource : 'http://cache.static.userplane.com/subtracts/adframes/int_frameset.html',
	requireDiv : false,
	
	doRender : function(o) {
		var fo, item, upContainer;
		// create the flashobject
		try {
			fo = new FlashObject(o.swfURL, "userplane_"  + o.appCode, o.options.width, o.options.height, "9", o.options.bg, false, "best");
			fo.addParam("wmode", "transparent");
			fo.addParam("scale", "noscale");
			fo.addParam("menu", "false");
			fo.addParam("salign", "LT");
			fo.addParam("salign", "LT");
			fo.addParam("allowScriptAccess", "always");
			fo.addVariable("strServer", o.options.flashcomServer);
			fo.addVariable("strDomainID", o.options.domainID);
			fo.addVariable("strInstanceID", o.options.instanceID);
			fo.addVariable("strSessionGUID", o.options.sessionGUID);
			fo.addVariable("strKey", o.options.key);
			fo.addVariable("strCSS", o.styleSwfURL);
			fo.addVariable("strCssID", o.options.container);
			fo.addVariable("strEnvironment", o.options.environment);
			fo.addVariable("strApplicationName", "CommunicationSuite");
			
			o.addOptionalArgs(fo, o.optionalArgs);
			
			fo.useExpressInstall(o.SWF_EXPRESS_INSTALL);
	  		fo.setAttribute('xiRedirectUrl', o.options.redirectURL);
			fo.write(o.parentElement);
			
			upContainer = document.createElement("div");
			upContainer.innerHTML = o.parentElement.innerHTML;
			upContainer.setAttribute("id",o.parentElement.id);
			
			// in the event we have the parentElement hidden, render it.
			o.parentElement.style.display = "block";
			o.parentElement.style.position = "relative";
			o.parentElement.id = 'upFlashContainer';
			// apparently we don't have to re-render we just have to set the id
			//o.parentElement.innerHTML = "";
			//o.parentElement.appendChild( upContainer );
			
		}
		catch (e) {
			USERPLANE.log("Error Trapped Loading Minichat");
			for (item in e)
				USERPLANE.log(item + " : " + e[item]);
		}

	}
});



/*
 * USERPLANE.app.Minichat
 * instantiation of the Userplane Minichat Class
 * This class creates a Userplane Minichat Object
 */
USERPLANE.app.Chat = function(options) {
	// CHAT SPECIFIC CONSTANTS HERE

	this.DEFAULT_SWF_URL = "http://swf.userplane.com/CommunicationSuite/ch.swf";
	this.DEFAULT_STYLE_SWF_URL = "";
	this.DEFAULT_CONTAINER = "userplane_chat_container";

	// initialize the board.
	this.init(options);
}

USERPLANE.lang.extend(USERPLANE.app.Chat, USERPLANE.app.Application, {
	options : {
				container:this.DEFAULT_CONTAINER,
				flashcomServer : '',
				domainID : '',
				instanceID : '',
				sessionGUID : '',
				key : '',
				environment : '',
				width : '100%',
				height : '100%',
				bg : '#ffffff',
				redirectURL : '',
				styleSwfURL : this.DEFAULT_STYLE_SWF_URL,
				swfURL : this.DEFAULT_SWF_URL,
				alt : '',
				viewerAge : '',
				viewerGender : '',
				viewerIP : ''
			},
	optionalArgs : {},
	adZoneID : 4209,
	textAdZoneID : 4210,
	appCode : 'ch',
	adFrameWidth : null,
	adFrameHeight : null,
	adSource : 'http://cache.static.userplane.com/subtracts/adframes/int_frameset.html',
	requireDiv : false,
	
	doRender : function(o) {
		var fo, item;
		// create the flashobject
		try {
			fo = new FlashObject(o.swfURL, "userplane_"  + o.appCode, o.options.width, o.options.height, "9", o.options.bg, false, "best");
			fo.addParam("wmode", "transparent");
			fo.addParam("scale", "noscale");
			fo.addParam("menu", "false");
			fo.addParam("salign", "LT");
			fo.addParam("salign", "LT");
			fo.addParam("allowScriptAccess", "always");
			fo.addVariable("strServer", o.options.flashcomServer);
			fo.addVariable("strDomainID", o.options.domainID);
			fo.addVariable("strInstanceID", o.options.instanceID);
			fo.addVariable("strSessionGUID", o.options.sessionGUID);
			fo.addVariable("strKey", o.options.key);
			fo.addVariable("strCSS", o.styleSwfURL);
			fo.addVariable("strCssID", o.options.container);
			fo.addVariable("strEnvironment", o.options.environment);
			
			o.addOptionalArgs(fo, o.optionalArgs);
			
			fo.useExpressInstall(o.SWF_EXPRESS_INSTALL);
	  		fo.setAttribute('xiRedirectUrl', o.options.redirectURL);
			fo.write(o.parentElement);
			// in the event we have the parentElement hidden, render it.
			o.parentElement.style.display = "block";
		}
		catch (e) {
			USERPLANE.log("Error Trapped Loading Userplane Chat");
			for (item in e)
				USERPLANE.log(item + " : " + e[item]);
		}

	}
});



	