/* Here we collect the standard javascripts */


// find browser version
var IE = 0;
if((navigator.appName.indexOf("Microsoft")>-1) || (navigator.appName.indexOf("MSIE")>-1)){ IE=1; }

var dynmenu_elements = new Array();
function dynMenu(path) {

	/* dynmenu_(TOP$|TOP:TWO$|TOP:TWO:TRE$) */
	elements = path.split(':');
	var regex; var pathbuild;
	for (var i=0; i<elements.length; i++) {
		if (pathbuild == null) pathbuild = elements[i];
		else pathbuild = pathbuild+':'+elements[i];
		if (regex == null) regex = pathbuild+'$';
		else regex = regex+'|'+pathbuild+'$';
	}
	var match = new RegExp('dynmenu_('+regex+')');	
	for (var i=0; i<dynmenu_elements.length; i++) {
		if (i==0) { continue; }
		if (match.exec(dynmenu_elements[i])) {
			if (document.getElementById(dynmenu_elements[i]).style.display != 'block') {
				document.getElementById(dynmenu_elements[i]).style.display = 'block'; }
		} else {
			document.getElementById(dynmenu_elements[i]).style.display = 'none';
		}	
	}
}


// display and hide layout-tables on action call from value in popup / checkbox / radio..
function layoutAction(check,path,inp,val) {
//	alert("layoutAction >>> check:"+check+"\n path:"+path+" \ninp:"+inp+" val:"+val);

	if (check == 'clear') {

		var oElm = getMultElementsByPartID(document.documentElement,"TABLE","tbBox_"+path+'_'+value);
		for (m=0; m<oElm.length; m++) {				
//			alert("found oElm "+oElm[m].id);
			if (vals[0] != val) { 
				oElm[m].style.display = '';
			}
		}

	} else if (check == 'show') {
		if (!inp) { return; }

		// set the edit parameters
		var regSemiColon = /\s*;\s*/;
		var regUnequals = /\s*!=\s*/;
		var regEquals = /\s*=\s*/;
		var regComma = /\s*,\s*/;
	
		opts = inp.split(regSemiColon);

// check:show path:DEUS_c1m1a_A_c1m1a_capewhite_c1m1a_A_c1m1a_simcorp_ajax_c1m1a_A_c1m1a_edit_prog_c1m1a_A_c1m1a_s114647204119995_c1m1a_A_c1m1a__a2t2r__c1m1a_obexp 
// inp:Y=yes1,comm1;P=quest1,comm1;N=quest1,comm1; val:

// inp: inget=N,Y,VEJ !comm1;P=quest1,comm1;N=quest1,comm1; val:
// inp: !ingen = 



		// set invisible on all conserned objects
		for (i=0; i<opts.length; i++) {
			var toggle = '';
			vals = opts[i].split(regUnequals);
			if (!vals[1]) { 
				toggle = 'none';
				vals = opts[i].split(regEquals);
			}

			if (!vals[1]) { continue; }
			if (vals[0] != val) {

				boxes = vals[1].split(regComma);

				for (k=0; k<boxes.length; k++) { 
					var value = boxes[k].toLowerCase();	
					var oElm = getMultElementsByPartID(document.documentElement,"TABLE","tbBox_"+path+'_'+value);

//					alert("hiding> path:"+path+" value:"+value);

					for (m=0; m<oElm.length; m++) {				
//						alert("eval> ["+m+"] path:"+path+" value:"+value);
						oElm[m].style.display = toggle;

						if (toggle != 'none' && AJAX_DEF['tbBox_'+path+'_'+value]) {
							// object is ajax defined. we gather it by reload the server.
//							alert('enter disp hier rows '+vals[0]);
							dispHierRows(path,value,AJAX_DEF['tbBox_'+path+'_'+value],'show');
						}
					}
				}
				
			// != shows the box in case of hit
			} else if (toggle == '') {
			
				boxes = vals[1].split(regComma);

				for (k=0; k<boxes.length; k++) { 
					var value = boxes[k].toLowerCase();	
					var oElm = getMultElementsByPartID(document.documentElement,"TABLE","tbBox_"+path+'_'+value);

					for (m=0; m<oElm.length; m++) {				
						oElm[m].style.display = 'none';

					}
				}
			
			}
		}

		// display just option choosed
		for (i=0; i<opts.length; i++) { 
			vals = opts[i].split(regEquals);
			if (!vals[1]) { continue; }
			if (vals[0] == val) {

				boxes = vals[1].split(regComma);

				for (k=0; k<boxes.length; k++) {
					var value = boxes[k].toLowerCase();
					var oElm = getMultElementsByPartID(document.documentElement,"TABLE","tbBox_"+path+'_'+value);
//					alert("display> path:"+path+" value:"+value);

					for (var m=0; m<oElm.length; m++){
						oElm[m].style.display = '';
//						alert("eval> ["+m+"] path:"+path+" value:"+value+" DEF:"+AJAX_DEF['tbBox_'+path+'_'+value]+" value:"+value);

						if (AJAX_DEF['tbBox_'+path+'_'+value]) {
							// object is ajax defined. we gather it by reload the server.
//							alert('enter disp hier rows '+vals[0]);
							dispHierRows(path,value,AJAX_DEF['tbBox_'+path+'_'+value],'show',1);
						}
					}
				}
			}
		}
	}
}

var toolbarIndicator = new Array();
function toolb(path,vers) {
//	 alert("enter toolbar path:"+path+" vers:"+vers);

	if (toolbarIndicator[path]) {
		toolbarIndicator[path] = 0;
	} else {
		toolbarIndicator[path] = 1;
	}

	// set border
	var oElm = getMultElementsByPartID(document.documentElement,"TABLE","box_tab_TB_"+path);
	for (var i=0; i<oElm.length; i++){
		if	(toolbarIndicator[path]) {
			oElm[i].border=1;
			oElm[i].style.borderWidth="1px";
			oElm[i].style.emptyCells="show";
//		oElm[i].cellpadding=5;
		} else {
			oElm[i].border=0;
		}
	}


	// display toolbar
	var oElm = getMultElementsByPartID(document.documentElement,"TR","box_toolbar_TR_"+path);
	for (var i=0; i<oElm.length; i++){
//		alert("["+i+"] IE:"+IE+" oElm>"+oElm[i].id+" style:"+oElm[i].style+" disp:"+oElm[i].style.display);
		if	(toolbarIndicator[path]) {
			if (IE) { oElm[i].style.display = 'inline';	} 
			else { oElm[i].style.display = 'table-row'; }
		} else {		
			oElm[i].style.display='none';
		}
	}

	// the horizontal position row
	var oElm = getMultElementsByPartID(document.documentElement,"TR","box_pos_TR_"+path);
	for (var i=0; i<oElm.length; i++){

//		alert("box_pos_TR obj:"+oElm[i].id+" disp:"+oElm[i].style.display);
		if	(toolbarIndicator[path]) {
			if (IE) { oElm[i].style.display = 'inline';	} 
			else { oElm[i].style.display = 'table-row'; }
		} else {
			oElm[i].style.display='none';
		}
	}

	// the vertical position column 
	var oElm = getMultElementsByPartID(document.documentElement,"TD","box_pos_TD_"+path);
	for (var i=0; i<oElm.length; i++){
//		alert("box_pos_TD obj:"+oElm[i].id+" disp:"+oElm[i].style.display);
		if	(toolbarIndicator[path]) {
//			oElm[i].style.borderWidth='1px';	
//			oElm[i].style.borderStyle='solid';
//			oElm[i].style.padding='2px';
// 			oElm[i].style.borderColor='#808080';	
			if (IE) { oElm[i].style.display = 'inline';	} 
			else { oElm[i].style.display = 'table-cell'; }
		} else {
//			oElm[i].style.borderWidth='0px';	
//			oElm[i].style.padding='0px';
			oElm[i].style.display='none';
		}
	}

	// the checkboxes (can be declared in both TD and UL fields)
	var oElm = getMultElementsByPartID(document.documentElement,"TD","box_checkbox_"+path);
	for (var i=0; i<oElm.length; i++){
		if	(toolbarIndicator[path]) {
			if (IE) { oElm[i].style.display = 'inline';	} 
			else { oElm[i].style.display = 'table-cell'; }
		} else { oElm[i].style.display='none'; }
	}

	var oElm = getMultElementsByPartID(document.documentElement,"UL","box_checkbox_"+path);
	for (var i=0; i<oElm.length; i++){
		if	(toolbarIndicator[path]) { oElm[i].style.display='block'; } 
		else { oElm[i].style.display='none'; }
	}
	
	var oElm = getMultElementsByPartID(document.documentElement,"TR","box_title_TR_"+path);
	for (var i=0; i<oElm.length; i++){
		if	(toolbarIndicator[path]) { 
			if (IE) { oElm[i].style.display = 'inline';	} 
			else { oElm[i].style.display = 'table-row'; }
		} else { oElm[i].style.display='none'; }
	}

}

var npPre; var npPos;
function retNodePath(path,stop) {
	npPre = ''; npPos = '';

	// set input path
	elements = path.split('&');
	nodes = new Array();
	for (var i=0; i<elements.length; i++) {
		temp = elements[i].split('=');
		nodes[temp[0]] = temp[1];
	}

	// combind the target
	for (var i=0; i<pathTree.length; i++) {
		var val = nodes[pathTree[i]] || currPath[i];
		npPre = npPre + val+ '['; npPos = npPos + ']';
		if (pathTree[i] == stop) { break; }
	}

	return;

}

/*

ex:	$vals => SI=db29 & PA=myPage & TA=users & TA_AL=# CO=info CO_AL=abc

	TA=# indicates we are entering the table attributes.... 
	the following steps enter the attribute name (info) and the att value (abc) 
	$Deep => CO_AL in the case above.. the last unit of the stairs where we hold values
			VA is not of interest in the ex above
	$localEnumSwitch => if the value should switch from Y or N locally..
			then we base the result of whats existing already
*/

// updThemeBound(';DEUS;A;capetwo;A;db50;A;ALL;A;userList;A;attst;A;ico_veditcolor;A;users;#;val)
function updThemeBound(themeBound,val,local) {
	if (local) {
		if (document.DEUS.elements[themeBound].value == 'Y') { val = "N"; } else { val = "Y"; }
	}
	document.DEUS.elements[themeBound].value = val;
}


/*
function checkboxSwitcher(Path,Class,Null) {

	if (Null) {
		if (document.DEUS.elements[Path].value == '#') {
			// turn null off
			document.getElementById('nullIndic_'+Path).className = Class+'_nullOff';
//			eval("document.DEUS.img_"+imgPath+".src=\"/pub/SYSTEM/images/website/symbols/null_off.gif\"");
			document.DEUS.elements[(alias||"check")+"_"+Path].checked = false;
			document.DEUS.elements[Path].value = 'N';
		
		} else {
			// turn null on
			document.getElementById('nullIndic_'+Path).className = Class+'_nullOn';
//			eval("document.DEUS.img_"+imgPath+".src=\"/pub/SYSTEM/images/website/symbols/null_on.gif\"");
			document.DEUS.elements[(alias||"check")+"_"+Path].checked = false;
			document.DEUS.elements[Path].value = '#';
		}
	} else {
		// turn null off
//		alert(' old:'+document.DEUS.elements[Path].value+' checked:'+document.DEUS.elements[(alias||"check")+"_"+Path].checked);
		if (imgPath) {
			document.getElementById('nullIndic_'+Path).className = Class+'_nullOff';
//			eval("document.DEUS.img_"+imgPath+".src=\"/pub/SYSTEM/images/website/symbols/null_off.gif\"");
		} if (document.DEUS.elements[(alias||"check")+"_"+Path].checked == true) {
			document.DEUS.elements[Path].value = 'Y';
		} else { 
			document.DEUS.elements[Path].value = 'N';
		}
	}


}

*/

function setDictVar (path,link) {
	myRe = new RegExp("\#lng\'.*\'");
	if (document.DEUS.elements[path].value &&
		myRe.exec(document.DEUS.elements[path].value)) {
		unitSwitch('nullInp',path,'DEF','check');
		// do nada
	} else {
		unitSwitch('nullInp',path,'DEF','check');
		document.DEUS.elements[path].value = "#lng'"+link+"'";
	}
}


//var hierRows = new Array();
var AJAX_DEF = new Array();
var AJAX_REN = new Array();
function dispHierRows(path,block,ajax,kind,fix,attr) {
	// path : unique path to the object
	// block : combined with the path makes the object unique even though its multiple
	// ajax : an ajax id is set for the object
	// kind : show or hide the object
	// fix : alter if multiple objects should be searched for.. or if we want just a single hit.

	// remove bug for odd symbols ajax makes 
	if (attr)
		attr = attr.replace(/[^A-Za-z0-9=&]/g, '');

	var oElm = new Array();
	if (fix) {
		oElm[0] = document.getElementById("hierbox_"+path+'_'+block);
	} else {
		oElm = getMultElementsByPartID(document.documentElement,"DIV,TR","hierbox_"+path+'_'+block);
	}
	
	var inclatts = '';
	if (attr) inclatts = attr;

	for (var i=0; i<oElm.length; i++){
		if ((kind && kind == 'show') || oElm[i].style.display == 'none') {
			oElm[i].style.display = '';
			if (document.getElementById('hierimg_'+path+'_'+block)) {
				document.getElementById('hierimg_'+path+'_'+block).src = '/pub/SYSTEM/images/formDisplay/arrows/a_arr_red_down.gif';
			}

			if (ajax && !AJAX_REN[ajax]) {
				document.getElementById('hierload_'+path+'_'+block).style.display = '';
				makeRequest('partPage=ajax&ajID='+ajax+inclatts,path+'_'+block);
			 	AJAX_REN[ajax] = 1;
			 }

		} else {
			oElm[i].style.display = 'none';
			if (document.getElementById('hierimg_'+path+'_'+block)) {
				document.getElementById('hierimg_'+path+'_'+block).src = '/pub/SYSTEM/images/formDisplay/arrows/a_arr_red_right.gif';
			}
		}
	}
}


function addMultVal(path,val) {
	
	var old = document.DEUS.elements[path].value;
	
	if (old) {
		var olds = old.split('\0');
		for (i=0; i<olds; i++) {
			if (olds[i] == val) { return; }	
		}
		document.DEUS.elements[path].value = old+"\0"+val;
	} else {
		document.DEUS.elements[path].value = val;
	}

}

function remMultVal(path,val) {
	
	var old = document.DEUS.elements[path].value;
	if (old) {
		var olds = old.split('\0');
		for (i=0; i<olds; i++) {
			if (olds[i] == val) { removed = olds.splice(i, 1); alert("removed: "+removed); }	
		}
		document.DEUS.elements[path].value = olds.join('\0');
	}
}



function unitSwitch(pre,path,cls,deNull) {
//	alert("enter unit switch >> "+pre+","+path+","+cls+","+deNull);
	// checkbox
	if (document.DEUS.elements[pre+"_"+path] && 
		document.DEUS.elements[pre+"_"+path].type == 'checkbox') {

		if (deNull == 'check') {
			// user change values
			if (document.getElementById('nullIndic_'+path)) {
				document.getElementById('nullIndic_'+path).className = cls+'_nullOff'; }
			if (document.DEUS.elements[path].value == 'Y') { 
				document.DEUS.elements[path].value = 'N'; } 
			else {  document.DEUS.elements[path].value = 'Y'; }

		} else {
			// path is "force transparency" - we change to "transparent"
			if (document.DEUS.elements[path].value == '#!') {
				if (document.getElementById('nullIndic_'+path)) {
					document.getElementById('nullIndic_'+path).className = cls+'_null'; }
				document.DEUS.elements[pre+"_"+path].checked = false;
				document.DEUS.elements[path].value = '#';
			// path is "transparent" - we change to "off"
			} else if (document.DEUS.elements[path].value == '#') {
				if (document.getElementById('nullIndic_'+path)) {
					document.getElementById('nullIndic_'+path).className = cls+'_nullOff'; }
				document.DEUS.elements[pre+"_"+path].checked = false;
				document.DEUS.elements[path].value = 'N';
			// path is "off" - we change to "force transparency"
			} else {
				if (document.getElementById('nullIndic_'+path)) {
					document.getElementById('nullIndic_'+path).className = cls+'_nullSet'; }
				document.DEUS.elements[pre+"_"+path].checked = false;
				document.DEUS.elements[path].value = '#!';
			}
		}

	// select
	} else {

		if (deNull == 'check') {
			if (document.DEUS.elements[pre+"_"+path] && document.DEUS.elements[pre+"_"+path].value) {
				// user change values
				if (document.getElementById('nullIndic_'+path)) {
					document.getElementById('nullIndic_'+path).className = cls+'_nullOff'; }
				document.DEUS.elements[pre+"_"+path].value = '';
			}

		} else {

			// path is "transparent" - we change to "off"
			if (document.DEUS.elements[pre+"_"+path].value == '#') {
				if (document.getElementById('nullIndic_'+path)) {
					document.getElementById('nullIndic_'+path).className = cls+'_nullOff'; }
				document.DEUS.elements[pre+"_"+path].value = '';
			// path is "force transparency" - we change to "transparent"
			} else if (document.DEUS.elements[pre+"_"+path].value == '#!') {
				if (document.getElementById('nullIndic_'+path)) {
					document.getElementById('nullIndic_'+path).className = cls+'_null'; }
				document.DEUS.elements[pre+"_"+path].value = '#';
			// path is "off" - we change to "force transparency"
			} else {
				if (document.getElementById('nullIndic_'+path)) {
					document.getElementById('nullIndic_'+path).className = cls+'_nullSet'; }
				document.DEUS.elements[pre+"_"+path].value = '#!';
			}
		}
	}
}





	// set the edit parameters
/*	ar = Vals.split('&');
	var regexstr = '';

	for (i=0; i<ar.length; i++) { eval(ar[i]); }
	var regexstr = '';
	for (i=0; i<deeps.length; i++) {
		reg = reg + eval(deeps[i])+'\\=\\[';
		row = row + eval(deeps[i])+'=[';
		regend = end + '\\]';
		rowend = end + ']';
		if (Deep == deeps[i]) break;
	}
	re = new RegExp(reg+'(\\w+)'+regend);
	Res = re.exec(document.DEUS.addTHEME.value);

	var val;
	if (localCriteria) {
		if (eval(localCriteria)) { eval(Deep+' = "N"'); }
		else { eval(Deep+' = "Y"'); }
	}

	if (realVal) document.DEUS.addTHEME.value = realVal+', '+ref;
	else document.DEUS.addTHEME.value = ref;	

	document.DEUS.addTHEME.value = realVal+', '+ref;

	} else {
	}


*/


/*	re = new RegExp(
			DO+'\\=\\['+DO_AL+'\\=\\['+
			SE+'\\=\\['+SE_AL+'\\=\\['+
			SI+'\\=\\['+SI_AL+'\\=\\['+
			PA+'\\=\\['+PA_AL+'\\=\\['+
			TA+'\\=\\['+TA_AL+'\\=\\['+
			CO+'\\=\\['+VAL+'\\+ATTR+'sID\\=\\['+sID+
			'\\=\\['+alias+'\\=\\['+tab+'\\=\\['+col+
			'\\=\\[attsc\\=\\['+attr+'\\=\\[(\\w+)\\]\\]\\]\\]\\]\\]\\]');
	

	var ref = '';
	var re; var val2;
	if (val == 'SWITCH_YES_NO') { val2 = 'Y'; }
	if (tab && col) {

		re = new RegExp(DO+'\\=\\['+DO_AL+'\\=\\['+SE+
				'\\=\\[A\\=\\['+SI+'\\=\\[A\\=\\['+PA+
				'\\=\\[A\\=\\['+PA_AL+'\\=\\['+TA+
				'\\=\\['+CO+'\\=\\['+VAL+ATTR+'sID\\=\\['+sID+
				'\\=\\['+alias+'\\=\\['+tab+'\\=\\['+col+
				'\\=\\[attsc\\=\\['+attr+'\\=\\[(\\w+)\\]\\]\\]\\]\\]\\]\\]');

		re = new RegExp(DO+'\\=\\['+DO_AL+'\\=\\['+SE+'\\=\\[A\\=\\['+SI+'\\=\\[A\\=\\['+PA+'\\=\\[A\\=\\['+PA_AL+
				'\\=\\['+TA+'\\=\\['+CO+'\\=\\['+VAL+ATTR+'sID\\=\\['+sID+'\\=\\['+alias+'\\=\\['+tab+'\\=\\['+col+'\\=\\[attsc\\=\\['+attr+'\\=\\[(\\w+)\\]\\]\\]\\]\\]\\]\\]');

	} else if (tab) {

		re = new RegExp('sID\\=\\['+sID+'\\=\\['+alias+'\\=\\['+tab+'\\=\\[attst\\=\\['+attr+'\\=\\[(\\w+)\\]\\]\\]\\]\\]\\]');

	}
	results = re.exec(document.DEUS.addTHEME.value);

	if (val == 'SWITCH_YES_NO' && results && results[1] == val2) { val = 'N'; }
	else if (val == 'SWITCH_YES_NO') { val = val2; }
	
//	stringName.length
	
	if (tab && col) {
		ref = 'sID=['+sID+'=['+alias+'=['+tab+'=['+col+'=[attsc=['+attr+'=['+val+']]]]]]]';
	} else if (tab) {
		ref = 'sID=['+sID+'=['+alias+'=['+tab+'=[attst=['+attr+'=['+val+']]]]]]';
	}
	
	var realVal = document.DEUS.addTHEME.value;

	if (results) {
		document.DEUS.addTHEME.value = realVal.replace(re,ref);
	} else {
		if (realVal) {
//			realVal = realVal.substr(0,realVal.length-1);
			document.DEUS.addTHEME.value = realVal+', '+ref;
		} else {
			document.DEUS.addTHEME.value = ref;	
		}
	}
//	window.alert("addTHEME after: "+document.DEUS.addTHEME.value);
}

*/

var switchImages
function switchIconImage(Path,Name) {
	myRe = new RegExp("/pub/SYSTEM/images/formDisplay/icons/"+Name+".gif$");
	eval("if (myRe.exec(document.DEUS.img_"+Path+".src)) "+
		"{ document.DEUS.img_"+Path+".src=\"/pub/SYSTEM/images/formDisplay/icons/"+Name+"_v2.gif\"; }"+ 
		" else { document.DEUS.img_"+Path+".src=\"/pub/SYSTEM/images/formDisplay/icons/"+Name+".gif\"; }"); 
}

/*

// switch location of default and set color
function renderColors(sID,attr) {
	var i = 0;
	var tmp;
	// set table color
	if (document.getElementById('matrix_'+sID).bgColor == eval("DTREE_"+attr+"_"+sID+"_tab")) {
		eval("document.getElementById('matrix_"+sID+"').bgColor = DTREE_DEFCOLORS_"+sID+"_tab");		
	} else {
		eval("document.getElementById('matrix_"+sID+"').bgColor = DTREE_"+attr+"_"+sID+
				"_tab || DTREE_DEFCOLORS_"+sID+"_tab");
	}

	// set column colors
	while (document.getElementById('matrix_'+sID+'__'+i) != null) {
		if (document.getElementById('matrix_'+sID+"__"+i).bgColor == eval("DTREE_"+attr+"_"+sID+"_col["+i+"]")) {
			eval("document.getElementById('matrix_"+sID+"__"+i+"').bgColor = "+
					"DTREE_DEFCOLORS_"+sID+"_col["+i+"]");		
		} else {
			eval("document.getElementById('matrix_"+sID+"__"+i+"').bgColor = "+
					"DTREE_"+attr+"_"+sID+"_col["+i+"] || DTREE_DEFCOLORS_"+sID+"_col["+i+"]");
		}
		i++;
	}

	// set row and values colors
	var i = 0;
	while (document.getElementById('matrix_'+sID+'_'+i) != null) {
		var j = 0;
		if (document.getElementById('matrix_'+sID+"_"+i).bgColor == eval("DTREE_"+attr+"_"+sID+"_row["+i+"]")) {
			eval("document.getElementById('matrix_"+sID+"_"+i+"').bgColor = "+
					"DTREE_DEFCOLORS_"+sID+"_row["+i+"]");
		} else {
			eval("document.getElementById('matrix_"+sID+"_"+i+"').bgColor = "+
					"DTREE_"+attr+"_"+sID+"_row["+i+"] || DTREE_DEFCOLORS_"+sID+"_row["+i+"]");
		}

		while (document.getElementById('matrix_'+sID+'_'+i+'_'+j) != null) {
			if (document.getElementById('matrix_'+sID+"_"+i+"_"+j).bgColor == eval("DTREE_"+attr+"_"+sID+"_val["+i+"]["+j+"]")) {
				eval("document.getElementById('matrix_"+sID+"_"+i+"_"+j+"').bgColor = "+
						"DTREE_DEFCOLORS_"+sID+"_val["+i+"]["+j+"]");
			} else {
				eval("document.getElementById('matrix_"+sID+"_"+i+"_"+j+"').bgColor = "+
						"DTREE_"+attr+"_"+sID+"_val["+i+"]["+j+"] || DTREE_DEFCOLORS_"+sID+"_val["+i+"]["+j+"]");
			}
			j++;
		}
		i++;
	}
}
*/

function switchIcon(Path,val) {
	
	var i = 1;
	while (document.getElementById('switch_'+Path+'-'+i)) {
		if	(document.getElementById('switch_'+Path+'-'+i).style.display=='none') {
			document.getElementById('switch_'+Path+'-'+i).style.display='inline';	

		} else if (document.getElementById('switch_'+Path+'-'+i).style.display=='inline') {
			document.getElementById('switch_'+Path+'-'+i).style.display='none';

		} else if (val == 'block') {
			document.getElementById('switch_'+Path+'-'+i).style.display='inline';

		} else if (val == 'none') {
			document.getElementById('switch_'+Path+'-'+i).style.display='none';

		} else {		
			document.getElementById('switch_'+Path+'-'+i).style.display='inline';
		}
		i++;
	}
}


// open up a new window
var setWin;
function newWin(path,width,height,ref) {
	setWin = window.open(path,(ref || "win"+Math.round(Math.random()*100)),
			'toolbar=no,scrollbars=yes,'+
			'resizable=yes,width='+width+',height='+height);
	// make sure this window is the opener
	setWin.opener = self;
	setWin.focus();
//	window.document.name = Math.round(Math.random()*1000);
//	setWin.opener.name = window.document.name;
}

// open a window displaying the info of a post
function infoWin(table,id) {
	newWin('','440','500','info');
	transmitPost('table='+table+'&id='+id,'info.cgi','info');
}

// open a window displaying the administration of a post
function adminWin(table, id, original_table, current_window) {
	if (original_table) id = id+"&original_table="+original_table;
	if (current_window) {
		transmitPost('table='+table+'&id='+id,'info_admin.cgi');
	} else {
		newWin('','440','500','info_admin');
//		window.open('','info_admin','scrollbars=yes,toolbar=no,width=440,height=500,resizable=yes');
		transmitPost('table='+table+'&id='+id,'info2.cgi','info_admin');
	}
}

// open a window displaying the administration of a post
function loginWin(params) {
	newWin('','300','250','login');
	transmitPost(params,'','login');
}


function searchWin(FD_table,operation,origin,table) {
	newWin('','750','600','searchWindow');
	update = '_FD_table='+FD_table+'&_FD_operation='+operation+'&_FD_origin='+origin;
	if (table) update += '&table='+table;
	transmitPost(update,'search.cgi','searchWindow');
}

function printWin(PRINT_table) {
	newWin('','750','600','printWindow');
	transmitPost('_PRINT_table='+PRINT_table,'print.cgi','printWindow');
}


// call the search function || list function || multiply edit function
/*
function to_search (table,find_operation,find_table,origin) {
	open('',operation+'Window','toolbar=no,scrollbars=yes,width=750,height=600,resizable');
	
	
	transmit_unSubmitted('search.cgi',operation+'Window');
	document.transmitForm.table.value = table;
	document.transmitForm._FD_table.value = find_table;
	document.transmitForm._FD_origin.value = origin;
	document.transmitForm._FD_operation.value = find_operation;
	document.transmitForm.submit();
}
*/

// a counter that keeps track of what the next invert version will be
function invert(table) {
	for (k=0; k<document.forms.length; k++) {
		for (i=0; i < eval("document.forms["+k+"].length"); i++) {
			if (document.forms[k].elements[i].name == '_FD_invert_'+table) {
				if (document.forms[k].elements[i].value == '1') {
					document.forms[k].elements[i].value = '0';
				} else {
					document.forms[k].elements[i].value = '1';
				}
				break;
			}
		}
	}
}

// gather together all parameters located at the form 'myform' to a string 
// name=value&name2=value2...
function gather_params() {
	if (document.myform.insert) {
		document.myform.insert.value = '0';
	}
	var paramlist = '';
	for (i=0; i<document.myform.length; i++) {
		// eliminate harmfull insert values
		if (document.myform.elements[i].name == "insert") continue;
		// ignore unselected checkboxes
		if (document.myform.elements[i].type == "checkbox" && document.myform.elements[i].checked == false) continue;
		// ignore nameless objects, like a submit button
		if (document.myform.elements[i].name == "") continue;
		paramlist += '&' +  document.myform.elements[i].name + '=' + (convert_to_parameter(document.myform.elements[i].value || ''));
	}
	return (paramlist);
}

// gather together all parameters located at the form $form to a string 
// name=value&name2=value2...

function convert_to_parameter(string) {
	var new_string = '';
	for (var i=0; i<string.length; i++) {
		ascii = string.charCodeAt(i);
		if (ascii == 10 || ascii == 13) {
			new_string += "%0D%0A";
		} else if (ascii == 32) {
			new_string += "%20";
		} else if (ascii == 42 || ascii == 45 || ascii == 46 || (47 < ascii && ascii < 58) || (63 < ascii && ascii < 91) || ascii == 95 || (96 < ascii && ascii < 123)) {
			new_string += string.charAt(i);
		} else {
//			alert("set strange ascii:"+string.charAt(i));
			new_string += escape(string.charAt(i)); // uc(sprintf("%lx", ascii));
//			alert("result:"+new_string);
		}
	}
	return (new_string);
}

/*
function warnUnselectedList(form) {
	var match = /_FD__\w+:\w+_check/;
	for (i = 0; i < document.myform.length; i++) {
		if (match.exec(document.myform.elements[i].name)) {
			if (document.myform.elements[i].checked == true) { return true; }
		}
	}
	alert('You must select at least one checkbox');
}

function warnUnselectedList(form, version) {
	var match;

	if (version == "search")
		match = /_FD__\w+:\w+_check/;
	else
		match = /\w+:SELECT:/;

	for (k=0; k<document.forms.length; k++) {
		for (i=0; i < eval("document.forms["+k+"].length"); i++) {
			if (match.exec(document.forms[k].elements[i].name)) {
				if (document.forms[k].elements[i].checked == true) { return true; }
			}
		}
	}
	alert('You must select at least one checkbox');
}

*/

function warnNoSel(text) {
	var match = new RegExp('\;\#\;sel$');	
	for (k=0; k<document.forms.length; k++) {
		for (i=0; i < eval("document.forms["+k+"].length"); i++) {
			if (match.exec(document.forms[k].elements[i].name)) {
				if (document.forms[k].elements[i].checked == true) { return true; }
			}
		}
	}
	alert(text);
}

var mode = new Array();
function select_all(vers,p1,p2) {
	var ma;
	if (vers == "day.cgi") ma = new RegExp("type"+p1+"_obj");
	else ma = /REM_LIST_TAB_\w+_OBJ_\d+/;

	for (k=0; k<document.forms.length; k++) {
		for (i=0; i < eval("document.forms["+k+"].length"); i++) {
			// ignore nameless objects, like a submit button
			if (ma.exec(document.forms[k].elements[i].name)) {
				if (mode[k] == true) {
					document.forms[k].elements[i].checked = true;
				} else {
					document.forms[k].elements[i].checked = false;
				}
			}
		}
		if (mode[k] == false) { mode[k] = true; } else { mode[k] = false; }
	}
}

function selMultCheck(pre,id) {
	var oElm = getMultElementsByPartID(document.documentElement,"input",pre+id);
	var checked = 0;
	for (m=0; m<oElm.length; m++) {
		if (oElm[m].type == 'checkbox') {
			if (checked == 0) {	// use first box to declare initial state
				if (oElm[m].checked == true) { checked = 2; }
				else { checked = 1; }
			}
			if (checked == 1 && oElm[m].checked == false) {
				oElm[m].click();	// row is not selected, we select it
			} else if (checked == 2 && oElm[m].checked == true) { 
				oElm[m].click();	// row is selected, we deselect it
			}
		}
	}
}



var selMode = new Array();
function selOpt(match) {
	var ma = new RegExp(match);
	for (k=0; k<document.forms.length; k++) {
		if (selMode[k] == false) selMode[k] = true; else selMode[k] = false;
		for (i=0; i < eval("document.forms["+k+"].length"); i++) {
			// ignore nameless objects, like a submit button
			if (ma.exec(document.forms[k].elements[i].name)) {
				if (selMode[k] == false) document.forms[k].elements[i].checked = true;
				else document.forms[k].elements[i].checked = false;
			}
		}
	}
}

function gather_params_glob() {

	var paramlist = '';
	for (k=0; k<document.forms.length; k++) {
		// remove harmfull parameter
//		if (eval("document.forms["+k+"].insert")) eval("document.forms["+k+"].insert.value = '0'");
//		if (eval("document.forms["+k+"].refreshed")) eval("document.forms["+k+"].refreshed.value = '0'");
		for (i=0; i < eval("document.forms["+k+"].length"); i++) {
			// eliminate harmfull insert values
			if (eval("document.forms["+k+"].elements["+i+"].name") == "insert") continue;
			// ignore unselected checkboxes
			if (eval("document.forms["+k+"].elements["+i+"].type") == "checkbox" && eval("document.forms["+k+"].elements[i].checked") == false) continue;			
			// ignore nameless objects, like a submit button
			if (eval("document.forms["+k+"].elements["+i+"].name") == "") continue;
			paramlist += '&' +  eval("document.forms["+k+"].elements["+i+"].name") + '=' + (convert_to_parameter(eval("document.forms["+k+"].elements["+i+"].value")) || '');
		}
	}	
	return (paramlist);
}

function refresh() {
	goTo_target(gather_params_glob());
}	

// eliminate strange non ascii input in textareas
function decode_text() {
	for (k=0; k<document.forms.length; k++) {
		for (i=0; i < eval("document.forms["+k+"].length"); i++) {
			if (document.forms[k].elements[i].type == "Textarea") {
				eval("document.forms["+k+"].elements["+i+"].name") + '=' + (convert_to_parameter(eval("document.forms["+k+"].elements["+i+"].value")) || '');
			}
		}
	}	
}

// prompt a warning window to be confirmed
function removewarning(question) {
	if (confirm(question)) return 1;
}

function warn(question) {
	if (confirm(question)) return true;
	return false;
}


/*
function change_pass35(id,table) {
	 adminWin(table, id+'&change_pass=start');
}
*/

// add a waggon entry to the present form
function waggon_entry(parameter) {
	if (document.myform.insert) {
		document.myform.insert.value = '0';
	}
	for (i = 0; i < document.myform.length; i++) {
		if (document.myform.elements[i].name == parameter) {
			document.myform.elements[i].value = '1';
		}
	}
	document.myform.submit();
}



//        -------- TRANSMIT DATA -------------


function gather_params_glob_all () {

	var paramlist = '';
	for (k=0; k<document.forms.length; k++) {
		// skip the transmit form itself
		if ( eval("document.forms["+k+"].name") == "transmitForm") continue;
		for (i=0; i < eval("document.forms["+k+"].length"); i++) {
			// ignore nameless objects, like a submit button
			if (eval("document.forms["+k+"].elements["+i+"].name") == "") continue;
			// unselected checkboxes is set to ''
			var value = eval("document.forms["+k+"].elements["+i+"].value");
			if (eval("document.forms["+k+"].elements["+i+"].type") == "checkbox" && 
					eval("document.forms["+k+"].elements[i].checked") == false) value = '';
			paramlist += '&' +  eval("document.forms["+k+"].elements["+i+"].name") + '=' + 
					(convert_to_parameter(value) || '');
		}
	}	
	return (paramlist);
}

function write_transmit () {
	document.writeln('<form name="transmitForm" method="post" action="">');
	
	var exists = new Array(); 

	for (k=0; k<document.forms.length; k++) {
//		alert("loop -> "+eval("document.forms["+k+"].name")+" == "+ eval("document.transmitForm.name"));
		if ( eval("document.forms["+k+"].name") == eval("document.transmitForm.name")) continue;
		for (i=0; i < eval("document.forms["+k+"].length"); i++) {
			if (eval("document.forms["+k+"].elements["+i+"].name") == "") continue;

			// test if the field already exists, copies are baaad!
			if (exists[eval("document.forms["+k+"].elements["+i+"].name")]) {
				continue;
			} else {
				exists[eval("document.forms["+k+"].elements["+i+"].name")] = true;
			}

			// write inputfield
			document.writeln('<input type="hidden" name="'+
					eval("document.forms["+k+"].elements["+i+"].name")+'" value="" />');
		}
	}
	document.writeln('</form>');
}









function transmit (inAction,inTarget) {

	if (!document.transmitForm) alert('No transmitForm found!!');
	if (inTarget) document.transmitForm.target = inTarget;
	if (inAction) document.transmitForm.action = inAction;

	parameters = gather_params_glob_all().split('&');
	var parameter; var exists = 0;
	for (k=0; k<document.transmitForm.length; k++) {

/*		match = new RegExp(parameter[0]+"=(.*)(?=&|)");
		// w+)\((.*?)(?<!\\)\)/
		var match = //g;
myArray = myRe.exec("cdbbdbsbz");
var match = /_FD__\w+:\w+_check/;
		for (i = 0; i < document.myform.length; i++) {
		if (match.exec(document.myform.elements[i].name)) {
*/

		for (i=0; i<parameters.length; i++) {
			parameter = parameters[i].split('=');
			if (parameter[0] == eval("document.transmitForm.elements["+k+"].name")) {
				exists = 1; break;
			}
		}
		if (exists == 0) continue;
/*		if (eval("document.transmitForm.elements["+k+"].type") == "checkbox" && 
				eval("document.transmitForm.elements["+k+"].checked") == false)
				eval("document.transmitForm.elements["+k+"].value = ''");			
*/

//		alert("DATA : " + eval("document.transmitForm.elements["+k+"].name") + "=" + 
//				eval("document.transmitForm.elements["+k+"].value") + " SET : "+parameter[0]+"="+parameter[1]);
//		eval("document.transmitForm."+parameter[0]+".value = '"+parameter[1]+"'");

		eval("document.transmitForm.elements["+k+"].value = '"+parameter[1]+"'");
	}
	document.transmitForm.submit();
}



function transmit_unSubmitted (inAction,inTarget) {

	if (!document.transmitForm) alert('No transmitForm found!!');
	if (inTarget) document.transmitForm.target = inTarget;
	if (inAction) document.transmitForm.action = inAction;

	parameters = gather_params_glob_all().split('&');
	var parameter; var exists = 0;
	for (k=0; k<document.transmitForm.length; k++) {
		for (i=0; i<parameters.length; i++) {
			parameter = parameters[i].split('=');
			if (parameter[0] == eval("document.transmitForm.elements["+k+"].name")) {
				exists = 1; break;
			}
		}
		if (exists == 0) continue;
		eval("document.transmitForm.elements["+k+"].value = '"+parameter[1]+"'");
	}
}


/* --------------------------------------------------------

 	function that submits the data
 	inUpdate = additional parameters set to the transform form
 			syntax: name=value&name2=value2..
 	inAction = form's action tag (the script the page is targeting)
 	inTarget = form's target tag (the window the page is targeting)
 			
 	POST-call: transmitPost() 
 	GET-call: goTo_target(gather_params_glob()) 

--------------------------------------------------------  */ 



function transmitPost (inUpdate,inAction,inTarget) {

	// add operations information, this can make harm if a user return to the page or
	// the operation opens a new window and the user keep working with the opener
	// we must reset the value after submission in the end
	var old_param = new Array();
	if (inUpdate) {
		var match = /^(.*?)=(.*)/;
		parameters = inUpdate.split('&');
		for (i=0; i<parameters.length; i++) {
			parameter = match.exec(parameters[i]);
			// save old value
			old_param[i] = document.DEUS.elements[parameter[1]].value;
			document.DEUS.elements[parameter[1]].value = parameter[2];
		}
	}

	if (inTarget == 'windowOpener' && self.opener) {
		document.DEUS.target = self.opener.name;

	} else if (inTarget && inTarget != 'windowOpener') {
		document.DEUS.target = inTarget;

	} else {
		document.DEUS.target = '_parent';
	}
	

	if (inAction) document.DEUS.action = inAction;
	else document.DEUS.action = '';

	if (OB) document.DEUS.action = document.DEUS.action+'#'+OB;
	
	// execute
	document.DEUS.method = 'POST';
	document.DEUS.submit();

	// revert changed hidden values (or they will remain)
	if (inUpdate) {
		var match = /^(.*?)=(.*)/;
		parameters = inUpdate.split('&');
		for (i=0; i<parameters.length; i++) {
			parameter = match.exec(parameters[i]);
			// raise old value
			document.DEUS.elements[parameter[1]].value = old_param[i];
		}
	}
	if (inTarget == 'windowOpener' && self.opener) {
		setTimeout("self.close()", 1000);	// bug in safari (mac) it closes before done with submit.
	}

}






function transmitPost_old (inUpdate,inAction,inTarget) {


//	alert('enter transmitPost');
	if (!document.transmitForm) alert('No transmitForm found!!');
	var testloop = 2;
	var formToSubmit;
	if (document.forms.length == 2) {
		// we got just one actual form, we print it and ignore the timewaste of copy
		formToSubmit = "forms[0]";
//		alert('Just one form, set forms[0]');

//		for (k=0; k<document.forms.length; k++) {
	//		if ( eval("document.forms["+k+"].name") == eval("document.transmitForm.name")) continue;
//		}
	} else {

		// we got many forms, we copy them to transmitForm
 		formToSubmit = "transmitForm";
//		alert("ALERT: "+eval("document.myform.elements[\"object\"].value"));
 		for (k=0; k<document.forms.length; k++) {
// 			alert("many forms: FORM ["+k+"] "+eval("document.forms["+k+"].name"));
			if ( eval("document.forms["+k+"].name") == eval("document.transmitForm.name")) continue;
			for (i=0; i < eval("document.forms["+k+"].length"); i++) {
				if (eval("document.forms["+k+"].elements["+i+"].name") == "") continue;
				// remove nasty checkboxes
				var value = eval("document.forms["+k+"].elements["+i+"].value");
				if (eval("document.forms["+k+"].elements["+i+"].type") == "checkbox" && 
						eval("document.forms["+k+"].elements["+i+"].checked") == false) value = '';
/*
				alert(eval("document.forms["+k+"].name")+ ":"+eval("document.forms["+k+"].elements["+i+"].name") +  "  -> " + value + " != " + 
						eval("document.transmitForm.elements[\"" +
						eval("document.forms["+k+"].elements["+i+"].name") + "\"].value"));
*/
/*				if (i < testloop) {

//				}
*/					
				// test if update is made
				if (value != eval("document.transmitForm.elements[\""+
						eval("document.forms["+k+"].elements["+i+"].name") + "\"].value")) {
		
					// set values to current state at transmitForm
					eval("document.transmitForm.elements[\"" + eval("document.forms["+k+"].elements["+i+"].name") + 
							"\"].value" + ' = \'' + (convert_to_parameter(value) || '')+'\'');
	
/*					if (i < testloop) {

					alert('make update...  '+eval("document.transmitForm.elements[\"" + 
							eval("document.forms["+k+"].elements["+i+"].name") + "\"].value"));

					}
*/
				}
			}
		}
	}
	
	// add operations information, this can make harm if a user return to the page or
	// the operation opens a new window and the user keep working with the opener
	// we must reset the value after submission in the end
//	var memory = new Array();
	if (inUpdate) {
		var match = /^(.*?)=(.*)/;
		parameters = inUpdate.split('&');
		for (i=0; i<parameters.length; i++) {
			parameter = match.exec(parameters[i]);
//			parameter = parameters[i].split('=');
//			alert('UPDATE '+parameter[0]+' = '+parameter[1]);
			eval("document."+formToSubmit+".elements[\""+parameter[1]+"\"].value = '"+parameter[2]+"'");
		}
	}

//	alert("processing form: "+formToSubmit);
//	alert(eval("document."+formToSubmit+".elements[\"_FD_table\"].value"));

	if (inTarget == 'windowOpener') {
		var var_targ;
		var_targ = Math.floor(Math.random() * 9999);
		self.opener.name = var_targ;
		eval("document."+formToSubmit+".target = '"+var_targ+"'");

	} else if (inTarget) {
		eval("document."+formToSubmit+".target = '"+inTarget+"'");

	} else {
		eval("document."+formToSubmit+".target = '_parent'");

	}




	if (inAction) {
		eval("document."+formToSubmit+".action = '"+inAction+"'");
	} else {
		eval("document."+formToSubmit+".action = ''");
	}
	eval("document."+formToSubmit+".method = 'POST'");

	// execute
	eval("document."+formToSubmit+".submit()");
}









/* ----------------- BELOW FOLLOWS SCRIPTS BOUND TO THE SHORTCUTS ----------------- */



var selVals; var selRows; var selCols; var selObj;
function countSelected() {

	selVals = 0; 
	selRows = 0;
	selCols = 0;
	selObjs = 0;

	var valMatch = new RegExp('^checkVal_');	
	var rowMatch = new RegExp('^checkRow_');	
	var colMatch = new RegExp('^checkCol_');
	var objMatch = new RegExp('^checkObj_');

	for (k=0; k<document.forms.length; k++) {
		for (i=0; i < eval("document.forms["+k+"].length"); i++) {
			if (document.forms[k].elements[i].checked == true) {
				if (valMatch.exec(document.forms[k].elements[i].name)) { 				
					selVals++;
				} else if (rowMatch.exec(document.forms[k].elements[i].name)) {
					selRows++;
				} else if (colMatch.exec(document.forms[k].elements[i].name)) { 
					selCols++;
				} else if (objMatch.exec(document.forms[k].elements[i].name)) { 
					selObjs++;
				}
			}
		}
	}
}




function dispWaitTxt(inp) {
	if (document.getElementById('waitWin_'+inp)) {
		document.getElementById('waitWin_'+inp).style.display = 'block';
	}
}

function ask(msg,def) {
	return window.prompt(msg,def);
}






var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}



// ###### AJAX FOLLOW BELOW ###############
function makeRequest(url,span) {
	url = '?'+url+'&'+URL;
	var http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = function() {
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				
				// create expansion div element (needed for explorer to not freak out)
				var container = document.getElementById('hierbox_'+span);

				// find tagname
				var tagName = container.tagName.toLowerCase(); 

 				result = http_request.responseText;
				
				// if tr is the tagname we must create it by DOM, not simply inserting.
				if (tagName == 'tr') {
					var p = document.createElement('div');
					p.innerHTML = '<table><tbody><tr>' + result + '</tr></tbody></table>';
		           	try {
						container.appendChild(p.childNodes[0].childNodes[0].childNodes[0]);
	    	        } catch (e) {
	        	    	alert("failed to appendChild --- hierbox_"+span+' + '+container.id);
	            	}
				} else {

		           	try {
		            	container.innerHTML = result;
	    	        } catch (e) {
	        	    	alert("failed to locate hierbox_"+span+' + '+container.id);
	            	}
	            }
	           	try {
					document.getElementById('hierload_'+span).style.display = 'none';
	            } catch (e) {
	            	alert("failed to locate hierload_"+span);
	            }

            } else {
				alert('There was a problem with the request.');
			}
		}
	};
	http_request.open('GET', url, true);
	http_request.send(null);

}





var fullFrameV = new Array();
function fullFrameView(id) {
	var block = getMultElementsByPartID(document.documentElement,"TABLE",id);

	if (fullFrameV[id]) {
		document.getElementById('addSpace').style.display = 'none';
		fullFrameV[id].appendChild(block[0]);
		document.getElementById('mainSpace').style.display = 'block';
		fullFrameV[id] = 0;
	
		// add menu system
		if (document.getElementById('s_c1')) document.getElementById('s_m1').style.display = 'inline'; 
		if (document.getElementById('s_c2')) document.getElementById('s_m2').style.display = 'inline'; 
		if (document.getElementById('s_c3')) document.getElementById('s_m3').style.display = 'inline'; 
		if (document.getElementById('s_m4')) document.getElementById('s_m4').style.display = 'inline'; 
		if (document.getElementById('s_m5')) document.getElementById('s_m5').style.display = 'inline'; 
		if (document.getElementById('s_m6')) document.getElementById('s_m6').style.display = 'inline'; 
		if (document.getElementById('s_m7')) document.getElementById('s_m7').style.display = 'inline'; 
		if (document.getElementById('s_m8')) document.getElementById('s_m8').style.display = 'inline'; 
		if (document.getElementById('s_m9')) document.getElementById('s_m9').style.display = 'inline'; 
		if (document.getElementById('s_m10')) document.getElementById('s_m10').style.display = 'inline'; 
		if (document.getElementById('s_m11')) document.getElementById('s_m11').style.display = 'inline'; 
		if (document.getElementById('s_m12')) document.getElementById('s_m12').style.display = 'inline'; 
		if (document.getElementById('s_m13')) document.getElementById('s_m13').style.display = 'inline'; 

	} else {
	
		fullFrameV[id] = block[0].parentNode;
		document.getElementById('mainSpace').style.display = 'none';
		document.getElementById('addSpace').style.display = 'block';
		document.getElementById('addSpace').appendChild(block[0]);

		// remove menu system
		if (document.getElementById('s_m1')) document.getElementById('s_m1').style.display = 'none'; 
		if (document.getElementById('s_m2')) document.getElementById('s_m2').style.display = 'none'; 
		if (document.getElementById('s_m3')) document.getElementById('s_m3').style.display = 'none'; 
		if (document.getElementById('s_m4')) document.getElementById('s_m4').style.display = 'none'; 
		if (document.getElementById('s_m5')) document.getElementById('s_m5').style.display = 'none'; 
		if (document.getElementById('s_m6')) document.getElementById('s_m6').style.display = 'none'; 
		if (document.getElementById('s_m7')) document.getElementById('s_m7').style.display = 'none'; 
		if (document.getElementById('s_m8')) document.getElementById('s_m8').style.display = 'none'; 
		if (document.getElementById('s_m9')) document.getElementById('s_m9').style.display = 'none'; 
		if (document.getElementById('s_m10')) document.getElementById('s_m10').style.display = 'none'; 
		if (document.getElementById('s_m11')) document.getElementById('s_m11').style.display = 'none'; 
		if (document.getElementById('s_m12')) document.getElementById('s_m12').style.display = 'none'; 
		if (document.getElementById('s_m13')) document.getElementById('s_m13').style.display = 'none'; 
	
	}

}

function getMultElementsByPartID(oElm, strTagName, regexID, matchkey) {
	var tagNames = strTagName.split(',');
	var arrReturnElements = new Array();
    for(var z=0; z<tagNames.length; z++){
    	strTagName = tagNames[z];
	    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	    var regExp = new RegExp(regexID);

	    for(var i=0; i<arrElements.length; i++){
	        if (matchkey == 'name' && regExp.test(arrElements[i].name)){
	            arrReturnElements.push(arrElements[i]);
    	    } else if (regExp.test(arrElements[i].id)){
	            arrReturnElements.push(arrElements[i]);
    	    }
    	}
    }
    return (arrReturnElements)
}

// box_title_TR_DEUS_c1m1a_A_c1m1a_capewhite_c1m1a_A_c1m1a_www_c1m1a_A_c1m1a_s116429649826030_c1m1a_A_c1m1a_mainframe_c1m1a_A_c1m1a__a2t2r__c1m1a_obexp-64798

function cleanNonNumericValues(oElm) {
	oElm.value = oElm.value.replace(/\D/g,'');
}


var indications = new Array();
function indicateRow(path, oper) {
	if (oper == 'forceZero') {
		indications[path] = 1;
	}
	
	
	if (!indications[path] && document.getElementById(path)) {
		document.getElementById(path).style.backgroundColor="#EEEEEE";
		document.getElementById(path).style.border="solid thin red";
		indications[path] = 1;

	} else if (indications[path] && document.getElementById(path)) {
		document.getElementById(path).style.backgroundColor="";
		document.getElementById(path).style.border="";	
		indications[path] = 0;
	}

}

var ONLOAD_SYNTAX = '';
function onResizeFnc() {
//	alert('onloadsyntax:'+ONLOAD_SYNTAX);
	if (window.ONLOAD_SYNTAX) {
		eval(ONLOAD_SYNTAX);
	}
}


var colorChart = new Array(); var colorChartORI = new Array(); 
var colorChart_onOff;
function setColor(bref,mode) {
//	alert('bref = '+bref);
	var bref2 = convCommaReverse(bref);
//	alert('bref2 = '+bref2);

	var oElm = getMultElementsByPartID(document.documentElement,"TD","indic_"+bref2);
	for (m=0; m<oElm.length; m++) {
//		alert("found oElm "+oElm[m].id + " color: "+colorChart[oElm[m].id][mode]);
		if (colorChart_onOff == 'on') {
			oElm[m].style.backgroundColor = colorChartORI[oElm[m].id];
		} else {
			colorChartORI[oElm[m].id] = oElm[m].style.backgroundColor;
			oElm[m].style.backgroundColor = colorChart[oElm[m].id][mode];
		}
	}
	if (colorChart_onOff == 'on') { colorChart_onOff = 'off'; }	
	else { colorChart_onOff = 'on'; }
}



function convComma(data) {
	var arr = data.split('_c1m1a_');
	data = arr.join(';');
	var arr = data.split('_a2t2r_');
	return arr.join('#');
}

function convCommaReverse(data) {
	var arr = data.split(';');
	data = arr.join('_c1m1a_');
	var arr = data.split('#');
	return arr.join('_a2t2r_');
}

var toggleCategorizedRowsDONE = new Array(); 
function toggleCategorizedRows(key,ref) {

	var oElm = getMultElementsByPartID(document.documentElement,"TR",key);
	for (m=0; m<oElm.length; m++) {
		if (toggleCategorizedRowsDONE[key]) {
			oElm[m].style.display = 'none';
			var imgElm = document.getElementById("hierimg_"+ref+'_'+key);
			imgElm.src = '/pub/SYSTEM/images/formDisplay/arrows/a_arr_red_right.gif';		
		} else {
			oElm[m].style.display = '';
			var imgElm = document.getElementById("hierimg_"+ref+'_'+key);
			imgElm.src = '/pub/SYSTEM/images/formDisplay/arrows/a_arr_red_down.gif';		
		}
	}

	if (toggleCategorizedRowsDONE[key]) { toggleCategorizedRowsDONE[key] = 0;
	} else { toggleCategorizedRowsDONE[key] = 1; }

}


function setEmail(name,loc,dom) { document.write(name+'@'+loc+'.'+dom); }

function setImgGalleryCategory(x) {
	var m = 0;
	while (1) {
		m++;
		if (document.getElementById(m)) { 
			document.getElementById(m).style.background = '#444';
			document.getElementById(m).style.border = '2px solid white';
			document.getElementById('block'+m).style.display = 'none';
		} else { break; }
	}
//	document.getElementById(x.id).style.background = '#222';
	document.getElementById(x.id).style.borderBottom = '0px solid white';
	document.getElementById(x.id).style.background = 'yellow url(\'/pub/SYSTEM/images/black50proc_dotted.gif\') repeat right top';
	document.getElementById('block'+x.id).style.display = 'block';


}

function printHiddenInput(iOB,iTA,iCO,iRO,iAT,iDA) {

	// render input
	if (SI) { document.write('<input type="HIDDEN" name="'+DO+CMA+DO_AL+CMA+SE+CMA+SE_AL+CMA+SI+CMA+SI_AL+CMA);
		if (PA) { document.write(PA+CMA+PA_AL+CMA)
			if (iOB) { document.write(iOB+CMA+OB_AL+CMA);
				if (iTA) { document.write(iTA+CMA+TA_AL+CMA);
					if (iCO) { document.write(iCO+CMA+CO_AL+CMA);
						if (iRO) { document.write(iRO+CMA+RO_AL+CMA);
						}
					}
				}
			}
		}
	}
	if (iAT) document.write(ATR+CMA+iAT);
	document.write('" value="');
	if (iAT && iDA) document.write(iDA);
	document.write('" />');
}
