function wd_PickupRecs(sText, sRecStart, sRecFin) {
	var arrAnswer=new Array();
	//
	var iCntr=0;
	var iRecStart=0; var iRecFin=0;
	while (iRecStart!==-1 && iRecFin!==-1) {
		iRecStart=sText.indexOf(sRecStart, iRecFin);
		if (iRecStart!==-1) {
			iRecFin=sText.indexOf(sRecFin, iRecStart);
			if (iRecFin!==-1) {
				var sRec=sText.substring(iRecStart, iRecFin);
				if (sRec.length) {
					var sHash=new Date().valueOf()+'_'+(iCntr++);
					arrAnswer[sHash]=sRec;
				}
			}
		}
	}
	//
	return arrAnswer;
}
function wd_PickupWDRecs(sText, sRecStart, sRecFin, sTpl) {
	var arrAnswer=new Array();
	//
	var iRecStart=0; var iRecFin=0;
	while (iRecStart!==-1 && iRecFin!==-1) {
		iRecStart=sText.indexOf(sRecStart, iRecFin);
		if (iRecStart!==-1) {
			iRecFin=sText.indexOf(sRecFin, iRecStart);
			if (iRecFin!==-1) {
				var sRec=sText.substring(iRecStart+sRecStart.length, iRecFin); // 10 = 'error rec '.length
				var arrRec=sRec.split('::');
				var sHash=arrRec[0];
				if (typeof(arrAnswer[sHash])==='undefined') {
					var i=0;
					var sRecord=sTpl;
					for (i=0; i<arrRec.length; i++) {
						var re = new RegExp("%"+i+"%","gm");
						sRecord=sRecord.replace(re, arrRec[i]);
						// float
						var re_f = new RegExp("%f"+i+"%","gm");
						sRecord=sRecord.replace(re_f, parseFloat(arrRec[i].replace(',', '.')));
						// int
						var re_i = new RegExp("%i"+i+"%","gm");
						sRecord=sRecord.replace(re_i, parseInt(arrRec[i]));
					}
					arrAnswer[sHash]=sRecord;
				}
			}
		}
	}
	//
	return arrAnswer;
}
// ==== MS DHTML ===============================================================
function absLeft(theEl) {
	var arrPosition=wd_AbsPos(theEl, document.body);
	return arrPosition[0];
	//
	var x=0;
	while (theEl.offsetParent) {
		x+=theEl.offsetLeft;
		theEl=theEl.offsetParent;
		if (theEl&&theEl.scrollLeft) x-=theEl.scrollLeft;
	}
	if (document.body) x+=document.body.scrollLeft;
	return x;
}
function absTop(theEl) {
	var arrPosition=wd_AbsPos(theEl, document.body);
	return arrPosition[1];
	//
	var y=0;
	while (theEl.offsetParent) {
		y+=theEl.offsetTop;
		theEl=theEl.offsetParent;
		if (theEl&&theEl.scrollTop) y-=theEl.scrollTop;
	}
	if (document.body) y+=document.body.scrollTop;
	return y;
}
function wd_AbsPos(theObj, theCeilObj) {
	if (!theCeilObj) var theCeilObj=null;
	var arrAnswer=new Array();
/*
	0,1				2,1
	-----------------
	|				|
	|				|
	|		x		|
	|				|
	|				|
	-----------------
	0,3				2,3
*/
	arrAnswer[0]=0;
	arrAnswer[1]=0;
	arrAnswer[2]=theObj.offsetWidth;
	arrAnswer[3]=theObj.offsetHeight;
	while (theObj.offsetParent && theObj!==theCeilObj) {
		arrAnswer[0]+=theObj.offsetLeft;
		if (theObj.scrollLeft) arrAnswer[0]-=theObj.scrollLeft;
		arrAnswer[1]+=theObj.offsetTop;
		if (theObj.scrollTop) arrAnswer[1]-=theObj.scrollTop;
		theObj=theObj.offsetParent;
	}
	arrAnswer[2]+=arrAnswer[0];
	arrAnswer[3]+=arrAnswer[1];
	return arrAnswer;
}
function wd_IsAncestor(theObj, theMbAncestor) {
	var bAnswer=false;
	if (theObj===theMbAncestor) {
		bAnswer=true;
	} else if (theObj && theMbAncestor) {
		while (theObj.offsetParent) {
			theObj=theObj.offsetParent;
			if (theObj===theMbAncestor) {
				bAnswer=true;
				break;
			}
		}
	}
	return bAnswer;
}
function wd_ClimbToTag(theObj, sTagName) {
	var theObj2=theObj;
	//
	sTagName=sTagName.toUpperCase();
	//
	var sNextTag=theObj2.tagName; if (sNextTag) sNextTag=sNextTag.toUpperCase();
	while (theObj2 && sNextTag!==sTagName && sNextTag!=='BODY' && theObj2.parentNode) {
		theObj2=theObj2.parentNode;
		//
		sNextTag=theObj2.tagName; if (sNextTag) sNextTag=sNextTag.toUpperCase();
	}
	return theObj2;
}

function wd_ClimbToAttr(theObj, sAttrName) {
	var theObj2=theObj;
	//
	var sNextAttrType=eval("typeof(theObj2."+sAttrName+");");
	while (theObj2 && sNextAttrType==='undefined' && theObj2.tagName.toUpperCase()!=='BODY' && theObj2.parentNode) {
		theObj2=theObj2.parentNode;
		//
		sNextAttrType=eval("typeof(theObj2."+sAttrName+");");
	}
	return theObj2;
}

function wd_CallHelpNote(e) {
	if (top && top.wd_ReqHelpNote) {
		var sIdx="";
		var theObj=event.toElement;
		var theIdxObj=wd_ClimbToAttr(theObj, 'wdhlpidx');
		if (typeof(theIdxObj.wdhlpidx)!=='undefined') sIdx=theIdxObj.wdhlpidx;
		top.wd_ReqHelpNote(theIdxObj.wdhlpidx, WD_LOCALE, WD_MODULE);
	}
	//
	return true;
}

function wd_SetHelpNote(e) {
	if (event.ctrlKey && event.altKey) {
		var theObj=event.srcElement;
		var theIdxObj=wd_ClimbToAttr(theObj, 'wdhlpidx');
		if (theIdxObj.wdhlpidx) {
			amg_ModalWin('/webdirector/smdl_hlp/shell/hnote.php?module='+WD_MODULE+'&locale='+WD_LOCALE+'&idx='+theIdxObj.wdhlpidx+'&act=getall', 901, 691, 'wd_hlpnotes', 0, false, WD_CHARSET, false);
		}
		return false;
	} else {
		return amg_SelectCanc();
	}
}

function wd_IsEl(theNode, sTagName) {
	if (!sTagName) var sTagName='';
	return (theNode && typeof(theNode)!=='undefined' && theNode.nodeType && theNode.nodeType===1 && (!sTagName.length || !theNode.tagName || theNode.tagName.toUpperCase()===sTagName.toUpperCase()));
}

function wd_IsTNode(theNode) {
	return (theNode && typeof(theNode)!=='undefined' && theNode.nodeType && theNode.nodeType===3);
}

var wd_ArrDefNoncontElements=new Array();
wd_ArrDefNoncontElements['BR']=1;
wd_ArrDefNoncontElements['HR']=1;
wd_ArrDefNoncontElements['TR']=1;
wd_ArrDefNoncontElements['TABLE']=1;
wd_ArrDefNoncontElements['THEAD']=1;
wd_ArrDefNoncontElements['TBODY']=1;
wd_ArrDefNoncontElements['TFOOT']=1;
function wd_IsContEl(theNode) {
	return (wd_IsEl(theNode) && typeof(wd_ArrDefNoncontElements[theNode.tagName.toUpperCase()])==='undefined');
}

var wd_ArrDefBlockElements=new Array();
wd_ArrDefBlockElements['ADDRESS']="block";		wd_ArrDefBlockElements['BLOCKQUOTE']="block";
wd_ArrDefBlockElements['BODY']="block";			wd_ArrDefBlockElements['CENTER']="block";
wd_ArrDefBlockElements['COL']="block";			wd_ArrDefBlockElements['COLGROUP']="block";
wd_ArrDefBlockElements['DD']="block";			wd_ArrDefBlockElements['DIR']="block";
wd_ArrDefBlockElements['DIV']="block";			wd_ArrDefBlockElements['DL']="block";
wd_ArrDefBlockElements['DT']="block";			wd_ArrDefBlockElements['FIELDSET']="block";
wd_ArrDefBlockElements['FORM']="block";			wd_ArrDefBlockElements['H1']="block";
wd_ArrDefBlockElements['H2']="block";			wd_ArrDefBlockElements['H3']="block";
wd_ArrDefBlockElements['H4']="block";			wd_ArrDefBlockElements['H5']="block";
wd_ArrDefBlockElements['H6']="block";			wd_ArrDefBlockElements['HR']="block";
wd_ArrDefBlockElements['IFRAME']="block";		wd_ArrDefBlockElements['LEGEND']="block";
wd_ArrDefBlockElements['LI']="list-item";		wd_ArrDefBlockElements['LISTING']="block";
wd_ArrDefBlockElements['MARQUEE']="block";		wd_ArrDefBlockElements['MENU']="block";
wd_ArrDefBlockElements['OL']="block";			wd_ArrDefBlockElements['P']="block";
wd_ArrDefBlockElements['PLAINTEXT']="block";	wd_ArrDefBlockElements['PRE']="block";
wd_ArrDefBlockElements['TABLE']="block";		wd_ArrDefBlockElements['TD']="block";
wd_ArrDefBlockElements['TH']="block";			wd_ArrDefBlockElements['TR']="block";
wd_ArrDefBlockElements['UL']="block";			wd_ArrDefBlockElements['XMP']="block";
function wd_IsBlockEl(theNode) {
	return (wd_IsEl(theNode) && typeof(wd_ArrDefBlockElements[theNode.tagName.toUpperCase()])!=='undefined');
}

function wd_ClimbToBlock(theObj) {
	var theObj2=theObj;
	//
	var sTag=theObj2.tagName; if (sTag) sTag=sTag.toUpperCase();
	var sDisplay=theObj2.style.display;
	var bBlock=(sDisplay==='block' || (!sDisplay && wd_ArrDefBlockElements[sTag]));
	var bNeedClimb=(theObj2 && !bBlock && sTag!=='BODY' && theObj2.parentNode);
	while (bNeedClimb) {
		theObj2=theObj2.parentNode;
		//
		sTag=theObj2.tagName; if (sTag) sTag=sTag.toUpperCase();
		sDisplay=theObj2.style.display;
		bBlock=(sDisplay==='block' || (!sDisplay && wd_ArrDefBlockElements[sTag]));
		bNeedClimb=(theObj2 && !bBlock && sTag!=='BODY' && theObj2.parentNode);
	}
	return theObj2;
}

//function wd_PickupAtoms(theNode) {
//	if (true) {
//		void(0);
//	}
//	var iI=0;
//	var arrChildren=theNode.childNodes;
//}
function wd_PickupContEls(theEl) {
	var arrAnswer=new Array();
	//
	if (theEl.nodeType && theEl.nodeType===1) {
		if (typeof(wd_ArrDefNoncontElements[theEl.tagName.toUpperCase()])==='undefined') {
			//alert("adding "+theEl.tagName);
			arrAnswer[arrAnswer.length]=theEl;
		}
		var iI=0;
		for (iI=0; iI<theEl.childNodes.length; iI++) {
			if (theEl.childNodes(iI).nodeType===1) {
				var arrRecursive=wd_PickupContEls(theEl.childNodes(iI));
				//alert("recursive length: "+arrRecursive.length);
				var iJ=0;
				for (iJ=0; iJ<arrRecursive.length; iJ++) {
					arrAnswer[arrAnswer.length]=arrRecursive[iJ];
				}
				//alert("arrAnswer length: "+arrRecursive.length);
			}
		}
	}
	//
	return arrAnswer;
}
function wd_PickupChain(theNode, theLimitNode, iDirection) {
	var arrAnswer=new Array();
	//
	//if (theNode!==theLimitNode && theNode.parentNode && theNode.parentNode!==theLimitNode && theNode.parentNode!==document) {
	//	arrAnswer[arrAnswer.length]=theNode;
	//}
	while (theNode!==theLimitNode && theNode.parentNode && theNode.parentNode!==theLimitNode && theNode.parentNode!==document) {
		//alert(wd_NodeVal(theNode)+"\n\n"+wd_ClimbToTag(theLimitNode, theNode.tagName)+"\n\n"+(wd_ClimbToTag(theLimitNode, theNode.tagName)===theNode));
		if (!(theNode.nodeType===1 && wd_ClimbToTag(theLimitNode, theNode.tagName)===theNode)) {
			if (iDirection===1) {
				while (theNode.nextSibling && theNode!==theLimitNode && theNode.parentNode!==theLimitNode) {
					theNode=theNode.nextSibling;
					arrAnswer[arrAnswer.length]=theNode;
				}
			} else if (iDirection===2) {
				while (theNode.previousSibling && theNode!==theLimitNode && theNode.parentNode!==theLimitNode) {
					theNode=theNode.previousSibling;
					arrAnswer[arrAnswer.length]=theNode;
				}
			}
			if (theNode!==theLimitNode && theNode.parentNode!==theLimitNode) {
				theNode=theNode.parentNode;
			}
		} else {
			break;
		}
	}
	//
	return arrAnswer;
}

function wd_NodeVal(theNode) {
	var sAnswer=theNode;
	if (theNode && theNode.nodeType) {
		if (theNode.nodeType===1) {
			sAnswer=theNode.tagName;
		} else { // theNode.nodeType===3
			sAnswer=theNode.nodeValue;
		}
	}
	return sAnswer;
}
function wd_NodeValEx(theNode) {
	var sAnswer=theNode;
	if (theNode && theNode.nodeType) {
		if (theNode.nodeType===1) {
			sAnswer=theNode.outerHTML;
		} else { // theNode.nodeType===3
			sAnswer=theNode.nodeValue;
		}
	}
	return sAnswer;
}

function wd_CommonAncestor(theNode1, theNode2) {
	var theAnswer=null;
	var iAncs1=1; var arrAncs1=new Array();
	arrAncs1[0]=theNode1;
	while (theNode1.parentNode) {
		arrAncs1[arrAncs1.length]=theNode1;
		iAncs1+=1;
		theNode1=theNode1.parentNode;
	}
	var iAncs2=1; var arrAncs2=new Array();
	arrAncs2[0]=theNode2;
	while (theNode2.parentNode) {
		arrAncs2[arrAncs2.length]=theNode2;
		iAncs2+=1;
		theNode2=theNode2.parentNode;
	}
	var iDiff=iAncs1-iAncs2;
	var iI=0;
	for (iI=0; iI<iAncs1+Math.abs(iDiff); iI++) {
		if (arrAncs1[iI+iDiff] && arrAncs2[iI] && arrAncs1[iI+iDiff]===arrAncs2[iI]) {
			theAnswer=arrAncs1[iI+iDiff];
			break;
		}
	}
	return theAnswer;
}
// ==== INTERFACE ==============================================================
function wd_ClxpImg() {
	var srrName=event.srcElement.name.split('_icon');
	var sImgsPath=event.srcElement.src.split("/").slice(0, -1).join('/')+'/';
	return wd_Collexpand(srrName[0], sImgsPath, 2, srrName[srrName.length-1]);
}
function wd_Collexpand(sBaseSID, sImgsPath, iAction, sPostfix) {
	// iAction: 0=collapse, 1=expand, 2=reverse
	var theDiv=document.getElementById(sBaseSID+'_chds'+sPostfix);
	if (theDiv) {
		var sCurrState=theDiv.style.overflow;
		var sNewState=""; var iNewState=0; var sNewDisplay="";
		if (iAction==0) {
			sNewState="hidden";
			iNewState=0;
			sNewDisplay="none";
		} else if (iAction==1) {
			sNewState="visible";
			iNewState=1;
			sNewDisplay="block";
		} else {
			if (sCurrState=='visible') {
				sNewState="hidden";
				iNewState=0;
				sNewDisplay="none";
			} else {
				sNewState="visible";
				iNewState=1;
				sNewDisplay="block";
			}
		}
		theDiv.style.overflow=sNewState;
		theDiv.style.display=sNewDisplay;
		//
		var theImg=document.images[sBaseSID+'_icon'+sPostfix];
		var sImgFile=wd_URLFileName(theImg.src);
		var sActiveMark=sImgFile.substr(0,1);
		if (sActiveMark!="c"&&sActiveMark!="d") sActiveMark="";
		//if (bActive) sActiveMark="";
		theImg.src=sImgsPath+sActiveMark+(sBaseSID=='root'?"home":"folder")+iNewState+".gif";
	}
}
//==============================================================================
function wd_PicCommand(sURL) {
	amg_ModalWin(sURL, 480, 600, "wd_picfldsettor", 0, 1);
}
function wd_MshtmlToPlaintext(sStr) {
	//alert ('MshtmlToPlaintext');
	//alert (sStr);
	//alert (sStr.replace(/\r?\n</gi, "<").replace(/<!-- wdcrlf --> ?/gi, "\n").replace(/<!-- wdtab --> ?/gi, "\t"));
	return sStr.replace(/\r?\n</gi, "<").replace(/<!-- wdcrlf -->\s*/gi, "\n").replace(/<!-- wdtab -->\s?/gi, "\t");
}
function wd_PlaintextToMshtml(sStr) {
	//alert ('PlaintextToMshtml');
	//alert (sStr);
	//alert (sStr.replace(/\r?\n/gi, "<!-- wdcrlf -->\n").replace(/\t/gi, "<!-- wdtab -->\t"));
	return sStr.replace(/\r?\n/gi, "<!-- wdcrlf -->\n").replace(/\t/gi, "<!-- wdtab -->\t");
}
//==============================================================================
function wd_getETo(ev){
	var answer=null;
	if (window.createPopup) {
		answer=ev.toElement;
	} else {
		answer=ev.target;
	}
	return answer;
}
function wd_getEFrom(ev){
	var answer=null;
	if (window.createPopup) {
		answer=ev.fromElement;
	} else {
		answer=ev.relatedTarget;
	}
	return answer;
}
function wd_getMouseOutETo(ev) {
	var answer=null;
	if (window.createPopup) {
		answer=ev.toElement;
	} else {
		answer=ev.relatedTarget;
	}
	return answer;
}
function wd_addEvent(theEl, strEvent, theFunc, sBubbles) {
	if (theEl.attachEvent) {
		eval("theEl.attachEvent('on"+strEvent+"',"+theFunc+");");
	} else {
		eval("theEl.addEventListener('"+strEvent+"',"+theFunc+","+sBubbles+");");
	}
}
//==============================================================================
function wd_LocationGoWithParam(sParamName, sParamVal) {
	var sParams=document.location.search;
	var arrParams=sParams.split('&');
	var arrAllParams=new Array(); var iParam=0;
	for (iParam=0; iParam<arrParams.length; iParam++) {
		var sParam=arrParams[iParam];
		var arrParam=sParam.split('=');
		if (arrParam.length===2) arrAllParams[arrParam[0]]=arrParam[1];
	}
	//
	arrAllParams[sParamName]=sParamVal;
	//
	var sNewSearch="";
	var sNextName="";
	for (sNextName in arrAllParams) {
		sNewSearch+=(sNewSearch.length?"&":"")+sNextName+"="+arrAllParams[sNextName];
	}
	//
	document.location.search=sNewSearch;
	return false;
}