
/*
 * B E A    S Y S T E M S
 *
 * Copyright (c) 2006  BEA Systems, Inc.
 *
 * All Rights Reserved. Unpublished rights reserved under the copyright laws
 * of the United States. The software contained on this media is proprietary
 * to and embodies the confidential technology of BEA Systems, Inc. The
 * possession or receipt of this information does not convey any right to
 * disclose its contents, reproduce it, or use,  or license the use, for
 * manufacture or sale, the information or anything described therein. Any
 * use, disclosure, or reproduction without BEA System's prior written
 * permission is strictly prohibited.
 */

//@package __BEA.com.bea.portal.common.js

if (window['__BEA'] == undefined) {
    window.__BEA = new function() { }
}

if (__BEA['com'] == undefined) {
    __BEA.com = new function() { }
}

if (__BEA.com['bea'] == undefined) {
    __BEA.com.bea = new function() { }
}

if (__BEA.com.bea['portal'] == undefined) {
    __BEA.com.bea.portal = new function() { }
}

if (__BEA.com.bea.portal['common'] == undefined) {
    __BEA.com.bea.portal.common = new function() { }
}

if (__BEA.com.bea.portal.common['js'] == undefined) {
    __BEA.com.bea.portal.common.js = new function() { }
}

__BEA.com.bea.portal.common.js.Common = new function() {

	/**
	 * Update the value of the specified composite name.
	 *
	 * <p>
	 * A composite name is a name consisting of one (1) or more
	 * name parts, separated by dot (<code>.</code>), that
	 * identify a nested reference,
	 * such as <code>__BEA.com.bea.portal.common.js.Common</code>.</p>
	 *
	 * @param namespace (optional) the root namespace object
	 * @param name... the composite name
	 * @param value the value
	 **/

	this.set = function() {
		var namespace = window
		var length = arguments.length
		var value = arguments[length - 1]
		for (var at = 0; at < length - 1; at += 1) {
			namespace = this.setOnInternal(namespace, arguments[at], (at == (length - 2)), value)
		}
		
		return namespace
	}

	/**
	 * Update the value of the specified composite name.
	 *
	 * <p>
	 * A composite name is a name consisting of one (1) or more
	 * name parts, separated by dot (<code>.</code>), that
	 * identify a nested reference,
	 * such as <code>__BEA.com.bea.portal.common.js.Common</code>.</p>
	 *
	 * @param namespace the root namespace object
	 * @param name... the composite name
	 * @param value the value
	 **/

	this.setOn = function() {
		var namespace = arguments[0]
		var length = arguments.length
		var value = arguments[length - 1]
		for (var at = 1; at < length - 1; at += 1) {
			namespace = this.setOnInternal(namespace, arguments[at], (at == (length - 2)), value)
		}
		
		return namespace
	}

	/**
	 * Update the value of the specified composite name.
	 *
	 * <p>
	 * A composite name is a name consisting of one (1) or more
	 * name parts, separated by dot (<code>.</code>), that
	 * identify a nested reference,
	 * such as <code>__BEA.com.bea.portal.common.js.Common</code>.</p>
	 *
	 * @param namespace the root namespace object
	 * @param name the composite name
	 * @param last indicates if this is the last call to <code>setOnInternal</code>
	 * @param value the value
	 **/

	this.setOnInternal = function(namespace, name, last, value) {
		var at
		while ((at = name.indexOf(".")) > 0) {
			var part = name.substring(0, at)
			name = name.substring(at + 1)
			var nnamespace
			if ((nnamespace = namespace[part]) == undefined) {
				namespace[part] = nnamespace = new Object()
			}
			namespace = nnamespace
		}
		
		namespace[name] = (!last)? new Object(): value
		
		return namespace[name]
	}
	
	this.load = function(href) {
		document.write("<scr" + "ipt type=\"text/javascript\" src=\"" + href + "\"></script>")
	}

}
