/*	Copyright	ASPerience BV	http://www.asperience.nl	M v/d Bovenkamp*/var alphanum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_";var numonly = "1234567890";var numextra = "1234567890.,";var xmlDoc = null;						//the xml object that is loaded, modified in the background and finally posted to the backend var xmlDoc2 = null;						//the xml object that is loaded, modified in the background and finally posted to the backend var htmlbody = null;					//the html code of the form var arrHtmlViewbodies = new Array();	//an array with 1 or more viewbodies that need to be loaded var arrHtmlLoaditems = new Array();		//an array with all the html items that need to be pre-loadedvar arrHtmlSaveitems = new Array();		//an array with all the html items that need to be savedvar arrHtmlReqitems = new Array();		//an array with all the html items that are required and need to be checked before submittingvar tmpXmlvalue = null;var resultXmlfill = null;var resultHtmlfill = null;var fckPrefix = "fck_";var FCKeditorLoaded = true;//This function retrieves the document unique identifier function getAspmlUNID(){	if (document.getElementById('aspml_docid')){		//in case editmode 		return ''+document.getElementById('aspml_docid').value;	}else{		//in case readmode 		return ''+document.getElementById('aspmlDocid').innerHTML;	}}//This function builds a javascript xml Dom object from a string or an url based on the loadType that was given as input function loadXMLDoc(loadType,strXml,strUrl){	//loadType 1 = generate xml (javascript DOM) from a string	//loadType 2 = load xml (javascript DOM) from an url by using DOM 	//loadType 3 = load xml (javascript DOM) from an url by using XMLHttp(Request) classes and doing a http GET	//loadType 4 = load xml (javascript DOM) from an url by using XMLHttp(Request) classes and doing a http POST	var xmlD = null;	if (loadType==1){			//Build the javascript xml Dom object from a string			xmlD = (new DOMParser()).parseFromString(strXml, "text/xml");	}else if(loadType==2){			//Build the javascript xml Dom object from an url 			// code for IE			if (window.ActiveXObject){				 try {			            xmlD = new ActiveXObject("Microsoft.XMLDOM"); 			      } catch (e) {			            try {				             xmlD=new ActiveXObject("Msxml2.XMLDOM"); 				        } catch (e) {}			      } //end try 			}			// code for Mozilla, Firefox, Opera, etc.			else if (document.implementation && document.implementation.createDocument){				xmlD=document.implementation.createDocument("","doc",null);			}			else			{				//alert('Your browser cannot handle this script');				xmlD = null;			}			if (xmlD!=null){				if (window.ActiveXObject){						//MS IE: Load the xml content from server						xmlD.async=false; 						xmlD.load(strUrl);					}else{						//Firefox, Chrome etc: Load the xml content from server						var xmlhttp2 = new window.XMLHttpRequest();						xmlhttp2.open("GET",strUrl,false);						xmlhttp2.send(null);						xmlD = xmlhttp2.responseXML.documentElement;					}			}	}else if ((loadType==3) || (loadType==4)){ 			// code for Mozilla, etc.			if (window.XMLHttpRequest){				//alert("XMLHttpRequest for Firefox etc");			 	 xmlD=new XMLHttpRequest();			  }			// code for IE			else if (window.ActiveXObject){					//alert("XMLHttpRequest for IE");				 try {			            xmlD = new ActiveXObject("Microsoft.XMLHTTP"); 			      } catch (e) {			            try {				             xmlD=new ActiveXObject("Msxml2.XMLHTTP"); 				        } catch (e) {}			      } //end try 			  } 			if (xmlD){			    //===============================			    //===============================			  	if (loadType==3){			  		xmlD.open("GET",strUrl,false); 			  		xmlD.send(null); 			  		xmlD.onreadystatechange=onResponse(xmlD); 				}else{	    				var poststr = encodeURI(strXml); 					xmlD.open("POST",strUrl, false); 				     xmlD.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 				     //xmlD.setRequestHeader("Content-length", poststr.length); 				     //xmlD.setRequestHeader("Connection", "close"); 				     xmlD.send(poststr); 					//xmlD.onreadystatechange=onResponse(xmlD); 				}			}	}return(xmlD);}//This function returns the actual xml content of a XMLHttpRequest request/object//In case the HttpRequest is complete (checkReadyState(obj))function onResponse(xmlhttp){	var response = null;	if(checkReadyState(xmlhttp)){		//response = xmlhttp.responseXML.documentElement;		response = xmlhttp.responseXml;	}	return response;}//This function checks the ready state of the xmlhttp request/objectfunction checkReadyState(obj){	//0 = uninitialized	//1 = loading	//2 = loaded	//3 = interactive	//4 = complete 	if(obj.readyState == 4){		if(obj.status == 200){			return true;		} else{			return false;		}	} else{		return false;	}}//This function returns the text/xml version of a xml DOM objectfunction xmlDom2text(xmlDomobj){	var xmltext = null;  	if(xmlDomobj.xml){		//For ie 		//alert("IE");		xmltext = xmlDomobj.xml;	}else {		//For Mozilla, firefox, opera etc		//alert("Mozilla, Firefox etc");		xmltext = new XMLSerializer().serializeToString(xmlDomobj);	}	return xmltext; }//This function retrieves the data between the first tags/elements found in 'doc' with name 'name' function getSingleValueFromXML(doc,name,fckItemprefix){	var mText = null;       var arrEl = doc.getElementsByTagName(name);       if(arrEl != null){       		//alert("before length");       		if (arrEl.length > 0){	       		//alert("before for: "+z);       			for(var z=0;z<arrEl.length;z++){       			     //alert("in for: "+z);       				if ( (arrEl[z].nodeName==name) && (arrEl[z].nodeType==1) && (arrEl[z].childNodes.length>0) ){        					if (name.indexOf(fckItemprefix)==0){							//mText = so_getText(arrEl[z]);							mText = xmlDom2text(arrEl[z]);							//alert("returning fck value: "+mText);       						return mText; 						} else if(name.indexOf("aspml_viewbody")==0){							mText = xmlDom2text(arrEl[z]);							//alert("returning viewbody value: "+mText);							return mText;						} else{							//alert("returning non fck value: "+mText);							return arrEl[z].childNodes[0].nodeValue; 						}       										} //.......End if ( (arrEl[z].nodeName==name) && 				}				return null;			}			else{				return null;			}       }       else{           return null;       }}function so_getText(obj) {// return the data of obj if its a text node    if (obj.nodeType == 3) return obj.nodeValue;    var txt = new Array(),i=0;    // loop over the children of obj and recursively pass them back to this function   while(obj.childNodes[i]) {		txt[txt.length] = so_getText(obj.childNodes[i]);		i++;	}    // return the array as a string    return txt.join("");}//This function sets the data between the first tags/elements with value 'val' if found in 'doc' with name 'name' function setSingleValueFromXML(doc,name,val,settype,separator){	 //settype 1 = insert data value	 //settype 2 = append data value with seperator (used for saving multivalue data separated by a separartor, like checkboxes) 	 //settype else = append data value     var arrEl = doc.getElementsByTagName(name);					//var used for searching the wanted tag/element	var objParent = doc.getElementsByTagName("aspmldoc");	//var used for searching the root aspml tag/element			var lastChild = objParent[0].childNodes.length;						//var used for counting the nr childs under the first root aspml element	var newel=null;																	//var used for creating a new xml element in general 	var newtext=null;																//var used for creating the content of the new xml element 'newel'	var delel = null;	//alert("aspmldoc has nr of children: "+lastChild);       if(arrEl != null){       		if (arrEl.length > 0){       			for(var z=0;z<arrEl.length;z++){       				if ( (arrEl[z].nodeName==name) && (arrEl[z].nodeType==1) && (arrEl[z].childNodes.length>0) ){       					if (settype==1){ 							//settype: just insert  							//alert("settype 1");							arrEl[z].childNodes[0].nodeValue=val; 						}else if(settype==2){ 							//alert("settype 2");							//settype: append with seperator 							var arrCurrdata = arrEl[z].childNodes[0].nodeValue.split(separator);							var currLength = arrCurrdata.length;							//only append if the data value does not exist yet 							if (!isMemberOff(arrCurrdata, val)>0){								arrEl[z].childNodes[0].nodeValue=arrEl[z].childNodes[0].nodeValue + separator + val;							}						}else if(settype==3){ 							//alert("settype 3"+name);							//settype: savin fck shit 							delel = objParent[0].removeChild(arrEl[z]);							if (window.ActiveXObject){								newel=doc.createElement(name);	//create the new element, result: <name></name> 								newtext=doc.createTextNode(val);	//create the content for the new element based on 'val' 							}else{								newel=document.createElement(name);	//create the new element, result: <name></name> 								newtext=document.createTextNode(val);	//create the content for the new element based on 'val' 							}							newel.appendChild(newtext);			//append 'val' to 'newel', result:  <name>val</name> 							objParent[0].appendChild(newel);													}else{							//settype: append							arrEl[z].childNodes[0].nodeValue=arrEl[z].childNodes[0].nodeValue + val;						}						return 1;					}				}				return 0;			}			else{				//no xml tag with <name> present yet, add it 				//alert('creating new xml element: '+name);				if (window.ActiveXObject){					newel=doc.createElement(name);	//create the new element, result: <name></name> 					newtext=doc.createTextNode(val);	//create the content for the new element based on 'val' 				}else{					newel=document.createElement(name);	//create the new element, result: <name></name>					newtext=document.createTextNode(val);	//create the content for the new element based on 'val' 				}				newel.appendChild(newtext);			//append 'val' to 'newel', result:  <name>val</name> 				objParent[0].appendChild(newel);	//append <name>val</name>  to the root element, result: <aspmldoc><name>val</name></aspmldoc>		       	//alert("aspmldoc after has: "+lastChild);				return 1;			}       }       else{           return -1;       }}//This function removes all or specifice data between the first tags/elements with value 'val' if found in 'doc' with name 'name' function removeSingleValueFromXML(doc,name,val,settype,separator){	 //settype 1 = remove single value (used for removing one value from multivalue data separated by a separartor, like checkboxes) 	 //settype else = clear data value        var arrEl = doc.getElementsByTagName(name);       if(arrEl != null){       		if (arrEl.length > 0){       			for(var z=0;z<arrEl.length;z++){       				if ( (arrEl[z].nodeName==name) && (arrEl[z].nodeType==1) && (arrEl[z].childNodes.length>0) ){       					if (settype==1){							//settype: remove a single value from multiple values 							var arrCurrdata = arrEl[z].childNodes[0].nodeValue.split(separator); 							var currLength = arrCurrdata.length; 							var arrNewdata = arrCurrdata; 							//only removable if the data value exist 							var posMember = isMemberOffpos(arrCurrdata, val);							if (posMember>=0){								//remove the value from the array 								arrNewdata.splice(posMember,1); 								arrEl[z].childNodes[0].nodeValue=arrNewdata.join(separator);							}						}else{							//settype: clear							arrEl[z].childNodes[0].nodeValue="";						}						return 1;					}				}				return 0;			}			else{				return -1;			}       }       else{           return -1;       }}//This function is used to do a XML POST function doAspmlPost(xmlDomobj, strUrl){ 	var xmlResultdoc = null; 	var xmlPostdoc = null;      if (xmlDomobj!=null){     	//Converse the DOM representation of the xml to a text representation that can be posted 		xmlPostdoc = xmlDom2text(xmlDomobj); 		//Do the post to the server (and catch the server response in xmlResultdoc). 		xmlResultdoc = loadXMLDoc(4, xmlPostdoc, strUrl); 		if (xmlResultdoc!=null){ 			//alert("post result ok");			//alert(xmlResultdoc.responseText);			return true; 		}else{			//alert("post result false");			return false; 		}	}else{	 return false; 	}}//This function can be used to set the selected value of a html radiobutton item function setRadioValue(radioObj, newValue) {	if(!radioObj)		return;	var radioLength = radioObj.length;	if(radioLength == undefined) {		radioObj.checked = (radioObj.value == newValue.toString());		return;	}	for(var i = 0; i < radioLength; i++) {		radioObj[i].checked = false;		if(radioObj[i].value == newValue.toString()) {			radioObj[i].checked = true;		}	}}//This function can be used to set the multiple selected values of a html checkbox item function setCheckboxValue(radioObj, newValue, arrAllValue) {	if(!radioObj)		return;	if (radioObj.checked){		//uncheck the 'checked item' if the value is not in the list(=backend values)		if ( !(isMemberOff(arrAllValue, radioObj.value)>0) ) {			radioObj.checked = false;		}		}	if (!radioObj.checked){		//Check the 'unchecked item' if it occurs in list(=backend values) and also matches this item		if ( (isMemberOff(arrAllValue, newValue)>0) && (radioObj.value == newValue)  ) {			radioObj.checked = true;		}				}}//Function returns 1 if the memberValue occurs in the arrMembers function isMemberOff(arrMembers, memberValue){	if ((!arrMembers) || (!memberValue)) {		return -1;	}	var memberLength = arrMembers.length;		for(var i = 0; i < memberLength; i++) {			if(memberValue==arrMembers[i].toString()){				return 1;			}		}		return 0;}//Function returns position of memberValue in the arrMembers (returns -1 if it does not appear)function isMemberOffpos(arrMembers, memberValue){	if ((!arrMembers) || (!memberValue)) {		return -1;	}	var memberLength = arrMembers.length;		for(var i = 0; i < memberLength; i++) {			if(memberValue==arrMembers[i].toString()){				return i;			}		}		return -1;}//Function is used to hide div elementsfunction show(obj) {   eval("document.all." + obj + ".style.display='block'");} //Function is used to un-hide div elementsfunction hide(obj) {   eval("document.all." + obj + ".style.display='none'"); } //This function fills an html item based on type//Supported are: text, textarea, radio, checkboxfunction fillHtmlitems(htmlElement, dataValue, fckItemprefix){	//dataValue = Utf8.decode(dataValue);	var intResult = -1;	if (htmlElement.type=="text"){		htmlElement.value = dataValue; 		intResult = 1;	}else if (htmlElement.type=="div"){		htmlElement.innerHTML = dataValue; 		intResult = 1;	}else if (htmlElement.type=="radio"){		setRadioValue(htmlElement, dataValue);		intResult = 1;	}else if ( (htmlElement.type=="select") || (htmlElement.type=="select-one") || (htmlElement.type=="select-multiple") ){		var selectboxLength = htmlElement.options.length;		for(var i = 0; i < selectboxLength; i++) {			if (dataValue==htmlElement.options[i].text){				htmlElement.selectedIndex = i;				intResult = 1;			}		}	}else if (htmlElement.type=="textarea"){		if (htmlElement.name.indexOf(fckItemprefix)==0){			//alert("Filling Fck html with: "+dataValue); 			var oEditor = FCKeditorAPI.GetInstance(htmlElement.name); 			oEditor.InsertHtml(dataValue);			intResult = 1;		} else{			//alert("Filling textarea html with: "+dataValue);			htmlElement.value = dataValue; 			intResult = 1;		}	}else if (htmlElement.type=="checkbox"){		var arrChecked = dataValue.split(";");		var checkboxLength = arrChecked.length;			for(var i = 0; i < checkboxLength; i++) {			setCheckboxValue(htmlElement, arrChecked[i].toString(), arrChecked);			intResult = 1;		}	}else{		intResult = 0;	}	return intResult;}//This function fills the content of a Xml text element based on an input array of html items//Supported are: text, textarea, radio, checkbox//The fckItemname variable only needs to be passed in case a FCKeditor is used with a textareafunction fillXmlitems(xmlDomobj, htmlElement, fckItemprefix){	var intResult = -1;	if (htmlElement.type=="text"){		intResult = setSingleValueFromXML(xmlDomobj,htmlElement.name,htmlElement.value,1,""); 	}else if (htmlElement.type=="radio"){		//only save the checked value		if (htmlElement.checked){			intResult = setSingleValueFromXML(xmlDomobj,htmlElement.name,htmlElement.value,1,""); 		}	}else if ( (htmlElement.type=="select") || (htmlElement.type=="select-one") || (htmlElement.type=="select-multiple") ){		//only save the selected value		//alert("select item index: "+htmlElement.selectedIndex);		//alert("select item programmatic value: "+htmlElement.options[htmlElement.selectedIndex].value);		//alert("select item text value that user sees: "+htmlElement.options[htmlElement.selectedIndex].text);		if (htmlElement.selectedIndex>=0){			varSelectedvalue = htmlElement.options[htmlElement.selectedIndex].text;			intResult = setSingleValueFromXML(xmlDomobj,htmlElement.name,varSelectedvalue,1,""); 		}	}else if (htmlElement.type=="textarea"){		if (htmlElement.name.indexOf(fckItemprefix)==0){ 			var oEditor = FCKeditorAPI.GetInstance(htmlElement.name); 			var oEditorContent = oEditor.GetXHTML();			//alert("Saving following FCK Content: " + oEditorContent); 			intResult = setSingleValueFromXML(xmlDomobj,htmlElement.name,oEditorContent,3,""); 			//intResult = 1;		} else{			//alert("Saving following Textare Content: " + htmlElement.value); 			intResult = setSingleValueFromXML(xmlDomobj,htmlElement.name,htmlElement.value,1,""); 		}	}else if (htmlElement.type=="checkbox"){		if (htmlElement.checked){			//Save the selected value 			intResult = setSingleValueFromXML(xmlDomobj,htmlElement.name,htmlElement.value,2,";"); 		}else{			//Remove a nonselected value 			intResult = removeSingleValueFromXML(xmlDomobj,htmlElement.name,htmlElement.value,1,";"); 		}	}	return intResult;}//This function lets the browser sleep for the time (in s) that was given as input  function aspmlSleep(timetosleep){      timetosleep = timetosleep * 1000;      var sleeping = true;      var now = new Date();      var dtalarm;      var startingms = now.getTime();      var alarmms = null;      //alert("start sleeping at: " + startingms + "\n going to sleep for: " + timetosleep + " s");      while(sleeping){         dtalarm = new Date();         alarmms = dtalarm.getTime();         if(alarmms - startingms > timetosleep){ sleeping = false; }      }            //alert("end of sleeping period");   }/*	Copyright	Robert Nyman, http://www.robertnyman.com	Free to use if this text is included*/function getElementsByAttribute(oElm, strTagName, strAttributeName, strAttributeValue){	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);	var arrReturnElements = new Array();	var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\\s)" + strAttributeValue + "(\\s|$)") : null;	var oCurrent;	var oAttribute;	for(var i=0; i<arrElements.length; i++){		oCurrent = arrElements[i];		oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);		if(typeof oAttribute == "string" && oAttribute.length > 0){			if(typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))){				arrReturnElements.push(oCurrent);			}		}	}	return arrReturnElements;}if(typeof Array.prototype.push != "function"){	Array.prototype.push = ArrayPush;	function ArrayPush(value){		this[this.length] = value;	}}/****  UTF-8 data encode / decode*  http://www.webtoolkit.info/***/var Utf8 = {    // public method for url encoding    encode : function (string) {        string = string.replace(/\r\n/g,"\n");        var utftext = "";        for (var n = 0; n < string.length; n++) {            var c = string.charCodeAt(n);            if (c < 128) {                utftext += String.fromCharCode(c);            }            else if((c > 127) && (c < 2048)) {                utftext += String.fromCharCode((c >> 6) | 192);                utftext += String.fromCharCode((c & 63) | 128);            }            else {                utftext += String.fromCharCode((c >> 12) | 224);                utftext += String.fromCharCode(((c >> 6) & 63) | 128);                utftext += String.fromCharCode((c & 63) | 128);            }        }        return utftext;    },    // public method for url decoding    decode : function (utftext) {        var string = "";        var i = 0;        var c = c1 = c2 = 0;        while ( i < utftext.length ) {            c = utftext.charCodeAt(i);            if (c < 128) {                string += String.fromCharCode(c);                i++;            }            else if((c > 191) && (c < 224)) {                c2 = utftext.charCodeAt(i+1);                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));                i += 2;            }            else {                c2 = utftext.charCodeAt(i+1);                c3 = utftext.charCodeAt(i+2);                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));                i += 3;            }        }        return string;    }}//Michael 2010-04-09function getFSQuerystring(parameter, default_) {   var loc = location.search.substring(1, location.search.length);  var param_value = false;  var params = loc.split("&");  for (i=0; i<params.length;i++) {      param_name = params[i].substring(0,params[i].indexOf('='));      if (param_name == parameter) {          param_value = params[i].substring(params[i].indexOf('=')+1);      }  }  if (param_value) {      return param_value;  }  else {	  //Here determine return if no parameter is found      return default_;   }}//Michael 2011-01-12function getFSLocationHost(){	//This function returns domain including portnumer	return window.location.host;}function getFSLocationHostname(){	//This function returns domain only 	return window.location.hostname;}function getFSLocationPort(){	//This function returns portnumber 	var portNumber = new String();	portNumber = window.location.host;	portNumber = portNumber.substring( portNumber.indexOf( ":" ) + 1 );	//return window.location.port;	return portNumber;}function getFSLocationProtocol(){	//This function returns the current protocol ie: https/http/ftp etc...	var strFSProtocol = ''+window.location.protocol;	if ((strFSProtocol=='http:')||(strFSProtocol=='https:')){		strFSProtocol = strFSProtocol+'//';	}else{		strFSProtocol = strFSProtocol+'';	}	return strFSProtocol;}function getFSLocationPathname(){	//This function returns the directory path 	return window.location.pathname;}//Fills the html items from the xml data function fillHtml(url){	//alert('url: '+url);	xmlDoc2 = loadXMLDoc(2,"",url);     //Start filling the Html from the Xml data     if (xmlDoc2!=null){		//alert("xml: "+xmlDom2text(xmlDoc2));		//Retrieve the html body 		htmlbody = document.getElementsByTagName("body")[0];		//Extract the imrc items from the html that needs to be loaded from the xml		arrHtmlLoaditems = this.getElementsByAttribute(htmlbody, "*", "aspmlld" , "1");		//alert('arrHtmlLoaditems lengte: '+arrHtmlLoaditems.length);		      for(var i=0;i<arrHtmlLoaditems.length;i++){			//alert("name: " + arrHtmlLoaditems[i].name + " value: " + arrHtmlLoaditems[i].value +  " type: " + arrHtmlLoaditems[i].type );			tmpXmlvalue = getSingleValueFromXML(xmlDoc2, arrHtmlLoaditems[i].name.toUpperCase(), fckPrefix);     		//alert("tmpXmlvalue: "+ tmpXmlvalue);      		if (tmpXmlvalue!=null){				resultHtmlfill = fillHtmlitems(arrHtmlLoaditems[i], tmpXmlvalue.replace(/&gt;/g,'>').replace(/&lt;/g,'<'), fckPrefix); 			}		}	}}function fillXml(){	if (xmlDoc2!=null){         	//Retrieve the html body 		htmlbody = document.getElementsByTagName("body")[0];		//Extract the imrc items from the html that need to be saved to the backend (xml)		arrHtmlSaveitems = this.getElementsByAttribute(htmlbody, "*", "aspmlsv" , "1");		//alert(arrHtmlSaveitems.length);	      for(var i=0;i<arrHtmlSaveitems.length;i++){		     //alert("name: " + arrHtmlSaveitems[i].name + " value: " + arrHtmlSaveitems[i].value +  " type: " + arrHtmlSaveitems[i].type );      		if (arrHtmlSaveitems[i].value!=null){				resultXmlfill = fillXmlitems(xmlDoc2, arrHtmlSaveitems[i], fckPrefix);				//alert("Save result: " + resultXmlfill + " name: " + arrHtmlSaveitems[i].name + " value: " + arrHtmlSaveitems[i].value +  " type: " + arrHtmlSaveitems[i].type ); 			}		} //end for      	//alert("xml: "+xmlDom2text(xmlDoc2));	}}function loadAspmldoc(url) {  if(!FCKeditorLoaded) {    setTimeout('loadAspmldoc(\'' + url + '\')', 500);    return;  }fillHtml(url);}function saveAspmldoc(js_server_name_sv){fillXml();//var js_aspml_docid_sv = ''+getFSQuerystring('lbid', '');var js_aspml_docid_sv = getAspmlUNID();var url_post_sv = js_server_name_sv+'(ls)?openagent&lbid='+js_aspml_docid_sv+'&tp=sv';//alert("url_post: "+url_post_sv);var resultPost = doAspmlPost(xmlDoc2, url_post_sv);//alert("resultPost: "+resultPost);	if (resultPost == true){				return true;	}else{		return false;	}}function aspmlReload(js_server_name_ld){ 	var js_aspml_docid_ld = getAspmlUNID();	//alert(js_aspml_docid_ld);  	var url_post_ld = js_server_name_ld+'(ls)?openagent&lbid='+js_aspml_docid_ld+'&tp=ld'; 	//alert('loading: '+url_post_ld); 	loadAspmldoc(url_post_ld);}//This function can be used to set the multiple selected values of a html checkbox item function resetCheckboxValue(radioObj) {	if(!radioObj)		return;	if (radioObj.checked){		//uncheck the 'checked item' 		radioObj.checked = false;	}}//ReplaceSubString equivalentfunction replaceSubstring(inputString, fromString, toString) {var temp = inputString;if (fromString == "") {return inputString;}if (toString.indexOf(fromString) == -1) { while (temp.indexOf(fromString) != -1) {var toTheLeft = temp.substring(0, temp.indexOf(fromString));var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);temp = toTheLeft + toString + toTheRight;}} else { var midStrings = new Array("~", "`", "_", "^", "#");var midStringLen = 1;var midString = "";while (midString == "") {for (var i=0; i < midStrings.length; i++) {var tempMidString = "";for (var j=0; j < midStringLen; j++) { tempMidString += midStrings; }if (fromString.indexOf(tempMidString) == -1) {midString = tempMidString;i = midStrings.length + 1;}}} while (temp.indexOf(fromString) != -1) {var toTheLeft = temp.substring(0, temp.indexOf(fromString));var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);temp = toTheLeft + midString + toTheRight;}while (temp.indexOf(midString) != -1) {var toTheLeft = temp.substring(0, temp.indexOf(midString));var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);temp = toTheLeft + toString + toTheRight;}} return temp; } //Michael 2010-04-13//Left equivalentfunction strLeft(sourceStr, keyStr){	var idx = sourceStr.indexOf(keyStr);	if ((idx == -1) || (keyStr=='')){		return '';	} else {		return sourceStr.split(keyStr)[0];	}}//Michael 2010-04-13//Right equivalentfunction strRight(sourceStr, keyStr){	var idx = sourceStr.indexOf(keyStr);	if ((idx == -1) || (keyStr=='')){		return '';	} else {		return sourceStr.substr(idx+ keyStr.length);	}}//Michael 2010-04-13//Rightback equivalentfunction strRightback(sourceStr, keyStr){	var idx = sourceStr.indexOf(keyStr);	var arr = sourceStr.split(keyStr);	if ((idx == -1) || (keyStr=='')){		return '';	} else {		return arr.pop();	}}//Michael 2010-04-13//Leftback equivalentfunction strLeftback(sourceStr, keyStr){	var idx = sourceStr.indexOf(keyStr);	var arr = sourceStr.split(keyStr);	arr.pop();	if ((idx == -1) || (keyStr=='') || (keyStr==null)){		return '';	} else {		return arr.join(keyStr);	}}//Michael 2010-04-13//Middle equivalentfunction strMiddle(sourceStr, keyStrLeft, keyStrRight){ 	return strLeft(strRight(sourceStr,keyStrLeft), keyStrRight);} //Michael 2010-04-13//IsNumeric equivalentfunction IsNumeric(sText){   var ValidChars = "0123456789";   var IsNumber = true;   var Char;    for (i = 0; i < sText.length && IsNumber == true; i++)       {       Char = sText.charAt(i);       if (ValidChars.indexOf(Char) == -1)          {         IsNumber = false;         }      }   return IsNumber;   }//Michael 2010-05-27 //Begins equivalent function strBegins(strInput,strKey){	if (	strInput.indexOf(strKey) == 0){		return true;	}else{		return false;	}}//Michael 2010-05-27 //Ends equivalent function strEnds(strInput,strKey){	if (	strInput.lastIndexOf(strKey) == strInput.length-1){		return true;	}else{		return false;	}}//This function retrieves the content of an html item based on type function getHtmlitems(htmlElement1, fckItemprefix){	var htmlElement = htmlElement1;	var dataValue = "";	//Handle html input text field 	if ( (htmlElement.type=="text")||(htmlElement.type=="hidden") ){		//alert('Type: text'); 		dataValue = htmlElement.value; 	//Handle html divs or span	}else if ( (htmlElement.type=="div")||(htmlElement.type=="span") ){			//alert('Type: div / span');			dataValue = htmlElement.innerHTML; 	//Handle html dropdownlist 	}else if ( (htmlElement.type=="select") || (htmlElement.type=="select-one") || (htmlElement.type=="select-multiple") ){ 		//alert('Type: select box');		var selectboxLength = htmlElement.options.length; 		for(var i = 0; i < selectboxLength; i++) { 			if (htmlElement.options[i].selected){ 				if (dataValue == ""){					dataValue =  htmlElement.options[i].value; 					//dataValue =  htmlElement.options[i].text; 				}else{					dataValue =  dataValue + ';' + htmlElement.options[i].value; 					//dataValue =  dataValue + ';' + htmlElement.options[i].text;				} //...end if...dataValue 								//alert(htmlElement.options[i].text);				//alert(htmlElement.options[i].value);			} 		} 	//Handle checkbox with single option/choice 	}else if (htmlElement.type=="checkbox"){		//alert('Type: checkbox'); 		if (htmlElement.length){			for(var i = 0; i < htmlElement.length; i++) {				if (htmlElement[i].checked){					if (dataValue == ""){						dataValue = htmlElement[i].value; 					}else{						dataValue = dataValue + ';' + htmlElement[i].value; 					} //...end if...dataValue 				} // ...end if...htmlElement[i].checked			} // ...end for 		}else{			if (htmlElement.checked){				dataValue = htmlElement.value; 			}		}			//Handle radiobutton with single option/choice	}else if (htmlElement.type=="radio"){		//alert('Type: radio box');		if (htmlElement.length){			for(i=0;i<htmlElement.length;i++){				if (htmlElement[i].checked) {					dataValue = htmlElement[i].value;				} //...end if.......checked			} //...end for 		}else{			if (htmlElement.checked){				dataValue = htmlElement.value; 			}		}	//Handle textarea (normal or fck) 	}else if (htmlElement.type=="textarea"){		//alert('Type: text area');		if (htmlElement.name.indexOf(fckItemprefix)==0){			//alert("Retrieving Fck html"); 			var oEditor = FCKeditorAPI.GetInstance(htmlElement.name); 			dataValue = "";   //oEditor.getHtml(dataValue);		} else{			//alert("Retrieving textarea html");			dataValue = htmlElement.value; 		}	//Handle undefined elements (i.e. radio button + checkbox) 	}else if ('undefined' == ''+htmlElement.type) {		//alert('here in undefined'); 		//Handle checkbox with multiple options/choices  		if (htmlElement.length){			if (htmlElement[0].type=="checkbox"){				//alert('Type: check box'); 				for(var i = 0; i < htmlElement.length; i++) {					if (htmlElement[i].checked){						if (dataValue == ""){							dataValue = htmlElement[i].value; 						}else{							dataValue = dataValue + ';' + htmlElement[i].value; 												} //...end if...dataValue 					} // ...end if...htmlElement[i].checked				} // ...end for 			//Handle radiobutton with multiple options/choices 			}else if (htmlElement[0].type=="radio"){				//alert('Type: radio box');				for(var i=0; i<htmlElement.length; i++){					if (htmlElement[i].checked) {						dataValue = htmlElement[i].value;					} // ...end if...htmlElement[i].checked				} //...end for 			} //... end if...htmlElement[0].type=="checkbox"/"radio"		} //...end if....htmlElement.length		//Handle other types 	}else{		//alert('Type: other');		dataValue = "";	}	//Finally return the dataValue 	//alert('dataValue: '+dataValue);	return dataValue;}function FCKeditor_OnComplete(editorInstance) {  FCKeditorLoaded = true;}//The original function (above) was altered to be able to fill multiple frontend div section (labelled with aspmllabel) with dynamic content from the backendfunction fillHtmlbyaspml(url,aspmllabelid,aspmllabelname){  if(!FCKeditorLoaded) {    setTimeout('fillHtmlbyaspml(\'' + url,aspmllabelid,aspmllabelname + '\')', 500);    return;	}else{		//alert(url);		xmlDoc = loadXMLDoc(2,"",url);		//Start filling the Html from the Xml backend data		if (xmlDoc!=null){			//alert("xml: "+xmlDoc.xml);			//Retrieve the html body 			htmlbody = document.getElementsByTagName("body")[0];			//Locate all the the special aspml div(s) on the html  			arrHtmlViewbodies = this.getElementsByAttribute(htmlbody, "*", aspmllabelid , aspmllabelname); 			for(var i=0;i<arrHtmlViewbodies.length;i++){				//Retrieve the data from the xml, its wrapped within a <aspml_viewbody></aspml_viewbody> tag 				tmpXmlvalue = getSingleValueFromXML(xmlDoc,"aspml_viewbody",fckPrefix); 				//alert(tmpXmlvalue); 				if (tmpXmlvalue!=null){					arrHtmlViewbodies[i].innerHTML = tmpXmlvalue.replace(/&gt;/g,'>').replace(/&lt;/g,'<').replace('<aspml_viewbody>','').replace('</aspml_viewbody>','').replace(/&amp;/g,'&');				}			}		}	}	}//This function can be used to dynamically create an onload event//Created by Michiel Vleugel: 2010-12-16  function addLoadEvent(func) {  var oldonload = window.onload;  if (typeof window.onload != 'function') {    window.onload = func;  } else {    window.onload = function() {      if (oldonload) {        oldonload();      }      func();    }  }}var classTrEmpty = "required";var classTr = "normal";function showReq(obj) {  	document.getElementById(obj).style.display='block';}function hideReq(obj) {  	document.getElementById(obj).style.display='none';}	function checkRequiredEmail(fldName) {	var email = document.getElementById(fldName);	var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;	if (!filter.test(email.value)) {		document.getElementById('tr_'+fldName).setAttribute("class", classTrEmpty);		document.getElementById('tr_'+fldName).setAttribute("className", classTrEmpty); 		return 1;	} else {		document.getElementById('tr_'+fldName).setAttribute("class", classTr);		document.getElementById('tr_'+fldName).setAttribute("className", classTr); 		return 0;	}}		function checkRequiredField(fldName) {	if (document.getElementById(fldName).value=="") {			document.getElementById('tr_'+fldName).setAttribute("class", classTrEmpty);		document.getElementById('tr_'+fldName).setAttribute("className", classTrEmpty); 		return 1;	} else {		document.getElementById('tr_'+fldName).setAttribute("class", classTr);		document.getElementById('tr_'+fldName).setAttribute("className", classTr); 		return 0;	}}function checkRequiredRadio(fldName) {      radios = document.getElementsByName(fldName);      itemChecked = false;      for (i = 0; i < radios.length; i++) {      	if (radios[i].checked) {			itemChecked = true;		}	      }	if (!itemChecked) {			document.getElementById('tr_'+fldName).setAttribute("class", classTrEmpty);		document.getElementById('tr_'+fldName).setAttribute("className", classTrEmpty); 		return 1;	} else {		document.getElementById('tr_'+fldName).setAttribute("class", classTr);		document.getElementById('tr_'+fldName).setAttribute("className", classTr); 		return 0;	}}
