// -------------- Object Utilities --------------------------

/*



--------------

Global variables within this module



o			- General purpose utilities related to JavaScript objects

			(***convert to Object.prototype extensions?)

DATAOBJ			- Censoft Data Object utilities



E			(*** convert to a property of another object)

$context	(*** convert to a property of another object)

getEntire	(*** convert to a property of another object)



--------------



Terminology



	Data Object = The definition of the Censoft Data Object starting at the root of the object

		e.g.: Company, News

	Element = A single property value for a Data Object that can be selected by the user

		e.g.: Profile.Description.Yahoo is an Element within Data Object called Company

	Input = A root level property of a Data Object that provides one or more values that can be used to calculate other Elements

		Data Objects can have 0-N Inputs

		e.g.: $Ticker_Symbol is an input for the Data Object called Company

		

	(Inherited) = Element properties that can be inherited from parent elements.

	(Root) = Element properties that can only be defined at the root data object level.

	(***) = Not yet implemented

		

Root level Data Object settings 

	

	_embed			- Object - relationships to other Data Objects

		.Weather	- String - name of property to join to named Object (e.g. "$Sources.Market_Guide.Address.Weather")



	

Properties related to Input values



	_listing (Root)		- Object - specifications for input dialog

		.url			- String - The URL for the input dialog to display (e.g. "../dialog/input_custom.htm")

		.dim

			.h			- Height of the input dialog

			.w			- Width of the input dialog

		.name			- String - The name to display next to the inputs portion of the Section

		.input			- Object

			.js			- String - The name of the javascript file to include in the dialog

	_noCacheInputs (Root)	- boolean - true to prevent input values from being cached on the client machine

		Cached inputs will be used whenever a Section is created and no Input values have been specified

	_multiInputs (Root)	- Indicates if multiple inputs are allowed.

		If _multiInputs is true, the user can enter multiple values seperated by commas and

		cause the section to display information for multiple Data Objects

	_inputHelp (Root) ***??? - Help information that is displayed in the output area if no inputs are specified

		e.g. "Enter one or more search terms seperated by commas, then click Go"

		

	_inputType - Indicates that the property IsContains a value that can be input by the user

		default: not an input

		0: not an input

		1: standard input value	(one of the combobox choices)

		2: default input value (selected in the combobox)

		3: mandatory input value (always appears on the input form)

		4: mandatory password field values

		5: mandatory hidden field values (always appears on the input form)



			

Properties related to the Element Chooser



	_Name - The displayed Element label that appears in the chooser

		Defaults to a calculated value based on Element name (__p)

	_sort - Sort order for the Element (defaults to _Name.lowerCase())

		This can be used to cause Elements to display in an order other than alphabetical order

	_HiddenT - Override value for the hierarchy type

		default: branch if an Element name starts with something other than "_" or "getEntire", otherwise leaf

		1: root

		2: branch - The Element has child Elements that are displayed in the hierarchy

		3: leaf - The Element does not have child Elements and should be treated as a hierarchy leaf Element

		9: hidden - Do not show the Element in the hierarchy

	_DefaultE - String - A list of Elements that are used if the Element is dropped from the Element chooser

		e.g. Company._DefaultE = "Profile.Company_Name,Profile.Logo,Profile.Description"

		

	

Properties related to the display of the Element within a Section



	_noTitles (Root)***	- Boolean - true if Titles should not be displayed within Sections for this Data Object

		(html.js, page.js, section.js)

	_Title - The displayed title for the Element (defaults to value of _Name)

		This value appears next to Element values within a Section or as a Section title

		If a numeric value is specified then it indicates the number of levels of labels to use in the title.

		A negative number indicates a parent label should be used.

			"Title" - use "Title" when displaying within a section

			-1 - use title of parent Element

			-2 - use title of grandparent Element

			1 - use parent label + " " + Element label

	_noClick (Inherited) (***) - Boolean - true to prevent click-through to the source page (use for XML, etc.)	

	_inProgressTitle (Inherited) (***) - HTML to display if the value is being loaded

	

		

Standard properties for objects:

	

	(function) - If an Element is defined as a function, it will automatically expand into an object with the _Function property set to the function

	

	Object initialization properties:

	

		_init - An initialization function that is evaluated and then cleared to null after usage

			This can be used to dynamically create properties using compact looping functions.

		_Copye - class name - name of the template object (e.g. "Yahoo.Profile").  Cleared after initialized.

		_src (***) - String - URL for the file that IsContains the element definition

			e.g. "/own/content/company_sources.js"

			This enables elements to be defined asynchronously

	

	_rootProp - Boolean - Indicates that property references starting with "/" should start with this property

		This is used with embedded objects to enable company calculations to use "/Ticker" instead of having

		to know a specific number of "../" prefix values to use





	Element value properties:

	

		_Function - Function used to calculate the value for the Element

		_FunctionToA	- Functions to apply to the result after calculation has been performed

				Function: apply a single function

				Array: apply a series of functions

				Calling syntax for applied functions: f(propContext,propValue)->propValue

		_DefaultV - the name of the default child property or a function that returns the default property value

				This is used when the property is really a reference to another property within the Data Object

		_TimeOut (Inherited) :N - timeout duration for cached results.

			0: use default cache settings

			-1: do not use cache.  Always calculate new value.

			+n: expire in n seconds

			default: ???

				1 hour = 3,600

				1 day = 86,400

				1 week = 604,800

	

	Properties for extraction functions:



		_xf				- The extraction function to use if x is specified for an object

		_xr				- A text range that provides the source range for the extraction

							Function: evaluates the function to determine source text

							String: uses the value as the name of the property to be evaluated (e.g. "$r")

		_xa				- Functions to apply to the result after extraction has been performed

							Function: apply a single function

							Array: apply a series of functions

							Calling syntax for applied functions: f(propContext,propValue)->propValue

		

		_x1				- Match value for extraction (defaults to ">"+name)

		_x2				- End value for extraction range

	

Properties related to Web Page objects



	$url - String - indicates the url to load and causes the WEBPAGE object to be used

	_errMsg404 (Inherited) - String - error message to display if a page can not be loaded

	_errTest (Inherited) - String - error test when the page has loaded.  If this value is found within the response then the error message is displayed.

	_errMsg (Inherited) - String - error message to display if the _errTest condition is met.  Default to "Invalid Input" if not specified

		

Internal properties including calculated values.  These properties should not be set in the content definition.

	

	__i				- Initialization status

						true = Child Elements have been initilized

						

	__p				- The name of the Element property within the parent Element

						This is populated automatically when the Element is initialized

						

	__v				- The cached value of the Element

	__vTime:D		- The time that the cached value was calculated

	__vAsync:S		- Indicates that the calculation of __v is in progress and waiting for results from this source

	__vSrcURL		- Indicates the source URL for the property value (used for click-through)

	__vSyncTime		- The earliest time for async content calculation used by the field value (e.g. the time the web page was synchronized)

	__vExpires		- The time that the calculated value expires based on exiring content

	__vError:S		- Error information if the calculation resulted in an error

	

	__parent		- Stores reference to parent Element (or Null if top level object)

	__template		- Stores reference to template Object (if o.template() is used)

	

	__clearDate (Root)		- The time the values were cleared (older ones will be treated as stale)

	__boundInputs (Root)	- HTML Elements that are bound to Censoft Data Object inputs

	__boundOutputs (Root)	- HTML Elements that are bound to Censoft Data Object output Elements



*/

var SCRIPT = {

	

	a: {},			// Status of scripts that have loaded or are loading

	

	// load: loads the script file found at the specified URL

	

	load: function(odo, onDone, onDoneArgs,bSync) {

		// find JS file Mapping

		var sd = null;

		var js = null;

		try{

			sd = onDoneArgs["sd"];

			

		}catch(err){}

		if(sd!=null&&sd.jsName!=null){

			js = sd.jsName;

	//		alert("js="+js);

		}else{

			js = DATAOBJ.odo2js( odo );

		}

		if(sd!=null)sd.jsName = js;

		if (!js) return null;

		

		var url = "/content".servletURL() + "?name=" + js + "&u=" + gUserCookie;

		return this.loadPkg(url, null, onDone, onDoneArgs, bSync);

	},

	

	loadTypes: function(types, onDone, onDoneArgs, bSync) {

		if (types && types.length > 0) {

			var url = "/type".servletURL();

			url += '?u='+ gUserCookie + '&name=' + types.deleteDup().join('&name=');



			return this.loadPkg(url, null, onDone, onDoneArgs, bSync);

		}

	},

	

	loadPkg: function(url, post, onDone, onDoneArgs,bSync) {

		var args = [onDone, onDoneArgs];

		

		var wp = INET.get(url, post, 0, SCRIPT.onDone, args,bSync);

		if ( wp.status == 1 ) SCRIPT.onDone( wp, args );

		

		return wp;

	},

	

	// Called when a SCRIPT has finished loading

	onDone: function(wp,args) {

		if (!wp.errNum) {

			// is this a content or a type call?

			var types = []; 

			if (wp.url.indexOf('/content'.servletURL()) > -1) {

				var _tpkg = eval(wp.response);			// Evaluate the script

				if (_tpkg) {

					types = _tpkg.split(',');

				}

				

				SCRIPT.loadTypes(types, args[0], args[1], true);

			} else { // type call

				eval(wp.response);			// Evaluate the script

			}

			if (types.length == 0 && args && args[0] ) {

				(args[0])( wp, args[1] );

			}

			

			

		}

		

	},

	

	addConnectTypes: function(wp,types) {

		var conn = wp.response.arrayByRange(/_connect\s*:\s*['"]/, /['"]/,null,null,true);

		var c=null;

		for (var i=0; i<conn.length; i++) {

			c = conn[i];

			if (!TYPEOBJ.getConnect(c)) {

				types[types.length] = c;

			}

		}

		

		return types;

	}

}



var o = {



	value: function(obj) {	// Get the value of an object

		if (obj && typeof obj == "object") {	// Make sure it is an object

			var r = "";							// Default to blank result

			o.validateCache(obj);	// Make sure the content has not expired

			if (obj.__v) {			// Check for a cached result value.

				r = obj.__v;		// Return the cached value

			} else {

				if ($context.error || obj.__vError) {

					if (!$context.error) $context.error = obj.__vError;

					r = "";			// Return blank value if there is an error

				} else if ($context.inProgress || obj.__vAsync) {	// Check if calculation is in progress

					if (!$context.inProgress) $context.inProgress = obj.__vAsync;

					r = "";			// Return blank value if calculation is in progress

				} else if (obj.__v != null) {	// Check for valid blank value

					r = obj.__v;	// Check for a cached result value.  "" is a valid value

				} else {



					$context.property = obj;	// Set the calculation context to the object



					if (obj._Function) {	// A function is defined for the object value

												

						if ( typeof obj._Function == "string" )

							obj._Function = o.getRoot( DATAOBJ.relPath( $context.props, obj._Function, obj ), true );

									

						r = obj._Function ? obj._Function(obj) : "";			// Calculate the results of the function

						

						if ($context.inProgress) {	// Calculation was not completed

							r = "";

						} else {

							//var fa = o.parentProp(obj,"_FunctionToA");

							var fa = obj._FunctionToA;

							if(!fa) fa = o.parentProp(obj,"_FunctionToA");	//added by zhou 2002-8-29

							if (fa) {	// Apply formatting after result calculated

								if (fa.constructor == Array) {

									for (var i=0; i<fa.length; i++) r = fa[i](obj,r);

								} else {

									r = fa(obj,r);

								}

							}				

							obj.__v = r;		// Cache the resulting value

						}

					} else if (obj._DefaultV) {	// A default property has been specified



						if (obj._DefaultV.constructor == String) {	// A property name was specified

							var p = (($context.props) ? $context.props : obj.__p) + "._DefaultV";

							r = DATAOBJ.get($context.root,DATAOBJ.relPath(p, obj._DefaultV,obj));

						} else {

							r = DATAOBJ.get($context.root,$context.props + "._DefaultV");	// A default value is specified

						}

					

					}

				}



 				// Track the source URL for click through behavior

				if (obj.__p == "$url2") {

					$context.srcURL = obj.__v;

				} else if (obj.__vSrcURL) {

					$context.srcURL = obj.__vSrcURL;

				} else {

					if (!obj.__vSrcURL && $context.srcURL) obj.__vSrcURL = $context.srcURL;

				}



				if (!obj.__vError && $context.error) obj.__vError = $context.error;		// Inherit the error information

				

				obj.__vTime = (new Date()).getTime();	// Store the time the value was calculated

				obj.__vSyncTime = $context.lastSyncTime;

				

				var _TimeOut = o.parentProp(obj,"_TimeOut",604800);	// Get the timeout setting for the property (in seconds)

				obj.__vExpires = (_TimeOut && obj.__vSyncTime) ? obj.__vSyncTime + (1000 * _TimeOut) : 0;

				

				// Set expiration to minimum of property value and context value

				if (obj.__vExpires && $context.expires && obj.__vExpires > $context.expires) obj.__vExpires = $context.expires;			

			}



			// Record the earliest sync time

			DATAOBJ.updateContext(obj.__vSyncTime,obj.__vExpires);

		//	Debug.trace("r="+r);

			/////////////dj zx///////////

		//	var u = getEntire("$baseURL");

		//	r = HTML.expandRefs(r,u);

			//////////////////////////

			return r;

			

		} else {	// Return the value that was passed if it is not an object

			return obj;

		}



	},

	

	source: function(path,odo) {			// Get the source object for an object



		var r = null;

		

		var obj = o.get(path,odo);

		if (obj && typeof obj == "object") {

		

			if (obj._Function) {					// A function is defined for the object value

				r = obj;

			} else if (obj._DefaultV) {			// A default property has been specified

				if (obj._DefaultV.constructor == String) {	// A property name was specified

					if ( odo ) {

						var p = (path) ? path+"."+obj.__p : obj.__p;

						r = o.source( DATAOBJ.relPath(p, obj._DefaultV,obj), odo);

					} else {

						r = o.source(path.firstProp() + "." + DATAOBJ.relPath(path.lastProps()+".xxx", obj._DefaultV, obj));

					}

				} else {

					r = obj;				// A default value is specified

				}

			}

		}

		

		return r;



	},

	

	$Object: function() {			// Alternate Object constructorm for NS compatibility

	},



	// obj - The object to use as a template

	//		String - The name of the object to use as a template

	//		Object - A reference to the object to use as a template

	//		Function - The constructor function for the object

	

	template: function(obj) {				// Create a new object using the specifed object as a template



		if (!obj) return new Object();		// Default to creating a generic object

		

		if (obj.constructor == String) {

			obj = o.getRoot(obj);			// Get the object corresponding to the name

			o.initProps(obj);				// Make sure the children are initialized

		}

		

		if (!obj) {

		

			var newObj = new Object();		// Return empty object if the object does not exist

			

		} else if ( obj.constructor == Object ) {

		

			o.$Object.prototype = obj;		// Can not override constuctor for Object so use alternate constuctor

			newObj = new o.$Object();

			newObj.__template = obj;



		} else if ( obj.constructor == Function) {

		

			newObj = new obj();				// Standard object constructor function syntax



		} else {

			var proto = obj.constructor.prototype;	// Save the original prototype

			obj.constructor.prototype = obj;		// Override the prototype object to provide template values

			newObj = new obj.constructor();			// Create object using the modified constructor

			obj.constructor.prototype = proto;		// Restore the original value to the constructor prototype	

		}



		////Zhou , clear outputs and inputs

		newObj.__boundOutputs=null;

		newObj.__boundInputs=null;



		return newObj;						// return the newly created object

	},

	

	label: function(obj,defaultLabel) {		// Get the label to use for an object

		if (obj && obj._Name) return obj._Name;

		return o.propToLabel(defaultLabel);

	},

	

	isLeaf: function (obj) {

		if (!obj._HiddenT) {		// Determine the hierarchy type

			for (var p in obj) {

				var ch = p.charAt(0);

				if (ch != "_" && ch != "$" && obj[p]._HiddenT != 9 && obj[p]._HiddenT != 8) {	// A visible property was found

					obj._HiddenT = 2;		// Object is a "branch"

					return false;

				}

			}

			obj._HiddenT = 3;

		}

		return obj._HiddenT == 3;

	},



	// title - Return the HTML to display in the title area within a section for the specified Element

	// The logic is driven by the _Title property of the Element

	//		String - Specifies the title to use

	//		Integer

	//			+1 - Use Label from parent Element

	//			+2 - Use Labels from grandparent + parent

	//			+N - Use Labels from N levels of ancestors

	//			-1 - Use Title from parent Element

	//			-2 - Use Title from grandparent Element

	//			-N - Use Title from ancestor level N

	

	title: function(obj,def) {			// Get the title to use for an object

		if (obj && typeof obj == "object") {

			if (obj._Title) {

				var t = obj._Title;

				var r = " ";

				if (typeof t == "number") {		// 3 = 3 levels of labels to create title

					if (t<0) {		// Use a single parent label

						t = -t;

						for (var i=0; i<t; i++) {

							if (obj) obj = obj.__parent;

						}

						r = obj._Name;

					} else {

						for (var i=0; i<t; i++) {

							if (obj) {

								r = obj._Name + ( (r) ? " " + r : "");

								obj = obj.__parent;

							}

						}

					}

				} else {

					r = obj._Title;				// Explicit object title

				}

				return r;

			} else {

				return o.label(obj,def);		// Default to the label if no title is specified

			}

		}

		return o.propToLabel(def);

	},

	

	// Function propPath - get the path to the specified Element

	// obj - Object - An Element within an Censoft Data Object

	// fmt - String - The format for the path

	//		"P" (default) - Property names (e.g. "Company.Profile.Company_Name")

	//		"N" - Element labels as the appear in the chooser

	// bOmitRoot - Boolean - true to omit the root object from the returned path

	

	propPath: function(obj,fmt,bOmitRoot) {	

		if (!obj) return "";

		// Check which property type to return

		var prop = (fmt == "N" ? "__n" : "__p");

		var r = obj[prop];

		var parent = obj.__parent;

		while (parent && parent[prop]) {

			// Check if not the root property

			if (parent.__parent || !bOmitRoot) r = parent[prop] + "." + r;

			parent = parent.__parent;

		}

		return r;

	},

	

	// Get a property from the specified data object or from a parent object

	parentProp: function(obj,propName,defaultProp) {

		var u = GLOBAL.undef;											// Undefined value

		while ( obj && obj[propName] == u) obj = obj.__parent;		// Traverse the object hierarchy

		return (obj && obj[propName] != u) ? obj[propName] : defaultProp;

	},

	

	// Get a reference to the root property based on a specified property

	rootProp: function(obj) {

		if (!obj) return null;

		while (obj && !obj._rootProp && obj.__parent) obj = obj.__parent;

		return obj;

	},

	

	sort: function(obj,label) {	// Get the sort order value to use for an object

		if (obj && typeof obj == "object") {

			if (obj._sort) {

				return obj._sort + "_" + label;

			} else {

				return label.toLowerCase() + "_" + label;

			}

		}

		return label.toLowerCase();

	},

	

	valid: function(obj) {	// Check if the current value is valid

		if (!obj) return false;

		if (obj.__vTime && $context.root) {

			if (obj.__vTime < $context.root.__clearDate) o.clearValue(obj);

		}

		return obj.__v;

	},

	

	validateCache: function(obj) {				// Make sure the cache value is still valid

		var valid = true;						// Default to valid value

		if (obj.__vTime && $context.root) {		// Check if the inputs have changed

			if (obj.__vTime < $context.root.__clearDate) valid = false;

		}

		if (valid && obj.__vExpires && $context.expires) {		// Check if the value has expired

			if (obj.__vExpires < $context.expires) valild = false;

		}

		if (!valid) o.clearValue(obj);

	},



	clearValue: function(obj) {

		

		if (obj.__vTime) {			// If the value was calculated, clear the value

			obj.__v = null;

			obj.__vTime = null;

		}

		obj.__vError = null;		// Clear the error indicator

		obj.__vSrcURL = null;		// Clear the source URL

		obj.__vAsync = null;		// Clear the async flag

		obj.__vSyncTime = 0;		// Clear the async time indicator

	},



	initProps: function(obj) {		// Initialize the properties of an object



		if (!obj) return;

		if (obj.__i) return;		// Children have already been initialized

		for (var prop in obj) {

			// do not try to initialize parent property

			if ( prop != "__parent" )

				o.prop(obj,prop);

		}

		obj.__i = true;				// Remember that the children have been initialized

	},

	

	init_pageDone: function(wp,args) {

		if(args.alias){

			o.init(args.parentObj,args.propName,DATAOBJ.roots.censoft[args.propName],args.bConvertFunc);

		} else {

			args.prop = o.getRoot(args.prop._Copye);

			args.propName = args.prop._Name;

			o.init(args.parentObj,args.propName,args.prop,args.bConvertFunc);

		}

//		var obj = args.prop;

		// Update values that are calculated based on the page that was loaded



//		alert( GLOBAL.ver );

//		if ( GLOBAL.ver < .3 ) {

			// Checks to see if we are trying to refresh an old sections.  This seems like a hack, unless the next round of garbage collection doesn't clean this up.

			// This will have to be checked out in the future is there is a memory leak, or other refresh problems.

//			if (args.root && args.root.__boundOutputs && args.root.__boundOutputs[0].element && eval(args.root.__boundOutputs[0].element.uniqueID)) {

//				DATAOBJ.refresh(args.root);

//				DATAOBJ.copyOutputs2(args.root);	// Redraw the root object

//			}

//		} else {	

//			PORTALPAGE.reload( args.sid );	// Redraw the section

//		}

	},

	////////////////////////////dj_portlet_init

	init: function(parentObj,propName,prop,bConvertFunc) {	// Initialize a property object

	//	Debug.traceObj(parentObj);

		//alert("DRAG.srcElement="+DRAG.srcElement);

		if ( prop.constructor == Object ) {	

					

			//if ( prop._src ) {

	

				//DEBUG.log("o.init:_src="+prop._src);

				// Check if the object has already been loaded.  This is based on whether the _Copye object

				// has already been created.

			if ( prop._a ){

				for(var i = 0; i < prop._a.length; i++){

					for(var j = 0;  j < prop._a[i].a.length; j++){

						if( !DATAOBJ.roots.censoft[prop._a[i].a[j].firstProp()] ) {

							var wp = SCRIPT.load( prop._a[i].a[j].firstProp(), o.init_pageDone, {parentObj: parentObj,propName: prop._a[i].a[j].firstProp(),prop: prop,bConvertFunc:bConvertFunc, alias: true},true );

							

							if (wp && wp.status != 1) {						// The page loaded from the cache	

								$context.inProgress = location.host;

								return prop;

							}

						}

					}

				}

			}

			

			//if ($context.root && prop._Copye && !o.getRoot(prop._Copye)) {

			if (  (prop._Copye && !o.getRoot(prop._Copye)) ) {

				//var wp = SCRIPT.load( prop._Copye, o.init_pageDone, {root:$context.root,sid:$context.sid,prop:prop},true );

				if(prop._Copye){

					var wp = SCRIPT.load( prop._Copye, o.init_pageDone, {parentObj: parentObj,propName: propName,prop: prop,bConvertFunc:bConvertFunc},true );

				}

				

				if (wp && wp.status != 1) {						// The page loaded from the cache

					$context.inProgress = location.host;

					return prop;

				}

			}

			

			//	delete prop._src;				// Clear the remote source location

				//DEBUG.log("o.init:done with _src");

			//}

			

			prop.__p = propName;		// Store the name of the property



			if (! prop._Name) prop._Name = o.propToLabel(propName);	// Store the field name

			

			////////////////////for portlet_new//////////////////////////////////

		//	prop.$url = "http://www.nanhai.gov.cn/nanhai_today.asp";	

			var dat = new Date(); 

		//	var js = DATAOBJ.odo2js( propName );

			if(prop.$portLetID)

			{

			//	alert("prop.$url="+prop.$url);

			//	prop.$url = PORTLET.portletPublicPath+'&CenEPAction=0&userid='+PORTLET.getUserID()+'&viewid='+PORTLET.tempViewID+'&portletid=' + prop.$portLetID+"&resetConnect="+dat.getTime();	

				prop.$url = PORTLET.makePortletInitURL(prop.$portLetID);

			}

			/////////////////////////////////////////////////////

			

			if (prop.$url && ! prop._Copye && prop != window.WEBPAGE) 

			{

				//alert(prop.$url);

				prop._Copye = "WEBPAGE";	// Default to a web page if $url specified

				

			}



			if (prop._Copye) {							// Name of the template object

				var tHt = prop._HiddenT;

				// If object already exists include it in the tree

				if ( o.getRoot( prop._Copye ) )

				{

				if (!prop.__i) prop.__i = false;	// Default to not initialized so it does not inherit setting

					var temp = o.template(prop._Copye);			// Create a new object based on the template

				delete prop._Copye;						// Clear the template flag

				o.applyProps(temp,prop);			// Merge the properties

				prop = parentObj[propName] = temp;	// Reset the parent property to the new object

				prop._HiddenT = tHt;

				}

			}



			if (prop._init) {

				prop._init(prop);

				delete prop._init;

			}



			prop.__parent = parentObj;				// Remember the parent element

			

		} else if ( prop.constructor == Function) {

			

			if (bConvertFunc || (propName.charAt(0) != "$" && propName.charAt(0) != "_")) {	// Convert to an object

				temp = {};

				temp.__p = propName;

				temp.__parent = parentObj;

				temp._Function = prop;

				temp._Name = o.propToLabel(propName);

				prop = parentObj[propName] = temp;	// Reset the parent property to the new object

			}

		}

		return prop;

	},



	prop: function(obj,propName,bConvertFunc) {	// Makes sure property is initialized

		var prop = obj[propName];

			

		if (prop && !prop.__p) {	// The property has not been initialized

			prop = o.init(obj,propName,prop,bConvertFunc);

		}

		return prop;

	},

	

	get: function(objName,obj,noprop) {	// Get an object based on the name (e.g. "window.location.href")



		if (!obj) obj = window;

		if ( !objName ) return null;

		

		var a = objName.split(".");

		for (var i=0; i<a.length; i++) {

			var propName = a[i];

			var parentObj = obj;

			obj = o.prop(parentObj,propName,!noprop);

			if (! obj) return obj;

		}

		return obj;

	},

	

	//

	// Get the DATAOBJ root object

	//

	getRoot: function( objName, convert )

	{

		

		var pr = DATAOBJ.roots;		



		if ( objName == "WEBPAGE" )

			return o.get( "WEBPAGE" );



		var obj = o.get( objName, pr, convert );

		

		if (!obj )

			obj= o.get( objName, pr.censoft, convert );

		if(obj)

		{

			obj.__boundOutputs=null;

			obj.__boundInputs=null;

			return obj;

		}

	

		return 

	},

	

	labelToProp: function(label) {	// Convert a label string to a valid property name

		if (label) {

			label = label.replace(/ /g,"_");						// Convert spaces to underscores

			label = label.replace(/[^a-zA-Z_0-9\$]/g,"");			// Convert to a valid property name

			if (/\d/.test(label.charAt(0))) label = "_" + label;	// Can not start with a number

		}

		return label;

	},

	

	propToLabel: function(propName) {	// Convert a property name to a corresponding label

		if (propName) {

			propName = propName.replace(/_/g," ");					// Convert underscores to spaces

			if (propName.charAt(0) == "$") propName = propName.substring(1);

		}

		return propName;

	},

	

	props: function(obj,bShowAll,bShowHt8) {	// Get an array of property information



		// returns an array of {name,_Name,obj,sort}

		var r = [];

		if (obj != null && typeof obj == "object") {

			o.initProps(obj);

			for (var name in obj) {

				var ch = name.charAt(0);

				var bShow = true;

				if (name && (bShowAll || (ch != "_" && ch != "$") ) ) {	// Ignore properties that start with "_"

					var prop = obj[name];

					if (prop && !bShowAll && prop._HiddenT==9 && prop._HiddenT==8) {	// Ignore properties that are marked as hidden

						bShow = false;

						if(bShowHt8 && prop._HiddenT == 8) {

							bShow = true;

						}

					}

					if(bShow) {

						var item = r[r.length] = {};

						item.name = name;

						item.obj = prop;

						var label = item._Name = o.label(prop,name);

						item.sort = o.sort(prop,label);

					}

				}

			}

		}

		return r;

	},

	

	

	rootProps: function(obj,bShowAll) {	// Get an array of property information

		var item = {};

		// returns an array of {name,_Name,obj,sort}

		if (obj != null && typeof obj == "object") {

			o.initProps(obj);

			var name = obj._Name;

			var prop = obj;

			item.name = obj._Name;

			item.obj = prop;

			var label = item._Name = o.label(prop,name);

			item.sort = o.sort(prop,label);

		}

		return item;

	},

	

	expandProps: function(obj) { // get an array of property information, recursively fetching child props

		r = [];

		var p = null;

		var prop = null;

		var p2 = null;

		var itm = null;

		var lbl = null;

		

		if (obj != null && typeof obj == "object") {

			o.initProps(obj);

			var p = o.props(obj);

			for (var i=0; i<p.length; i++) {

				prop = p[i].obj;

				p2 = o.props(prop);

				if (p2.length == 0) {

					itm = r[r.length] = {};

					itm.name = name;

					itm.obj = prop;

					lbl = itm._Name = o.label(prop,name);

					itm.sort = o.sort(prop,lbl);

				} else 

					p = p.concat(p2);

			}

		}

		return r;

	},

	doSection:function(obj){

		if(obj.id&&obj.id.indexOf("sMain") > -1)

		{

			var newsMain = document.all[obj.id];

			if(newsMain)

			{

				

				////////////////for portlet///////////////////

				if(obj.portletObj!=null)

				{

			//		PORTLET.connectPortLet(newsMain,"exist",obj.portletObj.portID);	

					var viewMode = obj.portletObj.portletViewMode?obj.portletObj.portletViewMode:"V";

					var portletIframeWidth = obj.portletObj.portletIframeWidth!=null?obj.portletObj.portletIframeWidth:"400px";

					var portletIframeHeight = obj.portletObj.portletIframeHeight!=null?obj.portletObj.portletIframeHeight:"700px";

					

					var newLink = PORTLET.portletPublicPath+'&CenEPAction=1&userid='+PORTLET.getUserID()+'&.piid='+obj.portletObj.portID+'&_md.'+obj.portletObj.portID+"="+viewMode+"&iscontent=N&portletIframeWidth="+portletIframeWidth+"&portletIframeHeight="+portletIframeHeight;	

				//	alert(newLink);

					if(obj.portletObj.lastPortletURL){

					//	newLink = obj.portletObj.lastPortletURL;

					}

					PORTLET.connectPortlet_new(newLink,newsMain,viewMode);

				}

				///////////////////////////////////

				if(obj.atSameRow)newsMain.atSameRow = obj.atSameRow;

				var ce = VIEW.getColumn(newsMain);

				var atSameRow = newsMain.atSameRow;

			//	alert("atSameRow="+atSameRow);

				if(atSameRow)

				{

					var index1 = atSameRow.indexOf("_");

					var index2 = atSameRow.indexOf("_",index1 + 1);

				//	alert("index1="+index1+";index2="+index2);

					var tableID = atSameRow.substring(0,index2);

					var newTab = document.all[tableID];

					if(!newTab)

					{

						VIEW.tempTableID = tableID;

						if(ce)

						{

							newTab = GUI.addChild(ce,"dj_Table");

							newTab.id = tableID;

							var newRow = newTab.insertRow(0);

							var newCell1 = newRow.insertCell(0);

							newCell1.className = "djCol";

							WEBBROWSER.moveElement(newTab,newsMain,"beforeBegin");			// Move the section

							WEBBROWSER.moveElement(newsMain,newCell1,"afterBegin");			// Move the section

						}

					}

					else if(VIEW.tempTableID == tableID)

					{

						if(newTab)

						{

							var newRow = newTab.rows[0];

							var newCell2 = newRow.insertCell(newRow.cells.length);

							newCell2.className = "djCol";

							WEBBROWSER.moveElement(newsMain,newCell2,"afterBegin");			// Move the section

						}

					}

					else if(newTab)VIEW.tempTableID = "";

				}

			}

		}

	},

	applyFunc: function(obj,func,args) {		// Apply the function to an object or members of an array

		//if (obj.constructor == Array) {		// THIS DOES NOT WORK IF ARRAY USERBROWSER IN ANOTHER FRAME

		if (typeof obj == "object" && obj.length != GLOBAL.undef) {

			var len = obj.length;

			//alert(func);

			for (var i=0; i<len; i++)

			{

			//	alert(func);

				func(obj[i],args);

				/////////////////////for sameRow////////////////////////////

				this.doSection(obj[i]);

			//////////////////////////////////////////////////	

			}

		} else {

			func(obj,args);

		//	alert(obj.);

		/*	if(root.$portLetID&&!se.portletObj)

			{

				var dat = new Date(); 

				PORTLET.connectPortlet_new(root.$url,se,"V");

				alert("sdgdfg");

			}

			*/

			

			///////////////////////////////////////////////////////

		}

	},

	

	applyProps: function(obj,otherObjs) {	// Copy properties of other objects to the specified object

		for (var i=1;i<arguments.length;i++) {

			var o2 = arguments[i];

			if (o2) {

				if (o2.constructor == String) o2 = o2.toObject()	// Support string version of object definition

				for (var prop in o2) obj[prop] = o2[prop];

			} 

		}

	},



	applyPropsHier: function(obj,otherObjs) {	// Copy properties hierarchy of other objects to the specified object

		for (var i=1;i<arguments.length;i++) {

			var o2 = arguments[i];

			if (o2) {

				if (o2.constructor == String) o2 = o2.toObject()	// Support string version of object definition

				for (var prop in o2) {

					var p = o2[prop];

					if (typeof p == "object") {

						if (!obj[prop]) obj[prop] = {};	// Create object if it does not yet exist

						var o3 = obj[prop];

						if (typeof o3 == "object") {	// Make sure it is an object

							o.applyPropsHier(o3,p);		// Add the child properties

						}

					} else {

						obj[prop] = o2[prop];

					}

				}

			} 

		}

	}

}



//--------------- Object Property Access --------------------



// Censoft Data Object (DATAOBJ)



var DATAOBJ = {



	objects: [],			// Array of root level objects that have been created using o.template

	

	roots: {

		censoft:	{}

	},

	///////////////////////////////////////////dj/////////////////////////////

	getPageStyles:function()

	{

			

	},

	

	getRootWidth:function(sMain)

	{

		if(!sMain)return 0;

		var widths0 = 0;

		if(sMain.width0)widths0 = parseInt(sMain.width0);

		var sBody = PORTALPAGE.getBody2(sMain);

		var children = sBody.children;

		var wS = [children.length];

		var widths = widths0 ;

		for(var i = 0; i < children.length; i++)

		{

			wS[i] = children[i].offsetWidth;	

		//	alert(children[i].outerHTML);

			widths = Math.max(widths,wS[i]);

		}

		var ofW = sBody.offsetWidth;

		//	alert("ofW="+ofW+";\nwidths="+widths);

		

		if(widths > ofW){

			var iframe = PORTLET.getCommonIframe(sMain);

			if(iframe!=null){

				widths = ofW;

			}

		}

	

		if(!sMain.width0)

		{

			sMain.width0 = widths;	

		}

	//	alert(widths);

		return widths;

	},

	getRootHeight:function(sMain)

	{

		if(!sMain)return 0;

		var heights0 = 0

		if(sMain.height0)heights0 = parseInt(sMain.height0);

		var sBody = PORTALPAGE.getBody2(sMain);

		var children = sBody.children;

		var heights1 = 0

		for(var i = 0; i < children.length; i++)

		{

			heights1 = heights1 + children[i].offsetHeight;

		}

		var heights = heights1;

		heights = Math.max(heights0,heights1);

	

	//	alert(heights0+"\n"+heights1);

		if(!sMain.height0)

		{

			sMain.height0 = heights;	

		}

		return heights;

	},

	setDefault:function(sMain)

	{

		var sBody = PORTALPAGE.getBody2(sMain);

		var rootObj= getCurDataObj(sBody);

		var webObj= getActiveWebPageObj(rootObj);

	//	alert(sMain.clickHref);

		if(sMain.clickHref)

		{

			DATAOBJ.setURL(sMain.clickHref,webObj);

		}

		if(sMain._Function)

		{

			DATAOBJ.setRootFunction(sMain._Function,webObj);

		}

		sMain.isRoot = "false";

	},

	getDataOutput:function(datas,e)

	{

		if(!e||!datas)return null;

		var varDatas = datas.split(",");

		var varData = null;

		if(varDatas.length == 1)return varDatas[0];

		var tbH1 = HTML.eorp.byClass(e,"oHTable");

		var tbH2 = HTML.eorp.byClass(e,"oHTable2");

		var tbH = tbH1?tbH1:tbH2;

		

		var tbV1 = HTML.eorp.byClass(e,"oVTable");

		var tbV2 = HTML.eorp.byClass(e,"oVTable2");

		var tbV = tbV1?tbV1:tbV2;

		

		if(tbH&&tbH.rows.length==varDatas.length)

		{

			var trH = HTML.eorp.byTag(e,"TR");

			for(var i = 0; i < tbH.rows.length;i++)

			{

				if(tbH.rows[i]==trH)

				{

					varData = varDatas[i];

					break;	

				}

			}

		}

		else if(tbV&&tbV.cols.length==varDatas.length)

		{

		/*	var tbV = HTML.eorp.byTag(e,"TD");

			for(var i = 0; i < tbH.rows.length;i++)

			{

				if(tbH.rows[i]==trH)

				{

					varData = varDatas[i];

					break;	

				}

			}

			*/

		}

		return varData;

		

	},

	getDataOutputLength:function(datas)

	{

		if(!datas)return null;

		var varDatas = datas.split(",");

		return varDatas.length;

	},

	getURL:function(webPage)

	{

		if(!webPage)return null;

		return webPage.$url;

	},

	setURL:function(href,webPage)

	{

		if(!href||!webPage)return false;

			webPage.$url = href;

		return true;

	},

	getFunction:function(webPage)

	{

		if(webPage)

			return webPage._DefaultV;

		return null;

	},

	setFunction:function(webPage)

	{

		//alert("webPage.$forIframe="+webPage.$forIframe);

		if(!webPage.$forIframe)

		{

			webPage._DefaultV= jumpDefaultV;

		}

		return true;

	},

	setPortletFunction:function(webPage)

	{

		webPage._DefaultV= portletDefaultV;

		return true;

	},

	setRootFunction:function(funct,webPage,data)

	{

		if(!funct)return false;

		if(!webPage.$forIframe)

		{

			webPage._DefaultV= funct;

		}

		return true;

	},

	//////////////////////////////////////////////////////////////////////////

	odo2js: function( name ) {

	//	alert(name);

	//	alert(location.href);

		try{

			if(document.location.href.indexOf("add.htm") > -1)return;

		}catch(err){}

		if (VIEW.CHOOSER_DATA == null)

			VIEW.CHOOSER_DATA = new ChooserData();

		

		var c = VIEW.CHOOSER_DATA.JSmapping;



		var r = c[name];

	//	alert("name="+name + ";r="+r);

		if (contentScripts.IsContains(r))

			return r;

		else

			return null;





	},

	

	$context: {				// Stores object context when evaluation functions

		root: null,			// The root object for calculating relative values in the object model

		props: "",			// Property path relative to the root object

		inProgress: null,	// Flag to indicate asynchronous calculation in progress (e.g. loading a web page)

		error: null,

		srcURL: null,

		lastSyncTime: null,

		expires: null,

		object: null		// The leaf level object being evaluated

	},

	

	load: function( pkg,_typePkg ) {



		if ( !pkg ) return;

		//

		// Default to Censoft root if none is specified by the package

		//		

		var pf = DATAOBJ.roots[ pkg._partner ? pkg._partner : "censoft" ];

		

		var aliases;

		

		if (!VIEW.CHOOSER_DATA) {

			aliases = [];

		}

		else {

			aliases = VIEW.CHOOSER_DATA.alias;

		}

		for (var name in aliases) {

			if (typeof pkg[name] != 'undefined') 

			{

				pkg[name]._a = [];

				var alias = aliases[name];

				pkg[name]._a = alias;

			}

		}

		

		var ht9;

		if (!VIEW.CHOOSER_DATA) {

			ht9 = {};

		}

		else if( VIEW.CHOOSER_DATA && !VIEW.CHOOSER_DATA.ht9 ) {

			VIEW.CHOOSER_DATA.ht9 = {};

			ht9 = {};	

		}

		else {

			ht9 = VIEW.CHOOSER_DATA.ht9;

		}

		var cens_root;

		for ( var i in pkg )

		{

			//

			// Store only objects not package attributes

			//

			if ( !i.match( /^[_$]/ ) )

			{

				pf[ i ] = pkg[ i ];



				if( typeof pkg[i] != 'undefined' ) {

					if( ht9[i] ) {

						for( var j=0; j < ht9[i].length; j++ ) {

							//ignore ht9 setting for objects that have a copy attribute.

							//if( !pf[i]['_Copye'] ) { 

								eval( 'cens_root = pf.' + ht9[i][j]);

								cens_root._HiddenT = 9;

							//}

						}

					}//end if

				}//end if

//				window[i] = pkg[ i ];

			}

		}

		

		return _typePkg;

	},



	// embed - utility to embed field values into a string

	// "www.abc.com/[/Ticker].htm" --> "www.abc.com/YHOO.htm"

	// Supports multiple fields in the same string

	//modification:

	//1. zhou, 2002-8-14

	//	return "" only when all inputs are empty

	embed: function(str,bNoEscape) {



		var matchRE = /\[[^\x5D]+\]/;

		var r = matchRE.exec(str);



		var bEmptyAll= r?true:false;

		while (r) {

			var fieldName = r[0];

			fieldName = fieldName.substring(1,fieldName.length - 1);

			var fieldValue = getEntire(fieldName);

			if (!fieldValue) 

				fieldValue='';

			else

				bEmptyAll= false;

			str = str.substring(0,r.index) + ((bNoEscape) ? fieldValue : escape(fieldValue) ) + str.substring(r.index + r[0].length);

			r = matchRE.exec(str);

		}



		if(bEmptyAll) return '';



		return str;

	},



	getPropValue: function(propName) {



		// Get the value of a property based on the current obj.getEntire() formula evaluation

		if (!propName)

		{

			var pV = DATAOBJ.getInheritedValue($context.property,"_r");

		//	alert("pV="+pV);

			 return pV

		}



		return DATAOBJ.get($context.root,DATAOBJ.relPath($context.props,propName,$context.property));

		

	},



	// Get the explicit property path for a property

	//	propPath - Path to the property being evaluated

	//	propName - Name of the property to retrieve

	//	prop - property object being evaluated



	relPath: function(propPath,propName,prop) {



		// Get the value of a property based on the current obj.getEntire() formula evaluation

	//	alert("propPath="+propPath+";propName="+propName+";prop="+prop);

		var done = false;

		if (propName) {

		

			if (propName.charAt(0) == "/") {			// Get property from root object

				while (prop && !prop._rootProp) {		// Look for a root property

					prop = prop.__parent;				// Step up the next level in the hierarchy

				}

				if (prop && prop._rootProp) {

					propPath = o.propPath(prop) + "." + propName.substring(1);

					propPath = propPath.lastProps();	// Omit the name of the root object

				} else {

					propPath = propName.substring(1);	// Default to using the path within the root of the object

				}

				done = true;

			} else if (propName == "..") {				// Get the parent value

				var p = propPath.lastIndexOf(".");

				if (p > -1) propPath = propPath.substring(0,p);

				done = true;

			} else {									// Get property from a parent object

				while (propName.substring(0,3) == "../") {

					propName = propName.substring(3);

					var p = propPath.lastIndexOf(".");

					if (p > -1) propPath = propPath.substring(0,p);

				}

			}

		}

		if (!done) {

			// Get specified propName within parent object

			var p = propPath.lastIndexOf(".");

			if (p == -1) {

				propPath = propName;

			} else {

				propPath = propPath.substring(0,p+1) + propName;

			}

		}

	//	alert("propName="+propName+";propPath="+propPath);

	//	alert("propPath2="+propPath);

		return propPath;

	},



	getInheritedValue: function(obj,propName) {		// Get a property value from an element or a parent of the element





		var ud = GLOBAL.undef;				// Undefined property value

		var prop = obj[propName];		// Get the specified property from the object

		if (prop != ud) {

		

			// Get a child property of the current Element

			if (propName == "_xr") {

				return DATAOBJ.getPropValue("");	

			}else {

				var path = obj.__p + "." + propName;

			}

		} else {

		

			var path = "";

			

			while (obj && prop == ud) {		// Check for an ancestor that IsContains the specified property

				obj = obj.__parent;

				if (obj) {

					prop = obj[propName];

					if (path) {

						path = "../" + path;

					} else {

						path = propName;

					}

				}

			}

			

		}

	//	alert("path="+DATAOBJ.getPropValue(path));

		if (prop != ud && path) {				// Make sure the property is valid and the path is valid

			return DATAOBJ.getPropValue(path);		// Evaluate the property value

		} else {

			return "";

		}

	},



	// asObject: TRUE to retrieve the object instead of the value of the object

	get: function(odo,propPath,asObject) {

		if (odo.__template) o.get(propPath,odo.__template);	// Make sure the base object is initialized

		if (propPath == "/") {



			if (asObject) {

				return odo;

			} else {

				return o.value(odo);

			}

		}



		var result = null;

		var saveProps = $context.props;

		

		$context.root = odo;

		

		var props = propPath.split(".")	// Get the names from the property hierarchy

		var thisChain = [];	// Object references to the hierarchy

		var lastProp = props.length - 1;

	//	alert("lastProp="+lastProp);

		thisChain[-1] = odo;

				

		for (var i=0 ; i<=lastProp; i++) {

			if (thisChain[i-1]) {

				var nextProp = o.prop(thisChain[i-1],props[i]);

				if ($context.inProgress) return "";

				thisChain[i] = nextProp;

			} else {

				thisChain[i] = null;

			}

		}



		var property = thisChain[lastProp];

	//	alert("property="+property);

		// Check if the property already has a value that can be used



		if (property) {

			if (property.constructor == Object) {

				if (property.__p) {	// Check if it is a DataField

					// Make sure the value is still valid and has not expired

					o.validateCache(property);

					if (asObject) return property;

						

					// Check if a value is already known

					if (property.__v) {

						DATAOBJ.updateContext(property.__vSyncTime,property.__vExpires);

						return property.__v;

					}

				} else {

					return property;

				}

			} else if ( property.constructor == Function) {

				o.validateCache(property);

				if (property.__v) return property.__v;

			} else {

				return property;

			}

		}

		propName = props[lastProp];



		// Saved unsaved intermediate objects up to the property

		for (var i=0; i<lastProp; i++) {

			if (thisChain[i]) {

				if (thisChain[i].__parent != thisChain[i-1]) {	// Need to create intermediate objects

					for (var j=i; j<props.length-1; j++) {

						thisChain[j] = thisChain[j-1][props[j]] = o.template(thisChain[j]);

						thisChain[j].__parent = thisChain[j-1];

					}

					i = props.length;	// exit the outer For loop

				}

			}

		}



		// Calculate the value of the object

		$this = thisChain[lastProp-1];

		if (property) {



			// Check if the property is being inheritted

			if (property.constructor == Object) {

				if (property.__parent != $this) {	// The DataField is being inheritted

					property = $this[propName] = o.template(property);

					property.__parent = $this;

				}



				// Set the context for the calculation

				$context.object = $this;

				$context.props = propPath;



				// Calculate the value for the property

				result = o.value(property);



				// Restore the context information

				$context.props = saveProps;



				// Return the result

				return result;

			} else if ( property.constructor == Function) {

				if (property.__parent != $this) {	// convert to a DataField

					//*** TEST THIS ***

					property = $this[propName] = property;

					property = o.init($this,propName,property,true);

				}

				$context.object = $this;

				$context.props = propPath;

				result = o.value(property);	// Save the evaluated function value

				$context.props = saveProps;

				return result;

			}

		}

		//$context.error = "Error: Invalid property name '" + propPath + "'";

		$context.error = loc.viewer_err_noProp;

		return "";	//Unable to get a value

	},

	

	set: function(odo,propName,value) {



		var thisObject = odo;

		if (thisObject.__template) o.get(propName,thisObject.__template);	// Make sure the base object is initialized

		var props = propName.split(".");

		for (var i=0;i<props.length;i++) {

			propName = props[i];

			var property = o.prop(thisObject,propName);

			if ( i == props.length-1 ) {	// The last property in the chain

				if (!property) {			// Create the property if it does not already exist

					thisObject[propName] = value;

					return;

				}

				if (property.constructor == Object) {

					if (property.__p) {	// The object is a DataField

						if (value && value.__p) {	// Setting the value to a DataField object (vs. a DataField value)

							thisObject[propName] = value;

						} else {

							if (property.__parent != thisObject) {	// The DataField is being inheritted

								property = thisObject[propName] = o.template(property);

								property.__parent = thisObject;

							}

							property.__v = value;

							property.__vTime = (new Date()).getTime();

						}

					} else {

						thisObject[propName] = value;

					}

				} else {

					thisObject[propName] = value; 

				}

			} else {	// Evaluating a property in the chain

				if (property.__parent != thisObject) {	// Need to create an intermediate object

					property = thisObject[propName] = o.template(property);

					property.__parent = thisObject;

				}

				thisObject = property;	// Move down the chain of objects

			}

		}

	},

	

	add: function(odo,propName,_Function,otherProps) {

		var result;

		if (propName.constructor == Array) {

			for (var i=0;i<propName.length;i++) DATAOBJ.add(odo,propName[i],_Function,otherProps);

		} else {

			var prop = {};

			if (_Function.constructor == Function) {

				prop._Function = _Function;

			} else {

				prop.__v = _Function;

			}

			if (otherProps) o.applyProps(prop,otherProps);

		

			odo[propName] = prop;	// Create the property for the parent object

			o.init(odo,propName,prop);	// Initialize the property

			

			result = odo[propName];

		}

		return result;

	},

	

	addChild: function(odo,object,propName) {

		var childObj = o.template(object);

		if (propName) {

			childObj._Name = propName;

		} else {

			propName = childObj._Name;	// Default property name to name of class for child object

		}

		if (propName) propName = o.labelToProp(propName);

		odo[propName] = childObj;



		childObj.__parent = odo;

		return childObj;

	},

	

	addChildren: function(odo,obj) {

		for (var propName in obj) {

			if (propName.charAt(0) != "$") {

				DATAOBJ.addChild(odo,obj[propName],propName);

			}

		}

	},

	

	addForm: function(odo,formName, inputName, propPath) {	// Bind inputs to a form

		if (!odo.__boundInputs) odo.__boundInputs = [];

		var i = odo.__boundInputs[odo.__boundInputs.length] = {};

		i.formName = formName;

		i.inputName = inputName;

		i.propPath = propPath;

	},

	

	addInput: function(odo,propPath, element, property) {

		if (!odo.__boundInputs) odo.__boundInputs = [];

		var input = odo.__boundInputs[odo.__boundInputs.length] = {};

		input.propPath = propPath;

		if (typeof element != "object") element = window[element];

		input.element = element;

		if (! property) property = "value";

		input.property = property;

	},

	

	addOutput: function(odo,propPath, element, property) {

		if (!odo.__boundOutputs) {

			DATAOBJ.objects[DATAOBJ.objects.length] = odo;		// Save a reference to the object so it can be de-allocated on unload

			odo.__boundOutputs = [];			// Create the array of bound outputs

		}

		var outputs = odo.__boundOutputs;

		var output = outputs[outputs.length] = new Object();

		output.propPath = propPath;

		if (typeof element != "object") element = window[element];

		output.element = element;

		//if (! property) property = "innerHTML";

		//output.property = property;

		output.done = false;

		output['connect'] = VIEWLVL.getConnTFName(element)

	},

	

	cleanOutputs: function(odo) {

		odo.__boundOutputs = null;

	},

	

	refreshInputs: function (odo) {

		//VIEW.modified ();

		DATAOBJ.refresh (odo);

	},

	

	refresh: function(odo) {

		if (odo._hasConnect) {

			var bRefreshed = false;

			var outputs = odo.__boundOutputs;

			var out;

			var outODO;

			var c;

			for (var i= 0; i<outputs.length; i++) {

				out = outputs[i];

				if(out)

				{

					tmpIP = $context.inProgress;

					$context.inProgress = null;

					outODO = DATAOBJ.get(odo,out.propPath,true);

					$context.inProgress = tmpIP;

					c = TYPEOBJ.getConnect(outODO._connect);

					

					if (c && c.status == 'failed') { c.reset(true); bRefreshed=true; }

				}

			}

			if (odo._connect) {

				c = TYPEOBJ.getConnect(odo._connect);

				if (c && c.status == 'failed') { c.reset(true); brRefreshed = true; }

			}

		}

		if (!bRefreshed) {

			DATAOBJ.clear(odo);

			DATAOBJ.copyInputs(odo);

			DATAOBJ.copyOutputs(odo);

		}

	},

	

	

	copyInputs: function(odo) {	// Retrieve input values from the GUI

		var inputs = odo.__boundInputs;

		var bSet = null;

		var vOld = null;

		if (inputs) {

			for (var i=0; i<inputs.length; i++) {		// Step through the inputs

				var input = inputs[i];

				var propPath = input.propPath;

				if (input.formName) {

					var form = window[input.formName];

					if (!form) return;			/// If the form has been wiped out



					if (!propPath) propPath = form[input.inputName+"_propPath"].value;

					var value = form[input.inputName].value.replace(';',',');

					form[input.inputName].value = value; // bulletproof out semicolons

				} else {

					var e = input.element;

					if (typeof e == "string") e = window[e];

					value = e[input.property];

				}

				if (value == "") value = null;

				

				if (!odo._noCacheInputs) {

					vOld = PREFS.getInput(propPath, odo);

					if (vOld == '') vOld = null;

					if (vOld != value) {

						if (odo[propPath]._secLevel && odo[propPath]._secLevel > 0) {

							// only prompt once for all secured inputs

							if (bSet == null) bSet = confirm(loc.saveCachedInputs);

							if (bSet) {

								PREFS.setInput(propPath,value,odo);

							}

						} else {

							PREFS.setInput(propPath,value,odo);

						}

					}				

				}

				DATAOBJ.set(odo,propPath,value);

			}

		}

	},

			

	clear: function(odo) {	// Clear all calculated property values





		odo.__clearDate = (new Date()).getTime();

		var outputs = odo.__boundOutputs;



 		if (outputs) for (var i=0; i<outputs.length; i++) {

			if (outputs[i]) {				// Make sure the element still exists

				outputs[i].done = false;	// mark output bindings as incomplete

			}

		}

	},

		

	isAllHidden: function(odo, dataInputs){

		var allHidden = true;

		for(var j=0; j<dataInputs.length;j++) {

			if(odo[dataInputs[j].Range("","=")] && (odo[dataInputs[j].Range("","=")]._inputType !=5)){

				allHidden = false;

				break;

			}

		}

		return allHidden;

	},

	

	getNumNew: function(odo){

		var input = odo.__boundInputs[0];

		var frm = window[input.formName];

		var num_new = 0;

			

		for (var i = 0; i < odo.__boundInputs.length; i ++ ) {

			var input = odo.__boundInputs[i];

			

			var propPath = (input.propPath) ? input.propPath : frm[input.inputName+'_propPath'].value

			var eIn = frm[input.inputName];

			var v = eIn.value;

			var oe = PORTALPAGE.getBody(eIn);

			

			if (v && odo._multiInputs)  {

				num_new = v.count(/,/)+1;

			}

		}

		

		eIn.blur();

		return num_new;

	},

	

	getNumOld: function(odo, oe){

		var input = odo.__boundInputs[0];

		var frm = window[input.formName];

			

		//Get the active input element

		for (var i = 0; i < odo.__boundInputs.length; i ++ ) {

			var input = odo.__boundInputs[i];

			var eIn = frm[input.inputName];

			var oe = PORTALPAGE.getBody(eIn);

		}

			

		var num_old = 0;

		

		if(oe.dataInputs){

			var dataInputs = oe.dataInputs.split(';');

			for (var i=0;i <dataInputs.length;i++) {

				//if(odo[dataInputs[i].Range("","=")]._inputType == 5){

					cnt=dataInputs[i].count(/,/);

					cnt = (cnt) ? (cnt + 1) : cnt;

					num_old=(num_old > cnt) ? num_old : cnt;

				//}

			}

		}

		return num_old;

	},

	

	setOE: function(odo){

		var input = odo.__boundInputs[0];

		var frm = window[input.formName];

		var oe;



		//Get the active input element

		for (var i = 0; i < odo.__boundInputs.length; i ++ ) {

			var input = odo.__boundInputs[i];

			

			var propPath = (input.propPath) ? input.propPath : frm[input.inputName+'_propPath'].value

			var eIn = frm[input.inputName];

			var v = eIn.value;

			oe = PORTALPAGE.getBody(eIn);

			if (v && odo._multiInputs)  {

				v = v.replace(/, [ ]*/g, ",");

			}

			

			if (i != 0) { 

				oe.dataInputs += ";";

			} else { 

				oe.dataInputs = "";

			}

			

			oe.dataInputs += propPath + "=" + v;

		}

		return oe;

	},

	

	getDataInputs: function(odo, dataInputs){

		if(dataInputs && odo._multiInputs){

			var c=0;

			var cnt=0;

			var idx;

			var dataInput;

			

			for (var i=0;i <dataInputs.length;i++) {

				idx = dataInputs[i].indexOf('=');

				dataInput = dataInputs[i].substring(0,idx);

				if(dataInput && odo[dataInput] && odo[dataInput]._inputType != 5){

					cnt=dataInputs[i].count(/,/);

					c=(c > cnt) ? c : cnt;

				}

			}

			

			for(var i=0;i<dataInputs.length;i++){

				cnt = dataInputs[i].count(/,/);

				if (cnt < c) {

					for (var j=cnt; j<c; j++) {

						dataInputs[i] += ',';

					}

				} else if (cnt > c) {

					var idx = 0;

					for (var j=0; j <= c; j++) {

						idx = dataInputs[i].indexOf(',',idx);

					}

					dataInputs[i] = dataInputs[i].substring(0, idx);

				}

			};			

		}

		return dataInputs;

	},

	

	//

	// BETA 2 - non NS compatible stuff

	//

	copyOutputs: function(odo) {	// Copy output values to the GUI

		var outputs = odo.__boundOutputs;

		// Make sure it has input values or don't bother to check if the number of inputs changed

		if ( odo.__boundInputs && odo.__boundInputs.length) {

			var input = odo.__boundInputs[0];

			var frm = window[input.formName];

			if (!frm) return;			/// If the form has been wiped out, so

			

			//不刷新跳转后的页面, zhou, 2002-9-3

			{

				var sMain = HTML.eorp.byClass(frm,"sMain");

				var sBody = PORTALPAGE.getBody2(sMain);

				var rootObj= getCurDataObj(sBody);

				if(!isMultiOutput(rootObj))

				{

					//alert("sdfsd");

					var webObj= getActiveWebPageObj(rootObj);

					if(webObj && webObj._DefaultV == jumpDefaultV)

						return;

				}

			}

				

			var num_old = this.getNumOld(odo, oe);

			var num_new = this.getNumNew(odo);



			//Get the active input element

			var oe = this.setOE(odo);

			

			if (odo._multiInputs && odo.__clearDate) {

				

				var dataInputs = oe.dataInputs;

				if (num_old != num_new || num_new > 1) {

					// bulletproof for missing input values

					dataInputs = dataInputs.split(';');

					

					var allHidden = this.isAllHidden(odo, dataInputs);

	

					if(!allHidden){

						dataInputs = this.getDataInputs(odo, dataInputs);

					}				

					oe.dataInputs=dataInputs.join(';');

					// end bulletproofing



					oe._status = 0;

					var out = PORTALPAGE.currentOutputs(oe);

					oe.dataOutputs = out.dataOutputs;

					oe.dataFormat = out.dataFormat;

					elementReady(oe);

				}

			}//end if

		}//end if

		DATAOBJ.copyOutputs2(odo);

	},

	

	copyOutputs2: function(odo) {	// Copy output values to the GUI

	//	Debug.traceObj(odo);

		var outputs = odo.__boundOutputs;

	//	Debug.traceObj(outputs);

		var sBody;		// the body of the section

		var isXf = false;

		// Step through the output elements that are bound to the object

	//	alert("isXf="+isXf)

		if (outputs) {



			for (var ii=0; ii<outputs.length; ii++) {

				var output = outputs[ii];

				if (output && ! output.done) {

					var e = output.element;

					if (e.parentElement) {

						e = WEBBROWSER.validElement(e);

						if (e) {

							output.element = e;

						} else {

							continue;

						}

					//	alert("e="+e.outerHTML);

						$context.inProgress = null;		// Clear the In Progress flag

						$context.error = "";			// Clear the error indicator

						$context.srcURL = "";			// Default to no source for the element

						$context.lastSyncTime = 0;		// The last time of synchronization for async content

						$context.expires = 0;			// The earliest expiration time while calculating the value

						$context.output = e;

						var result = '';				// if no connection, no result

						var _conn = null;

						// if this object has a _connect property, use it

						var outODO = DATAOBJ.get(odo,output.propPath,true);

						_conn = o.parentProp(outODO,'_connect');

						if (!_conn) {

							_conn = o.parentProp(odo,'_connect');

						}

						$context.error = '';

						if (_conn) {

							var c = TYPEOBJ.getConnect(_conn);

							if (!c || c.isConnected(odo)) {

								if( output.propPath.indexOf('|') == -1 ) {//normal outputs

									result = DATAOBJ.get(odo,output.propPath);

									if( !odo.sid ) {

										var sec = PORTALPAGE.get(output.element);

										if(sec){

											odo.sid = sec.id;

										}

									}

									isXf = false;

								} else {//embedded outputs

									TYPEOBJ.updateOutput(output);

									isXf = true;

								}

							}

						} else {//embedded outputs

							if( output.propPath.indexOf('|') == -1 ) {//normal outputs

								result = DATAOBJ.get(odo,output.propPath);

								if( !odo.sid ) {

									var sec = PORTALPAGE.get(output.element);

									if(sec){

										odo.sid = sec.id;

									}

								}

								isXf = false;

							} else {//embedded outputs

								TYPEOBJ.updateOutput(output);

								isXf = true;

							}

						}

						// If we didn't get a URL value, then try to find it.

						if (!$context.srcURL) {

						//	alert("dfsdf");

							if ($context.object) {

								var temp_obj = $context.object;

								while (temp_obj) {

									if (temp_obj.$url2) {

										$context.srcURL = temp_obj.$url2.__v;

										break;

									}

									if (!temp_obj.__parent) {

										break;

									}

									temp_obj = temp_obj.__parent;

								}

							}

						} 

						if( !isXf ) {

							

							if ($context.error) {

								if( $context.useDefaultErr ) {

									e.innerHTML = "<img src=\"" + "/img/nodata.gif".absURL(true) + "\" width=15 height=14> " + $context.error;	// Error indicator				

								} else {

									e.innerHTML = $context.error;	// Error indicator				

								}

								

								

								VIEWLVL.pushSrcOutput(output.element,true);

								var errBody = HTML.eorp.byClass(e,"sBody");

								if(!errBody)return;

								var errMain = HTML.eorp.byClass(errBody,"sMain");

								

								//////for template ////////////////////////

								if(!isCUSTOMDRAG&&VIEW_MODE=="template"&&errMain)

								{

									drag.setRuntimeStyle(errMain,"");

									viewTemplate.setSectionWidth(errMain.id);

									if(errBody)errBody.innerHTML = "";

									viewTemplate.setMainContent(errMain);

									return 

								}

								/////////////////////////////////////////////

								

								var sec = EP_VIEW.sections[errMain.id];	

								var errHead = HTML.firstChild.byClass(errMain,"sHead");

								DATAOBJ.setSectionGUI(errMain);

								return;

								///////////////////////////

								

								////////////////////////////////////

							}

							 else if ($context.inProgress) {

							 	if ($context.inProgress == "www\.isyndicate\.com" || $context.inProgress == "www\.moreover\.com") {

									$context.inProgress = "New Stories";

								}

								e.innerHTML = result+'<img src="' + '/img/clock.gif'.absURL(true) + '" width=15 height=14 title="正在装载 ' + $context.inProgress + '...">';	// In progress	

							} 

							else {

								if (!result || result == ""){

									result = (USERBROWSER.ie4) ? " " : "&nbsp;";				// So TD cells will have borders

								}

								if (result.constructor != String) result = "" + result;		// Force the result to be a string

					//			alert("result="+result);

								//////////////////for portlet/////////////////

								var rootObj= getCurDataObj(e);

								var webObj= getActiveWebPageObj(rootObj);

								var portlet = PORTLET.isPortlet(webObj);

								var isIframe = PORTLET.isForIframe(webObj);

						//		alert(isIframe);	

						//		Debug.traceObj(webObj);

								if(portlet!=null)

								{

								//	alert("result="+result);

									result = PORTLET.parsePortletContent(result,e);

									

								//	alert("result="+result);

						//			if(result == null)return;

								}

								else if(isIframe != null)

								{

									

									PORTLET.constuctIframeContent(e,result);

									DATAOBJ.setSection(e);

									return;

									

								}

						//		Debug.trace("result="+result);

								//////////////////////////////////////////////

								if (e.tagName != "TABLE") {			// Not able to set contents of a TABLE element

									if (GLOBAL.displayHTML) {

										// Omit formatting

									} else if ( $context.srcURL && !(result.match(/<div/))) {

										var url_text = HTML.href.split($context.srcURL).host.replace(/www\./,"");

										if (url_text == "censdev" || url_text == "censoft\.com") {

										} else {

											result = '<SPAN class="imgMap" title="点击进入 ' + url_text + '">' + result + '</SPAN>';

										}

									} else if ($context.property && $context.property.__parent && $context.property.__parent.$url2 && $context.property.__parent.$url2.__v && !(result.match(/<div/))) {

										var url_text = HTML.href.split($context.property.__parent.$url2.__v).host.replace(/www\./,"");

										result = '<SPAN class="imgMap" title="点击进入 ' + url_text + '">' + result + '</SPAN>';

									} else if ($context.property && $context.property.__vSrcURL && !(result.match(/<div/)) ) {

										var url_text = HTML.href.split($context.property.__vSrcURL).host.replace(/www\./,"");

										result = '<SPAN class="imgMap" title="点击进入 ' + url_text + '">' + result + '</SPAN>';

									}

									if (GLOBAL.displayHTML) {

										e.innerText = result;

									} else {

										if ($context.inProgress) {

											if ($context.inProgress == "www\.isyndicate\.com" || $context.inProgress == "www\.moreover\.com") {

												$context.inProgress = "New Stories";

											}

											result += '<img src="' + '/img/clock.gif'.absURL(true) + ' width=15 height=14 title="正在装载 ' + $context.inProgress + '...">';	// In progress	

										}

										/////////////重新设置Section/////////////////////

									//	DATAOBJ.setDefualtSection(e);

										/////////////////////////////////////////////////

										

										//////for template ////////////////////////

										

										if(!isCUSTOMDRAG&&VIEW_MODE=="template")

										{

											var sMain = HTML.eorp.byClass(e,"sMain");

											var sBody = PORTALPAGE.getBody2(sMain);

											drag.setRuntimeStyle(sMain,"");

											viewTemplate.setSectionWidth(sMain.id);

											if(sBody)sBody.innerHTML = "";

											viewTemplate.setMainContent(sMain);

											return 

										}

										/////////////////////////////////////////////

									//	alert(result);

										

										e.innerHTML = result;

										

									}

								}

								///////////////////////dj////设置section 的显示width和height///////////////////

							//	alert(result);

								//////////////////by dj in 20030328///////////

								var sMain = HTML.eorp.byClass(e,"sMain");

							

							////////////////////////

									DATAOBJ.setSection(e);

							///////////////////////////

							

								////////////////////////////////////////////////////

						//		alert("2");

								//////////////////////////////////////////////

								

								/*;;;;;;;;*/

							//	VIEWER_RENDER.setConnectPortletSrc();

							//	PortalInstances = null;

							//	DATAOBJ.testPortalInstances();

								/*;;;;;;;;;*/

								

								

								output.done = true;					// Flag the output as completed

							

								var e = WEBBROWSER.firstChild(e);			// Check if the new child needs to be initialized

								if (e && e._status && e._status == 0) {

									elementReady(e);				// Initialize the element (in case dynamic expansion is used)

								}	

								

								VIEWLVL.pushSrcOutput(output.element);

								

								

							}//end if

						}//end if( !isXf ) 

					} else {

						outputs[ii] = null;	// Element no longer exists

					}//end if

				}//end if

			}//end for

			

			// Code the tries to resize the column if they are going to have two scroll bars.8/9/00

			// May get executed too many times.  Haven't been too careful, just getting it working.

			if (e && !e.data) {

				sBody = HTML.eorp.byClass (e,"sBody");

				if (sBody && sBody.clientHeight + 10 < sBody.offsetHeight) 

				{

			//		sBody.style.height = sBody.scrollHeight +18;

				}

					

			}//end if

		}

		

	},

	

	///////////////////////dj////设置section 的显示width和height///////////////////

setOutTable:function(e)//////////设置显示区域的标题
{

	var outTable = PORTALPAGE.getOutputTable(e);

	if(outTable)

	{

		try

		{

			var label = outTable.children[0].children[0].children[0];

			var outputs = PORTALPAGE.getOutputs(e);

			if(outputs.length == 1){

			//	alert("sdfd");

				outTable.className = "oHTable2";

			}

		/*	if(label&&label.innerText.trim().length==0)

			{

			//	alert("");

				outTable.className = "oHTable2";

			}

			*/

		}

		catch(e)

		{

			outTable.className = "oHTable";

		}

	}

},

////////设置标题//

setSectionTitle:function(e)

{

	

	var s = PORTALPAGE.getSection(e.id);

	if(s)

	{

		var title = "";

		title = s.title;

		try{

			var rootObj= getCurDataObj($context.output);

			var webObj= getActiveWebPageObj(rootObj);

			if(!isMultiOutput(rootObj)){

				title = webObj._Name;

			}

		}catch(se){

		//	alert(e);

		}

		

	//	alert("s.title="+s.title);

		if(e.hrefTitle)title = e.hrefTitle;

		var hdr = document.all['sTitle_'+e.id];

		var temphTD = document.all['tempHeadTD_'+e.id];

	//	var temphTB = document.all['tempHead_'+e.id];

	//	alert("title="+title);

		if(temphTD&&title)

		{

			title = title.great_summary(50);

			temphTD.innerHTML = "&nbsp;" + title;

		}

		

		if(hdr&&title)

		{

			title = title.great_summary(50);

			hdr.innerText = title;

		}

		

	}

},

setSectionTempProp:function(e)

{

		var sMain = HTML.eorp.byClass(e,"sMain");

		var sBody = PORTALPAGE.getBody2(sMain);

		var sec = EP_VIEW.sections[sMain.id];

		var rootWidth = 0;

		var rootHeight = 0;

		

		var rootObj= getCurDataObj(e);

		var webObj= getActiveWebPageObj(rootObj);

		

		

		

		var url2 = DATAOBJ.getURL(webObj);

		var function2 = DATAOBJ.getFunction(webObj);

		

		if(url2&&function2)

		{

			sMain.currentHref =  url2;

		}

		/**********************************************************/

		if(sec&&sec.objects[0].isShowWide)

		{

			sMain.isShowWide = sec.objects[0].isShowWide;

		}

		if(sec&&sec.objects[0].isShowLable)

		{

			sMain.isShowLable = sec.objects[0].isShowLable;

		}

		/**********************************************************/

		

		if(sec&&!sMain.clickHref&&!sMain.history)

		{

			if(sec.objects[0].width)rootWidth = sec.objects[0].width;

			if(sec.objects[0].height)rootHeight = sec.objects[0].height;

			if(sec.objects[0].hrefHistory)sMain.history = sec.objects[0].hrefHistory;

			if(url2&&function2&&sec.objects[0].height)

			{

				sMain._Function  = function2;

				sMain.clickHref  = url2;

				sMain.rootWidth  = rootWidth;

				sMain.rootHeight = rootHeight;

				sMain.rootURL = url2;

			}

		}

	//////////////还原/////////////

		if(sMain.clickHref&&!sMain.portletObj)

		{

			if(typeof url2 == "string"&&sMain.clickHref != url2)

			{

				sMain.hrefTitle = url2;

			}

			else

			{

				sMain.hrefTitle = sec.title;

				if(sMain.clickHref == url2)sMain.isRoot = "true";

				

			}

		}

},

setSectionGUI:function(e)

{

		var sMain = HTML.eorp.byClass(e,"sMain");

		var sBody = PORTALPAGE.getBody2(sMain);

		var bodyContainer = PORTALPAGE.getBodyContainer(sBody);

		var sec = EP_VIEW.sections[sMain.id];

		var webPage = HTML.eorp.getProp(e,"censoft_object");

		var rootWidth = 0;

		var rootHeight = 0;

		var borderWidths = 0;

		var borderHeight = 0;

		var headOffsetWidth = 0;

		var headOffsetHeight = 0;

		//////////////////





	//	DATAOBJ.setSectionTempProp(e);

		if((sMain.isRoot&&sMain.isRoot=="true"))

		{

			rootWidth = sMain.rootWidth;

			rootHeight = sMain.rootHeight;

		}

		if(sec)

		{

			/////////////////////////////////////////

			var tempHead = document.all["tempHead_"+sMain.id];

			var rend = SECTION_RENDER.getRend(sMain.id);

			var isShowWide  = "H";

			var isShowTitle = "S";

			if(rend&&rend.isShowWide)isShowWide = rend.isShowWide;

			if(rend&&rend.isShowTitle)isShowTitle = rend.isShowTitle;

			//alert(isShowTitle);

			/////////////////////////

			var isShowLable  = "H";

			try{

				PORTALPAGE.setLabelState(sMain,rend);

			}catch(err){

				isShowLable  = "H";

			}

			



			if(rend&&rend.isShowLable)isShowLable = rend.isShowLable;

			

			//////////////////////////

//			return;

			

			var isShowtTitle  = "S";

			if(rend&&rend.isShowtTitle)isShowtTitle = rend.isShowtTitle;

			if(isShowWide == "S")isShowtTitle = "H";

			try{

				PORTALPAGE.showOrhiddenLable(sMain,isShowLable);

			//	PORTALPAGE.showOrHideTitle(sMain,isShowTitle);

			}catch(err){

				

			}

			/////////////////////////////////////////

			

			var borderWidth = SECTION_RENDER.getBodyBoderWidth(rend);

	

			if(tempHead&&sBody)

			{

				if(isShowWide == "H")

				{

					borderWidths	= borderWidth * 2;

					borderHeight = 20;

					headOffsetWidth = tempHead.offsetWidth;

					headOffsetHeight = tempHead.offsetHeight;

				}

				if(sec.collapsed)////section处于最小化状态
				{

					var secWidth = 0;

					if(sec.objects[0].width)secWidth = parseInt(sec.objects[0].width);

					var secHeight = 0;

					if(sec.objects[0].height)secHeight = parseInt(sec.objects[0].height);

					if(secWidth>0)

					{

						sMain.style.widthTemp = parseInt(secWidth) + borderWidths;

						sBody.style.width = secWidth;

					}

					else

					{

						sBody.style.width = sMain.offsetWidth;

						sMain.style.widthTemp = sMain.offsetWidth;

					}

					if(secHeight>0)

					{

						sMain.style.heightTemp = parseInt(secHeight) + borderHeight;

						sBody.style.height = secHeight;

					}

					else

					{

						sBody.style.height = sMain.offsetHeight - borderHeight;

						sMain.style.heightTemp = sMain.offsetHeight;

					}

					var minWidth = 0;

					if(isShowWide == "H")

					{

						minWidth = parseInt(tempHead.offsetWidth);

						sMain.style.height = 21;	

					}

					////////////noice//////////////////

					sMain.style.width = Math.max(180,minWidth);

					tempHead.style.width = sMain.style.width;

				}

				else

				{

					if(VIEW.isRefresh)

					{

						VIEW.isRefresh = false;

						if(sMain.style.widthTemp)

						{

							var tempW = parseInt(sMain.style.widthTemp);

							sMain.style.width    = tempW;

							sBody.style.width    = tempW - borderWidths;

							tempHead.style.width = tempW;

						}

						if(sMain.style.heightTemp)

						{

							sMain.style.height = sMain.style.heightTemp;

							sBody.style.height = parseInt(sMain.style.heightTemp) - borderHeight;

						}

					}

					else

					{



						/////////////////////////////////

						var bodyTable = VIEW.getTbInBody(sBody);

						

						//////////////////////////////////////////

						var secWidth = DATAOBJ.getRootWidth(sMain);

						var secHeight = DATAOBJ.getRootHeight(sMain);

//						alert(secWidth);



						var scrollW = 0;

						var scrollHt = 0;

						/////////////////////在点击联接后再点击前进时会用到////////////////////////

						if(sBody.scrollWidth > sBody.offsetWidth)	

						{

							secWidth = sBody.offsetWidth;

							scrollW = secWidth - sBody.scrollWidth;

						}	

						if(sBody.scrollHeight > sBody.offsetHeight)	

						{

							secHeight = sBody.offsetHeight;

							scrollHt = secHeight - sBody.scrollHeight;

						}	

				//		alert(sec.objects[0].width);

						if(sec.objects[0].width)

						{

							secWidth = parseInt(sec.objects[0].width);

							scrollW = 0;

						}

						if(sec.objects[0].height)

						{

							secHeight = parseInt(sec.objects[0].height);

							scrollHt = 0;

						}

						///////////////////////////////////////////

						if(rootWidth&&rootWidth!=0)

						{

							secWidth = rootWidth;

							scrollW = 0;

						}

						if(rootHeight&&rootHeight!=0)

						{

							secHeight = rootHeight;

							scrollHt = 0;

						}

					

				//		alert("secWidth="+secWidth);

						///////////////////////////////////////////////////////////////

						var sBodyW = parseInt(secWidth) - scrollW;

						var pubW = sBodyW + borderWidths;

						sMain.style.widthTemp = pubW;

						tempHead.style.width = pubW + "px";

						

 					//	alert("2*borderWidth="+borderWidth);

						if(isShowWide == "H")pubW = sBodyW + 2*borderWidth;

					

						sMain.style.width = pubW + "px";	

						sBody.style.width = sBodyW + "px";

						

						var temp = parseInt(secHeight) - scrollHt;

						var mainHeight    = headOffsetHeight + temp;

						sMain.style.heightTemp = mainHeight;

						

						if(isShowWide == "H")mainHeight = headOffsetHeight + temp + 2*borderWidth;

						sBody.style.height= temp;

						sMain.style.height= mainHeight + "px";	



						if(isShowWide == "H")

						{

					//		alert("tempHead.offsetWidth="+tempHead.offsetWidth+"\ntempHead.style.width="+tempHead.style.width);

							if(tempHead.offsetWidth > parseInt(tempHead.style.width))

							{

								sMain.style.width = sMain.offsetWidth + "px";	

								sBodyW = tempHead.offsetWidth - borderWidths;

								sBody.style.width = sBodyW + "px";

								tempHead.style.width = tempHead.offsetWidth + "px";

								sMain.style.widthTemp =  sMain.offsetWidth;

							}

								

						}

					}

					

					if(tempHead&&isShowWide == "H")

		 			{

						if(sMain.style.width != "" && sMain.style.width != null)

						{

		 					tempHead.style.width = parseInt(sMain.style.width);

		 					sBody.style.width = parseInt(sMain.style.width) - 2*borderWidth;

						}

		 			}

				}

		}

		

		////////////////////////////////

			try{

			

				SECTION_RENDER.setSectionMargin(sMain,rend);

				

			//	PORTALPAGE.showOrhiddenLable(sMain,isShowLable);

			//	PORTALPAGE.showOrHideTitle(sMain,isShowTitle);

				viewTemplate.setTemplateSectionSize(sMain);

				

				//alert(location.search);



			}catch(err){}

			////////////////////////////////

	  

	  

	  }



		

},

	setSection:function(e)

	{



		var sMain = HTML.eorp.byClass(e,"sMain");

		

		if(!sMain.width0)sMain.width0 = DATAOBJ.getRootWidth(sMain);

		if(!sMain.height0)sMain.height0 = DATAOBJ.getRootHeight(sMain);

	//	alert(sMain.width0);

		sMain.clickSrcE = e;

		//Debug.trace("sMain="+sMain.outerHTML);	

		//////////设置显示区域的显示格式///////////

		DATAOBJ.setOutTable(e);

		///////////////////////////////////

		DATAOBJ.setSectionTempProp(e);

		

		DATAOBJ.setSectionTitle(sMain);

		

		DATAOBJ.setSectionGUI(e);

		

		///////////////////////设置工具图标/////////////////////////////////

		DATAOBJ.setToolPic(sMain);

		/////////////////////////////////////////////////////////////////////

		

		DATAOBJ.setDefault(sMain);

	

		////by dj in 20030328 for more outputs to first setSection

		sMain.seted = "yes";

		///////////////////////////////

	},

	setDefualtSection:function(e)

	{

		var sMain = HTML.eorp.byClass(e,"sMain");

		var sHead = HTML.firstChild.byClass(sMain,"sHead");

		var sBody = PORTALPAGE.getBody2(sMain);

	},

	///////////////////////设置工具图标/////////////////////////////////

	//////////for templet/////////////////

	setTempletImgpath:function(secID,isShowWide)

	{

		var imgPath = "/img/titlebar/";

		return imgPath;

	},

	

	///////////////////////////////////////

	setToolPic:function(sMain,rend)

	{

			

	//	if( !(HEADER.isView() && isMyView()) ) return;

		var isHome = viewTemplate.isDisabled();

		if(BUTTON.getPageName() == 'view_reveal'||BUTTON.getPageName() == 'pubView'||BUTTON.getPageName() == 'portlet_reveal')isHome = true;

		var bWeb0 = false;

		if(BUTTON.getPageName() == 'web0')bWeb0 = true;

		if(bWeb0)return;

		if(bWeb0)isHome = true;

		//if(isHome)return;

		if(!sMain)return;

		var currentHref_tool = sMain.currentHref;

		var history_tool = sMain.history;

		if(rend==null)rend = SECTION_RENDER.getRend(sMain.id);

		

		var imgBack = null;

		var imgNext = null;

		

		///////////////for templet//////////////////

		var imgPath = DATAOBJ.setTempletImgpath(sMain.id);

		

	

	//	alert("imgPath="+imgPath);

		///////////////////////////////////////////

		

		var maxImg = document.all[sMain.id+"_toggle"];

		var closeImg = document.all["imgClose_"+sMain.id];

		

		

		

		var customImg2 = document.all['imgCustomizetemp_'+sMain.id];

		var configImg2 = document.all['imgConfigtemp_'+sMain.id];

		var helpImg2 = document.all['imgHelptemp_'+sMain.id];

		

		imgBack   = document.all['imgForwardtemp_'+sMain.id];

		imgNext   = document.all['imgNexttemp_'+sMain.id];

		

		maxImg = document.all[sMain.id+"_toggletemp"];

		closeImg = document.all["imgCloseTemplet_"+sMain.id];

	//	alert(sMain.innerHTML);

	//	alert(maxImg);

	

		var bCollapsed = getGUIState(sMain);

		

		if(maxImg)

		{

			if(bCollapsed)

			{

				maxImg.src = (imgPath+'max.gif').absURL();

			}

			else

			{

				maxImg.src = (imgPath+'min.gif').absURL();

			}

		}

		if(closeImg)

		{

			if(!isHome)closeImg.src = (imgPath+'close.gif').absURL();

		}

	//	alert(closeImg.src);

	//	if(history_tool)alert("history_tool="+history_tool);

	//	else alert("history is null");

		var isPortlet = false;

		if(!bWeb0){

			if(sMain.portletObj)

			{

				isPortlet = true;	

			}

			if(isPortlet)

			{

				var portMode = sMain.portletObj.portMode;

				var isEdit = false;

				var isConfig = false;

				var isHelp = false;

				if(portMode)

				{

					if(portMode.indexOf("1") > -1 )isEdit = true;

					if(portMode.indexOf("3") > -1 )isConfig = true;

					if(portMode.indexOf("2") > -1 )isHelp = true;

				}

				//alert("isConfig="+isConfig);

				if(isEdit)

				{

					if(customImg2)customImg2.src = (imgPath+'customize.gif').absURL();

				}

				if(isConfig)

				{

					if(configImg2)configImg2.src = (imgPath+'title_config.gif').absURL();

				}

				if(isHelp)

				{

					if(helpImg2)helpImg2.src = (imgPath+'title_help.gif').absURL();

				}

			}

		}

	

		//PORTLET.isPortlet();

		if(imgBack&&imgNext)

		{

			

			if(!currentHref_tool||!history_tool)

			{

				imgBack.src = (imgPath+'back_disable.gif').absURL();

				imgNext.src = (imgPath+'forward_disable.gif').absURL();

			}

			else

			{

				if(currentHref_tool == history_tool[0])

				{

					imgBack.src = (imgPath+'back_disable.gif').absURL();

					imgNext.src = (imgPath+'forward.gif').absURL();

					imgNext.isClick = "true";

					imgBack.isClick = "false";

				}

				else if(currentHref_tool == history_tool[history_tool.length - 1])

				{

					imgNext.src = (imgPath+'forward_disable.gif').absURL();

					imgBack.src = (imgPath+'back.gif').absURL();

				//	imgBack.src = (imgPath+'back.png').absURL();

					imgNext.isClick = "false";

					imgBack.isClick = "true";

				}

				else

				{

					imgBack.src = (imgPath+'back.gif').absURL();

				//	imgBack.src = (imgPath+'back.png').absURL();

					imgNext.src = (imgPath+'forward.gif').absURL();

					imgNext.isClick = "true";

					imgBack.isClick = "true";	

				}

					

			}

		}	

	},

	getOutputObj:function(sec)

	{

		var rootObj= getCurDataObj(sec);

		var e = null;

		if(rootObj && rootObj.__boundOutputs)

		{

			var outputs = rootObj.__boundOutputs;

			e = outputs[0].element

		}

		return e;

	},

	// t1: lastSyncTime

	// t2: expiration time

	updateContext: function(t1,t2) {

	

		// Remember the earliest synchronization time

		if (t1 && (!$context.lastSyncTime || (t1 < $context.lastSyncTime)) ) {

			$context.lastSyncTime = t1;

		}

		

		// Remember the minimum expiration time

		if (t2 && (!$context.expires || (t2 < $context.expires)) ) {

			$context.expires = t2;

		}

	},

	

	onunload: function() {



		return;

		var a = DATAOBJ.objects;

		for (var i=0; i<a.length; i++) {

			var odo = a[i];

			// Clear element references for bound inputs

			var inp = odo.__boundInputs;

			if (inp && inp.length) {

				for (var j=0; j<inp.length; j++) {

					inp[j].element = null;

				}

			}

			// Clear element references for bound outputs

			var out = odo.__boundOutputs;

			if (out && out.length) {

				for (var j=0; j<out.length; j++) {

					out[j].element = null;

				}

			}

		}

	}

}



// Define shorthand variable names that are used within Data Object definitions



var getEntire = DATAOBJ.getPropValue;

var $r = o.getRoot;

var E = DATAOBJ.embed;

var $context = DATAOBJ.$context;



var jumpDefaultV = 

{

	_Function:function()

	{

		var h= getEntire();

		if(!h) return '';

		h = h + h.KeepJs(); 

		h= h.formatPage();

		return h;

		

		//var u = getEntire("$baseURL"); 

		//return HTML.expandRefs(getEntire().replace(/<form /gi,"<form onsubmit='EVENT.onsubmit(this)' "),u)+getEntire().KeepJs();

	},

	_FunctionToA: fa.href

};

var portletDefaultV = 

{

	_Function:function()

	{

		var h= getEntire();

		if(!h) return '';

		h= h.formatPageForPortlet();

		return h;

	},

	_FunctionToA: fa.href

};

var getCurDataObj= function(e)

{

	var body = PORTALPAGE.getBody(e);

	// Get the first data object within the section

	if(body)

	{

		var dataObject = body.dataObject;

		// Refresh the section display (causes the data objects to be re-created)

		return window[dataObject];	

	}

}



//oWpRoot : view 根对象
//是不是有多个输出

function isMultiOutput(oWpRoot)

{

	if(oWpRoot && oWpRoot.__boundOutputs)

	{

		var count=0;

		for(var i=0; i<oWpRoot.__boundOutputs.length; i++)

		{

			if(oWpRoot.__boundOutputs[i]) count++;

		}

		if(count > 1)	return true;

	}

	return false;

}



//得到活动的对象
function getActiveWebPageObj(oWpRoot)

{

	if(oWpRoot && oWpRoot.__boundOutputs)

	{

		var count=0;

		for(var i=0; i<oWpRoot.__boundOutputs.length; i++)

		{

			if(oWpRoot.__boundOutputs[i])

			{

				var path= oWpRoot.__boundOutputs[i].propPath;

				var oWp;

				if(path == '_DefaultV')

					oWp=oWpRoot;

				else

					{oWp=o.get(path, oWpRoot);}

				if(typeof oWp == "undefined")return null;

				if(typeof oWp.$url == "undefined")

					oWp.$url=' ';

				

				if(!oWp.$url2)

				{

					copyWEBPAGE(oWp);

					//o.init(oWp.__parent, oWp.__p, oWp);

				}

				return oWp;

			}

		}

	}



	return null;

}



function copyWEBPAGE(obj)

{

	if(!obj)	return;

	var wp = o.template('WEBPAGE');

	for (var prop in wp)

	{

		if(!obj[prop]) obj[prop] = wp[prop];

	}

}


