/* encoding utf-8 */

/**
 * Contents JavaScript Library (alpha version)
 *
 *
 * @author    Toru Yamaguchi@Contents Co.,Ltd. <tyamaguchi@contents.ne.jp>
 * @version   $Id$
 * @copyright 2002-2004 Contents Co.,Ltd. System Design Laboratory All Right Reserved
 */

if (!Array.push) {
	Array.prototype.push = function(elem) {
		this[this.length] = elem;
	};
}

if (!String.split) {
	String.prototype.split = function(separator) {
		var index = 0;
		var str = this.toString();
		var splited = new Array();

		index = str.indexOf(separator);

		while (index > 0) {
			splited.push(str.substr(0, index));				

			str = str.substr(index + 1);
			index = str.indexOf(separator);
		}

		if (str.length > 0) {
			splited.push(str);
		}

		return (splited);
	};
}

/**
 * return as bool which the variable is defined. 
 *
 *
 * @access public
 * @param object variable
 * @return bool
 */
function isDefined(variable) {
	return (typeof variable != 'undefined');
}

function dump(variable) {
	var newWin = window.open();

	newWin.onload = function() {
		newWin.document.writeln('<html><head><title>variable dump</title></head><body><pre>');
		if (typeof variable == 'object') {
			newWin.document.writeln(typeof variable + '{');
			for (var propName in variable) {
				newWin.document.writeln("\t(" + typeof variable[propName] + ') ' + propName + ' : ' + variable[propName]);
			}
			newWin.document.writeln('}');
		}
		else {
			newWin.document.writeln('(' + typeof variable + ')' + variable);
		}
		newWin.document.writeln('</pre></body></html>');
		window.close();
	};
}

/**
 * declare namespace
 *
 *
 * @access public
 * @param  string namespace
 * @return bool
 */
function declareNamespace(namespace) {
	if (typeof namespace != 'string') {
		return;
	}

	var parentNS = window;
	var nsLeafs = namespace.split('.');

	for (var i = 0; i < nsLeafs.length; i++) {
		if (!isDefined(parentNS[nsLeafs[i]])) {
			parentNS[nsLeafs[i]] = new Object();
		}

		parentNS = parentNS[nsLeafs[i]];
	}
}

/**
 * return as bool which rendering mode is standard mode
 *
 *
 * @access public
 * @return bool
 */
function isStandardMode() {
	if (isDefined(document.compatMode)) {
		return (document.compatMode == 'CSS1Compat');
	}

	return (false);
}




