
var READY_STATE_COMPLETE=4;function rbf_getXMLHTTPRequest(){var xreq=false;if(window.XMLHttpRequest){xreq=new XMLHttpRequest();}
else if(typeof ActiveXObject!="undefined"){try{xreq=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{xreq=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){xreq=false;}}}
return xreq;}
function rbf_sendAjaxRequest(query){var req=rbf_getXMLHTTPRequest();if(req){req.open("GET",rbf_getAjaxURL()+query,true);req.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");req.setRequestHeader("Cache-control","no-cache");req.send(null);}}
function rbf_showInfoMessage(message,isError){if(message.indexOf("Error")==0)
isError=true;var imSection=document.getElementById("rb_infoMessage");if(imSection){var imTextDiv=document.getElementById("rb_infoMessageText");if(imTextDiv){imSection.style.display='block';if(isError==true){imTextDiv.className='rbs_alertMsg';}
else{imTextDiv.className='bold black';}
imTextDiv.innerHTML=message;}}
if(isError==true){scroll(0,0);}
else{setTimeout("rbf_hideInfoMessage()",40000);}}
function rbf_hideInfoMessage(){var imSection=document.getElementById("rb_infoMessage");if(imSection){imSection.style.display='none';}}
var rbv_onLoadMethods=new Array();function rbf_addOnLoadMethod(method){if(method){rbv_onLoadMethods[rbv_onLoadMethods.length]=method;}}
function rbf_showLoadingMessage(){var msg=document.getElementById("rbe_loading");if(msg)
msg.style.display="block";}
function rbf_hideLoadingMessage(){var msg=document.getElementById("rbe_loading");if(msg)
msg.style.display="none";}
function rbf_getServletURL(servletName){var u=rbf_getExportURL();var index=u.indexOf('/Export');return u.substring(0,index)+servletName+u.substring(index+7);}
function rbf_doObjectTabCreateConfirmed(tabType){if(tabType=="OBJECT"){window.location.href="../setup/objectEdit.jsp?act=app";}
else if(tabType=="TAB"){window.location.href="../setup/tabEdit.jsp?act=app";}
else if(tabType=="SPR"){window.location.href="../setup/objImport.jsp";}}
function rbf_doNewAppCreateConfirmed(appType){if(appType=="BLANK"){window.location.href="../setup/appEdit.jsp?act=blank";}
else if(appType=="OBJS"){window.location.href="../setup/appEdit.jsp";}
else if(appType=="XML"){window.location.href="../setup/appFromXML.jsp";}
else if(appType=="SFDC"){window.location.href="../setup/appFromSFDC.jsp";}
else if(appType=="ACCESS"){window.location.href="../setup/accessUpload.jsp";}
return false;}
function rbf_setImage(imageID,source,imageAlt){var img=document.getElementById(imageID);if(img){img.src=source;img.alt=imageAlt;}}
function rbf_goMain(query){if(query){window.location.href="../m/main.jsp?"+query;return true;}
return false;}
function rbf_setDestination(destPageId,destAction){document.theForm.destId.value=destPageId;document.theForm.act.value=destAction;}
function rbf_openPopup(query){window.open('../m/popup.jsp?'+query,'pageView','WIDTH=650, HEIGHT=600, RESIZABLE=YES, SCROLLBARS=YES, TOOLBAR=YES, MENUBAR=YES, LEFT=20, TOP=20').focus();return false;}
function rbf_openPdf(pageId,objId,sessionId){window.open(rbf_getServletURL('/Pdf')+'&pageId='+pageId+"&id="+objId,'pdfView','WIDTH=650, HEIGHT=600, RESIZABLE=YES, SCROLLBARS=YES, TOOLBAR=YES, MENUBAR=YES, LEFT=20, TOP=20').focus();return false;}
function rbf_selectViewRecord(objId,objName,viewPageId,pageURL){window.open(pageURL+'&id='+objId,'pageView','WIDTH=650, HEIGHT=600, RESIZABLE=YES, SCROLLBARS=YES, TOOLBAR=YES, MENUBAR=YES, LEFT=20, TOP=20').focus();return false;}
function rbf_populateSelect(actionName){var ajaxRreq=rbf_getXMLHTTPRequest();if(!ajaxRreq)
return false;ajaxRreq.onreadystatechange=function(){if(ajaxRreq.readyState==READY_STATE_COMPLETE){var jsResponse=ajaxRreq.responseText;if(rbf_checkAjaxError(jsResponse))
return;eval(jsResponse);}};var url=rbf_getAjaxURL()+"&cmd="+actionName;ajaxRreq.open("GET",url,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);return false;}
var rbv_validationFields=new Array();function rbf_initializeValidationField(fieldName){var labelTD=document.getElementById(fieldName+"_label");var fieldTD=document.getElementById(fieldName+"_field");var errorSpan=document.getElementById(fieldName+"_error");rbv_validationFields[rbv_validationFields.length]=[fieldName,labelTD,fieldTD,errorSpan];}
function rbf_activateError(fieldName,errorMessage,stylePrefix){if(!stylePrefix){stylePrefix="detail";}
for(var i=0;i<rbv_validationFields.length;i++){if(rbv_validationFields[i]&&rbv_validationFields[i][0]&&rbv_validationFields[i][0]==fieldName)
{if(rbv_validationFields[i][1]){rbv_validationFields[i][1].className='right small bold top required fieldbottom rblightred '+stylePrefix+'WideLabelCol';}
if(rbv_validationFields[i][2]){rbv_validationFields[i][2].className='left top fieldbottom rblightred '+stylePrefix+'WideDataCol';}
if(rbv_validationFields[i][3]){rbv_validationFields[i][3].className='rbs_alertMsg';rbv_validationFields[i][3].innerHTML=errorMessage;}}}}
function rbf_activateOK(fieldName,okMessage,stylePrefix){if(!stylePrefix){stylePrefix="detail";}
for(var i=0;i<rbv_validationFields.length;i++){if(rbv_validationFields[i]&&rbv_validationFields[i][0]&&rbv_validationFields[i][0]==fieldName)
{if(rbv_validationFields[i][1]){rbv_validationFields[i][1].className='right small bold top required fieldbottom rblightgreen '+stylePrefix+'WideLabelCol';}
if(rbv_validationFields[i][2]){rbv_validationFields[i][2].className='left top fieldbottom rblightgreen '+stylePrefix+'WideDataCol';}
if(rbv_validationFields[i][3]){rbv_validationFields[i][3].className='bold darkgreen';rbv_validationFields[i][3].innerHTML=okMessage;}}}}
function rbf_clearErrors(stylePrefix){if(!stylePrefix){stylePrefix="detail";}
for(var i=0;i<rbv_validationFields.length;i++){if(rbv_validationFields[i]&&rbv_validationFields[i][0])
{if(rbv_validationFields[i][1]){rbv_validationFields[i][1].className='right small bold top required fieldbottom '+stylePrefix+'WideLabelCol';}
if(rbv_validationFields[i][2]){rbv_validationFields[i][2].className='left top fieldbottom '+stylePrefix+'WideDataCol';}
if(rbv_validationFields[i][3]){rbv_validationFields[i][3].className='rbs_alertMsg';rbv_validationFields[i][3].innerHTML='';}}}
rbf_hideInfoMessage();}
var rbv_currentCollapsableContent=null;function rbf_toggleCollapse(sectionId,doNotAnimate,horizontal){if(rbv_currentCollapsableContent==null){var divID="coldiv_"+sectionId;var imageID="colimg_"+sectionId;var section=document.getElementById(divID);var sectionSize=(horizontal?section.offsetWidth:section.offsetHeight);if(sectionSize>300)
doNotAnimate=true;var step=Math.max(49,sectionSize/6)+1;var interval=50;var collapsed='false';if(section.style.display=='block'){if(doNotAnimate){section.style.display='none';}
rbf_setImage(imageID,"../images/collapsed.gif",'Expand');collapsed='true';}
else{if(doNotAnimate){section.style.display='block';}
rbf_setImage(imageID,"../images/expanded.gif",'Collapse');collapsed='false';}
if(doNotAnimate){rbv_currentCollapsableContent=null;}
else{rbv_currentCollapsableContent=section;rbv_currentCollapsableContent.style.overflow="hidden";var expand=(rbv_currentCollapsableContent.style.display=="none");if(expand)
rbv_currentCollapsableContent.style.display="block";if(horizontal){var max_width=rbv_currentCollapsableContent.offsetWidth;var step_width=step+(expand?0:-max_width);rbv_currentCollapsableContent.style.width=Math.abs(step_width)+"px";setTimeout("togglePannelAnimatingStatusHorizontal("
+interval+","+step+","+max_width+","+step_width+")",interval);}
else{var max_height=rbv_currentCollapsableContent.offsetHeight;var step_height=step+(expand?0:-max_height);rbv_currentCollapsableContent.style.height=Math.abs(step_height)+"px";setTimeout("togglePannelAnimatingStatus("
+interval+","+step+","+max_height+","+step_height+")",interval);}}
rbf_sendAjaxRequest("&cmd=toggleColl&section="+sectionId+"&collapsed="+collapsed);}}
function togglePannelAnimatingStatus(interval,step,max_height,step_height){var step_height_abs=Math.abs(step_height);if(step_height_abs>=step&&step_height_abs<=(max_height-step)){step_height+=step;rbv_currentCollapsableContent.style.height=Math.abs(step_height)+"px";setTimeout("togglePannelAnimatingStatus("
+interval+","+step+","+max_height+","+step_height+")",interval);}
else{if(step_height_abs<step)
rbv_currentCollapsableContent.style.display="none";rbv_currentCollapsableContent.style.height="";rbv_currentCollapsableContent=null;}}
function togglePannelAnimatingStatusHorizontal(interval,step,max_width,step_width){var step_width_abs=Math.abs(step_width);if(step_width_abs>=step&&step_width_abs<=(max_width-step)){step_width+=step;rbv_currentCollapsableContent.style.width=Math.abs(step_width)+"px";setTimeout("togglePannelAnimatingStatusHorizontal("
+interval+","+step+","+max_width+","+step_width+")",interval);}
else{if(step_width_abs<step)
rbv_currentCollapsableContent.style.display="none";rbv_currentCollapsableContent.style.width="";rbv_currentCollapsableContent=null;}}
function toggleHide(sectionId,displayText,hideText){var section=document.getElementById(sectionId).style;var collapsed='false';if(section.display=='none'){section.display='block';collapsed='false';setLinkText(sectionId+"toggle",hideText);}
else{section.display='none';collapsed='true';setLinkText(sectionId+"toggle",displayText);}
rbf_sendAjaxRequest("&cmd=toggleColl&section="+sectionId+"&collapsed="+collapsed);}
function rbf_toggleViewTab(pageId,objId,index,numTabs){for(var i=0;i<numTabs;i++){var tabDiv=document.getElementById('rbe_viewTab'+i);tabDiv.style.display='none';var tabSpan=document.getElementById('rbe_viewTabSpan'+i);tabSpan.className='rbwhite gray bold solidlightgray-nobottom';tabSpan.onmouseout=function(){this.className='rbwhite gray bold solidlightgray-nobottom';}}
var selectedTabDiv=document.getElementById('rbe_viewTab'+index);selectedTabDiv.style.display='block';var selectedTabSpan=document.getElementById('rbe_viewTabSpan'+index);selectedTabSpan.className='highlight black bold solidlightgray-nobottom';selectedTabSpan.onmouseout=function(){this.className='highlight black bold solidlightgray-nobottom';}
if(selectedTabDiv.getAttribute("isLoaded")=="Y"){rbf_sendAjaxRequest('&cmd=setPageTab&pageId='+pageId+'&pageTab='+index);selectedTabDiv.setAttribute("isLoaded","Y");}
else{var ajaxRreq=rbf_getXMLHTTPRequest();if(ajaxRreq){rbf_showLoadingMessage();ajaxRreq.onreadystatechange=function(){if(ajaxRreq.readyState==READY_STATE_COMPLETE){var data=ajaxRreq.responseText;if(data.length>2){selectedTabDiv.innerHTML=data;selectedTabDiv.setAttribute("isLoaded","Y");rbf_hideLoadingMessage();}}};var u=rbf_getAjaxURL()+'&cmd=renderPageTab&pageId='+pageId+'&id='+objId+'&pageTab='+index;ajaxRreq.open("GET",u);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);}}}
function setLinkText(linkID,text){var link=document.getElementById(linkID);if(link){link.innerHTML=text;}}
var rbv_objectActions=new Array();function rbf_runObjectAction(value){if(value){for(var i=0;i<rbv_objectActions.length;i++){var action=rbv_objectActions[i];if(action&&action.value==value){if(action.url)
window.location.href=action.url;else
action();}}}}
function rbf_addObjectAction(value,method){if(value&&method){method.value=value;rbv_objectActions[rbv_objectActions.length]=method;}}
function rbf_addObjectURL(value,url){if(value&&url){var method=new Object();method.value=value;method.url=url;rbv_objectActions[rbv_objectActions.length]=method;}}
var rbv_useSmallWYSIWYG=true;var rbv_useStyleSheetInWYSIWYG=true;function rbf_initializeWYSIWYGs(){if(rbv_useSmallWYSIWYG){WYSIWYG.attachAll(WYSIWYGsmall);}
else{WYSIWYG.attachAll(WYSIWYGfull);}}
var gPopupMask=null;var gPopupContainer=null;var gPopFrame=null;var gReturnFunc;var gReturnFunc2;var gPopupIsShown=false;var gDefaultPage="../dialog/loading.html";var gHideSelects=false;var gReturnVal=null;var gContent=null;var gItemName=null;var gTabIndexes=new Array();var gTabbableTags=new Array("A","BUTTON","TEXTAREA","INPUT","IFRAME");if(!document.all){document.onkeypress=keyDownHandler;}
function initPopUp(){theBody=document.getElementsByTagName('BODY')[0];popmask=document.createElement('div');popmask.id='popupMask';popcont=document.createElement('div');popcont.id='popupContainer';popcont.className='popupContainer';popcont.innerHTML=''+'<div id="popupInner">'+'<div id="popupTitleBar" class="popupTitleBar">'+'<div id="popupTitle"></div>'+'<div id="popupControls">'+"<img src='../images/close.gif' width='14' height='14' align='absmiddle' onclick='hidePopWin2(true);' id='popCloseBox' />"+'</div>'+'</div>'+'<div id="rbe_popupIframeContainer"><iframe src="'+gDefaultPage+'" style="width:100%;height:100%;background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" ></iframe></div>'+'</div>';theBody.appendChild(popmask);theBody.appendChild(popcont);gPopupMask=document.getElementById("popupMask");gPopupContainer=document.getElementById("popupContainer");gPopFrame=document.getElementById("popupFrame");var brsVersion=parseInt(window.navigator.appVersion.charAt(0),10);if(brsVersion<=6&&window.navigator.userAgent.indexOf("MSIE")>-1){gHideSelects=true;}
var elms=document.getElementsByTagName('a');for(i=0;i<elms.length;i++){if(elms[i].className.indexOf("submodal")==0){elms[i].onclick=function(){var width=400;var height=200;params=this.className.split('-');if(params.length==3){width=parseInt(params[1],10);height=parseInt(params[2],10);}
showPopWin(this.href,width,height,null);return false;}}}}
rbf_addOnLoadMethod(initPopUp);function setPopWinHeight(height){gPopupContainer.style.height=(height)+"px";gPopFrame.style.height=(height)+"px";}
function showPopWin(url,width,height,returnFunc,showCloseBox,content,title,returnFunc2,itemName){gContent=content;gItemName=itemName;if(showCloseBox==null||showCloseBox==true){document.getElementById("popCloseBox").style.display="block";}else{document.getElementById("popCloseBox").style.display="none";}
gPopupIsShown=true;disableTabIndexes();gPopFrame.style.display="none";gPopupMask.style.display="block";gPopupContainer.style.display="block";centerPopWin(width,height);var titleBarHeight=parseInt(document.getElementById("popupTitleBar").offsetHeight,10);gPopupContainer.style.width=width+"px";gPopupContainer.style.height=(height+titleBarHeight)+"px";setMaskSize();gPopFrame.style.width=parseInt(document.getElementById("popupTitleBar").offsetWidth,10)+"px";gPopFrame.style.height=(height)+"px";rbf_loadPopupIframe(url);gReturnFunc=returnFunc;gReturnFunc2=returnFunc2;if(gHideSelects==true){hideSelectBoxes();}
if(!title){title='';}
setPopTitle(title);gPopFrame.style.display="block";}
function rbf_loadPopupIframe(target){var iframeContainer=document.getElementById('rbe_popupIframeContainer');if(iframeContainer){gPopupContainer=document.getElementById("popupContainer");gPopFrame=document.getElementById("popupFrame");gPopFrame.src=target;}}
var gi=0;function centerPopWin(width,height){if(gPopupIsShown==true){if(width==null||isNaN(width)){width=gPopupContainer.offsetWidth;}
if(height==null){height=gPopupContainer.offsetHeight;}
var theBody=document.getElementsByTagName("BODY")[0];var scTop=parseInt(getScrollTop(),10);var scLeft=parseInt(theBody.scrollLeft,10);setMaskSize();var titleBarHeight=parseInt(document.getElementById("popupTitleBar").offsetHeight,10);var fullHeight=getViewportHeight();var fullWidth=getViewportWidth();gPopupContainer.style.top=(scTop+((fullHeight-(height+titleBarHeight))/2))+"px";gPopupContainer.style.left=(scLeft+((fullWidth-width)/2))+"px";}}
function setMaskSize(){var theBody=document.getElementsByTagName("BODY")[0];var fullHeight=getViewportHeight();var fullWidth=getViewportWidth();if(fullHeight>theBody.scrollHeight){popHeight=fullHeight;}else{popHeight=theBody.scrollHeight;}
if(fullWidth>theBody.scrollWidth){popWidth=fullWidth;}else{popWidth=theBody.scrollWidth;}
gPopupMask.style.height=popHeight+"px";gPopupMask.style.width=popWidth+"px";}
function hidePopWin(callReturnFunc){gPopupIsShown=false;var theBody=document.getElementsByTagName("BODY")[0];theBody.style.overflow="";restoreTabIndexes();if(gPopupMask==null){return;}
gPopupMask.style.display="none";gPopupContainer.style.display="none";if(callReturnFunc==true&&gReturnFunc!=null){gReturnVal=window.frames["popupFrame"].returnVal;window.setTimeout('gReturnFunc(gReturnVal);',1);}
rbf_loadPopupIframe(gDefaultPage);if(gHideSelects==true){displaySelectBoxes();}}
function hidePopWin2(callReturnFunc){gPopupIsShown=false;var theBody=document.getElementsByTagName("BODY")[0];theBody.style.overflow="";restoreTabIndexes();if(gPopupMask==null){return;}
gPopupMask.style.display="none";gPopupContainer.style.display="none";if(callReturnFunc==true&&gReturnFunc2!=null){gReturnVal=window.frames["popupFrame"].returnVal;window.setTimeout('gReturnFunc2(gReturnVal);',1);}
rbf_loadPopupIframe(gDefaultPage);if(gHideSelects==true){displaySelectBoxes();}}
function setPopTitle(title){document.getElementById("popupTitle").innerHTML=title;}
function keyDownHandler(e){if(gPopupIsShown&&e.keyCode==9)return false;}
function disableTabIndexes(){if(document.all){var i=0;for(var j=0;j<gTabbableTags.length;j++){var tagElements=document.getElementsByTagName(gTabbableTags[j]);for(var k=0;k<tagElements.length;k++){gTabIndexes[i]=tagElements[k].tabIndex;tagElements[k].tabIndex="-1";i++;}}}}
function restoreTabIndexes(){if(document.all){var i=0;for(var j=0;j<gTabbableTags.length;j++){var tagElements=document.getElementsByTagName(gTabbableTags[j]);for(var k=0;k<tagElements.length;k++){tagElements[k].tabIndex=gTabIndexes[i];tagElements[k].tabEnabled=true;i++;}}}}
function hideSelectBoxes(){for(var i=0;i<document.forms.length;i++){for(var e=0;e<document.forms[i].length;e++){if(document.forms[i].elements[e].tagName=="SELECT"){document.forms[i].elements[e].style.visibility="hidden";}}}}
function displaySelectBoxes(){for(var i=0;i<document.forms.length;i++){for(var e=0;e<document.forms[i].length;e++){if(document.forms[i].elements[e].tagName=="SELECT"){document.forms[i].elements[e].style.visibility="visible";}}}}
function getViewportHeight(){if(window.innerHeight!=window.undefined)return window.innerHeight;if(document.compatMode=='CSS1Compat')return document.documentElement.clientHeight;if(document.body)return document.body.clientHeight;return window.undefined;}
function getViewportWidth(){var offset=17;var width=null;if(window.innerWidth!=window.undefined)return window.innerWidth;if(document.compatMode=='CSS1Compat')return document.documentElement.clientWidth;if(document.body)return document.body.clientWidth;}
function getScrollTop(){if(self.pageYOffset){return self.pageYOffset;}
else if(document.documentElement&&document.documentElement.scrollTop){return document.documentElement.scrollTop;}
else if(document.body){return document.body.scrollTop;}}
function getScrollLeft(){if(self.pageXOffset){return self.pageXOffset;}
else if(document.documentElement&&document.documentElement.scrollLeft){return document.documentElement.scrollLeft;}
else if(document.body){return document.body.scrollLeft;}}
function rbf_popupReminder(eventText,eventId){rbf_sendAjaxRequest("&cmd=reminded&id="+eventId);alert(eventText);}
function rbf_doQuickRelCreate(funcName,objDefId,pageId,fieldId,returnId,relId,popupPrompt){var buff='../dialog/objectQuickCreate.jsp?funcName='+funcName+'&objDefId='+objDefId+'&pageId='+pageId+'&fieldId='+fieldId;if(returnId>0)
buff+='&returnId='+returnId+'&relId='+relId;showPopWin(buff,700,0,null,true,'',popupPrompt);return false;}
function rbf_selectInLookup(objId,objName,inputName,multiSel){var inp=document.getElementById(inputName);if(!inp)
return;var newOpt=new Option(objName,objId);newOpt.selected=true;inp.options[inp.length]=newOpt;}
function gmailTest(){var debugWindow=window.open('../m/gmailTest.jsp','Debug','WIDTH=600, HEIGHT=600, RESIZABLE=YES, SCROLLBARS=YES, TOOLBAR=YES, LEFT=20, TOP=20');debugWindow.focus();return false;}
function rbf_doChartDelete(chartDelQuery,chartForm){var dc=chartForm.chartDeletePrompt.value;var dt=chartForm.chartDeletePromptTitle.value;showPopWin('../dialog/confirmCheckDialog.jsp',500,175,function(){window.location.href='../servlet/Designer?'+chartDelQuery+'&chartId='+chartForm.chartDefs.value;},true,dc,dt);}
var rbv_inlineEditFieldName=null;var rbv_inlineEditCellName=null;var rbv_inlineEditFieldHTML=null;var rbv_inlineEditFieldSaver=null;var rbv_inlineEditField=null;function rbf_inline(activate,fieldName,recId){var cellName=fieldName+(recId?'_'+recId:'');if(rbv_inlineEditCellName!=null&&rbv_inlineEditCellName==cellName)
return false;var fieldCell=document.getElementById('rbi_F_'+cellName);if(fieldCell){var editPicture=document.getElementById('rbi_I_'+cellName);if(activate&&editPicture){editPicture.src='../images/pencil.gif';}
else if(!activate&&editPicture){editPicture.src='../images/pencil_no.gif';}}}
function rbf_start(objDefId,id,fieldName,recId){rbf_cancelFieldEditing();var cellName=fieldName+(recId?'_'+recId:'');var ajaxRreq=rbf_getXMLHTTPRequest();if(!ajaxRreq)
return false;var fieldCell=document.getElementById('rbi_F_'+cellName);if(fieldCell){rbv_inlineEditFieldHTML=fieldCell.innerHTML;fieldCell.innerHTML="<table><tr><td><input disabled=false value='Loading...'></td><td>&nbsp;</td><td><img src='../images/loadinganim.gif' width='16' height='16' align='absmiddle'></td></tr></table>";}
ajaxRreq.onreadystatechange=function(){if(ajaxRreq.readyState!=READY_STATE_COMPLETE)
return;var resp=ajaxRreq.responseText;var cell=document.getElementById('rbi_F_'+cellName);if(!cell||resp.length<2)
return;if(rbv_inlineEditFieldName)
rbf_cancelFieldEditing();rbv_inlineEditFieldName=fieldName;rbv_inlineEditCellName=cellName;var table=document.createElement("table");var tbody=document.createElement("tbody");var tr=document.createElement("tr");var td1=document.createElement("td");var td2=document.createElement("td");var td3=document.createElement("td");var td4=document.createElement("td");var td5=document.createElement("td");var td6=document.createElement("td");rbv_inlineEditFieldSaver=document.createElement("td");td1.innerHTML=resp;td2.innerHTML="&nbsp;";var saveButton=document.createElement("input");saveButton.className='xsmall';saveButton.type='button';saveButton.value=rbv_savePrompt;td3.appendChild(saveButton);td4.innerHTML="&nbsp;";var cancelButton=document.createElement("input");cancelButton.className='xsmall';cancelButton.type='button';cancelButton.value=rbv_cancelPrompt;cancelButton.onclick=rbf_cancelFieldEditing;td5.appendChild(cancelButton);td6.innerHTML="&nbsp;";tr.appendChild(td1);tr.appendChild(td2);tr.appendChild(td3);tr.appendChild(td4);tr.appendChild(td5);tr.appendChild(td6);tr.appendChild(rbv_inlineEditFieldSaver);table.appendChild(tbody);tbody.appendChild(tr);cell.innerHTML="";cell.appendChild(table);var fields=document.getElementsByName(fieldName);var editField=fields[0];rbv_inlineEditField=editField;saveButton.editField=editField;saveButton.onclick=function(e){var fieldValue=this.editField.value;if(this.editField.type=='checkbox')
fieldValue=(this.editField.checked?"on":"off");rbf_finishFieldEditing(objDefId,id,fieldValue);if(!e)var e=window.event;e.cancelBubble=true;if(e.stopPropagation)e.stopPropagation();}
if(editField){editField.save=function(){return rbf_finishFieldEditing(objDefId,id,this.value);}
editField.onclick=function(e){if(!e)var e=window.event;e.cancelBubble=true;if(e.stopPropagation)e.stopPropagation();};editField.onkeypress=function(event){event=event?event:window.event;if(event.keyCode==13)
return rbf_finishFieldEditing(objDefId,id,this.value);else if(event.keyCode==27)
return rbf_cancelFieldEditing();return true;};editField.focus();rbf_showInfoMessage(rbv_editInfoMessage,false);}};var url=rbf_getAjaxURL()+"&cmd=editField&objDefId="+objDefId+"&id="+id+"&fieldName="+encodeURIComponent(fieldName);ajaxRreq.open("GET",url,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);return false;}
function rbf_finishFieldEditing(objDefIdValue,idValue,newValue){rbf_hideInfoMessage();if(rbv_inlineEditFieldSaver){rbv_inlineEditFieldSaver.innerHTML="&nbsp;<img src='../images/loadinganim.gif' width='16' height='16' align='absmiddle'>";}
if(rbv_inlineEditField){rbv_inlineEditField.disabled=true;}
with(document.inlineForm){objDefId.value=objDefIdValue;id.value=idValue;fieldName.value=rbv_inlineEditFieldName;fieldValue.value=newValue;fieldValue.name=rbv_inlineEditFieldName;}
document.inlineForm.submit();return false;}
function rbf_cancelFieldEditing(){if(!rbv_inlineEditFieldName||!rbv_inlineEditFieldHTML)
return false;var cell=document.getElementById('rbi_F_'+rbv_inlineEditCellName);if(cell)
cell.innerHTML=rbv_inlineEditFieldHTML;var pencilElement=document.getElementById('rbi_I_'+rbv_inlineEditCellName);if(pencilElement){pencilElement.src='../images/pencil_no.gif';}
rbf_hideInfoMessage();rbv_inlineEditFieldName=null;rbv_inlineEditCellName=null;rbv_inlineEditFieldHTML=null;rbv_inlineEditFieldSaver=null;rbv_inlineEditField=null;return false;}
function rbf_getFields(objName,id,fields,callback){var ajaxRreq=rbf_getXMLHTTPRequest();if(!ajaxRreq)
return;ajaxRreq.onreadystatechange=function(){if(ajaxRreq.readyState==READY_STATE_COMPLETE){var jsResponse=ajaxRreq.responseText;if(rbf_checkAjaxError(jsResponse))
return;var dataValues=eval('('+jsResponse+')');callback(objName,id,dataValues);}};var url=rbf_getAjaxURL()+"&cmd=apiGetFields&output=json&objName="+objName+"&id="+id+"&fields="+encodeURIComponent(fields);ajaxRreq.open("GET",url,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);}
function rbf_getRelatedIds(relName,id,callback){var ajaxRreq=rbf_getXMLHTTPRequest();if(!ajaxRreq)
return;ajaxRreq.onreadystatechange=function(){if(ajaxRreq.readyState==READY_STATE_COMPLETE){var jsResponse=ajaxRreq.responseText;if(rbf_checkAjaxError(jsResponse))
return;var idsArray=eval('('+jsResponse+')');callback(relName,id,idsArray);}};var url=rbf_getAjaxURL()+"&cmd=apiGetRelIds&output=json&relName="+relName+"&id="+id;ajaxRreq.open("GET",url,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);}
function rbf_getRelatedFields(relName,id,fieldName,callback){var ajaxRreq=rbf_getXMLHTTPRequest();if(!ajaxRreq)
return;ajaxRreq.onreadystatechange=function(){if(ajaxRreq.readyState==READY_STATE_COMPLETE){var jsResponse=ajaxRreq.responseText;if(rbf_checkAjaxError(jsResponse))
return;var fieldArray=eval('('+jsResponse+')');callback(relName,id,fieldArray);}};var url=rbf_getAjaxURL()+"&cmd=apiGetRelFields&output=json&relName="+relName+"&id="+id+"&fieldName="+encodeURIComponent(fieldName);ajaxRreq.open("GET",url,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);}
function rbf_getCount(viewId,callback){var ajaxRreq=rbf_getXMLHTTPRequest();if(!ajaxRreq)
return;ajaxRreq.onreadystatechange=function(){if(ajaxRreq.readyState==READY_STATE_COMPLETE){var jsResponse=ajaxRreq.responseText;if(rbf_checkAjaxError(jsResponse))
return;var count=parseInt(jsResponse);callback(count);}};var url=rbf_getAjaxURL()+"&cmd=apiGetCount&viewId="+viewId;ajaxRreq.open("GET",url,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);}
function rbf_getPage(viewId,startRow,rowsPerPage,composite,objNames,fieldList,callback){rbf_getPage2(viewId,startRow,rowsPerPage,composite,objNames,fieldList,null,null,callback);}
function rbf_getPage2(viewId,startRow,rowsPerPage,composite,objNames,fieldList,filterName,filterValue,callback){var ajaxRreq=rbf_getXMLHTTPRequest();if(!ajaxRreq)
return;ajaxRreq.onreadystatechange=function(){if(ajaxRreq.readyState==READY_STATE_COMPLETE){var jsResponse=ajaxRreq.responseText;if(rbf_checkAjaxError(jsResponse))
return;var recsArray=eval('('+jsResponse+')');callback(recsArray);}};var url=rbf_getAjaxURL()+"&cmd=apiGetPage&viewId="+viewId;if(startRow!=null)
url+="&startRow="+startRow;if(rowsPerPage!=null)
url+="&rowsPerPage="+rowsPerPage;if(composite!=null)
url+="&composite="+composite;if(objNames!=null)
url+="&objNames="+encodeURIComponent(objNames);if(fieldList!=null)
url+="&fieldList="+encodeURIComponent(fieldList);if(filterName!=null&&filterValue!=null)
url+="&filterName="+encodeURIComponent(filterName)+"&filterValue="+encodeURIComponent(filterValue);ajaxRreq.open("GET",url,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);}
function rbf_setField(objName,id,fieldName,fieldValue,useIds){var ajaxRreq=rbf_getXMLHTTPRequest();if(!ajaxRreq)
return;ajaxRreq.onreadystatechange=function(){if(ajaxRreq.readyState==READY_STATE_COMPLETE){var jsResponse=ajaxRreq.responseText;if(rbf_checkAjaxError(jsResponse))
return;}};var url=rbf_getAjaxURL()+"&cmd=apiSetField&useIds="+(useIds?"true":"false")+"&objName="+objName+"&id="+id+"&field="+encodeURIComponent(fieldName)+"&value="+encodeURIComponent(fieldValue);ajaxRreq.open("GET",url,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);}
function rbf_runTrigger(objName,id,triggerId,checkValidation){var ajaxRreq=rbf_getXMLHTTPRequest();if(!ajaxRreq)
return;ajaxRreq.onreadystatechange=function(){if(ajaxRreq.readyState==READY_STATE_COMPLETE){var jsResponse=ajaxRreq.responseText;if(rbf_checkAjaxError(jsResponse))
return;}};var url=rbf_getAjaxURL()+"&cmd=apiRunTrigger&objName="+objName+"&id="+id+"&eventId="+encodeURIComponent(triggerId)+(checkValidation!=null&&checkValidation==true?"&checkValidation=true":"");ajaxRreq.open("GET",url,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);}
function rbf_selectQuery(query,maxRows,callback){rbf_selectQuery2(query,0,maxRows,callback);}
function rbf_selectQuery2(query,rowFrom,maxRows,callback){var ajaxRreq=rbf_getXMLHTTPRequest();if(!ajaxRreq)
return;ajaxRreq.onreadystatechange=function(){if(ajaxRreq.readyState==READY_STATE_COMPLETE){var jsResponse=ajaxRreq.responseText;if(rbf_checkAjaxError(jsResponse))
return;var arr=eval('('+jsResponse+')');callback(arr);}};var url=rbf_getAjaxURL()+"&cmd=apiSelectQuery&output=json&rowFrom="+encodeURIComponent(rowFrom)+"&maxRows="+encodeURIComponent(maxRows)+"&query="+encodeURIComponent(query);ajaxRreq.open("GET",url,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);}
function rbf_selectValue(query,callback){var ajaxRreq=rbf_getXMLHTTPRequest();if(!ajaxRreq)
return;ajaxRreq.onreadystatechange=function(){if(ajaxRreq.readyState==READY_STATE_COMPLETE){var jsResponse=ajaxRreq.responseText;if(rbf_checkAjaxError(jsResponse))
return;var value=eval('('+jsResponse+')');callback(value);}};var url=rbf_getAjaxURL()+"&cmd=apiSelectValue&query="+encodeURIComponent(query);ajaxRreq.open("GET",url,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);}
function rbf_selectNumber(query,callback){var ajaxRreq=rbf_getXMLHTTPRequest();if(!ajaxRreq)
return;ajaxRreq.onreadystatechange=function(){if(ajaxRreq.readyState==READY_STATE_COMPLETE){var jsResponse=ajaxRreq.responseText;if(rbf_checkAjaxError(jsResponse))
return;var x=parseFloat(jsResponse);if(isNaN(x))x=0;callback(x);}};var url=rbf_getAjaxURL()+"&cmd=apiSelectValue&query="+encodeURIComponent(query);ajaxRreq.open("GET",url,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);}
function rbf_getIdByCode(objName,fieldName,code,callback){var ajaxRreq=rbf_getXMLHTTPRequest();if(!ajaxRreq)
return;ajaxRreq.onreadystatechange=function(){if(ajaxRreq.readyState==READY_STATE_COMPLETE){var jsResponse=ajaxRreq.responseText;if(rbf_checkAjaxError(jsResponse))
return;var x=parseInt(eval('('+jsResponse+')'));if(isNaN(x))x=0;callback(x);}};var url=rbf_getAjaxURL()+"&cmd=apiGetIdByCode&&objName="+objName+"&field="+encodeURIComponent(fieldName)+"&code="+encodeURIComponent(code);ajaxRreq.open("GET",url,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);}
function rbf_getCodeById(objName,fieldName,id,callback){var ajaxRreq=rbf_getXMLHTTPRequest();if(!ajaxRreq)
return;ajaxRreq.onreadystatechange=function(){if(ajaxRreq.readyState==READY_STATE_COMPLETE){var jsResponse=ajaxRreq.responseText;if(rbf_checkAjaxError(jsResponse))
return;callback(jsResponse);}};var url=rbf_getAjaxURL()+"&cmd=apiGetCodeById&&objName="+objName+"&field="+encodeURIComponent(fieldName)+"&id="+id;ajaxRreq.open("GET",url,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);}
function rbf_getSectionIdByTitle(sectionTitle){if(sectionTitle==null)
return null;var arr=document.getElementsByTagName("div");var numElements=arr.length;if(numElements==0)
return null;for(var k=0;k<numElements;k++){var element=arr[k];var elementName=element.getAttribute("name");if(elementName==null||elementName!=sectionTitle)
continue;var elementId=element.id;if(elementId==null||elementId.indexOf("rbi_S_")!=0)
continue;return elementId.substring(6);}
return null;}
function rbf_setSectionCollapse(sectionId,collapsed){var divID="coldiv_"+sectionId;var imageID="colimg_"+sectionId;var section=document.getElementById(divID);if(section==null)
return;if(collapsed==true){section.style.display='none';rbf_setImage(imageID,"../images/collapsed.gif",'Expand');collapsed='true';}
else{section.style.display='block';rbf_setImage(imageID,"../images/expanded.gif",'Collapse');}}
function rbf_showOrHideSection(sectionId,showSection){var section=document.getElementById("rbi_S_"+sectionId);if(section==null)
return;if(showSection==false){section.style.display='none';}
else{section.style.display='block';}}
function rbf_showOrHideField(fieldName,showField){var labelTD=document.getElementById("rbi_L_"+fieldName);var fieldTD=document.getElementById("rbi_F_"+fieldName);if(labelTD==null||fieldTD==null)
return;var isIE=(window.navigator.userAgent.indexOf("MSIE")>-1);if(isIE){labelTD.style.display=(showField?'block':'none');fieldTD.style.display=(showField?'block':'none');}
else{if(showField){var labelTDDiv=labelTD.firstElementChild;if(labelTDDiv!=null)
labelTDDiv.style.display='block';else
labelTD.style.display='block';var fieldTDDiv=fieldTD.firstElementChild;if(fieldTDDiv!=null)
fieldTDDiv.style.display='block';else
fieldTD.style.display='block';}
else{var divL=document.createElement('div');divL.innerHTML=labelTD.innerHTML;labelTD.innerHTML="";labelTD.appendChild(divL);divL.style.display="none";var divF=document.createElement('div');divF.innerHTML=fieldTD.innerHTML;fieldTD.innerHTML="";fieldTD.appendChild(divF);divF.style.display="none";}}}
function rbf_getFloat(value){if(!value||value.length==0)
return 0;var buff='';for(var k=0;k<value.length;k++){var ch=value.charAt(k);if("-.1234567890".indexOf(ch)>=0)
buff+=ch;}
var x=parseFloat(buff);return isNaN(x)?0:x;}
function rbf_getInt(value){if(!value||value.length==0)
return 0;var buff='';for(var k=0;k<value.length;k++){var ch=value.charAt(k);if("-1234567890".indexOf(ch)>=0)
buff+=ch;}
var x=parseInt(buff);return isNaN(x)?0:x;}
function rbf_formatCurrency(value,currSymbol,showZero){if(currSymbol==null||typeof currSymbol=="undefined")
currSymbol="$";if(showZero==null||typeof showZero=="undefined")
showZero=false;if(!value||isNaN(value))
return(showZero?currSymbol+"0.00":"");return currSymbol+value.toFixed(2);}
function rbf_getDate(value){if(value==null||value=="")
return null;return new Date(value);}
function rbf_formatDate(d,format){if(d==null)
return"";var sMonth=""+(d.getMonth()+1);if(sMonth.length<2)sMonth="0"+sMonth;var sDay=""+d.getDate();if(sDay.length<2)sDay="0"+sDay;var sYear=""+d.getFullYear();var sDate=format.toLowerCase();sDate=sDate.replace("dd",sDay);sDate=sDate.replace("d",""+d.getDate());sDate=sDate.replace("mm",sMonth);sDate=sDate.replace("m",sMonth);sDate=sDate.replace("yyyy",sYear);sDate=sDate.replace("yy",sYear.substring(2));return sDate;}
function rbf_getDigits(value){if(!value||value.length==0)
return'';var buff='';for(var k=0;k<value.length;k++){var ch=value.charAt(k);if("1234567890".indexOf(ch)>=0)
buff+=ch;}
return buff;}
function rbf_formatUsingMask(value,mask){if(!mask||mask.length==0)
return value;var digits=rbf_getDigits(value);if(digits.length==0)
return value;var buff='';var index=0;for(var k=0;k<mask.length;k++){var ch=mask.charAt(k);if(ch!='#'){buff+=ch;continue;}
if(index>=digits.length)
continue;buff+=digits.charAt(index);index++;}
if(index<digits.length)
buff+=digits.substring(index);return buff;}
function rbf_getFieldValue(fieldName){try{var field=eval("document.theForm."+fieldName);if(!field)
return rbf_getFieldContent(fieldName);return field.value;}
catch(e){if(rbv_errorsCallback)
rbv_errorsCallback(e.message,"rbf_getFieldValue");return null;}}
function rbf_setFieldValue(fieldName,value){try{var field=eval("document.theForm."+fieldName);if(!field)
return;field.value=value;if(field.onchange)
field.onchange();}
catch(e){if(rbv_errorsCallback)
rbv_errorsCallback(e.message,"rbf_setFieldValue");}}
function rbf_getFieldContent(fieldName){var cell=document.getElementById("rbi_F_"+fieldName);if(cell)
return cell.innerHTML;else
return null;}
function rbf_setFieldContent(fieldName,value){var cell=document.getElementById("rbi_F_"+fieldName);if(cell)
cell.innerHTML=value;}
function rbf_setPicklistCode(fieldName,optCode){try{var field=eval("document.theForm."+fieldName);if(!field)
return;var opts=field.options;if(opts!=null&&opts.length>0){for(var k=0;k<opts.length;k++){var opt=opts[k];if(opt.getAttribute('code')==optCode){field.value=opt.value;if(field.onchange)
field.onchange();break;}}}
else if(field.length>0){for(var k=0;k<field.length;k++){var comp=field[k];if(comp.getAttribute('code')==optCode){comp.checked=true;if(comp.onclick)
comp.onclick();}}}}
catch(e){if(rbv_errorsCallback)
rbv_errorsCallback(e.message,"rbf_setPicklistCode");}}
function rbf_getPicklistCode(fieldName){try{var field=document.getElementById("rbi_C_"+fieldName);if(field)
return field.value;field=eval("document.theForm."+fieldName);if(!field)
return null;var opts=field.options;if(opts!=null&&opts.length>0){for(var k=0;k<opts.length;k++){var opt=opts[k];if(opt.selected==true){var optCode=opt.getAttribute('code');return optCode;}}}
else if(field.length>0){for(var k=0;k<field.length;k++){var comp=field[k];if(comp.checked==true){var optCode=comp.getAttribute('code');return optCode;}}}}
catch(e){if(rbv_errorsCallback)
rbv_errorsCallback(e.message,"rbf_getPicklistCode");}
return null;}
function rbf_getPicklistCodes(fieldName){try{var field=document.getElementById("rbi_C_"+fieldName);if(field)
return field.value;var buff='';field=eval("document.theForm."+fieldName);if(field){var opts=field.options;for(var k=0;k<opts.length;k++){var opt=opts[k];if(opt.selected==true){var optCode=opt.getAttribute('code');if(buff.length>0)
buff+=',';if(optCode)
buff+=optCode;}}}
else{var sl=document.theForm;var prefix=fieldName+"_";var len=sl.elements.length;for(var k=0;k<len;k++){var ch=sl.elements[k];if(ch&&ch.type&&ch.type=="checkbox"&&ch.name.indexOf(prefix)==0&&ch.checked==true){var optCode=ch.getAttribute('code');if(buff.length>0)
buff+=',';if(optCode)
buff+=optCode;}}}
return buff;}
catch(e){if(rbv_errorsCallback)
rbv_errorsCallback(e.message,"rbf_getPicklistCodes");}
return null;}
function rbf_setChecked(fieldName,isChecked){try{var field=eval("document.theForm."+fieldName);if(!field)
return;if(field.checked==isChecked)
return;field.checked=isChecked;if(field.onchange)
field.onchange();}
catch(e){if(rbv_errorsCallback)
rbv_errorsCallback(e.message,"rbf_setChecked");}}
function rbf_isChecked(fieldName){try{var field=eval("document.theForm."+fieldName);if(!field)
return false;return field.checked;}
catch(e){if(rbv_errorsCallback)
rbv_errorsCallback(e.message,"rbf_isChecked");return false;}}
function rbf_isSelected(recordId){try{var fields=document.getElementsByName("sel_"+recordId);if(fields.length!=1)
return false;var field=fields[0];if(!field)
return false;return field.checked;}
catch(e){if(rbv_errorsCallback)
rbv_errorsCallback(e.message,"rbf_isSelected");return false;}}
function rbf_setSelected(recordId,selected){try{var fields=document.getElementsByName("sel_"+recordId);if(fields.length!=1)
return;var field=fields[0];field.checked=selected;rbf_checkListBox(field.form,field,"sel_");}
catch(e){if(rbv_errorsCallback)
rbv_errorsCallback(e.message,"rbf_setSelected");return false;}}
function rbf_openPopupSelector(inputName,selPageId,viewPageId,selectorViewId,isMultiple){var textbox=document.getElementById("txt"+inputName);if(textbox){var viewId=parseInt(textbox.getAttribute('selectorViewId'));if(viewId>0)
selectorViewId=viewId;}
var url="../m/selector.jsp?act=clean&pageId="+selPageId+"&viewPageId="+viewPageId+"&selectorViewId="+selectorViewId+"&inputName="+inputName+"&multiSel="+(isMultiple?"true":"false");var w=window.open(url,'Selector','WIDTH=600, HEIGHT=400, RESIZABLE=YES, SCROLLBARS=YES, TOOLBAR=YES, LEFT=20, TOP=20')
w.focus();return false;}
function rbf_setViewSelector(fieldName,selectorViewId){var textbox=document.getElementById("txt"+fieldName);if(textbox)
textbox.setAttribute('selectorViewId',selectorViewId);}
function rbf_getViewSelector(fieldName){var textbox=document.getElementById("txt"+fieldName);if(textbox)
return textbox.getAttribute('selectorViewId');return-1;}
function rbf_getExchangeRate(srcCode,destCode,date,callback){var ajaxRreq=rbf_getXMLHTTPRequest();if(!ajaxRreq)
return;ajaxRreq.onreadystatechange=function(){if(ajaxRreq.readyState==READY_STATE_COMPLETE){var jsResponse=ajaxRreq.responseText;if(rbf_checkAjaxError(jsResponse))
return;var x=parseFloat(jsResponse);if(isNaN(x))x=0;callback(x);}};var url=rbf_getAjaxURL()+"&cmd=apiGetExchangeRate&&srcCode="+srcCode+"&destCode="+destCode;if(date)
url+="&startDate="+date.getTime();ajaxRreq.open("GET",url,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);}
var rbv_errorsCallback=null;function rbf_setErrorsCallback(callback){if(typeof callback=='function')
rbv_errorsCallback=callback;}
function rbf_isEmpty(arg){if(arg==null||arg=='')
return true;var s=String(arg);return(s==null)||(s.length==0);}
function rbf_isZero(arg){if(arg==null||arg=='')
return true;var n=Number(arg);return(n==null)||isNaN(n)||(n==0);}
function rbf_checkAjaxError(jsResponse){if(jsResponse.indexOf("<Error>")==0){var errMessage=jsResponse.substring(7,jsResponse.length-8);if(rbv_errorsCallback)
rbv_errorsCallback(errMessage,"rbf_populateSelect");else
rbf_showInfoMessage(errMessage,true);return true;}
return false;}
function rbf_isEmpty(str){if((str==null)||(str==""))
return true;for(var k=0;k<str.length;k++){var ch=str.charAt(k);if(ch!=' '&&ch!='\n')
return false;}
return true;}
function rbf_disableAllButtons(){var buttonArray=document.getElementsByTagName("input");for(var k=0;k<buttonArray.length;k++){var button=buttonArray[k];if(button.type=="submit"){button.disabled=true;}}
return true;}
function rbf_getIntegrationName(str,maxLen){if(str==null||str.length==0)
return"";var str2="";var excluded=' =-+*/;:,.(){}[]<>&#@$%^~`|?!\\\"\'';for(var k=0;k<str.length;k++){if(str.charCodeAt(k)>=255)
continue;var ch=str.charAt(k);if(excluded.indexOf(ch)>=0)
ch='_';str2+=ch;if(str2.length>=maxLen)
break;}
return str2.toLowerCase();}
function rbf_showDependentSelect(mainSelect,dependentSelect,valuesArray){if(!mainSelect||!dependentSelect||!valuesArray||mainSelect.length<=1){return;}
var currValue=dependentSelect.value;while(dependentSelect.length>1){dependentSelect.options[1]=null;}
if(dependentSelect.length>0&&dependentSelect.options[0].value!=''){dependentSelect.options[0]=null;}
var availableValues=valuesArray[mainSelect.value];if(!availableValues)
return;for(var k=0;k<availableValues.length;k++){var opt=availableValues[k];var newOpt=new Option(opt.text,opt.value);var selLength=dependentSelect.length;dependentSelect.options[selLength]=newOpt;}
dependentSelect.value=currValue;return false;}
function rbf_removeAllChildren(ele){if(ele){while(ele.firstChild){ele.removeChild(ele.firstChild);}}}
function rbf_htmlToText(oldString){val=rbf_replaceAll(oldString,/<[\s\\\/]*[bB][rR][^>]*>/g,"\n");var val=rbf_replaceAll(val,/<[^>]*>/g,"");return val;}
function rbf_textToHtml(oldString){val=rbf_replaceAll(oldString,/\n/g,"<br>");return val;}
function rbf_opacity(ele,opacity){ele.style.opacity=opacity;ele.style.mozOpacity=opacity;ele.style.filter="alpha(opacity="+(opacity*100)+")";}
function rbf_xGetElementById(e){if(typeof(e)!='string')return e;if(document.getElementById)e=document.getElementById(e);else if(document.all)e=document.all[e];else e=null;return e;}
function rbf_findPosition(obj){var curleft=curtop=0;if(obj&&obj.offsetParent){curleft=obj.offsetLeft
curtop=obj.offsetTop
while(obj=obj.offsetParent){curleft+=obj.offsetLeft
curtop+=obj.offsetTop}}
return[curleft,curtop];}
function rbf_createPaddingTable(style){var divX=document.createElement("div");divX.className='wide supersmall';divX.height='5';divX.innerHTML="<table height=5 class='wide "+style+"' cellpadding=0 cellspacing=0><tr><td width=5 height=5></td><td></td><td width=5 height=5></td></tr></table>";return divX;}
function rbf_createContainerTop(style){var divX=document.createElement("div");divX.className='wide supersmall';divX.height='6';divX.innerHTML="<table border=0 cellpadding=0 cellspacing=0 class='wide'><tr height='6'><td width='7' class='rbs_"+style+"_tlc'><img src='../images/borderspacer.gif' alt='' width='7' height='1' border='0' align='absmiddle'/></td><td class='wide rbs_"+style+"_top'></td><td width=7 class='rbs_"+style+"_trc'><img src='../images/borderspacer.gif' alt='' width='7' height='1' border='0' align='absmiddle'/></td></tr></table>";return divX;}
function rbf_createContainerBottom(style){var divX=document.createElement("div");divX.className='wide supersmall';divX.height='9';divX.innerHTML="<table border=0 cellpadding=0 cellspacing=0 class='wide'><tr height='9'><td width='7' class='rbs_"+style+"_blc'><img src='../images/borderspacer.gif' alt='' width='7' height='1' border='0' align='absmiddle'/></td><td class='wide rbs_"+style+"_bottom'></td><td width=7 class='rbs_"+style+"_brc'><img src='../images/borderspacer.gif' alt='' width='7' height='1' border='0' align='absmiddle'/></td></tr></table>";return divX;}
function rbf_createContainerLeftCell(style){var tdX=document.createElement("td");tdX.className='rbs_'+style+'_left';tdX.width='7';tdX.innerHTML="<img src='../images/borderspacer.gif' alt='' width='7' height='1' border='0' align='absmiddle'/>";return tdX;}
function rbf_createContainerRightCell(style){var tdX=document.createElement("td");tdX.className='rbs_'+style+'_right';tdX.width='7';tdX.innerHTML="<img src='../images/borderspacer.gif' alt='' width='7' height='1' border='0' align='absmiddle'/>";return tdX;}
function rbf_getMousePosition(e){if(e==null){e=window.event;}
if(e==null){return false;}
var iebody=(document.compatMode&&document.compatMode!="BackCompat")?document.documentElement:document.body;var dsocleft=document.all?iebody.scrollLeft:pageXOffset;var dsoctop=document.all?iebody.scrollTop:pageYOffset;var pos=new Array();pos[0]=e.clientX+dsocleft;pos[1]=e.clientY+dsoctop;return pos;}
function rbf_isMouseIn(e,component){var mousePos=rbf_getMousePosition(e);if(!mousePos){return false;}
var pos=rbf_findPosition(component);var pxMin=pos[0];var pyMin=pos[1];var pwidth=rbf_extractNumber(component.offsetWidth);var pheight=rbf_extractNumber(component.offsetHeight);var pxMax=pxMin+pwidth;var pyMax=pyMin+pheight;if(mousePos[0]>=pxMin&&mousePos[0]<=pxMax&&mousePos[1]>=pyMin&&mousePos[1]<=pyMax){return true;}
return false;}
function rbf_extractNumber(value){var n=parseInt(value,10);return n==null||isNaN(n)?0:n;}
function rbf_replaceAll(str,fromExp,to){str=str.replace(fromExp,to);return str;}
function rbf_encode(str){return rbf_replaceAll(encodeURI(str),'#','%23');}
function rbf_stopEnterKey(evt){var evt=(evt)?evt:((event)?event:null);var node=(evt.target)?evt.target:((evt.srcElement)?evt.srcElement:null);if((evt.keyCode==13)&&(node.type!="textarea")){return false;}}
function rbf_checkForInt(evt){evt=(evt)?evt:window.event;var charCode=(evt.which)?evt.which:evt.keyCode
return(charCode<=31||(charCode>=48&&charCode<=57))}
function rbf_ensureIntInput(e){if(!rbf_checkForInt(e)){if(!e)var e=window.event;e.cancelBubble=true;if(e.stopPropagation)e.stopPropagation();return false;}
return true;}
function rbf_consumeEvent(e){if(!e)var e=window.event;e.cancelBubble=true;if(e.stopPropagation)e.stopPropagation();return false;}
document.onmouseup=hidePopupCalendar;var rbv_calPopupToday=new Date();var rbv_calPopupYear=rbv_calPopupToday.getFullYear();var rbv_calPopupMonth=rbv_calPopupToday.getMonth();var rbv_calPopupExtField="";var rbv_calPopupPattern="MM/dd/yyyy";var rbv_calPopupTimePattern="hh:mm a";var rbv_calPopup=document.createElement('div');var rbv_calPopupContainer=document.createElement('div');var rbv_hidePopupCalendarEnabled=true;var rbv_calPopupTimeEnabled=false;var rbv_calPopupSelectedDay=0;function rbf_initializeCalendar(){rbv_calPopupContainer.style.cssText='position:absolute;display:none;';rbv_calPopupContainer.style.width="180px";rbv_calPopupContainer.className="primary";rbv_calPopupContainer.appendChild(rbv_calPopup);rbv_calPopupContainer.style.borderStyle='solid';rbv_calPopupContainer.style.borderWidth='2px';rbv_calPopupContainer.style.borderColor='#CCCCCC'
rbv_calPopupContainer.timeDiv=document.createElement('div');rbv_calPopupContainer.className='top wide center primary';rbv_calPopupContainer.hourSelect=document.createElement('select');rbv_calPopupContainer.hourSelect.id='hourSelect';rbv_calPopupContainer.hourSelect.onfocus=rbf_disablePopupCalendarHide;rbv_calPopupContainer.hourSelect.onblur=rbf_enablePopupCalendarHide;rbv_calPopupContainer.hourSelect.onchange=function(){setDate(rbv_calPopupSelectedDay);};rbv_calPopupContainer.minSelect=document.createElement('select');rbv_calPopupContainer.minSelect.id='minSelect';rbv_calPopupContainer.minSelect.onfocus=rbf_disablePopupCalendarHide;rbv_calPopupContainer.minSelect.onblur=rbf_enablePopupCalendarHide;rbv_calPopupContainer.minSelect.onchange=function(){setDate(rbv_calPopupSelectedDay);};var spacer1=document.createElement('span');spacer1.innerHTML="&nbsp;:&nbsp;";rbv_calPopupContainer.timeDiv.appendChild(rbv_calPopupContainer.hourSelect);rbv_calPopupContainer.timeDiv.appendChild(spacer1);rbv_calPopupContainer.timeDiv.appendChild(rbv_calPopupContainer.minSelect);rbv_calPopupContainer.appendChild(rbv_calPopupContainer.timeDiv);rbv_calPopupContainer.linespace1=document.createElement('div');rbv_calPopupContainer.linespace1.innerHTML="<table><tr height=5><td></td></tr></table>";rbv_calPopupContainer.appendChild(rbv_calPopupContainer.linespace1);rbv_calPopupContainer.buttonDiv=document.createElement('div');rbv_calPopupContainer.buttonDiv.className='top wide center primary';rbv_calPopupContainer.closeButton=document.createElement('input');rbv_calPopupContainer.closeButton.type="button";rbv_calPopupContainer.closeButton.value="Close";rbv_calPopupContainer.buttonDiv.appendChild(rbv_calPopupContainer.closeButton);rbv_calPopupContainer.appendChild(rbv_calPopupContainer.buttonDiv);if(rbv_calPopupContainer.closeButton.addEventListener){rbv_calPopupContainer.closeButton.addEventListener('click',rbf_hidePopupCalendarAction,false);}
else if(rbv_calPopupContainer.closeButton.attachEvent){rbv_calPopupContainer.closeButton.attachEvent('onclick',rbf_hidePopupCalendarAction);}
rbv_calPopupContainer.linespace2=document.createElement('div');rbv_calPopupContainer.linespace2.innerHTML="<table><tr height=5><td></td></tr></table>";rbv_calPopupContainer.appendChild(rbv_calPopupContainer.linespace2);}
function rbf_appendCalendar(){document.body.appendChild(rbv_calPopupContainer);}
function rbf_disablePopupCalendarHide(){rbv_hidePopupCalendarEnabled=false;}
function rbf_enablePopupCalendarHide(){rbv_hidePopupCalendarEnabled=true;}
function rbf_hidePopupCalendarAction(e){rbv_calPopupContainer.style.display='none';rbv_hidePopupCalendarEnabled=true;}
function hidePopupCalendar(e){if(!rbv_hidePopupCalendarEnabled){return;}
if(rbv_calPopupContainer){if(rbv_calPopupContainer.style.display=='block'){if(rbf_isMouseIn(e,rbv_calPopupContainer)){return;}
else if(rbf_isMouseIn(e,rbv_calPopupContainer.hourSelect)){return;}
rbv_calPopupContainer.style.display='none';}}}
function generateDate(userDateStr){var dateArray;var day;var month;var year;if(!userDateStr)
return new Date();switch(rbv_calPopupPattern){case"dd/MM/yyyy":dateArray=userDateStr.split("/");day=parseInt(dateArray[0],10);month=parseInt(dateArray[1],10)-1;year=parseInt(dateArray[2],10);break;case"MM/dd/yyyy":dateArray=userDateStr.split("/");day=parseInt(dateArray[1],10);month=parseInt(dateArray[0],10)-1;year=parseInt(dateArray[2],10);break;case"dd.MM.yyyy":dateArray=userDateStr.split(".");day=parseInt(dateArray[0],10);month=parseInt(dateArray[1],10)-1;year=parseInt(dateArray[2],10);break;case"yyyy-MM-dd":dateArray=userDateStr.split("-");year=parseInt(dateArray[0],10);month=parseInt(dateArray[1],10)-1;day=parseInt(dateArray[2],10);break;case"dd-MM-yyyy":dateArray=userDateStr.split("-");day=parseInt(dateArray[0],10);month=parseInt(dateArray[1],10)-1;year=parseInt(dateArray[2],10);break;}
if(isNaN(day)||isNaN(month)||isNaN(year))
return new Date();if(year<50)
year+=2000;else if(year<100)
year+=1900;var dateTokens=userDateStr.split(" ");if(dateTokens.length>1){var time=dateTokens[1].split(":");var hr=parseInt(time[0],10);var min=parseInt(time[1],10);if(isNaN(hr)||isNaN(min))
newDate=new Date(year,month,day);else
newDate=new Date(year,month,day,hr,min);}
else
newDate=new Date(year,month,day);return newDate;}
function rbf_openCalendar(valInputName,datePattern,showTime,timePattern){rbv_hidePopupCalendarEnabled=true;rbv_calPopupExtField=valInputName;rbv_calPopupTimePattern=timePattern;rbv_calPopupPattern=datePattern;if(valInputName)
rbv_userDateStr=document.getElementsByName(valInputName)[0].value;rbv_calPopupDate=generateDate(rbv_userDateStr);if(timePattern&&timePattern.indexOf('a')>-1){if(rbv_userDateStr!="")
{var dateTokens=rbv_userDateStr.split(" ");userampm=dateTokens[dateTokens.length-1].toLowerCase();}
else
userampm=null;}
else
userampm=null;if(showTime&&timePattern){rbv_calPopupTimeEnabled=true;rbv_calPopupTimePattern=timePattern;initializeTime(rbv_calPopupDate,userampm);}
else{rbv_calPopupTimeEnabled=false;}
if(rbv_calPopupTimeEnabled){rbv_calPopupContainer.linespace1.style.display='block';rbv_calPopupContainer.timeDiv.style.display='block';}
else{rbv_calPopupContainer.linespace1.style.display='none';rbv_calPopupContainer.timeDiv.style.display='none';}
var field=document.getElementById(rbv_calPopupExtField);var pos=rbf_findCPPosition(field);var x=pos[0];var y=pos[1];rbv_calPopupContainer.style.left=x+"px";rbv_calPopupContainer.style.top=y+field.offsetHeight+"px";rbv_calPopupContainer.style.display='block';rbv_calPopup.innerHTML=getCldBody(rbv_calPopupDate);return false;}
function initializeTime(calDate,userampm){rbf_removeAllChildren(rbv_calPopupContainer.hourSelect);rbf_removeAllChildren(rbv_calPopupContainer.minSelect);userhour=calDate.getHours();usermin=calDate.getMinutes();var hours=new Array();if(rbv_calPopupTimePattern.indexOf('a')>-1){if(!userampm)
{userampm='am';if(userhour>11)
userampm='pm';}
if(userhour==0)
userhour=12;if(userhour>12)userhour-=12;var hour=12;var ampm='am';for(var i=0;i<24;i++){hours[i]={"name":""+hour+ampm,"hour":hour,"ampm":ampm,"index":i};if(hour==12){hour=1;}
else if(hour==11){hour=12;ampm='pm';}
else{hour++;}}}
else{var hour=0;for(var i=0;i<24;i++){hours[i]={"name":""+(hour<10?'0'+hour:hour),"hour":hour,"ampm":'',"index":i};hour++;}}
var minutes=new Array();for(var i=0;i<60;i++){var minute=i;if(i<10){minute='0'+minute;}
minutes[i]=minute;}
for(var i=0;i<hours.length;i++){var option=document.createElement("option");option.value=hours[i].hour;option.id="rbe_calPopupHoursOption"+hours[i].index;if(hours[i].hour==userhour&&(!userampm||hours[i].ampm==userampm))
option.selected='true';option.hindex=hours[i].index;option.innerHTML=hours[i].name;rbv_calPopupContainer.hourSelect.appendChild(option);}
for(var i=0;i<minutes.length;i++){var option=document.createElement("option");option.value=minutes[i];option.id="rbe_calPopupMinutesOption"+minutes[i];if(minutes[i]==usermin)
option.selected='true';option.mindex=minutes[i];option.innerHTML=minutes[i];rbv_calPopupContainer.minSelect.appendChild(option);}}
function getDaysInMonth(calDate){var days;var month=calDate.getMonth()+1;var year=calDate.getFullYear();if(month==1||month==3||month==5||month==7||month==8||month==10||month==12){days=31;}
else if(month==4||month==6||month==9||month==11){days=30;}
else if(month==2){if(isLeapYear(year)){days=29;}
else{days=28;}}
return(days);}
function isLeapYear(Year){if(((Year%4)==0)&&((Year%100)!=0)||((Year%400)==0)){return(true);}
else{return(false);}}
function minusMonth(month,year,day){rbv_calPopupMonth=month;rbv_calPopupYear=year;if(rbv_calPopupMonth==0){rbv_calPopupMonth=11;rbv_calPopupYear=rbv_calPopupYear-1;}
else{rbv_calPopupMonth=rbv_calPopupMonth-1;}
calDate=new Date(rbv_calPopupYear,rbv_calPopupMonth,day);rbv_calPopup.innerHTML=getCldBody(calDate);}
function plusMonth(month,year,day){day=1;rbv_calPopupMonth=month;rbv_calPopupYear=year;if(rbv_calPopupMonth==11){rbv_calPopupMonth=0;rbv_calPopupYear=rbv_calPopupYear+1;}
else{rbv_calPopupMonth=rbv_calPopupMonth+1;}
calDate=new Date(rbv_calPopupYear,rbv_calPopupMonth,day);rbv_calPopup.innerHTML=getCldBody(calDate);}
function setDate(day){rbv_calPopupSelectedDay=day;var sMonth=""+(rbv_calPopupMonth+1);if(sMonth.length<2)sMonth="0"+sMonth;var sDay=""+day;if(sDay.length<2)sDay="0"+sDay;var sYear=""+rbv_calPopupYear;var date=rbv_calPopupPattern;date=date.replace("dd",sDay);date=date.replace("d",""+day);date=date.replace("MM",sMonth);date=date.replace("M",sMonth);date=date.replace("yyyy",sYear);date=date.replace("yy",sYear.substring(2));if(rbv_calPopupTimeEnabled){var sHour=parseInt(rbv_calPopupContainer.hourSelect.value,10);var sMin=rbv_calPopupContainer.minSelect.value;var hourIndex=document.getElementById('hourSelect').selectedIndex;var option;if(hourIndex){option=document.getElementById('hourSelect')[hourIndex];}
var sAMPM="AM";if(option){sAMPM=option.hindex>11?"PM":"AM";}
date=date+" "+rbv_calPopupTimePattern;date=date.replace("hh",sHour);date=date.replace("HH",sHour);date=date.replace("mm",sMin);date=date.replace("MM",sMin);date=date.replace("a",sAMPM);}
try{var field=document.getElementById(rbv_calPopupExtField);if(field!=null){field.value=date;field.focus();if(field.onchange)
field.onchange();}}
catch(e){alert("problem setting Date value: exception="+e);}
if(!rbv_calPopupTimeEnabled){rbv_calPopupContainer.style.display='none';}}
function getCldBody(rbv_calDate){rbv_calPopupMonth=rbv_calDate.getMonth();rbv_calPopupYear=rbv_calDate.getFullYear();rbv_calPopupDate=rbv_calDate.getDate();var buff="";buff+="<center>";buff+="<table class='rbs_primaryTableNoborder' cellpadding=0 id='cldBody'>";buff+="<tr height='2'><td></td></tr>";buff+="<tr height='2'><td></td></tr>";buff+="<tr>";buff+="<td>";buff+="<table class='rbs_primaryWide'>";buff+="<tr>";buff+="<td class='left' nowrap><a href='javascript:minusMonth("+rbv_calPopupMonth+","+rbv_calPopupYear+","+rbv_calPopupDate+");'>&#60;&#60;</a></td>";buff+="<td class='rbs_miniCalHeader' width='100%' nowrap id='cldHeader'>"+monthArray[rbv_calPopupMonth]+" "+rbv_calPopupYear+"</td>";buff+="<td class='right' nowrap><a href='javascript:plusMonth("+rbv_calPopupMonth+","+rbv_calPopupYear+","+rbv_calPopupDate+");'>&#62;&#62;</a></td>";buff+="</tr>";buff+="</table>";buff+="</td>";buff+="</tr>";buff+="<tr height='2'><td></td></tr>";buff+="<tr>";buff+="<td>";buff+="<table class='miniCalendar'>";buff+="<tr>";for(var k=0;k<7;k++){buff+="<th>"+dowArray[k]+"</th>";}
buff+="</tr>";var firstOfMonth=new Date(rbv_calPopupYear,rbv_calPopupMonth,1);var startingPos=firstOfMonth.getDay();buff+="<tr>";var columnCount=0;for(var k=0;k<firstOfMonth.getDay();k++){buff+="<td class='";if(k==0||k==6)
buff+="weekendDayNotInViewNotBusy";else
buff+="dayNotInViewNotBusy";buff+="'>&nbsp;</td>";columnCount++;}
var days=getDaysInMonth(firstOfMonth);for(var day=1;day<=days;day++){var dow=columnCount%7;buff+="<td align='center' class='";if(day==rbv_calDate.getDate()&&rbv_calPopupMonth==rbv_calDate.getMonth()&&rbv_calPopupYear==rbv_calDate.getFullYear()){buff+="dayCurrent";rbv_calPopupSelectedDay=day;}
else if(dow==0||dow==6)
buff+="weekendDayNotInViewNotBusy";else
buff+="dayNotInViewNotBusy";buff+="'>";var str="<a href='javascript:setDate("+day+");'>"+day+"</a>";buff+=str+"</td>";columnCount++;if(columnCount%7==0)
buff+="</tr><tr>";}
buff+="</tr>";buff+="</table>";buff+="</td>";buff+="</tr>";buff+="<tr height=5><td></td></tr>";buff+="</table>";buff+="</center>";return buff;}
function rbf_findCPPosition(obj){var curleft=curtop=0;if(obj&&obj.offsetParent){curleft=obj.offsetLeft
curtop=obj.offsetTop
while(obj=obj.offsetParent){curleft+=obj.offsetLeft
curtop+=obj.offsetTop}}
return[curleft,curtop];}/********************************************************************
 * openWYSIWYG v1.46c Copyright (c) 2006 openWebWare.com
 * Contact us at devs@openwebware.com
 * This copyright notice MUST stay intact for use.
 *
 * $Id: wysiwyg.js,v 1.10 2006/12/25 09:17:07 xhaggi Exp $
 *
 * An open source WYSIWYG editor for use in web based applications.
 * For full source code and docs, visit http://www.openwebware.com
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along
 * with this library; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, MA 02111-1307 USA
 ********************************************************************/
var rbv_CSStheme = (typeof rbv_rootCSSURL == "undefined" ? "" : rbv_rootCSSURL);

var WYSIWYG = {

	/**
	 * Settings class, holds all customizeable properties
	 */
	Settings: function() {

		// Images Directory
		this.ImagesDir = rbv_rootURL+"images/wysiwyg/";

		// Popups Directory
		this.PopupsDir = rbv_rootURL+"wysiwyg/";

		// CSS Directory File
		this.CSSFile = rbv_rootURL+"css/wysiwyg.css";

		// Default WYSIWYG width and height (use px or %)
		this.Width = "100%";
		this.Height = "270px";

		// Default stylesheet of the WYSIWYG editor window
		this.DefaultStyle = "font-family: Arial; font-size: 12px; background-color: #FFFFFF";

		// Stylesheet if editor is disabled
		this.DisabledStyle = "font-family: Arial; font-size: 12px; background-color: #EEEEEE";

		// Width + Height of the preview window
		this.PreviewWidth = 650;
		this.PreviewHeight = 450;

		// Confirmation message if you strip any HTML added by word
		this.RemoveFormatConfMessage = "Clean HTML inserted by MS Word ?";

		// Nofication if browser is not supported by openWYSIWYG, leave it blank for no message output.
		this.NoValidBrowserMessage = "The Rollbase HTML editor does not support your browser. An up to date version of Firefox or Internet Explorer is recommended.";

		// Anchor path to strip, leave it blank to ignore
		// or define auto to strip the path where the editor is placed
		// (only IE)
		this.AnchorPathToStrip = "";//"auto";
		
		// Image path to strip, leave it blank to ignore
		// or define auto to strip the path where the editor is placed
		// (only IE)
		this.ImagePathToStrip = "";//"auto";

		// Enable / Disable the custom context menu
		this.ContextMenu = false;

		// Enabled the status bar update. Within the status bar
		// node tree of the actually selected element will build
		this.StatusBarEnabled = false;

		// If enabled than the capability of the IE inserting line breaks will be inverted.
		// Normal: ENTER = <p> , SHIFT + ENTER = <br>
		// Inverted: ENTER = <br>, SHIFT + ENTER = <p>
		this.InvertIELineBreaks = false;

		// Replace line breaks with <br> tags
		this.ReplaceLineBreaks = false;

		// Insert image implementation
		this.ImagePopupFile = "";
		this.ImagePopupWidth = 0;
		this.ImagePopupHeight = 0;

		// Holds the available buttons displayed
		// on the toolbar of the editor
		this.Toolbar = new Array();
		this.Toolbar[0] = new Array(
			"bold",
			"italic",
			"underline",
			"seperator",
			"font",
			"fontsize",
			"seperator",
			"forecolor",
			"backcolor",
			"createlink",
			"insertimage",
			"inserttable",
			"seperator",
			"orderedlist",
			"unorderedlist",
			"outdent",
			"indent",
			"seperator",
			"justifyleft",
			"justifycenter",
			"justifyright",
			"removeformat",
			"seperator",
			"preview",
			"seperator",
			"viewSource"
		);
		/*this.Toolbar[1] = new Array(
			//"subscript",
			//"superscript",
			//"seperator",
			//"cut",
			//"strikethrough",
			"copy",
			"paste",
			"removeformat",
			"seperator",
			"undo",
			"redo",
			"seperator",
			"inserttable",
			"insertimage",
			"createlink",
			"seperator",
			"preview",
			"print",
			"seperator",
			"viewSource"//,
			//"seperator",
			//"help"
		);*/

		// List of available font types
	    this.Fonts = new Array(
			"Arial",
			"Sans Serif",
			"Tahoma",
			"Verdana",
			"Courier New",
			"Georgia",
			"Times New Roman",
			"Impact",
			"Comic Sans MS"
		);

		// List of available font sizes
	    this.Fontsizes = new Array(
			"1",
			"2",
			"3",
			"4",
			"5",
			"6",
			"7"
		);

		// Add the given element to the defined toolbar
		// on the defined position
		this.addToolbarElement = function(element, toolbar, position) {
			if(element != "seperator") {this.removeToolbarElement(element);}
			if(this.Toolbar[toolbar-1] == null) {
				this.Toolbar[toolbar-1] = new Array();
			}
			this.Toolbar[toolbar-1].splice(position+1, 1, element);
		};

		// Remove an element from the toolbar
		this.removeToolbarElement = function(element) {
			if(element == "seperator") {return;} // do not remove seperators
			for(var i=0;i<this.Toolbar.length;i++) {
				if(this.Toolbar[i]) {
					var toolbar = this.Toolbar[i];
					for(var j=0;j<toolbar.length;j++) {
						if(toolbar[j] != null && toolbar[j] == element) {
							this.Toolbar[i].splice(j,1);
						}
					}
				}
			}
		};

		// clear all or a given toolbar
		this.clearToolbar = function(toolbar) {
			if(typeof toolbar == "undefined") {
				this.Toolbar = new Array();
			}
			else {
				this.Toolbar[toolbar+1] = new Array();
			}
		};

	},


	/* ---------------------------------------------------------------------- *\
		!! Do not change something below or you know what you are doning !!
	\* ---------------------------------------------------------------------- */

	// List of available block formats (not in use)
	//BlockFormats: new Array("Address", "Bulleted List", "Definition", "Definition Term", "Directory List", "Formatted", "Heading 1", "Heading 2", "Heading 3", "Heading 4", "Heading 5", "Heading 6", "Menu List", "Normal", "Numbered List"),

	// List of available actions and their respective ID and images
	ToolbarList: {
	//Name              buttonID               buttonTitle           	buttonImage               buttonImageRollover
	"bold":           ['Bold',                 'Bold',               	'bold.gif',               'bold_on.gif'],
	"italic":         ['Italic',               'Italic',             	'italics.gif',            'italics_on.gif'],
	"underline":      ['Underline',            'Underline',          	'underline.gif',          'underline_on.gif'],
	"strikethrough":  ['Strikethrough',        'Strikethrough',      	'strikethrough.gif',      'strikethrough_on.gif'],
	"seperator":      ['',                     '',                   	'seperator.gif',          'seperator.gif'],
	"subscript":      ['Subscript',            'Subscript',          	'subscript.gif',          'subscript_on.gif'],
	"superscript":    ['Superscript',          'Superscript',        	'superscript.gif',        'superscript_on.gif'],
	"justifyleft":    ['Justifyleft',          'Justifyleft',        	'justify_left.gif',       'justify_left_on.gif'],
	"justifycenter":  ['Justifycenter',        'Justifycenter',      	'justify_center.gif',     'justify_center_on.gif'],
	"justifyright":   ['Justifyright',         'Justifyright',       	'justify_right.gif',      'justify_right_on.gif'],
	"unorderedlist":  ['InsertUnorderedList',  'Insert Unordered List',	'list_unordered.gif',     'list_unordered_on.gif'],
	"orderedlist":    ['InsertOrderedList',    'Insert Ordered List',  	'list_ordered.gif',       'list_ordered_on.gif'],
	"outdent":        ['Outdent',              'Outdent',            	'indent_left.gif',        'indent_left_on.gif'],
	"indent":         ['Indent',               'Indent',             	'indent_right.gif',       'indent_right_on.gif'],
	"cut":            ['Cut',                  'Cut',                	'cut.gif',                'cut_on.gif'],
	"copy":           ['Copy',                 'Copy',               	'copy.gif',               'copy_on.gif'],
	"paste":          ['Paste',                'Paste',              	'paste.gif',              'paste_on.gif'],
	"forecolor":      ['ForeColor',            'Fore Color',          	'forecolor.gif',          'forecolor_on.gif'],
	"backcolor":      ['BackColor',            'Back Color',          	'backcolor.gif',          'backcolor_on.gif'],
	"undo":           ['Undo',                 'Undo',               	'undo.gif',               'undo_on.gif'],
	"redo":           ['Redo',                 'Redo',               	'redo.gif',               'redo_on.gif'],
	"inserttable":    ['InsertTable',          'Insert Table',        	'insert_table.gif',       'insert_table_on.gif'],
	"insertimage":    ['InsertImage',          'Insert Image',        	'insert_picture.gif',     'insert_picture_on.gif'],
	"createlink":     ['CreateLink',           'Create Link',         	'insert_hyperlink.gif',   'insert_hyperlink_on.gif'],
	"viewSource":     ['ViewSource',           'View Source',         	'view_source.gif',        'view_source_on.gif'],
	"viewText":       ['ViewText',             'View Text',           	'view_text.gif',          'view_text_on.gif'],
	"help":           ['Help',                 'Help',               	'help.gif',               'help_on.gif'],
	"selectfont":     ['SelectFont',           'Select Font',        	'select_font.gif',        'select_font_on.gif'],
	"selectsize":     ['SelectSize',           'Select Size',        	'select_size.gif',        'select_size_on.gif'],
	"preview":		  ['Preview', 			   'Preview',       	 	'preview.gif',			   'preview_on.gif'],
	"print":		  ['Print', 			   'Print',       	 	 	'print.gif',			   'print_on.gif'],
	"removeformat":   ['RemoveFormat',         'Strip Word HTML',    	'remove_format.gif',      'remove_format_on.gif'],
	"delete":         ['Delete',               'Delete',             	'delete.gif',     		   'delete_on.gif']
	},

	// stores the different settings for each textarea
	// the textarea identifier is used to store the settings object
	config: new Array(),
	// Create viewTextMode global variable and set to 0
	// enabling all toolbar commands while in HTML mode
	viewTextMode: new Array(),

	/**
	 * Get the range of the given selection
	 *
	 * @param {Selection} sel Selection object
	 * @return {Range} Range object
	 */
	getRange: function(sel) {
		return sel.createRange ? sel.createRange() : sel.getRangeAt(0);
	},

	/**
	 * Get the iframe object of the WYSIWYG editor
	 *
	 * @param {String} n Editor identifier
	 * @return {HtmlIframeObject} Iframe object
	 */
	getEditor: function(n) {
		return $("wysiwyg" + n);
	},

	/**
	 * Get editors window element
	 *
	 * @param {String} n Editor identifier
	 * @return {Object} Html window object
	 */
	getEditorWindow: function(n) {
		return this.getEditor(n).contentWindow;
	},

	/**
	 * Attach the WYSIWYG editor to the given textarea element
	 *
	 * @param {String} id Textarea identifier (all = all textareas)
	 * @param {Settings} settings the settings which will be applied to the textarea
	 */
	attach: function(id, settings) {
		if(id != "all") {
			this.setSettings(id, settings);
			WYSIWYG_Core.includeCSS(this.config[id].CSSFile);
			if (rbv_useStyleSheetInWYSIWYG) {
				WYSIWYG_Core.includeCSS(rbv_CSStheme);
			}
			WYSIWYG_Core.addEvent(window, "load", function generateEditor() {WYSIWYG._generate(id, settings);});
		}
		else {
			WYSIWYG_Core.addEvent(window, "load", function generateEditor() {WYSIWYG.attachAll(settings);});
		}
	},

	/**
	 * Attach the WYSIWYG editor to all textarea elements
	 *
	 * @param {Settings} settings Settings to customize the look and feel
	 *
	 * CUSTOMIZED BY MATT: Look for specifically named divs and unhide
	 *                     them after activation
	 */
	attachAll: function(settings) {
		var areas = document.getElementsByTagName("textarea");
		for(var i=0;i<areas.length;i++) {
			var id = areas[i].getAttribute("id");
			if(!id || id == null || id == "") continue;

			var wysiwygDiv = document.getElementById('wysiwyg_'+id+'_div');
			if (!wysiwygDiv || wysiwygDiv == null || wysiwygDiv == "") continue;

			this.setSettings(id, settings);
			WYSIWYG_Core.includeCSS(this.config[id].CSSFile);
			WYSIWYG._generate(id, settings);

			wysiwygDiv.style.display='block';
		}
		if (rbv_useStyleSheetInWYSIWYG) {
			WYSIWYG_Core.includeCSS(rbv_CSStheme);
		}
	},

	/**
	 * Display an iframe instead of the textarea.
	 * It's used as textarea replacement to display HTML.
	 *
	 * @param id Textarea identifier (all = all textareas)
	 * @param settings the settings which will be applied to the textarea
	 */
	display: function(id, settings) {
		if(id != "all") {
			this.setSettings(id, settings);
			WYSIWYG_Core.includeCSS(this.config[id].CSSFile);
			if (rbv_useStyleSheetInWYSIWYG) {
				WYSIWYG_Core.includeCSS(rbv_CSStheme);
			}
			WYSIWYG_Core.addEvent(window, "load", function displayIframe() {WYSIWYG._display(id, settings);});
		}
		else {
			WYSIWYG_Core.addEvent(window, "load", function displayIframe() {WYSIWYG.displayAll(settings);});
		}
	},

	/**
	 * Display an iframe instead of the textarea.
	 * It's apply the iframe to all textareas found in the current document.
	 *
	 * @param settings Settings to customize the look and feel
	 */
	displayAll: function(settings) {
		var areas = document.getElementsByTagName("textarea");
		for(var i=0;i<areas.length;i++) {
			var id = areas[i].getAttribute("id");
			if(id == null || id == "") continue;
			this.setSettings(id, settings);
			WYSIWYG_Core.includeCSS(this.config[id].CSSFile);
			WYSIWYG._display(id, settings);
		}
		if (rbv_useStyleSheetInWYSIWYG) {
			WYSIWYG_Core.includeCSS(rbv_CSStheme);
		}
	},

	/**
	 * Set settings in config array, use the textarea id as identifier
	 *
	 * @param n Textarea identifier (all = all textareas)
	 * @param settings the settings which will be applied to the textarea
	 */
	setSettings: function(n, settings) {
		if(typeof(settings) != "object") {
			this.config[n] = new this.Settings();
		}
		else {
			this.config[n] = settings;
		}
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : insertImage()
	  Description : insert an image into WYSIWYG in rich text
	  Usage       : WYSIWYG.insertImage("test.jpg", 500, 200, "center", 0, "Picture Alternativ", 5, 5, "textareaID")
	  Arguments   : src - Source of the image
	  				width - Width
					height - Height
					align - Alignment of the image
					border - border
					alt - Alternativ Text
					hspace - Horizontal Space
					vspace - Vertical Space
	                n  - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	insertImage: function(src, width, height, align, border, alt, hspace, vspace, n) {

		// get editor
		var doc = this.getEditorWindow(n).document;
		// get selection and range
		var sel = this.getSelection(n);
		var range = this.getRange(sel);

		// the current tag of range
		var img = this.findParentTag("img", range);

		// element is not a link
		var update = (img == null) ? false : true;
		if(!update) {
			img = doc.createElement("img");
		}

		// set the attributes
		WYSIWYG_Core.setAttribute(img, "src", src);
		WYSIWYG_Core.setAttribute(img, "style", "width:" + width + ";height:" + height);
		if(align != "") { WYSIWYG_Core.setAttribute(img, "align", align); } else { img.removeAttribute("align"); }
		WYSIWYG_Core.setAttribute(img, "border", border);
		WYSIWYG_Core.setAttribute(img, "alt", alt);
		WYSIWYG_Core.setAttribute(img, "hspace", hspace);
		WYSIWYG_Core.setAttribute(img, "vspace", vspace);
		img.removeAttribute("width");
		img.removeAttribute("height");

		// on update exit here
		if(update) { return; }

		// Check if IE or Mozilla (other)
		if (WYSIWYG_Core.isMSIE) {
			range.pasteHTML(img.outerHTML);
		}
		else {
			this.insertNodeAtSelection(img, n);
		}
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : insertLink()
	  Description : insert a link into WYSIWYG in rich text
	  Usage       : WYSIWYG.insertLink("http://www.google.de", "_blank", "", "", "", "textareaID")
	  Arguments   : href - The link url
	  				target - Target of the link
					style - Stylesheet of the link
					styleClass - Stylesheet class of the link
					name - Name attribute of the link
	                n  - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	insertLink: function(href, target, style, styleClass, name, n) {

		// get editor
		var doc = this.getEditorWindow(n).document;
		// get selection and range
		var sel = this.getSelection(n);
		var range = this.getRange(sel);
		var lin = null;

		// get element from selection
		if(WYSIWYG_Core.isMSIE) {
			if(sel.type == "Control" && range.length == 1) {
				range = this.getTextRange(range(0));
				range.select();
			}
		}

		// find a as parent element
		lin = this.findParentTag("a", range);

		// check if parent is found
		var update = (lin == null) ? false : true;
		if(!update) {
			lin = doc.createElement("a");
		}

		// set the attributes
		WYSIWYG_Core.setAttribute(lin, "href", href);
		WYSIWYG_Core.setAttribute(lin, "class", styleClass);
		WYSIWYG_Core.setAttribute(lin, "className", styleClass);
		WYSIWYG_Core.setAttribute(lin, "target", target);
		WYSIWYG_Core.setAttribute(lin, "name", name);
		WYSIWYG_Core.setAttribute(lin, "style", style);

		// on update exit here
		if(update) { return; }

		// Check if IE or Mozilla (other)
		if (WYSIWYG_Core.isMSIE) {
			range.select();
			lin.innerHTML = range.htmlText;
			range.pasteHTML(lin.outerHTML);
		}
		else {
			var node = range.startContainer;
			var pos = range.startOffset;
			if(node.nodeType != 3) { node = node.childNodes[pos]; }
			if(node.tagName)
				lin.appendChild(node);
			else
				lin.innerHTML = sel;
			this.insertNodeAtSelection(lin, n);
		}
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : removeFormat()
	  Description : Strip any HTML added by word
	  Usage       : removeFormat(n)
	  Arguments   : n  - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	removeFormat: function(n) {
		if ( !confirm(this.config[n].RemoveFormatConfMessage) ) { return; }
		var doc = this.getEditorWindow(n).document;
		var str = doc.body.innerHTML;

		str = str.replace(/<span([^>])*>(&nbsp;)*\s*<\/span>/gi, '');
	    str = str.replace(/<span[^>]*>/gi, '');
	    str = str.replace(/<\/span[^>]*>/gi, '');
	    str = str.replace(/<p([^>])*>(&nbsp;)*\s*<\/p>/gi, '');
	    str = str.replace(/<p[^>]*>/gi, '');
	    str = str.replace(/<\/p[^>]*>/gi, '');
	    str = str.replace(/<h([^>])[0-9]>(&nbsp;)*\s*<\/h>/gi, '');
	    str = str.replace(/<h[^>][0-9]>/gi, '');
	    str = str.replace(/<\/h[^>][0-9]>/gi, '');
		str = str.replace (/<B [^>]*>/ig, '<b>');

		// var repl_i1 = /<I[^>]*>/ig;
		// str = str.replace (repl_i1, '<i>');

		str = str.replace (/<DIV[^>]*>/ig, '');
		str = str.replace (/<\/DIV>/gi, '');
		str = str.replace (/<[\/\w?]+:[^>]*>/ig, '');
		str = str.replace (/(&nbsp;){2,}/ig, '&nbsp;');
		str = str.replace (/<STRONG>/ig, '');
		str = str.replace (/<\/STRONG>/ig, '');
		str = str.replace (/<TT>/ig, '');
		str = str.replace (/<\/TT>/ig, '');
		str = str.replace (/<FONT [^>]*>/ig, '');
		str = str.replace (/<\/FONT>/ig, '');
		str = str.replace (/STYLE=\"[^\"]*\"/ig, '');
		str = str.replace(/<([\w]+) class=([^ |>]*)([^>]*)/gi, '<$1$3');
  	    str = str.replace(/<([\w]+) style="([^"]*)"([^>]*)/gi, '<$1$3');
		str = str.replace(/width=([^ |>]*)([^>]*)/gi, '');
	    str = str.replace(/classname=([^ |>]*)([^>]*)/gi, '');
	    str = str.replace(/align=([^ |>]*)([^>]*)/gi, '');
	    str = str.replace(/valign=([^ |>]*)([^>]*)/gi, '');
	    str = str.replace(/<\\?\??xml[^>]>/gi, '');
	    str = str.replace(/<\/?\w+:[^>]*>/gi, '');
	    str = str.replace(/<st1:.*?>/gi, '');
	    str = str.replace(/o:/gi, '');

	    str = str.replace(/<!--([^>])*>(&nbsp;)*\s*<\/-->/gi, '');
   		str = str.replace(/<!--[^>]*>/gi, '');
   		str = str.replace(/<\/--[^>]*>/gi, '');

		doc.body.innerHTML = str;
	},

	/**
	 * Display an iframe instead of the textarea.
	 *
	 * @param n - ID of textarea to replace
	 * @param settings - object which holds the settings
	 */
	_display: function(n, settings) {

		// Get the textarea element 
		var textarea = $(n);

		// Validate if textarea exists
		if(textarea == null) {
			alert("No textarea found with the given identifier (ID: " + n + ").");
			return;
		}

		// Validate browser compatiblity
		if(!WYSIWYG_Core.isBrowserCompatible()) {
			//if(this.config[n].NoValidBrowserMessage != "") { //alert(this.config[n].NoValidBrowserMessage); }
			return;
		}

	        // Load settings in config array, use the textarea id as identifier
		if(typeof(settings) != "object") {
			this.config[n] = new this.Settings();
		}
		else {
			this.config[n] = settings;
		}

		// Hide the textarea
		textarea.style.display = "none";

		// Override the width and height of the editor with the
		// size given by the style attributes width and height
		if(textarea.style.width) {
			this.config[n].Width = textarea.style.width;
		}
		if(textarea.style.height) {
			this.config[n].Height = textarea.style.height
		}

	    // determine the width + height
		var currentWidth = this.config[n].Width;
		var currentHeight = this.config[n].Height;

		// Calculate the width + height of the editor
		var ifrmWidth = "100%";
		var	ifrmHeight = "100%";
		if(currentWidth.search(/%/) == -1) {
			ifrmWidth = currentWidth;
			ifrmHeight = currentHeight;
		}

		// Create iframe which will be used for rich text editing
		var iframe = '<table cellpadding="0" cellspacing="0" border="0" style="width:' + currentWidth + '; height:' + currentHeight + ';" class="tableTextareaEditor"><tr><td valign="top">\n'
	    + '<iframe' + (!WYSIWYG_Core.isMSIE?'onmouseover="this.contentWindow.document.designMode=\'on\'"':'')+' frameborder="0" id="wysiwyg' + n + '" class="iframeText" style="width:' + ifrmWidth + ';height:' + ifrmHeight + ';" src="javascript:void(0)"></iframe>\n'
	    + '</td></tr></table>\n';

	    // Insert after the textArea both toolbar one and two
		textarea.insertAdjacentHTML("afterEnd", iframe);

		// Pass the textarea's existing text over to the content variable
	    var content = textarea.value;
		var doc = this.getEditorWindow(n).document;

		// Replace all \n with <br>
		if(this.config[n].ReplaceLineBreaks) {
			content = content.replace(/(\r\n)|(\n)/ig, "<br>");
		}

		// Write the textarea's content into the iframe
	    doc.open();
	    doc.write(content);
		  if (content.indexOf("browntheme.css")<1 && rbv_useStyleSheetInWYSIWYG){
			var csslink = document.createElement("link");
			WYSIWYG_Core.setAttribute(csslink, "rel", "stylesheet");
			WYSIWYG_Core.setAttribute(csslink, "type", "text/css");
			WYSIWYG_Core.setAttribute(csslink, "href", rbv_CSStheme);
			var heads = doc.getElementsByTagName("head");
			for(var i=0;i<heads.length;i++) {
				heads[i].appendChild(csslink);
			}
		  }
	    doc.close();

	    // Set default style of the editor window
		WYSIWYG_Core.setAttribute(doc.body, "style", this.config[n].DefaultStyle);
	},

	/**
	 * Replace the given textarea with wysiwyg editor
	 *
	 * @param n - ID of textarea to replace
	 * @param settings - object which holds the settings
	 */
	_generate: function(n, settings) {

		 // Get the textarea element
		var textarea = $(n);
		// Validate if textarea exists
		if(textarea == null) {
			alert("No textarea found with the given identifier (ID: " + n + ").");
			return;
		}

		// Validate browser compatiblity
		if(!WYSIWYG_Core.isBrowserCompatible()) {
			//if(this.config[n].NoValidBrowserMessage != "") { //alert(this.config[n].NoValidBrowserMessage); }
			return;
		}

		// Hide the textarea
		textarea.style.display = 'none';

		// Override the width and height of the editor with the
		// size given by the style attributes width and height
		if(textarea.style.width) {
			this.config[n].Width = textarea.style.width;
		}
		if(textarea.style.height) {
			this.config[n].Height = textarea.style.height
		}

	    // determine the width + height
		var currentWidth = this.config[n].Width;
		var currentHeight = this.config[n].Height;

		// Calculate the width + height of the editor
		var toolbarWidth = currentWidth;
		var ifrmWidth = "100%";
		var	ifrmHeight = "100%";
		if(currentWidth.search(/%/) == -1) {
			toolbarWidth = currentWidth.replace(/px/gi, "");
			toolbarWidth = (parseFloat(toolbarWidth) + 2) + "px";
			ifrmWidth = currentWidth;
			ifrmHeight = currentHeight;
		}


	    // Generate the WYSIWYG Table
	    // This table holds the toolbars and the iframe as the editor
	    var editor = "";
	    editor += '<table border="0" cellpadding="0" cellspacing="0" class="tableTextareaEditor" id="wysiwyg_table_' + n + '" style="width:' + currentWidth  + '; height:' + currentHeight + ';">';
	    editor += '<tr><td>';

		// Output all command buttons that belong to toolbar one
		for (var j = 0; j < this.config[n].Toolbar.length;j++) {
			if(this.config[n].Toolbar[j] && this.config[n].Toolbar[j].length > 0) {
				var toolbar = this.config[n].Toolbar[j];

				// Generate WYSIWYG toolbar one
			    editor += '<table border="0" cellpadding="0" cellspacing="0" class="toolbar1" style="width:100%;" id="toolbar' + j + '_' + n + '">';
	    		editor += '<tr><td style="width: 6px;"><img src="' + this.config[n].ImagesDir + 'seperator2.gif" alt="" hspace="3"></td>';

				for (var i = 0; i < toolbar.length;i++) {
				    if (toolbar[i]) {
				    	// Font selection
						if (toolbar[i] == "font"){
							editor += '<td style="width: 90px;"><span id="FontSelect' + n + '"></span></td>';
						}
						// Font size selection
						else if (toolbar[i] == "fontsize"){
							editor += '<td style="width: 60px;"><span id="FontSizes'  + n + '"></span></td>';
						}
						// Button print out
						else {
							// Get the values of the Button from the global ToolbarList object
							var buttonObj = this.ToolbarList[toolbar[i]];
							var buttonID = buttonObj[0];
							var buttonTitle = buttonObj[1];
							var buttonImage = this.config[n].ImagesDir + buttonObj[2];
							var buttonImageRollover  = this.config[n].ImagesDir + buttonObj[3];

							if (toolbar[i] == "seperator") {
								editor += '<td style="width: 12px;" align="center">';
								editor += '<img src="' + buttonImage + '" border=0 unselectable="on" width="2" height="18" hspace="2" unselectable="on">';
								editor += '</td>';
							}
							// View Source button
							else if (toolbar[i] == "viewSource"){
							    editor += '<td style="width: 36px;">';
								editor += '<span id="HTMLMode' + n + '"><img src="'  + buttonImage +  '" border="0" unselectable="on" title="' + buttonTitle + '" id="' + buttonID + '" class="buttonEditorSource" onmouseover="this.className=\'buttonEditorSourceOver\'; this.src=\'' + buttonImageRollover + '\';" onmouseout="this.className=\'buttonEditorSource\'; this.src=\'' + buttonImage + '\';" onclick="WYSIWYG.formatText(\'' + buttonID + '\',\'' + n + '\');" unselectable="on" width="34" height="20"></span>';
								editor += '<span id="textMode' + n + '"><img src="' + this.config[n].ImagesDir + 'view_text.gif" border="0" unselectable="on" title="viewText" id="ViewText" class="buttonEditorSource" onmouseover="this.className=\'buttonEditorSourceOver\'; this.src=\'' + this.config[n].ImagesDir + 'view_text_on.gif\';" onmouseout="this.className=\'buttonEditorSource\'; this.src=\'' + this.config[n].ImagesDir + 'view_text.gif\';" onclick="WYSIWYG.formatText(\'ViewText\',\'' + n + '\');" unselectable="on"  width="34" height="20"></span>';
						        editor += '</td>';
					        }
							else {
								editor += '<td style="width: 22px;">';
								editor += '<img src="' + buttonImage + '" border=0 unselectable="on" title="' + buttonTitle + '" id="' + buttonID + '" class="buttonEditor" onmouseover="this.className=\'buttonEditorOver\'; this.src=\'' + buttonImageRollover + '\';" onmouseout="this.className=\'buttonEditor\'; this.src=\'' + buttonImage + '\';" onclick="WYSIWYG.formatText(\'' + buttonID + '\',\'' + n + '\');" unselectable="on" width="20" height="20">';
								editor += '</td>';
							}
						}
			  		}
			  	}
			  	editor += '<td>&nbsp;</td></tr></table>';
			}
		}

	 	editor += '</td></tr><tr><td valign="top">\n';
		// Create iframe which will be used for rich text editing
		editor += '<iframe ' + (!WYSIWYG_Core.isMSIE?'onmouseover="this.contentWindow.document.designMode=\'on\'"':'')+' frameborder="0" id="wysiwyg' + n + '" class="iframeText" style="width:100%;height:' + currentHeight + ';" src="javascript:void(0)"></iframe>\n'
	    + '</td></tr>';
	    // Status bar HTML code
	    if(this.config[n].StatusBarEnabled) {
		    editor += '<tr><td class="wysiwyg-statusbar" style="height:10px;" id="wysiwyg_statusbar_' + n + '">&nbsp;</td></tr>';
		}
	    editor += '</table>\n';

	    // Insert the editor after the textarea
	    textarea.insertAdjacentHTML("afterEnd", editor);

	    // Insert the Font Type and Size drop downs into the toolbar
	    // Hide the dynamic drop down lists for the Font Types and Sizes
    	this.outputFontSelect(n);
	  	this.outputFontSizes(n);
	  	this.hideFonts(n);
		this.hideFontSizes(n);

		// Hide the "Text Mode" button
		// Validate if textMode Elements are prensent
		if($("textMode" + n)) {
			$("textMode" + n).style.display = 'none';
		}

		// Pass the textarea's existing text over to the content variable
	    var content = textarea.value;
		var doc = this.getEditorWindow(n).document;


		// Replace all \n with <br>
		if(this.config[n].ReplaceLineBreaks) {
			content = content.replace(/\n\r|\n/ig, "<br>");
		}

		// Write the textarea's content into the iframe
	    doc.open();
	    doc.write(content);
		  if (content.indexOf("browntheme.css")<1 && rbv_useStyleSheetInWYSIWYG){
			var csslink = doc.createElement("link");
			WYSIWYG_Core.setAttribute(csslink, "rel", "stylesheet");
			WYSIWYG_Core.setAttribute(csslink, "type", "text/css");
			WYSIWYG_Core.setAttribute(csslink, "href", rbv_CSStheme);
			var heads = doc.getElementsByTagName("head");
			for(var i=0;i<heads.length;i++) {
				heads[i].appendChild(csslink);

			}
		  }
	    doc.close();

		// Make the iframe editable in both Mozilla and IE
		// Improve compatiblity for IE + Mozilla
		if (doc.body.contentEditable) {
			doc.body.contentEditable = true;
		}
		else {
			if (WYSIWYG_Core.isMSIE) {
				doc.designMode = "on";
			}
		}

		// Set default font style
		WYSIWYG_Core.setAttribute(doc.body, "style", this.config[n].DefaultStyle);

	    // Event Handling
	    // Update the textarea with content in WYSIWYG when user submits form
	    for (var idx=0; idx < document.forms.length; idx++) {
	    	WYSIWYG_Core.addEvent(document.forms[idx], "submit", function xxx_aa() { WYSIWYG.updateTextArea(n); });
	    }

	    // close font selection if mouse moves over the editor window
	    WYSIWYG_Core.addEvent(doc, "mouseover", function xxx_bb() { WYSIWYG.hideFonts(n); WYSIWYG.hideFontSizes(n); });

	    // If it's true invert the line break capability of IE
		if(this.config[n].InvertIELineBreaks) {
			if (WYSIWYG_Core.isMSIE) {
				WYSIWYG_Core.addEvent(doc, "keypress", function xxx_cc() { WYSIWYG.invertIELineBreakCapability(n); });
			}
		}

		// status bar update
		if(this.config[n].StatusBarEnabled) {
			WYSIWYG_Core.addEvent(doc, "mouseup", function xxx_dd() { WYSIWYG.updateStatusBar(n); });
		}

    	// custom context menu
		if(this.config[n].ContextMenu) {
			WYSIWYG_ContextMenu.init(n);
		}

		// init viewTextMode var
	    this.viewTextMode[n] = false;
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : disable()
	  Description : Disable the given WYSIWYG Editor Box
	  Usage       : WYSIWYG.disable(textareaID)
	  Arguments   : textareaID - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	disable: function(textareaID) {
		// set n to textareaID
		var n = textareaID;

		// get the editor window
		var editor = this.getEditorWindow(n);

		// Validate if editor exists
		if(editor == null) {
			alert("No editor found with the given identifier (ID: " + n + ").");
			return;
		}

		if(editor) {
			// disable design mode or content editable feature
			if(editor.document.body.contentEditable) {
				editor.document.body.contentEditable = false;
			}
			else {
				editor.document.designMode = "Off";
			}

			// change the style of the body
			WYSIWYG_Core.setAttribute(editor.document.body, "style", this.config[n].DisabledStyle);

			// hide the status bar
			this.hideStatusBar(n);

			// hide all toolbars
			this.hideToolbars(n);
		}
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : enable()
	  Description : Enables the given WYSIWYG Editor Box
	  Usage       : WYSIWYG.enable(textareaID)
	  Arguments   : textareaID - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	enable: function(textareaID) {
		// set n to textareaID
		var n = textareaID;

		// get the editor window
		var editor = this.getEditorWindow(n);

		// Validate if editor exists
		if(editor == null) {
			alert("No editor found with the given identifier (ID: " + n + ").");
			return;
		}

		if(editor) {
			// disable design mode or content editable feature
			if(editor.document.body.contentEditable){
				editor.document.body.contentEditable = true;
			}
			else {
				editor.document.designMode = "On";
			}

			// change the style of the body
			WYSIWYG_Core.setAttribute(editor.document.body, "style", this.config[n].DefaultStyle);

			// hide the status bar
			this.showStatusBar(n);

			// hide all toolbars
			this.showToolbars(n);
		}
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : getNodeTree()
	  Description : Returns the node structure of the current selection as array
	  Usage       : WYSIWYG.getNodeTree(n);
	  Arguments   : n  - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	getNodeTree: function(n) {

		var sel = this.getSelection(n);
		var range = this.getRange(sel);

		// get element of range
		var tag = this.getTag(range);
		if(tag == null) { return; }
		// get parent of element
		var node = this.getParent(tag);
		// init the tree as array with the current selected element
		var nodeTree = new Array(tag);
		// get all parent nodes
		var ii = 1;

		while(node != null && node.nodeName != "#document") {
			nodeTree[ii] = node;
			node = this.getParent(node);
			ii++;
		}

		return nodeTree;
	},

	/**
	 * Removes the current node of the selection
	 *
	 * @param {String} n The editor identifier (the textarea's ID)
	 */
	removeNode: function(n) {
		// get selection and range
		var sel = this.getSelection(n);
		var range = this.getRange(sel);
		// the current tag of range
		var tag = this.getTag(range);
		var parent = tag.parentNode;
		if(tag == null || parent == null) { return; }
		if(tag.nodeName == "HTML" || tag.nodeName == "BODY") { return; }

		// copy child elements of the node to the parent element before remove the node
		//var childNodes = new Array();
		//for(var i=0; i < tag.childNodes.length;i++)
		//	childNodes[i] = tag.childNodes[i];
		//for(var i=0; i < childNodes.length;i++)
		//	parent.insertBefore(childNodes[i], tag);

		// remove node
		parent.removeChild(tag);
		// validate if parent is a link and the node is only
		// surrounded by the link, then remove the link too
		if(parent.nodeName == "A" && !parent.hasChildNodes()) {
			if(parent.parentNode) { parent.parentNode.removeChild(parent); }
		}
		// update the status bar
		this.updateStatusBar(n);
	},

	/**
	 * Get the selection of the given editor
	 *
	 * @param n The editor identifier (the textarea's ID)
	 */
	getSelection: function(n) {
		var ifrm = this.getEditorWindow(n);
		var doc = ifrm.document;
		var sel = null;
		if(ifrm.getSelection){
			sel = ifrm.getSelection();
		}
		else if (doc.getSelection) {
			sel = doc.getSelection();
		}
		else if (doc.selection) {
			sel = doc.selection;
		}
		return sel;
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : updateStatusBar()
	  Description : Updates the status bar with the current node tree
	  Usage       : WYSIWYG.updateStatusBar(n);
	  Arguments   : n  - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	updateStatusBar: function(n) {

		// get the node structure
		var nodeTree = this.getNodeTree(n);
		if(nodeTree == null) { return; }
		// format the output
		var outputTree = "";
		var max = nodeTree.length - 1;
		for(var i=max;i>=0;i--) {
			if(nodeTree[i].nodeName != "HTML" && nodeTree[i].nodeName != "BODY") {
				outputTree += '<a class="wysiwyg-statusbar" href="javascript:WYSIWYG.selectNode(\'' + n + '\',' + i + ');">' + nodeTree[i].nodeName + '</a>';
			}
			else {
				outputTree += nodeTree[i].nodeName;
			}
			if(i > 0) { outputTree += " > "; }
		}

		// update the status bar
		var statusbar = $("wysiwyg_statusbar_" + n);
		if(statusbar){
			statusbar.innerHTML = outputTree;
		}
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : disableDesignMode()
	  Description : Disable the design mode if right mouse button is pressed.
	  				It's needed for custom context menus on mozilla (firefox),
	  				because if design mode is on then you can`t diabled the browser
	  				context menu.
	  Usage       : WYSIWYG.disableDesignMode(e, n);
	  Arguments   : event - browser event (like which button pressed)
	  				n  - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	disableDesignMode: function(event, n) {
		var doc = this.getEditorWindow(n).document;
		if(event.which == 3) {
			doc.designMode = "off";
			return false;
		}
		else if(event.which != 3 && doc.designMode == "off") {
			doc.designMode = "on";
			return true;
		}
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : formatText() (changed)
	  Description : Format the content within the WYSIWYG Editor
	  Usage       : WYSIWYG.formatText(id, n, selected);
	  Arguments   : cmd - The execCommand (e.g. Bold)
	                n  - The editor identifier that the command affects (the textarea's ID)
	                selected - The selected value when applicable (e.g. Arial)
	\* ---------------------------------------------------------------------- */
	formatText: function(cmd, n, selected) {

		// When user clicks toolbar button make sure it always targets its respective WYSIWYG
		this.getEditorWindow(n).focus();

		// When in Text Mode these execCommands are disabled
		var formatIDs = new Array("FontSize","FontName","Bold","Italic","Underline","Subscript","Superscript","Strikethrough","Justifyleft","Justifyright","Justifycenter","InsertUnorderedList","InsertOrderedList","Indent","Outdent","ForeColor","BackColor","InsertImage","InsertTable","CreateLink", "Preview", "RemoveFormat");

		// Check if button clicked is in disabled list
		for (var i = 0; i < formatIDs.length; i++) {
			if (formatIDs[i] == cmd) {
				 var disabled_id = 1;
			}
		}

		// rbg to hex convertion implementation dependents on browser
		var toHexColor = WYSIWYG_Core.isMSIE ? WYSIWYG_Core._dec_to_rgb : WYSIWYG_Core.toHexColor;

		// popup screen positions
		var popupPosition = {left: parseInt(window.screen.availWidth / 3, 10), top: parseInt(window.screen.availHeight / 3, 10)};

		// Check if in Text Mode and disabled button was clicked
		if (this.viewTextMode[n] == true && disabled_id == 1) {
		  alert("You are in TEXT Mode. This feature has been disabled.");
		  return;
		}

		// Check the insert image popup implementation
		var imagePopupFile = this.config[n].PopupsDir + 'insert_image.html';
		var imagePopupWidth = 400;
		var imagePopupHeight = 210;
		if(typeof this.config[n].ImagePopupFile != "undefined" && this.config[n].ImagePopupFile != "") {
			imagePopupFile = this.config[n].ImagePopupFile;
		}
		if(typeof this.config[n].ImagePopupWidth && this.config[n].ImagePopupWidth > 0) {
			imagePopupWidth = this.config[n].ImagePopupWidth;
		}
		if(typeof this.config[n].ImagePopupHeight && this.config[n].ImagePopupHeight > 0) {
			imagePopupHeight = this.config[n].ImagePopupHeight;
		}

		// switch which action have to do
		switch(cmd) {
			// Font size
			case "FontSize":
				this.getEditorWindow(n).document.execCommand("FontSize", false, selected);
			break;

			// FontName
			case "FontName":
				this.getEditorWindow(n).document.execCommand("FontName", false, selected);
			break;

			// ForeColor and
			case "ForeColor":
				var rgb = this.getEditorWindow(n).document.queryCommandValue(cmd);
		      	var currentColor = rgb != '' ? toHexColor(this.getEditorWindow(n).document.queryCommandValue(cmd)) : "000000";
			  	window.open(this.config[n].PopupsDir + 'select_color.html?color=' + currentColor + '&command=' + cmd + '&wysiwyg=' + n, 'popup', 'location=0,status=0,scrollbars=0,width=210,height=165,top=' + popupPosition.top + ',left=' + popupPosition.left).focus();
			break;

			// BackColor
			case "BackColor":
				var currentColor = toHexColor(this.getEditorWindow(n).document.queryCommandValue(cmd));
			  	window.open(this.config[n].PopupsDir + 'select_color.html?color=' + currentColor + '&command=' + cmd + '&wysiwyg=' + n, 'popup', 'location=0,status=0,scrollbars=0,width=210,height=165,top=' + popupPosition.top + ',left=' + popupPosition.left).focus();
			break;

			// InsertImage
			case "InsertImage":
				window.open(imagePopupFile + '?wysiwyg=' + n, 'popup', 'location=0,status=0,scrollbars=0,resizable=0,width=' + imagePopupWidth + ',height=' + imagePopupHeight + ',top=' + popupPosition.top + ',left=' + popupPosition.left).focus();
			break;

			// Remove Image
			case "RemoveImage":
				this.removeImage(n);
			break;

			// Remove Link
			case "RemoveLink":
				this.removeLink(n);
			break;

			// Remove a Node
			case "RemoveNode":
				this.removeNode(n);
			break;

			// Create Link
			case "CreateLink":
				window.open(this.config[n].PopupsDir + 'insert_hyperlink.html?wysiwyg=' + n, 'popup', 'location=0,status=0,scrollbars=0,resizable=0,width=350,height=160,top=' + popupPosition.top + ',left=' + popupPosition.left).focus();
			break;

			// InsertTable
			case "InsertTable":
				window.open(this.config[n].PopupsDir + 'create_table.html?wysiwyg=' + n, 'popup', 'location=0,status=0,scrollbars=0,resizable=0,width=400,height=360,top=' + popupPosition.top + ',left=' + popupPosition.left).focus();
			break;

			// ViewSource
			case "ViewSource":
				this.viewSource(n);
			break;

			// ViewText
			case "ViewText":
				this.viewText(n);
			break;

			// Help
			case "Help":
				window.open(this.config[n].PopupsDir + 'about.html?wysiwyg=' + n, 'popup', 'location=0,status=0,scrollbars=0,resizable=0,width=400,height=350,top=' + popupPosition.top + ',left=' + popupPosition.left).focus();
			break;

			// Strip any HTML added by word
			case "RemoveFormat":
				this.removeFormat(n);
			break;

			// Preview thx to Korvo
			case "Preview":
				window.open(this.config[n].PopupsDir + 'preview.html?wysiwyg=' + n,'popup', 'location=0,status=0,scrollbars=1,resizable=1,width=' + this.config[n].PreviewWidth + ',height=' + this.config[n].PreviewHeight + ',top=' + popupPosition.top + ',left=' + popupPosition.left).focus();
			break;

			// Print
			case "Print":
				this.print(n);
			break;

			default:
				WYSIWYG_Core.execCommand(n, cmd);

		}

		// hide node the font + font size selection
		this.hideFonts(n);
		this.hideFontSizes(n);
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : insertHTML()
	  Description : Insert HTML into WYSIWYG in rich text
	  Usage       : WYSIWYG.insertHTML("<b>hello</b>", "textareaID")
	  Arguments   : html - The HTML being inserted (e.g. <b>hello</b>)
	                n  - The editor identifier that the HTML
						 will be inserted into (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	insertHTML: function(html, n) {
		if (WYSIWYG_Core.isMSIE) {
			this.getEditorWindow(n).document.selection.createRange().pasteHTML(html);
		}
		else {
			var span = this.getEditorWindow(n).document.createElement("span");
			span.innerHTML = html;
			this.insertNodeAtSelection(span, n);
		}
	},


	/* ---------------------------------------------------------------------- *\
	   Function    : set_wysiwyg()
	   Description : sets html to wysiwyg editor
	   Usage       : set_wysiwyg(html, n);
	   Arguments   : html - The HTML being inserted (e.g. <b>hello</b>)
					 n    - The editor identifier that the HTML will be
							inserted into (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	set_wysiwyg: function(html, n) {
		//var doc = document.getElementById("wysiwyg" + n).contentWindow.document;

		this.getEditorWindow(n).document.body.innerHTML = html;

		// Write the textarea's content into the iframe
		//doc.open();
		//doc.write(html);
		//doc.close();
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : insertNodeAtSelection()
	  Description : insert HTML into WYSIWYG in rich text (mozilla)
	  Usage       : WYSIWYG.insertNodeAtSelection(insertNode, n)
	  Arguments   : insertNode - The HTML being inserted (must be innerHTML inserted within a div element)
	                n          - The editor identifier that the HTML will be inserted into (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	insertNodeAtSelection: function(insertNode, n) {

		// get editor document
		var doc = this.getEditorWindow(n).document;
		// get current selection
		var sel = this.getSelection(n);

		// get the first range of the selection
		// (there's almost always only one range)
		var range = sel.getRangeAt(0);

		// deselect everything
		sel.removeAllRanges();

		// remove content of current selection from document
		range.deleteContents();

		// get location of current selection
		var container = range.startContainer;
		var pos = range.startOffset;

		// make a new range for the new selection
		range = doc.createRange();

		if (container.nodeType==3 && insertNode.nodeType==3) {
			// if we insert text in a textnode, do optimized insertion
			container.insertData(pos, insertNode.data);
			// put cursor after inserted text
			range.setEnd(container, pos+insertNode.length);
			range.setStart(container, pos+insertNode.length);
		}
		else {

			var afterNode;
			var beforeNode;
			if (container.nodeType==3) {
				// when inserting into a textnode
				// we create 2 new textnodes
				// and put the insertNode in between
				var textNode = container;
				container = textNode.parentNode;
				var text = textNode.nodeValue;

				// text before the split
				var textBefore = text.substr(0,pos);
				// text after the split
				var textAfter = text.substr(pos);

				beforeNode = document.createTextNode(textBefore);
				afterNode = document.createTextNode(textAfter);

				// insert the 3 new nodes before the old one
				container.insertBefore(afterNode, textNode);
				container.insertBefore(insertNode, afterNode);
				container.insertBefore(beforeNode, insertNode);

				// remove the old node
				container.removeChild(textNode);
			}
			else {
				// else simply insert the node
				afterNode = container.childNodes[pos];
				container.insertBefore(insertNode, afterNode);
			}

			range.setEnd(afterNode, 0);
			range.setStart(afterNode, 0);
		}

		sel.addRange(range);
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : print()
	  Description : Print out the content of the WYSIWYG editor area
	  Usage       : WYSIWYG.print(n)
	  Arguments   : n - The editor identifier (textarea ID)
	\* ---------------------------------------------------------------------- */
	print: function(n) {
		if(document.all && navigator.appVersion.substring(22,23)==4) {
			var doc = this.getEditorWindow(n).document;
			doc.focus();
			var OLECMDID_PRINT = 6;
			var OLECMDEXECOPT_DONTPROMPTUSER = 2;
			var OLECMDEXECOPT_PROMPTUSER = 1;
			var WebBrowser = '<object id="WebBrowser1" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
			doc.body.insertAdjacentHTML('beforeEnd',WebBrowser);
			WebBrowser.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER);
			WebBrowser.outerHTML = '';
		} else {
			this.getEditorWindow(n).print();
		}
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : outputFontSelect()
	  Description : creates the Font Select drop down and inserts it into the toolbar
	  Usage       : WYSIWYG.outputFontSelect(n)
	  Arguments   : n - The editor identifier that the Font Select will update
		                when making font changes (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	outputFontSelect: function(n) {

		var fontDiv = $('FontSelect' + n);
		if(fontDiv == null) { return; }

		var fonts = this.config[n].Fonts;
		var FontSelectObj = this.ToolbarList['selectfont'];
		var FontSelect = this.config[n].ImagesDir  + FontSelectObj[2];
		var FontSelectOn  = this.config[n].ImagesDir + FontSelectObj[3];
		fonts.sort();

		var FontSelectDropDown = new Array;
		FontSelectDropDown[n] = '<table border="0" cellpadding="0" cellspacing="0"><tr><td onMouseOver="$(\'selectFont' + n + '\').src=\'' + FontSelectOn + '\';" onMouseOut="$(\'selectFont' + n + '\').src=\'' + FontSelect + '\';"><img src="' + FontSelect + '" id="selectFont' + n + '" width="85" height="20" onClick="WYSIWYG.showFonts(\'' + n + '\');" unselectable="on" border="0"><br>';
		FontSelectDropDown[n] += '<span id="Fonts' + n + '" class="dropdown" style="width: 145px;">';

		for (var i = 0; i < fonts.length;i++) {
		  	if (fonts[i]) {
		  		FontSelectDropDown[n] += '<button type="button" onClick="WYSIWYG.formatText(\'FontName\',\'' + n + '\',\'' + fonts[i] + '\')\;" onMouseOver="this.className=\'mouseOver\'" onMouseOut="this.className=\'mouseOut\'" class="mouseOut" style="width: 120px;"><table cellpadding="0" cellspacing="0" border="0"><tr><td align="left" style="font-family:' + fonts[i] + '; font-size: 12px;">' + fonts[i] + '</td></tr></table></button><br>';
		  	}
	  	}

		FontSelectDropDown[n] += '</span></td></tr></table>';
		fontDiv.insertAdjacentHTML("afterBegin", FontSelectDropDown[n]);
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : outputFontSizes()
	  Description : creates the Font Sizes drop down and inserts it into the toolbar
	  Usage       : WYSIWYG.outputFontSelect(n)
	  Arguments   : n   - The editor identifier that the Font Sizes will update
		                    when making font changes (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	outputFontSizes: function(n) {

		var fontSizeDiv = $('FontSizes' + n);
		if(fontSizeDiv == null) { return; }

		var fontSize = this.config[n].Fontsizes;
		var FontSizeObj = this.ToolbarList['selectsize'];
		var FontSize = this.config[n].ImagesDir + FontSizeObj[2];
		var FontSizeOn = this.config[n].ImagesDir + FontSizeObj[3];

		fontSize.sort();
		var FontSizesDropDown = new Array;
		FontSizesDropDown[n] = '<table border="0" cellpadding="0" cellspacing="0"><tr><td onMouseOver="$(\'selectSize' + n + '\').src=\'' + FontSizeOn + '\';" onMouseOut="$(\'selectSize' + n + '\').src=\'' + FontSize + '\';"><img src="' + FontSize + '" id="selectSize' + n + '" width="49" height="20" onClick="WYSIWYG.showFontSizes(\'' + n + '\');" unselectable="on" border="0"><br>';
	  	FontSizesDropDown[n] += '<span id="Sizes' + n + '" class="dropdown" style="width: 170px;">';

		for (var i = 0; i < fontSize.length;i++) {
		  if (fontSize[i]) {
	      	FontSizesDropDown[n] += '<button type="button" onClick="WYSIWYG.formatText(\'FontSize\',\'' + n + '\',\'' + fontSize[i] + '\')\;" onMouseOver="this.className=\'mouseOver\'" onMouseOut="this.className=\'mouseOut\'" class="mouseOut" style="width: 145px;"><table cellpadding="0" cellspacing="0" border="0"><tr><td align="left" style="font-family: arial, verdana, helvetica;"><font size="' + fontSize[i] + '">size ' + fontSize[i] + '</font></td></tr></table></button><br>';
	      }
	  	}

		FontSizesDropDown[n] += '</span></td></tr></table>';
		fontSizeDiv.insertAdjacentHTML("afterBegin", FontSizesDropDown[n]);
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : hideFonts()
	  Description : Hides the list of font names in the font select drop down
	  Usage       : WYSIWYG.hideFonts(n)
	  Arguments   : n   - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	hideFonts: function(n) {
		if($('Fonts' + n)) { $('Fonts' + n).style.display = 'none'; }
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : hideFontSizes()
	  Description : Hides the list of font sizes in the font sizes drop down
	  Usage       : WYSIWYG.hideFontSizes(n)
	  Arguments   : n   - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	hideFontSizes: function(n) {
		if($('Sizes' + n)) { $('Sizes' + n).style.display = 'none'; }
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : showFonts()
	  Description : Shows the list of font names in the font select drop down
	  Usage       : WYSIWYG.showFonts(n)
	  Arguments   : n   - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	showFonts: function(n) {
		if($('Fonts' + n) == null) { return; }
		if ($('Fonts' + n).style.display == 'block') {
			$('Fonts' + n).style.display = 'none';
		}
		else {
			$('Fonts' + n).style.display = 'block';
			$('Fonts' + n).style.position = 'absolute';
		}

		// hide font size selection
		this.hideFontSizes(n);
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : showFontSizes()
	  Description : Shows the list of font sizes in the font sizes drop down
	  Usage       : WYSIWYG.showFonts(n)
	  Arguments   : n   - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	showFontSizes: function(n) {
		if($('Sizes' + n) == null) { return; }
		if ($('Sizes' + n).style.display == 'block') {
			$('Sizes' + n).style.display = 'none';
		}
		else {
			$('Sizes' + n).style.display = 'block';
			$('Sizes' + n).style.position = 'absolute';
		}

		// hide font size selection
		this.hideFonts(n);
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : viewSource()
	  Description : Shows the HTML source code generated by the WYSIWYG editor
	  Usage       : WYSIWYG.showFonts(n)
	  Arguments   : n   - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	viewSource: function(n) {

		// document
		var doc = this.getEditorWindow(n).document;

		// View Source for IE
		if (WYSIWYG_Core.isMSIE) {
			var iHTML = doc.body.innerHTML;
			// strip off the absolute urls
			iHTML = this.stripURLPath(n, iHTML);
			// replace all decimal color strings with hex decimal color strings
			iHTML = WYSIWYG_Core.replaceRGBWithHexColor(iHTML);
			
iHTML = WYSIWYG_Core.replaceURLEncodes(iHTML);
			
			
			doc.body.innerText = iHTML;
		}
	  	// View Source for Mozilla/Netscape
	  	else {
	  		// replace all decimal color strings with hex decimal color strings
			var html = WYSIWYG_Core.replaceRGBWithHexColor(doc.body.innerHTML);
html = WYSIWYG_Core.replaceURLEncodes(html);
	    		html = document.createTextNode(html);    		
	    		doc.body.innerHTML = "";
	    		doc.body.appendChild(html);
	  	}

		// Hide the HTML Mode button and show the Text Mode button
		// Validate if Elements are present
		if($('HTMLMode' + n)) {
		    $('HTMLMode' + n).style.display = 'none';
		}
	    	if($('textMode' + n)) {
		    $('textMode' + n).style.display = 'block';
		}

		// set the font values for displaying HTML source
		doc.body.style.fontSize = "12px";
		doc.body.style.fontFamily = "Courier New";

	  	this.viewTextMode[n] = true;
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : viewSource()
	  Description : Shows the HTML source code generated by the WYSIWYG editor
	  Usage       : WYSIWYG.showFonts(n)
	  Arguments   : n   - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	viewText: function(n) {

		// get document
		var doc = this.getEditorWindow(n).document;

		// View Text for IE
		if (WYSIWYG_Core.isMSIE) {
	    		var iText = doc.body.innerText;
	    		// strip off the absolute urls
			iText = this.stripURLPath(n, iText);
			// replace all decimal color strings with hex decimal color strings
			iText = WYSIWYG_Core.replaceRGBWithHexColor(iText);
iText = WYSIWYG_Core.replaceURLEncodes(iText);
	    		doc.body.innerHTML = iText;
		}

		// View Text for Mozilla/Netscape
	  	else {
	    		var html = doc.body.ownerDocument.createRange();
	    		html.selectNodeContents(doc.body);
	    		// replace all decimal color strings with hex decimal color strings
			html = WYSIWYG_Core.replaceRGBWithHexColor(html.toString());
html = WYSIWYG_Core.replaceURLEncodes(html);			
	    		doc.body.innerHTML = html;
		}

		// Hide the Text Mode button and show the HTML Mode button
		// Validate if Elements are present
		if($('textMode' + n)) {
			$('textMode' + n).style.display = 'none';
		}
		if($('HTMLMode' + n)) {
			$('HTMLMode' + n).style.display = 'block';
		}

		// reset the font values (changed)
		WYSIWYG_Core.setAttribute(doc.body, "style", this.config[n].DefaultStyle);

		this.viewTextMode[n] = false;
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : getDocumentPath()
	  Description : Get the path of the given document
	  Usage       : WYSIWYG.getDocumentPath(doc)
	  Arguments   : doc  - Document of which you get the the path
	\* ---------------------------------------------------------------------- */
	getDocumentPathOfUrl: function(url) {
		var path = null;

		// if local file system, convert local url into web url
		url = url.replace(/file:\/\//gi, "file:///");
		url = url.replace(/\\/gi, "\/");
		var pos = url.lastIndexOf("/");
		if(pos != -1) {
			path = url.substring(0, pos + 1);
		}
		return path;
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : getDocumentUrl()
	  Description : Get the documents url, convert local urls to web urls
	  Usage       : WYSIWYG.getDocumentUrl(doc)
	  Arguments   : doc  - Document of which you get the the path
	\* ---------------------------------------------------------------------- */
	getDocumentUrl: function(doc) {
		// if local file system, convert local url into web url
		var url = doc.URL;
		url = url.replace(/file:\/\//gi, "file:///");
		url = url.replace(/\\/gi, "\/");
		return url;
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : stripURLPath()
	  Description : Strips off the defined image and the anchor urls of the given content.
	  				It also can strip the document URL automatically if you define auto.
	  Usage       : WYSIWYG.stripURLPath(content)
	  Arguments   : content  - Content on which the stripping applies
	\* ---------------------------------------------------------------------- */
	stripURLPath: function(n, content, exact) {

		return content;
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : updateTextArea()
	  Description : Updates the text area value with the HTML source of the WYSIWYG
	  Arguments   : n   - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	updateTextArea: function(n) {
		// on update switch editor back to html mode
		if(this.viewTextMode[n]) { this.viewText(n); }
		// get inner HTML
		var content = this.getEditorWindow(n).document.body.innerHTML;
		// strip off defined URLs on IE
		content = this.stripURLPath(n, content);
		// replace all decimal color strings with hex color strings
		content = WYSIWYG_Core.replaceRGBWithHexColor(content);
		// remove line breaks before content will be updated
		if(this.config[n].ReplaceLineBreaks) { content = content.replace(/(\r\n)|(\n)/ig, ""); }
		// set content back in textarea
		$(n).value = content;
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : hideToolbars()
	  Description : Hide all toolbars
	  Usage       : WYSIWYG.hideToolbars(n)
	  Arguments   : n - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	hideToolbars: function(n) {
		for(var i=0;i<this.config[n].Toolbar.length;i++) {
			var toolbar = $("toolbar" + i + "_" + n);
			if(toolbar) { toolbar.style.display = "none"; }
		}
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : showToolbars()
	  Description : Display all toolbars
	  Usage       : WYSIWYG.showToolbars(n)
	  Arguments   : n - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	showToolbars: function(n) {
		for(var i=0;i<this.config[n].Toolbar.length;i++) {
			var toolbar = $("toolbar" + i + "_" + n);
			if(toolbar) { toolbar.style.display = ""; }
		}
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : hideStatusBar()
	  Description : Hide the status bar
	  Usage       : WYSIWYG.hideStatusBar(n)
	  Arguments   : n - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	hideStatusBar: function(n) {
		var statusbar = $('wysiwyg_statusbar_' + n);
		if(statusbar) {	statusbar.style.display = "none"; }
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : showStatusBar()
	  Description : Display the status bar
	  Usage       : WYSIWYG.showStatusBar(n)
	  Arguments   : n - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	showStatusBar: function(n) {
		var statusbar = $('wysiwyg_statusbar_' + n);
		if(statusbar) { statusbar.style.display = ""; }
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : findParentTag()
	  Description : Get the given parent tag of a range
	  Usage       : WYSIWYG.findParentTag(parentTagName, range)
	  Arguments   : parentTagName - Parent tag to find
	  				range - Range
	\* ---------------------------------------------------------------------- */
	findParentTag: function(parentTagName, range){
		parentTagName = parentTagName.toUpperCase();
		var rangeWorking;
		var elmWorking = null;
		try {
			if(!WYSIWYG_Core.isMSIE) {
				var node = range.startContainer;
				var pos = range.startOffset;
				if(node.nodeType != 3) { node = node.childNodes[pos]; }
				elmWorking = node;
				while (elmWorking.tagName != "HTML") {
			  		if (elmWorking.tagName == parentTagName){
			  			return elmWorking;
			  		}
			  		elmWorking = elmWorking.parentNode;
			 	}
			 	return null;
			}
			else {
				if(range.length > 0) {
					elmWorking = range.item(0);
				}
				else {
					elmWorking = range.parentElement();
				}
				while (elmWorking.tagName != "HTML") {
			  		if (elmWorking.tagName == parentTagName){
			   			return elmWorking;
			  		} else {
			   			elmWorking = elmWorking.parentElement;
			  		}
			 	}
				rangeWorking = range.duplicate();
				rangeWorking.collapse(true);
				rangeWorking.moveEnd("character", 1);
				if (rangeWorking.text.length>0) {
					while (rangeWorking.compareEndPoints("EndToEnd", range) < 0){
			  			rangeWorking.move("Character");
			  			if (null != this.findParentTag(parentTagName, rangeWorking)){
			   				return this.findParentTag(parentTagName, rangeWorking);
			  			}
			 		}
			 	}
			 	return null;
			}
		}
		catch(e) {
			return null;
		}
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : getTag()
	  Description : Get the acutally tag of the given range
	  Usage       : WYSIWYG.getTag(range)
	  Arguments   : range - Range
	\* ---------------------------------------------------------------------- */
	getTag: function(range) {
		try {
		    if(!WYSIWYG_Core.isMSIE) {
				var node = range.startContainer;
				var pos = range.startOffset;
				if(node.nodeType != 3) { node = node.childNodes[pos]; }

				if(node.nodeName && node.nodeName.search(/#/) != -1) {
					return node.parentNode;
				}
				return node;
			}
			else {
				if(range.length > 0) {
					return range.item(0);
				}
				else if(range.parentElement()) {
					return range.parentElement();
				}
			}
			return null;
		}
		catch(e) {
			return null;
		}
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : getParent()
	  Description : Get the parent node of an node
	  Usage       : WYSIWYG.getParent(node)
	  Arguments   : element - Element which parent will be returned
	\* ---------------------------------------------------------------------- */
	getParent: function(element) {
		if(element.parentNode) {
			return element.parentNode;
		}
		return null;
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : getTextRange()
	  Description : Get the text range object of the given element
	  Usage       : WYSIWYG.getTextRange(element)
	  Arguments   : element - An element of which you get the text range object
	\* ---------------------------------------------------------------------- */
	getTextRange: function(element){
		var range = element.parentTextEdit.createTextRange();
		range.moveToElementText(element);
		return range;
	},



	/* ---------------------------------------------------------------------- *\
	  Function    : invertIELineBreakCapability()
	  Description : Inverts the line break capability of IE (Thx to richyrich)
	  				Normal: ENTER = <p> , SHIFT + ENTER = <br>
	  				Inverted: ENTER = <br>, SHIFT + ENTER = <p>
	  Usage       : WYSIWYG.invertIELineBreakCapability(n)
	  Arguments   : n   - The editor identifier (the textarea's ID)
	\* ---------------------------------------------------------------------- */
	invertIELineBreakCapability: function(n) {

		var editor = this.getEditorWindow(n);
		var sel;

		// validate if the press key is the carriage return key
		if (editor.event.keyCode==13) {

	    	if (!editor.event.shiftKey) {
				sel = this.getRange(this.getSelection(n));
	            sel.pasteHTML("<br>");
	            editor.event.cancelBubble = true;
	            editor.event.returnValue = false;
	            sel.select();
	            sel.moveEnd("character", 1);
	            sel.moveStart("character", 1);
	            sel.collapse(false);
	            return false;
			}
	        else {
	            sel = this.getRange(this.getSelection(n));
	            sel.pasteHTML("<p>");
	            editor.event.cancelBubble = true;
	            editor.event.returnValue = false;
	            sel.select();
	            sel.moveEnd("character", 1);
	            sel.moveStart("character", 1);
	            sel.collapse(false);
	            return false;
	    	}
		}
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : selectNode()
	  Description : Select a node within the current editor
	  Usage       : WYSIWYG.selectNode(n, level)
	  Arguments   : n   - The editor identifier (the textarea's ID)
	  				level - identifies the level of the element which will be selected
	\* ---------------------------------------------------------------------- */
	selectNode: function(n, level) {

		var sel = this.getSelection(n);
		var range = this.getRange(sel);
		var parentnode = this.getTag(range);
		var i = 0;

		for (var node=parentnode; (node && (node.nodeType == 1)); node=node.parentNode) {
			if (i == level) {
				this.nodeSelection(n, node);
			}
			i++;
		}

		this.updateStatusBar(n);
	},

	/* ---------------------------------------------------------------------- *\
	  Function    : nodeSelection()
	  Description : Do the node selection
	  Usage       : WYSIWYG.nodeSelection(n, node)
	  Arguments   : n   - The editor identifier (the textarea's ID)
	  				node - The node which will be selected
	\* ---------------------------------------------------------------------- */
	nodeSelection: function(n, node) {

		var doc = this.getEditorWindow(n).document;
		var sel = this.getSelection(n);
		var range = this.getRange(sel);

		if(!WYSIWYG_Core.isMSIE) {
			if (node.nodeName == "BODY") {
				range.selectNodeContents(node);
			} else {
				range.selectNode(node);
			}

			/*
			if (endNode) {
				try {
					range.setStart(node, startOffset);
					range.setEnd(endNode, endOffset);
				} catch(e) {
				}
			}
			*/

			if (sel) { sel.removeAllRanges(); }
			if (sel) { sel.addRange(range);	 }
		}
		else {
			// MSIE may not select everything when BODY is selected -
			// start may be set to first text node instead of first non-text node -
			// no known workaround
			if ((node.nodeName == "TABLE") || (node.nodeName == "IMG") || (node.nodeName == "INPUT") || (node.nodeName == "SELECT") || (node.nodeName == "TEXTAREA")) {
				try {
					range = doc.body.createControlRange();
					range.addElement(node);
					range.select();
				}
				catch(e) { }
			}
			else {
				range = doc.body.createTextRange();
				if (range) {
					range.collapse();
					if (range.moveToElementText) {
						try {
							range.moveToElementText(node);
							range.select();
						} catch(e) {
							try {
								range = doc.body.createTextRange();
								range.moveToElementText(node);
								range.select();
							}
							catch(e) {}
						}
					} else {
						try {
							range = doc.body.createTextRange();
							range.moveToElementText(node);
							range.select();
						}
						catch(e) {}
					}
				}
			}
		}
	}
}

/********************************************************************
 * openWYSIWYG core functions Copyright (c) 2006 openWebWare.com
 * Contact us at devs@openwebware.com
 * This copyright notice MUST stay intact for use.
 *
 * $Id: wysiwyg.js,v 1.10 2006/12/25 09:17:07 xhaggi Exp $
 ********************************************************************/
var WYSIWYG_Core = {

	/**
	 * Holds true if browser is MSIE, otherwise false
	 */
	isMSIE: navigator.appName == "Microsoft Internet Explorer" ? true : false,

	/**
	 * Holds true if browser is Firefox (Mozilla)
	 */
	isFF: !document.all && document.getElementById && !this.isOpera,

	/**
	 * Holds true if browser is Opera, otherwise false
	 */
	isOpera: navigator.appName == "Opera" ? true : false,

	/**
	 * Trims whitespaces of the given string
	 *
	 * @param str String
	 * @return Trimmed string
	 */
	trim: function(str) {
		return str.replace(/^\s*|\s*$/g,"");
	},

	/**
	 * Determine if the given parameter is defined
	 *
	 * @param p Parameter
	 * @return true/false dependents on definition of the parameter
	 */
	defined: function(p) {
		return typeof p == "undefined" ? false : true;
	},

	/**
	 * Determine if the browser version is compatible
	 *
	 * @return true/false depending on compatiblity of the browser
	 */
	isBrowserCompatible: function() {
		// Validate browser and compatiblity
		//if ((navigator.userAgent.indexOf('Safari') != -1 ) || !document.getElementById || //!document.designMode){
		//	//no designMode (Safari lies)
	   	//	return false;
		//}
		return true;
	},

	/**
	 * Set the style attribute of the given element.
	 * Private method to solve the IE bug while setting the style attribute.
	 *
	 * @param element The element on which the style attribute will affect
	 * @param style Stylesheet which will be set
	 */
	_setStyleAttribute: function(element, style) {
		var styles = style.split(";");
		var pos;
		for(var i=0;i<styles.length;i++) {
			var attributes = styles[i].split(":");
			if(attributes.length == 2) {
				try {
					var attr = WYSIWYG_Core.trim(attributes[0]);
					while((pos = attr.search(/-/)) != -1) {
						var strBefore = attr.substring(0, pos);
						var strToUpperCase = attr.substring(pos + 1, pos + 2);
						var strAfter = attr.substring(pos + 2, attr.length);
						attr = strBefore + strToUpperCase.toUpperCase() + strAfter;
					}
					var value = WYSIWYG_Core.trim(attributes[1]).toLowerCase();
					element.style[attr] = value;
				}
				catch (e) {
					//alert(e);
				}
			}
		}
	},

	/**
	 * Set an attribute's value on the given node element.
	 *
	 * @param node Node element
	 * @param attr Attribute which is set
	 * @param value Value of the attribute
	 */
	setAttribute: function(node, attr, value) {
		if(value == "") {return;}
		if(attr.toLowerCase() == "style") {
			this._setStyleAttribute(node, value);
		}
		else {
			node.setAttribute(attr, value);
		}
	},

	/**
	 * Cancel the given event.
	 *
	 * @param e Event which will be canceled
	 */
	cancelEvent: function(e) {
		if (!e) return false;
		if (this.isMSIE) {
			e.returnValue = false;
			e.cancelBubble = true;
		} else {
			e.preventDefault();
			e.stopPropagation && e.stopPropagation();
		}
		return false;
	},

	/**
	 * Converts a RGB color string to hex color string.
	 *
	 * @param color RGB color string
	 * @param Hex color string
	 */
	toHexColor: function(color) {
		color = color.replace(/^rgb/g,'');
		color = color.replace(/\(/g,'');
		color = color.replace(/\)/g,'');
		color = color.replace(/ /g,'');
		color = color.split(',');
		var r = parseFloat(color[0]).toString(16).toUpperCase();
		var g = parseFloat(color[1]).toString(16).toUpperCase();
		var b = parseFloat(color[2]).toString(16).toUpperCase();
		if (r.length<2) { r='0'+r; }
		if (g.length<2) { g='0'+g; }
		if (b.length<2) { b='0'+b; }
		return r + g + b;
	},

	/**
	 * Converts a decimal color to hex color string.
	 *
	 * @param Decimal color
	 * @param Hex color string
	 */
	_dec_to_rgb: function(value) {
		var hex_string = "";
		for (var hexpair = 0; hexpair < 3; hexpair++) {
			var myByte = value & 0xFF;            // get low byte
			value >>= 8;                          // drop low byte
			var nybble2 = myByte & 0x0F;          // get low nybble (4 bits)
			var nybble1 = (myByte >> 4) & 0x0F;   // get high nybble
			hex_string += nybble1.toString(16);   // convert nybble to hex
			hex_string += nybble2.toString(16);   // convert nybble to hex
		}
		return hex_string.toUpperCase();
	},

	/**
	 * Replace RGB color strings with hex color strings within a string.
	 *
	 * @param {String} str RGB String
	 * @param {String} Hex color string
	 */
	replaceRGBWithHexColor: function(str) {
		// find all decimal color strings
		var matcher = str.match(/rgb\([0-9 ]+,[0-9 ]+,[0-9 ]+\)/gi);
		if(matcher) {
			for(var j=0; j<matcher.length;j++) {
				var regex = eval("/" + WYSIWYG_Core.stringToRegex(matcher[j]) + "/gi");
				// replace the decimal color strings with hex color strings
				str = str.replace(regex, "#" + this.toHexColor(matcher[j]));
			}
		}
		return str;
	},
	
	/**
	 * Replace encoded URL characters %7B, %21 and %7D with {, !, and } respectively
	 *
	 * NOTE: This hack is necessary for merge fields to work in HTML components
	 *
	 * @param {String} str RGB String
	 */
	replaceURLEncodes: function(str) {
		if (str) {
			str=str.replace(/%7B/g, "{");
			str=str.replace(/%21/g, "!");
			str=str.replace(/%7D/g, "}");
			str=str.replace(/&amp;/g, "&");
		}
		return str;
	},	

	/**
	 * Execute the given command on the given editor
	 *
	 * @param n The editor's identifier
	 * @param cmd Command which is execute
	 */
	execCommand: function(n, cmd, value) {
		if(typeof(value) == "undefined") value = null;

		// firefox BackColor problem fixed
		if(cmd == 'BackColor' && WYSIWYG_Core.isFF) cmd = 'HiliteColor';

		// firefox cut, paste and copy
		if(WYSIWYG_Core.isFF && (cmd == "Cut" || cmd == "Paste" || cmd == "Copy")) {
			try {
				WYSIWYG.getEditorWindow(n).document.execCommand(cmd, false, value);
			}
			catch(e) {
				if(confirm("Copy/Cut/Paste is not available in Mozilla and Firefox\nDo you want more information about this issue?")) {
					window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html');
				}
			}
		}

		else {
			WYSIWYG.getEditorWindow(n).document.execCommand(cmd, false, value);
		}
	},

	/**
	 * Parse a given string to a valid regular expression
	 *
	 * @param {String} string String to be parsed
	 * @return {RegEx} Valid regular expression
	 */
	stringToRegex: function(string) {
		string = string.replace(/\//gi, "\\/");
		string = string.replace(/\(/gi, "\\(");
		string = string.replace(/\)/gi, "\\)");
		string = string.replace(/\[/gi, "\\[");
		string = string.replace(/\]/gi, "\\]");
		string = string.replace(/\+/gi, "\\+");
		string = string.replace(/\$/gi, "\\$");
		string = string.replace(/\*/gi, "\\*");
		string = string.replace(/\?/gi, "\\?");
		string = string.replace(/\^/gi, "\\^");
		string = string.replace(/\\b/gi, "\\\\b");
		string = string.replace(/\\B/gi, "\\\\B");
		string = string.replace(/\\d/gi, "\\\\d");
		string = string.replace(/\\B/gi, "\\\\B");
		string = string.replace(/\\D/gi, "\\\\D");
		string = string.replace(/\\f/gi, "\\\\f");
		string = string.replace(/\\n/gi, "\\\\n");
		string = string.replace(/\\r/gi, "\\\\r");
		string = string.replace(/\\t/gi, "\\\\t");
		string = string.replace(/\\v/gi, "\\\\v");
		string = string.replace(/\\s/gi, "\\\\s");
		string = string.replace(/\\S/gi, "\\\\S");
		string = string.replace(/\\w/gi, "\\\\w");
		string = string.replace(/\\W/gi, "\\\\W");

		return string;
	},

	/**
	 * Add an event listener
	 *
	 * @param obj Object on which the event will be attached
	 * @param ev Kind of event
	 * @param fu Function which is execute on the event
	 */
	addEvent: function(obj, ev, fu) {
		//if(obj.addEventListener ) {
		//	obj.addEventListener(ev, fu, false);
		//}
		//else if(obj.attachEvent) {
		//	obj.attachEvent("on" + ev, fu);
		//}

		if (obj.attachEvent)
			obj.attachEvent("on" + ev, fu);
		else
			obj.addEventListener(ev, fu, false);
	},

	/**
	 * Remove an event listener
	 *
	 * @param obj Object on which the event will be attached
	 * @param ev Kind of event
	 * @param fu Function which is execute on the event
	 */
	removeEvent:  function(obj, ev, fu) {
		if (obj.attachEvent)
			obj.detachEvent("on" + ev, fu);
		else
			obj.removeEventListener(ev, fu, false);
	},

	/**
	 * Includes a javascript file
	 *
	 * @param file Javascript file path and name
	 */
	includeJS: function(file) {
		var script = document.createElement("script");
		this.setAttribute(script, "type", "text/javascript");
		this.setAttribute(script, "src", file);
		var heads = document.getElementsByTagName("head");
		for(var i=0;i<heads.length;i++) {
			heads[i].appendChild(script);
		}
	},

	/**
	 * Includes a stylesheet file
	 *
	 * @param file Stylesheet file path and name
	 */
	includeCSS: function(path) {
		var link = document.createElement("link");
		this.setAttribute(link, "rel", "stylesheet");
		this.setAttribute(link, "type", "text/css");
		this.setAttribute(link, "href", path);
		var heads = document.getElementsByTagName("head");
		for(var i=0;i<heads.length;i++) {
			heads[i].appendChild(link);
		}
	},

	/**
	 * Get the screen position of the given element.
	 *
	 * @param {HTMLObject} elm1 Element which position will be calculate
	 * @param {HTMLObject} elm2 Element which is the last one before calculation stops
	 * @param {Object} Left and top position of the given element
	 */
	getElementPosition: function(elm1, elm2) {
		var top = 0, left = 0;
		while (elm1 && elm1 != elm2) {
			left += elm1.offsetLeft;
			top += elm1.offsetTop;
			elm1 = elm1.offsetParent;
		}
		return {left : left, top : top};
	}
}

/**
 * Context menu object
 */
var WYSIWYG_ContextMenu = {

	html: "",
	contextMenuDiv: null,

	/**
	 * Init function
	 *
	 * @param {String} n Editor identifier
	 */
	init: function(n) {
		var doc = WYSIWYG.getEditorWindow(n).document;

		// create context menu div
		this.contextMenuDiv = document.createElement("div");
		this.contextMenuDiv.className = "wysiwyg-context-menu-div";
		this.contextMenuDiv.setAttribute("class", "wysiwyg-context-menu-div");
		this.contextMenuDiv.style.display = "none";
		this.contextMenuDiv.style.position = "absolute";
		this.contextMenuDiv.style.zindex = 1000;
		this.contextMenuDiv.style.left = "0px";
		this.contextMenuDiv.style.top = "0px";
		this.contextMenuDiv.unselectable = "on";
		document.body.insertBefore(this.contextMenuDiv, document.body.firstChild);

		// bind event listeners
		WYSIWYG_Core.addEvent(doc, "contextmenu", function context(e) { WYSIWYG_ContextMenu.show(e, n); });
		WYSIWYG_Core.addEvent(doc, "click", function context(e) { WYSIWYG_ContextMenu.close(); });
		WYSIWYG_Core.addEvent(doc, "keydown", function context(e) { WYSIWYG_ContextMenu.close(); });
		WYSIWYG_Core.addEvent(document, "click", function context(e) { WYSIWYG_ContextMenu.close(); });
	},

	/**
	 * Show the context menu
	 *
	 * @param e Event
	 * @param n Editor identifier
	 */
	show: function(e, n) {
		if(this.contextMenuDiv == null) return false;

		var ifrm = WYSIWYG.getEditor(n);
		var doc = WYSIWYG.getEditorWindow(n).document;

		// set the context menu position
		var pos = WYSIWYG_Core.getElementPosition(ifrm);
		var x = WYSIWYG_Core.isMSIE ? pos.left + e.clientX : pos.left + (e.pageX - doc.body.scrollLeft);
		var y = WYSIWYG_Core.isMSIE ? pos.top + e.clientY : pos.top + (e.pageY - doc.body.scrollTop);

		this.contextMenuDiv.style.left = x + "px";
		this.contextMenuDiv.style.top = y + "px";
		this.contextMenuDiv.style.visibility = "visible";
		this.contextMenuDiv.style.display = "block";

		// call the context menu, mozilla needs some time
		window.setTimeout("WYSIWYG_ContextMenu.output('" + n + "')", 10);

		WYSIWYG_Core.cancelEvent(e);
		return false;
	},

	/**
	 * Output the context menu items
	 *
	 * @param n Editor identifier
	 */
	output: function (n) {

		// get selection
		var sel = WYSIWYG.getSelection(n);
		var range = WYSIWYG.getRange(sel);

		// get current selected node
		var tag = WYSIWYG.getTag(range);
		if(tag == null) { return; }

		// clear context menu
		this.clear();

		// Determine kind of nodes
		var isImg = (tag.nodeName == "IMG") ? true : false;
		var isLink = (tag.nodeName == "A") ? true : false;

		// Selection is an image or selection is a text with length greater 0
		var len = 0;
		if(WYSIWYG_Core.isMSIE)
			len = (document.selection && range.text) ? range.text.length : 0;
		else
			len = range.toString().length;
		var sel = len != 0 || isImg;

		// Icons
		var iconLink = { enabled: WYSIWYG.config[n].ImagesDir + WYSIWYG.ToolbarList["createlink"][3], disabled: WYSIWYG.config[n].ImagesDir + WYSIWYG.ToolbarList["createlink"][2]};
		var iconImage = { enabled: WYSIWYG.config[n].ImagesDir + WYSIWYG.ToolbarList["insertimage"][3], disabled: WYSIWYG.config[n].ImagesDir + WYSIWYG.ToolbarList["insertimage"][2]};
		var iconDelete = { enabled: WYSIWYG.config[n].ImagesDir + WYSIWYG.ToolbarList["delete"][3], disabled: WYSIWYG.config[n].ImagesDir + WYSIWYG.ToolbarList["delete"][2]};
		var iconCopy = { enabled: WYSIWYG.config[n].ImagesDir + WYSIWYG.ToolbarList["copy"][3], disabled: WYSIWYG.config[n].ImagesDir + WYSIWYG.ToolbarList["copy"][2]};
		var iconCut = { enabled: WYSIWYG.config[n].ImagesDir + WYSIWYG.ToolbarList["cut"][3], disabled: WYSIWYG.config[n].ImagesDir + WYSIWYG.ToolbarList["cut"][2]};
		var iconPaste = { enabled: WYSIWYG.config[n].ImagesDir + WYSIWYG.ToolbarList["paste"][3], disabled: WYSIWYG.config[n].ImagesDir + WYSIWYG.ToolbarList["paste"][2]};

		// Create context menu html
		this.html += '<table class="wysiwyg-context-menu" border="0" cellpadding="0" cellspacing="0">';

		// Add items
		this.addItem(n, 'Copy', iconCopy, 'Copy', sel);
		this.addItem(n, 'Cut', iconCut, 'Cut', sel);
		this.addItem(n, 'Paste', iconPaste, 'Paste', true);
		this.addSeperator();
		this.addItem(n, 'InsertImage', iconImage, 'Modify Image Properties...', isImg);
		this.addItem(n, 'CreateLink', iconLink, 'Create or Modify Link...', sel || isLink);
		this.addItem(n, 'RemoveNode', iconDelete, 'Remove', true);

		this.html += '</table>';
		this.contextMenuDiv.innerHTML = this.html;
	},

	/**
	 * Close the context menu
	 */
	close: function() {
		this.contextMenuDiv.style.visibility = "hidden";
		this.contextMenuDiv.style.display = "none";
	},

	/**
	 * Clear context menu
	 */
	clear: function() {
		this.contextMenuDiv.innerHTML = "";
		this.html = "";
	},

	/**
	 * Add context menu item
	 *
	 * @param n editor identifier
	 * @param cmd Command
	 * @param icon Icon which is diabled
	 * @param title Title of the item
	 * @param disabled If item is diabled
	 */
	addItem: function(n, cmd, icon, title, disabled) {
		var item = '';

		if(disabled) {
			item += '<tr>';
			item += '<td class="icon"><a href="javascript:WYSIWYG.formatText(\'' + cmd + '\',\'' + n + '\', null);"><img src="' + icon.enabled + '" border="0"></a></td>';
			item += '<td onmouseover="this.className=\'mouseover\'" onmouseout="this.className=\'\'" onclick="WYSIWYG.formatText(\'' + cmd + '\',\'' + n + '\', null);WYSIWYG_ContextMenu.close();"><a href="javascript:void(0);">' + title + '</a></td>';
			item += '</tr>';
		}
		else {
			item += '<tr>';
			item += '<td class="icon"><img src="' + icon.disabled + '" border="0"></td>';
			item += '<td onmouseover="this.className=\'mouseover\'" onmouseout="this.className=\'\'"><span class="disabled">' + title + '</span></td>';
			item += '</tr>';
		}

		this.html += item;
	},

	/**
	 * Add seperator to context menu
	 */
	addSeperator: function() {
		var output = '';
		output += '<tr>';
		output += '<td colspan="2" style="text-align:center;"><hr size="1" color="#C9C9C9" width="95%"></td>';
		output += '</tr>';
		this.html += output;
	}
}

/**
 * Get an element by it's identifier
 *
 * @param id Element identifier
 */
function $(id) {
	return document.getElementById(id);
}

/**
 * Emulates insertAdjacentHTML(), insertAdjacentText() and
 * insertAdjacentElement() three functions so they work with Netscape 6/Mozilla
 *
 * ADDED BY MATT [07/28/08 - rbv_bd_saf checks for Safari and Opera manually and allows this to proceed]
 *
 * by Thor Larholm me@jscript.dk
 */
if (!document.all && !rbv_bd_ie && !rbv_bd_ie4 && !rbv_bd_ie5x && !rbv_bd_ie5mac && !rbv_bd_ie5xwin) {
	if(!rbv_bd_saf || !rbv_bd_op || (typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentElement)){
		HTMLElement.prototype.insertAdjacentElement = function (where,parsedNode) {
		  switch (where){
			case 'beforeBegin':
				this.parentNode.insertBefore(parsedNode,this);
				break;
			case 'afterBegin':
				this.insertBefore(parsedNode,this.firstChild);
				break;
			case 'beforeEnd':
				this.appendChild(parsedNode);
				break;
			case 'afterEnd':
				if (this.nextSibling) {
					this.parentNode.insertBefore(parsedNode,this.nextSibling);
				}
				else {
					this.parentNode.appendChild(parsedNode);
				}
				break;
		  }
		};

		HTMLElement.prototype.insertAdjacentHTML = function (where,htmlStr) {
			var r = this.ownerDocument.createRange();
			r.setStartBefore(this);
			var parsedHTML = r.createContextualFragment(htmlStr);
			this.insertAdjacentElement(where,parsedHTML);
		};


		HTMLElement.prototype.insertAdjacentText = function (where,txtStr) {
			var parsedText = document.createTextNode(txtStr);
			this.insertAdjacentElement(where,parsedText);
		};
	}
}

var WYSIWYGsmall = new WYSIWYG.Settings();
WYSIWYGsmall.Width = "100%";
WYSIWYGsmall.Toolbar[0] = new Array(
			"bold",
			"italic",
			"underline",
			"seperator",
			"font",
			"fontsize",
			"seperator",
			"forecolor",
			"backcolor",
			"createlink",
			"seperator",
			"orderedlist",
			"unorderedlist",
			"outdent",
			"indent",
			"seperator",
			"justifyleft",
			"justifycenter",
			"justifyright",
			"removeformat"
);
WYSIWYGsmall.Toolbar[1] = ""; // disable toolbar 2
WYSIWYGsmall.StatusBarEnabled = false;

var WYSIWYGfull = new WYSIWYG.Settings();
WYSIWYGfull.Width = "100%";
WYSIWYGfull.Toolbar[0] = new Array(
			"bold",
			"italic",
			"underline",
			"seperator",
			"font",
			"fontsize",
			"seperator",
			"forecolor",
			"backcolor",
			"createlink",
			"insertimage",
			"seperator",
			"orderedlist",
			"unorderedlist",
			"outdent",
			"indent",
			"seperator",
			"justifyleft",
			"justifycenter",
			"justifyright",
			"removeformat",
			"seperator",
			"preview",
			"seperator",
			"viewSource"
);
WYSIWYGsmall.Toolbar[1] = ""; // disable toolbar 2
WYSIWYGsmall.StatusBarEnabled = false;


var rbv_expandAll=false;var rbv_collapseAll=false;function rbf_collapseExpandLevel1(lid,numcols){var l1dh1=document.getElementById("rbe_level1_"+lid+"h1");var l1dh2=document.getElementById("rbe_level1_"+lid+"h2");var collapsed="none";if(l1dh1){collapsed=(l1dh1.style.display=="none");if(rbv_expandAll){l1dh1.style.display="block";}
else if(rbv_collapseAll){l1dh1.style.display="none";}
else{l1dh1.style.display=(collapsed?"block":"none");}}
if(l1dh2){collapsed=(l1dh2.style.display=="none");if(rbv_expandAll){l1dh2.style.display="block";}
else if(rbv_collapseAll){l1dh2.style.display="none";}
else{l1dh2.style.display=(collapsed?"block":"none");}
var l1ds=new Array();for(var i=0;i<numcols;i++){l1ds[l1ds.length]=document.getElementById("rbe_level1_"+lid+i);if(rbv_expandAll){l1ds[l1ds.length-1].style.display="block";}
else if(rbv_collapseAll){l1ds[l1ds.length-1].style.display="none";}
else{l1ds[l1ds.length-1].style.display=(collapsed?"block":"none");}}}
var img=document.getElementById("rbe_level1_"+lid+"img");if(img){if(rbv_expandAll){img.src="../images/minus.gif";}
else if(rbv_collapseAll){img.src="../images/plus.gif";}
else{if(img.src.indexOf("minus.gif")>=0){img.src="../images/plus.gif";}
else{img.src="../images/minus.gif";}}}
var l1container=document.getElementById("rbe_level1_"+lid+"container");if(l1container){if(rbv_expandAll){l1container.style.display="block";}
else if(rbv_collapseAll){l1container.style.display="none";}
else{collapsed=(l1container.style.display=="none");l1container.style.display=(collapsed?"block":"none");}}}
function rbf_ecAllLevel1(idarray,numcols,collapse){if(idarray&&numcols>0){if(numcols<=0){return;}
if(collapse){rbv_expandAll=false;rbv_collapseAll=true;}
else{rbv_expandAll=true;rbv_collapseAll=false;}
rbf_showLoadingMessage();for(var i=0;i<idarray.length;i++){var idx=parseInt(idarray[i],10);rbf_collapseExpandLevel1(idx,numcols);}
rbf_hideLoadingMessage();rbv_expandAll=false;rbv_collapseAll=false;}}
function rbf_collapseExpandLevel2(lid,numcols){var l2dh=document.getElementById("rbe_level2_"+lid+"h");var collapsed="none";if(l2dh){collapsed=(l2dh.style.display=="none");if(rbv_expandAll){l2dh.style.display="block";}
else if(rbv_collapseAll){l2dh.style.display="none";}
else{l2dh.style.display=(collapsed?"block":"none");}
var l2ds=new Array();for(var i=0;i<numcols;i++){l2ds[l2ds.length]=document.getElementById("rbe_level2_"+lid+"_"+i);if(rbv_expandAll){l2ds[l2ds.length-1].style.display="block";}
else if(rbv_collapseAll){l2ds[l2ds.length-1].style.display="none";}
else{l2ds[l2ds.length-1].style.display=(collapsed?"block":"none");}}}
var img=document.getElementById("rbe_level2_"+lid+"img");if(img){if(rbv_expandAll){img.src="../images/minus.gif";}
else if(rbv_collapseAll){img.src="../images/plus.gif";}
else{if(img.src.indexOf("minus.gif")>=0){img.src="../images/plus.gif";}
else{img.src="../images/minus.gif";}}}
var l2container=document.getElementById("rbe_level2_"+lid+"container");if(l2container){if(rbv_expandAll){l2container.style.display="block";}
else if(rbv_collapseAll){l2container.style.display="none";}
else{collapsed=(l2container.style.display=="none");l2container.style.display=(collapsed?"block":"none");}}}
function rbf_ecAllLevel2(idarray,rowarray,numcols,collapse){if(idarray&&rowarray&&numcols>0){if(collapse){rbv_expandAll=false;rbv_collapseAll=true;}
else{rbv_expandAll=true;rbv_collapseAll=false;}
rbf_showLoadingMessage();for(var i=0;i<rowarray.length;i++){for(var j=0;j<rowarray[i].length;j++){rbf_collapseExpandLevel2(idarray[i]+"_"+rowarray[i][j],numcols);}}
rbf_hideLoadingMessage();rbv_expandAll=false;rbv_collapseAll=false;}}
function rbf_toggleNode(nodeId,sendAjax,doNotAnimate){var nodeDiv=document.getElementById('rbe_dv'+nodeId);if(nodeDiv==null)
return;var attr1=nodeDiv.getAttribute('isCollapsed');if(!attr1)
return;var isCollapsed=('Y'==attr1);nodeDiv.setAttribute('isCollapsed',isCollapsed?'N':'Y');var nodeIcon=document.getElementById('rbe_ico'+nodeId);if(isCollapsed==true){nodeIcon.src="../images/minus.gif";}
else{nodeIcon.src="../images/plus.gif";}
var attr2=nodeDiv.getAttribute('children');rbf_processNodes(attr2,isCollapsed==true?'show':'hide',doNotAnimate);if(sendAjax==true){rbf_sendAjaxRequest("&cmd=toggleColl&section="+nodeId+"&collapsed="+(isCollapsed==true?"false":"true"));}}
function rbf_bringAppTreeContent(appId){var ajaxRreq=rbf_getXMLHTTPRequest();if(ajaxRreq){ajaxRreq.onreadystatechange=function(){if(ajaxRreq.readyState==READY_STATE_COMPLETE){var appTreeHTML=ajaxRreq.responseText;var treeSection=document.getElementById("rbi_appTreeSection");if(appTreeHTML.length>2)
treeSection.innerHTML=appTreeHTML;}};ajaxRreq.open("GET",rbf_getAjaxURL()+'&cmd=getAppTree&appId='+appId,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);}}
function rbf_processNodes(nodeIds,showHide,doNotAnimate){if(!nodeIds||nodeIds.length==0)
return;while(nodeIds.length>0){var nodeId='';var index=nodeIds.indexOf(',');if(index<0){nodeId=nodeIds;nodeIds='';}
else{nodeId=nodeIds.substring(0,index);nodeIds=nodeIds.substring(index+1);}
rbf_processNode(nodeId,showHide,doNotAnimate);}}
var rbv_currentCollapsableNode=null;function rbf_processNode(nodeId,showHide,doNotAnimate){var step=5;var interval=50;var nodeDiv=document.getElementById('rbe_dv'+nodeId);if(nodeDiv==null)
return;var attr2=nodeDiv.getAttribute('children');if(showHide=='show'){if(doNotAnimate){nodeDiv.style.display='block';}
var attr1=nodeDiv.getAttribute('isCollapsed');if(!attr1)
return;if('N'==attr1){rbf_processNodes(attr2,showHide,true);}}
else{if(doNotAnimate){nodeDiv.style.display='none';}
rbf_processNodes(attr2,showHide,true);}
if(!doNotAnimate){nodeDiv.style.overflow="hidden";var expand=(nodeDiv.style.display=="none");if(expand)
nodeDiv.style.display="block";var max_height=nodeDiv.offsetHeight;var step_height=step+(expand?0:-max_height);nodeDiv.style.height=Math.abs(step_height)+"px";setTimeout("toggleTreeNodeAnimatingStatus("+nodeId+", "+interval+","+step
+","+max_height+","+step_height+")",interval);}}
function toggleTreeNodeAnimatingStatus(nodeId,interval,step,max_height,step_height){var step_height_abs=Math.abs(step_height);var nodeDiv=document.getElementById('rbe_dv'+nodeId);if(nodeDiv==null)
return;if(step_height_abs>=step&&step_height_abs<=(max_height-step)){step_height+=step;nodeDiv.style.height=Math.abs(step_height)+"px";setTimeout("toggleTreeNodeAnimatingStatus("+nodeId+", "+interval+","+step
+","+max_height+","+step_height+")",interval);}
else{if(step_height_abs<step)
nodeDiv.style.display="none";nodeDiv.style.height="";}}
var rbv_dropDownPopup;function rbf_showDropDownPopup(content,parentId,xoffset,yoffset,width){if(rbv_dropDownPopup){rbv_dropDownPopup.style.display="none";rbf_removeAllChildren(rbv_dropDownPopup);}
div=document.createElement("div");div.className='rbwhite';div.innerHTML=content;rbv_dropDownPopup=rbf_createPopup(div);rbv_dropDownPopup.div=div;if(width>0){div.width=width;rbv_dropDownPopup.div.style.width=width+'px';}
rbv_dropDownPopup.onmouseover=function(e){rbf_consumeEvent(e);}
var parent=document.getElementById(parentId);if(parent){var pos=rbf_findPosition(parent);rbv_dropDownPopup.style.left=(pos[0]-xoffset)+"px";rbv_dropDownPopup.style.top=(pos[1]-yoffset)+"px";rbv_dropDownPopup.style.display="block";}
document.onmousemove=function(e){rbv_hideDropDownPopup(e);rbf_consumeEvent(e);return false;}
document.body.appendChild(rbv_dropDownPopup);return false;}
function rbv_hideDropDownPopup(e){if(rbv_dropDownPopup){var isin=rbf_isMouseIn(e,rbv_dropDownPopup);if(!isin&&rbv_dropDownPopup.isin){rbv_dropDownPopup.style.display="none";}
rbv_dropDownPopup.isin=isin;}}
function rbv_forceHideDropDownPopup(){if(rbv_dropDownPopup){rbv_dropDownPopup.style.display="none";}}
function rbf_createPopup(container){var popupElement=document.createElement('div');popupElement.style.cssText='position:absolute;display:none;';popupElement.style.zIndex=3;var containerTable=document.createElement("table");containerTable.cellPadding='0px';containerTable.cellSpacing='0px';var containerTableBody=document.createElement("tbody");var toptr=document.createElement("tr");toptr.style.height='6px';var tlc=document.createElement("td");tlc.className='rbs_popup_tlc';tlc.style.width='7px';var tc=document.createElement("td");tc.className='rbs_popup_top';var trc=document.createElement("td");trc.className='rbs_popup_trc';trc.style.width='7px';var centertr=document.createElement("tr");var left=document.createElement("td");left.className='rbs_popup_left';var center=document.createElement("td");var right=document.createElement("td");right.className='rbs_popup_right';var bottomtr=document.createElement("tr");bottomtr.style.height='9px';var blc=document.createElement("td");blc.className='rbs_popup_blc';blc.style.width='7px';var bc=document.createElement("td");bc.className='rbs_popup_bottom';var brc=document.createElement("td");brc.className='rbs_popup_brc';brc.style.width='7px';containerTable.appendChild(containerTableBody);containerTableBody.appendChild(toptr);toptr.appendChild(tlc);toptr.appendChild(tc);toptr.appendChild(trc);containerTableBody.appendChild(centertr);centertr.appendChild(left);centertr.appendChild(center);centertr.appendChild(right);containerTableBody.appendChild(bottomtr);bottomtr.appendChild(blc);bottomtr.appendChild(bc);bottomtr.appendChild(brc);center.appendChild(container);popupElement.appendChild(containerTable);return popupElement;}
if(typeof addDREvent!='function'){var addDREvent=function(o,t,f,l){var d=null;var n='on'+t,rO=o,rT=t,rF=f,rL=l;if(!document.addEventListener&&document.attachEvent){d='attachEvent';if(o[d]&&!l)return o[d](n,f);}
else{d='addEventListener';if(o[d]&&!l)return o[d](t,f,false);}
if(!o._evts)
o._evts={};if(!o._evts[t]){o._evts[t]=o[n]?{b:o[n]}:{};o[n]=new Function('e','var r = true, o = this, a = o._evts["'+t+'"], i; for (i in a) {'+'o._f = a[i]; r = o._f(e||window.event) != false && r; o._f = null;'+'} return r');if(t!='unload')
addDREvent(window,'unload',function(){removeDREvent(rO,rT,rF,rL);});}
if(!f._i)f._i=addDREvent._i++;o._evts[t][f._i]=f;};addDREvent._i=1;var removeDREvent=function(o,t,f,l){var d=null;if(document.removeEventListener&&!document.detachEvent){d='removeEventListener';if(o[d]&&!l)return o[d](t,f,false);}
else{d='detachEvent';if(o[d]&&!l)return o[d](n,f);}
if(o._evts&&o._evts[t]&&f._i)delete o._evts[t][f._i];};}
function cancelDREvent(e,c){e.returnValue=false;if(e.preventDefault)e.preventDefault();if(c){e.cancelBubble=true;if(e.stopPropagation)e.stopPropagation();}};function DragResize(myName){var maxDRLeft=0;var maxDRTop=0;if(window.innerHeight!=window.undefined)maxDRTop=window.innerHeight;else if(document.compatMode=='CSS1Compat')maxDRTop=document.documentElement.clientHeight;else if(document.body)maxDRTop=document.body.clientHeight;if(window.innerWidth!=window.undefined)maxDRLeft=window.innerWidth;else if(document.compatMode=='CSS1Compat')maxDRLeft=document.documentElement.clientWidth;else if(document.body)maxDRLeft=document.body.clientWidth;var props={myName:myName,enabled:true,handles:['tl','tm','tr','ml','mr','bl','bm','br'],isElement:null,isHandle:null,element:null,handle:null,minWidth:10,minHeight:10,minLeft:0,maxLeft:3999,minTop:0,maxTop:3999,zIndex:12204,mouseX:0,mouseY:0,lastMouseX:0,lastMouseY:0,mOffX:0,mOffY:0,elmX:0,elmY:0,elmW:0,elmH:0,allowBlur:true,gframe:null,frameParent:null,ondragfocus:null,ondragstart:null,ondragmove:null,ondragend:null,ondragblur:null};for(var p in props)
this[p]=props[p];};DragResize.prototype.apply=function(node){var obj=this;addDREvent(node,'mousedown',function(e){obj.mouseDown(e)});addDREvent(node,'mousemove',function(e){obj.mouseMove(e)});addDREvent(node,'mouseup',function(e){obj.mouseUp(e)});};DragResize.prototype.select=function(newElement){with(this){if(!document.getElementById||!enabled)return;if(newElement&&(newElement!=element)&&enabled){element=newElement;element.style.zIndex=++zIndex;if(this.resizeHandleSet)this.resizeHandleSet(element,true);gframe=document.getElementById("popupFrame");frameParent=gframe.parentNode;elmX=parseInt(element.style.left,10);elmY=parseInt(element.style.top,10);elmW=element.offsetWidth;elmH=element.offsetHeight;if(ondragfocus)this.ondragfocus();}}};DragResize.prototype.deselect=function(delHandles){with(this){if(!document.getElementById||!enabled)return;if(delHandles){if(ondragblur)this.ondragblur();if(this.resizeHandleSet)this.resizeHandleSet(element,false);element=null;}
handle=null;mOffX=0;mOffY=0;}};DragResize.prototype.mouseDown=function(e){with(this){if(!document.getElementById||!enabled)return true;var elm=e.target||e.srcElement,newElement=null,newHandle=null,hRE=new RegExp(myName+'-([trmbl]{2})','');while(elm){if(elm.className){if(!newHandle&&(hRE.test(elm.className)||isHandle(elm)))newHandle=elm;if(isElement(elm)){newElement=elm;break}}
elm=elm.parentNode;}
if(element&&(element!=newElement)&&allowBlur)deselect(true);if(newElement&&(!element||(newElement==element))){if(newHandle)cancelDREvent(e);select(newElement,newHandle);handle=newHandle;if(handle&&ondragstart){gframe.style.display="none";this.ondragstart(hRE.test(handle.className));}}}};DragResize.prototype.mouseMove=function(e){with(this){if(!document.getElementById||!enabled)return true;var scrOfX=0,scrOfY=0;if(self.pageYOffset){scrOfY=self.pageYOffset;scrOfX=self.pageXOffset;}
else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){scrOfY=document.body.scrollTop;scrOfX=document.body.scrollLeft;}
else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){scrOfY=document.documentElement.scrollTop;scrOfX=document.documentElement.scrollLeft;}
mouseX=(e.pageX||e.clientX)+scrOfX;mouseY=(e.pageY||e.clientY)+scrOfY;var diffX=mouseX-lastMouseX+mOffX;var diffY=mouseY-lastMouseY+mOffY;mOffX=mOffY=0;lastMouseX=mouseX;lastMouseY=mouseY;if(!handle)return true;var isResize=false;if(this.resizeHandleDrag&&this.resizeHandleDrag(diffX,diffY)){isResize=true;}
else{var dX=diffX,dY=diffY;if(elmX+dX<minLeft)mOffX=(dX-(diffX=minLeft-elmX));else if(elmX+elmW+dX>maxLeft)mOffX=(dX-(diffX=maxLeft-elmX-elmW));if(elmY+dY<minTop)mOffY=(dY-(diffY=minTop-elmY));else if(elmY+elmH+dY>maxTop)mOffY=(dY-(diffY=maxTop-elmY-elmH));elmX+=diffX;elmY+=diffY;}
gframe.style.width=parseInt(document.getElementById("popupTitleBar").offsetWidth,10)+"px";gframe.style.height=elmH+'px';frameParent.style.height=gframe.style.height;frameParent.style.width=gframe.style.width;with(element.style){left=elmX+'px';width=elmW+'px';top=elmY+'px';height=elmH+'px';}
if(window.opera&&document.documentElement){var oDF=document.getElementById('op-drag-fix');if(!oDF){var oDF=document.createElement('input');oDF.id='op-drag-fix';oDF.style.display='none';document.body.appendChild(oDF);}
oDF.focus();}
if(ondragmove)this.ondragmove(isResize);cancelDREvent(e);}};DragResize.prototype.mouseUp=function(e){with(this){if(!document.getElementById||!enabled)return;var hRE=new RegExp(myName+'-([trmbl]{2})','');if(handle&&ondragend){gframe.style.display="block";this.ondragend(hRE.test(handle.className));}
deselect(false);}};DragResize.prototype.resizeHandleSet=function(elm,show){with(this){if(!elm._handle_tr){for(var h=0;h<handles.length;h++){var hDiv=document.createElement('div');hDiv.className=myName+' '+myName+'-'+handles[h];elm['_handle_'+handles[h]]=elm.appendChild(hDiv);}}
for(var h=0;h<handles.length;h++){elm['_handle_'+handles[h]].style.visibility=show?'inherit':'hidden';}}};DragResize.prototype.resizeHandleDrag=function(diffX,diffY){with(this){var hClass=handle&&handle.className&&handle.className.match(new RegExp(myName+'-([tmblr]{2})'))?RegExp.$1:'';var dY=diffY,dX=diffX,processed=false;if(hClass.indexOf('t')>=0){rs=1;if(elmH-dY<minHeight)mOffY=(dY-(diffY=elmH-minHeight));else if(elmY+dY<minTop)mOffY=(dY-(diffY=minTop-elmY));elmY+=diffY;elmH-=diffY;processed=true;}
if(hClass.indexOf('b')>=0){rs=1;if(elmH+dY<minHeight)mOffY=(dY-(diffY=minHeight-elmH));else if(elmY+elmH+dY>maxTop)mOffY=(dY-(diffY=maxTop-elmY-elmH));elmH+=diffY;processed=true;}
if(hClass.indexOf('l')>=0){rs=1;if(elmW-dX<minWidth)mOffX=(dX-(diffX=elmW-minWidth));else if(elmX+dX<minLeft)mOffX=(dX-(diffX=minLeft-elmX));elmX+=diffX;elmW-=diffX;processed=true;}
if(hClass.indexOf('r')>=0){rs=1;if(elmW+dX<minWidth)mOffX=(dX-(diffX=minWidth-elmW));else if(elmX+elmW+dX>maxLeft)mOffX=(dX-(diffX=maxLeft-elmX-elmW));elmW+=diffX;processed=true;}
return processed;}};var dragresize=new DragResize('dragresize');dragresize.isElement=function(elm){if(elm.className&&elm.className.indexOf('popupContainer')>-1)return true;};dragresize.isHandle=function(elm){if(elm.className&&elm.className.indexOf('popupTitleBar')>-1)return true;};dragresize.ondragfocus=function(){};dragresize.ondragstart=function(isResize){};dragresize.ondragmove=function(isResize){};dragresize.ondragend=function(isResize){};dragresize.ondragblur=function(){};dragresize.apply(document);
var rbv_bd_dom,rbv_bd_ie,rbv_bd_ie4,rbv_bd_ie5x,rbv_bd_moz,rbv_bd_mac,rbv_bd_win,rbv_bd_lin,rbv_bd_old,rbv_bd_ie5mac,rbv_bd_ie5xwin,rbv_bd_op,rbv_bd_konq,rbv_bd_saf,rbv_bd_chrome;rbv_bd_na=navigator.appVersion;rbv_bd_nua=navigator.userAgent;rbv_bd_win=(rbv_bd_na.indexOf('Win')!=-1);rbv_bd_mac=(rbv_bd_na.indexOf('Mac')!=-1);rbv_bd_lin=(rbv_bd_nua.indexOf('Linux')!=-1);if(!navigator.layers){rbv_bd_dom=(navigator.getElementById);rbv_bd_op=(rbv_bd_nua.indexOf('Opera')!=-1);rbv_bd_konq=(rbv_bd_nua.indexOf('Konqueror')!=-1);rbv_bd_saf=(rbv_bd_nua.indexOf('Safari')!=-1);rbv_bd_moz=(rbv_bd_nua.indexOf('Gecko')!=-1&&!rbv_bd_saf&&!rbv_bd_konq);rbv_bd_chrome=(rbv_bd_nua.indexOf('Chrome')!=-1);rbv_bd_ie=(navigator.all&&!rbv_bd_op);rbv_bd_ie4=(rbv_bd_ie&&!rbv_bd_dom);rbv_bd_ie5x=(navigator.all&&rbv_bd_dom);rbv_bd_ie5mac=(rbv_bd_mac&&rbv_bd_ie5x);rbv_bd_ie5xwin=(rbv_bd_win&&rbv_bd_ie5x);}
function openFuncSelector(pageId,funcName,multiSel){var selectorWindow=window.open('../m/selector.jsp?act=clean&pageId='+pageId+'&funcName='+funcName+'&multiSel='+multiSel,'Selector','WIDTH=600, HEIGHT=400, RESIZABLE=YES, SCROLLBARS=YES, TOOLBAR=YES, LEFT=20, TOP=20');selectorWindow.focus();return false;}
function openLDFSelector(pageId,viewPageId,inputName){var selectorWindow=window.open('../m/selector.jsp?act=clean&pageId='+pageId+'&viewPageId='+viewPageId+'&inputName='+inputName+'&funcName=rbf_selectLDF&multiSel=false','Selector','WIDTH=600, HEIGHT=400, RESIZABLE=YES, SCROLLBARS=YES, TOOLBAR=YES, LEFT=20, TOP=20');selectorWindow.focus();return false;}
function rbf_selectObject(objId,objName,viewPageId,inputName,multiSel){var objTableBody=document.getElementById('rtable_'+inputName);var inp=document.getElementById(inputName);if(!objTableBody||!inp){return;}
if(inp.value.indexOf(objId)>=0){return;}
if(multiSel==true&&objTableBody){var objRow=document.getElementById(inputName+'_'+objId);if(objRow){return;}
if(inp.value.length>0){inp.value+=",";}
else{rbf_removeAllChildren(objTableBody);}
inp.value+=objId;}
else if(objTableBody){inp.value=objId;rbf_removeAllChildren(objTableBody);}
addRow(inputName,objId,objName,viewPageId,objTableBody);var hiddenChange=inp.getAttribute("hidenChange");if(hiddenChange)
eval(hiddenChange);}
function addRow(inputName,objId,objName,viewPageId,objTableBody){rbf_insertRow(inputName,objId,objName,viewPageId,objTableBody,false);}
function addLDFRow(inputName,objId,objName,viewPageId,objTableBody){rbf_insertRow(inputName,objId,objName,viewPageId,objTableBody,true);}
function rbf_insertRow(inputName,objId,objName,viewPageId,objTableBody,isLDF){var newRow=document.createElement("tr");newRow.id=inputName+'_'+objId;var removeCell=document.createElement("td");removeCell.className='right';var divSpace=document.createElement("div");divSpace.className='supersmall';divSpace.innerHTML="&nbsp;"
var iconSpan=document.createElement("span");iconSpan.inputName=inputName;iconSpan.objId=objId
if(isLDF){iconSpan.onclick=function(){removeLDF(this.objId,this.inputName);}}
else{iconSpan.onclick=function(){rbf_removeObject(this.objId,this.inputName);}}
iconSpan.style.cursor='pointer';var removeImage=document.createElement("img");removeImage.src=rbv_rootURL+"images/deleteicon.gif";removeImage.width=11;removeImage.height=11;removeImage.align="absmiddle";removeImage.border=0;removeImage.alt="Remove";iconSpan.appendChild(removeImage);removeCell.appendChild(iconSpan);var newCell=document.createElement("td");newCell.className='wide';if(viewPageId>0)
newCell.innerHTML="<b><a href='#undefined' onClick=\"rbf_openPopup('pageId="+viewPageId+"&id="+objId+"')\">"+objName+"</a></b>";else
newCell.innerHTML="<b>"+objName+"</b>";newRow.appendChild(removeCell);newRow.appendChild(newCell);objTableBody.appendChild(newRow);var parent=objTableBody.parentNode;if(parent){parent.removeChild(objTableBody);parent.appendChild(objTableBody);}}
function rbf_removeObject(objId,inputName){var row=document.getElementById(inputName+'_'+objId);var hiddenInput=document.getElementById(inputName);if(row&&hiddenInput){var parent=row.parentNode;if(parent){parent.removeChild(row);}
var value=hiddenInput.value;var values=value.split(",");var newValues=new Array();for(var i=0;i<values.length;i++){if(values[i]&&values[i]!=objId){newValues[newValues.length]=values[i];}}
hiddenInput.value=newValues;var hChange=hiddenInput.getAttribute("hidenChange");if(hChange)
eval(hChange);}}
function removeLDF(objId,inputName){var row=document.getElementById(inputName+'_'+objId);var hiddenField=document.getElementById('h_'+inputName);if(row&&hiddenField){var parent=row.parentNode;if(parent){parent.removeChild(row);}
hiddenField.value="";}}
function rbf_selectLDF(objId,objName,viewPageId,inputName){var hiddenField=document.getElementById('h_'+inputName);hiddenField.value=objId;var hiddenChange=hiddenField.getAttribute("hidenChange");if(hiddenChange)
eval(hiddenChange);var objTableBody=document.getElementById('rtable_'+inputName);if(!objTableBody){return;}
if(objTableBody){rbf_removeAllChildren(objTableBody);}
addLDFRow(inputName,objId,objName,viewPageId,objTableBody);}
function AutoSuggestControl(oTextbox,objDefId,selectorViewId){this.layer=null;this.suggDiv=null;this.textbox=oTextbox;this.objDefId=objDefId;this.selectorViewId=selectorViewId;this.fieldName=oTextbox.getAttribute('matchField');this.matchRule=oTextbox.getAttribute('matchRule');this.viewPageId=oTextbox.getAttribute('viewPageId');this.suggType=oTextbox.getAttribute('suggType');this.isMultiple=(oTextbox.getAttribute('isMultiple')=="false")?Boolean(false):Boolean(true);this.inputName=oTextbox.id.replace(/txt/gi,"");var viewId=parseInt(oTextbox.getAttribute('selectorViewId'));if(viewId>0)
this.selectorViewId=viewId;this.showSugg=false;this.pattern=null;this.init();}
AutoSuggestControl.prototype.init=function(){var oThis=this;this.textbox.onkeyup=function(oEvent){if(!oEvent){oEvent=window.event;}
oThis.requestSuggestions();};this.textbox.onblur=function(){oThis.hideSuggestions();};this.textbox.onfocus=null;this.createDropDown();};AutoSuggestControl.prototype.createDropDown=function(){var oThis=this;this.layer=document.createElement("div");this.layer.className="rbwhite";this.layer.style.display="none";this.layer.style.position="absolute";this.layer.innerHTML='<table width="100%" cellspacing="0" cellpadding="0"><tbody>'+'<tr style="height: 6px;">'+'<td class="rbs_popup_tlc" style="width: 7px;"/>'+'<td class="rbs_popup_top"/>'+'<td class="rbs_popup_trc" style="width: 7px;"/></tr>'+'<tr> <td class="rbs_popup_left"/>'+'<td> <div><div id="suggestions'+this.inputName+'" class="rbwhite" ></div> </div></td>'+'<td class="rbs_popup_right"/> </tr>'+'<tr style="height: 9px;">'+'<td class="rbs_popup_blc" style="width: 7px;"/>'+'<td class="rbs_popup_bottom"/>'+'<td class="rbs_popup_brc" style="width: 7px;"/></tr>'+'</tbody></table>';document.body.appendChild(this.layer);this.suggDiv=document.getElementById("suggestions"+this.inputName);this.suggDiv.onmousedown=this.suggDiv.onmouseup=this.suggDiv.onmouseover=function(oEvent){oEvent=oEvent||window.event;oTarget=oEvent.target||oEvent.srcElement;if(oEvent.type=="mousedown"){var recName=oTarget.firstChild.nodeValue;var recId=parseInt(oTarget.parentNode.id,10);if(recId>0&&recName&&recName.length>=1){if(oThis.suggType=='rObj'&&oThis.showSugg)
rbf_selectObject(recId,recName,oThis.viewPageId,oThis.inputName,oThis.isMultiple);else if(oThis.suggType=='ldf')
rbf_selectLDF(recId,recName,oThis.viewPageId,oThis.inputName);}
oThis.hideSuggestions();oThis.textbox.value="";}
else if(oEvent.type=="mouseover"){oThis.highlightSuggestion(oTarget);}
else{oThis.textbox.focus();}};};AutoSuggestControl.prototype.getLeft=function(){var oNode=this.textbox;var iLeft=0;while(oNode.tagName!="BODY"){iLeft+=oNode.offsetLeft;oNode=oNode.offsetParent;}
return iLeft;};AutoSuggestControl.prototype.getTop=function(){var oNode=this.textbox;var iTop=0;while(oNode.tagName!="BODY"){iTop+=oNode.offsetTop;oNode=oNode.offsetParent;}
return iTop;};AutoSuggestControl.prototype.hideSuggestions=function(){if(this.layer){this.layer.style.display="none";}};AutoSuggestControl.prototype.highlightSuggestion=function(oSuggestionNode){for(var i=0;i<this.suggDiv.childNodes.length;i++){var oNode=this.suggDiv.childNodes[i];if(oNode==oSuggestionNode){oNode.className="highlight"}else if(oNode.className=="highlight"){oNode.className="rbwhite";}}};AutoSuggestControl.prototype.showError=function(errorMessage){this.textbox.onblur();this.suggDiv=document.getElementById('suggestions'+this.inputName)
this.suggDiv.innerHTML="";var oDiv=document.createElement("div");oDiv.innerHTML=errorMessage;this.suggDiv.appendChild(oDiv);this.layer.style.width="200px";this.layer.style.left=this.getLeft()+"px";this.layer.style.top=(this.getTop()+this.textbox.offsetHeight)+"px";this.layer.style.display="block";this.showSugg=false;}
AutoSuggestControl.prototype.showSuggestions=function(matches){var oDiv=null;this.textbox.onblur();this.suggDiv=document.getElementById('suggestions'+this.inputName)
this.suggDiv.innerHTML="";var i=0;var nummatchs=matches.length;if(nummatchs==0)
return;var isIE=(window.navigator.userAgent.indexOf("MSIE")>-1);if(nummatchs>=25&&!isIE){this.suggDiv.parentNode.style.height="150px";this.suggDiv.parentNode.style.overflow="auto";this.suggDiv.parentNode.style.overflowY="scroll";}
else{this.suggDiv.parentNode.style.height="100%";this.suggDiv.parentNode.style.overflow="";}
var ht=0;for(i=0;i<nummatchs;i++){var match=matches[i];oDiv=document.createElement("div");oDiv.id=match.recid;oDiv.style.whiteSpace="nowrap";oDiv.innerHTML="<a href='#'>"+match.val+"</a>";this.suggDiv.appendChild(oDiv);if(ht<match.val.length)ht=match.val.length;}
var divWidth=ht+160;this.suggDiv.style.width=(divWidth<200)?(divWidth)+"px":"200px";this.suggDiv.parentNode.style.width=(divWidth<200)?(divWidth)+"px":"200px";this.layer.style.width=(divWidth<200)?(divWidth+10)+"px":"210px";if(divWidth>200){this.suggDiv.parentNode.style.overflow="auto";this.suggDiv.parentNode.style.overflowX="scroll";}
this.layer.style.left=this.getLeft()+"px";this.layer.style.top=(this.getTop()+this.textbox.offsetHeight)+"px";this.layer.style.display="block";this.showSugg=true;};AutoSuggestControl.prototype.requestSuggestions=function(){var rrThis=this;var pattern=this.textbox.value;var textBoxLen=pattern.length;if(textBoxLen>=3){var ajaxsreq=rbf_getXMLHTTPRequest();if(ajaxsreq){var url=rbf_getAjaxURL()+'&cmd=matchedObjects&objDefId='+this.objDefId+'&selectorViewId='+this.selectorViewId+'&name='+rbf_encode(this.fieldName)+'&matchRule='+encodeURI(this.matchRule)+'&query='+rbf_encode(pattern);ajaxsreq.open("GET",url,true);ajaxsreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxsreq.onreadystatechange=function(){rrThis.requestSuggestionsCallback(ajaxsreq,pattern);};ajaxsreq.send(null);this.pattern=pattern;}}
return;};AutoSuggestControl.prototype.requestSuggestionsCallback=function(ajaxsreq,pattern){if(ajaxsreq&&ajaxsreq.readyState==READY_STATE_COMPLETE&&(!ajaxsreq.status||ajaxsreq.status==200)&&(pattern==this.pattern)){var resultXML=ajaxsreq.responseText;if(resultXML.indexOf("<Error>")==0){this.showError(resultXML.substring(7,resultXML.length-8));return;}
var resultArr=resultXML.split("\n");var resultLen=resultArr.length;var suggestions=new Array();var pos=0;var k=0;while(pos<resultLen){var recid=resultArr[pos++];if(pos>=resultLen)
break;var val=resultArr[pos++];suggestions[k++]=new DataStruct(val,recid);}
this.showSuggestions(suggestions);}
return;};function DataStruct(val,recid){this.val=val;this.recid=recid;}
var rbv_listForm;var rbv_selAction;var rbv_objId=-1;var rbv_cellId=-1;function rbf_manageSelection(listForm,action){if("all"==action)
rbf_checkListBoxes(listForm,true,"sel_");else if("none"==action)
rbf_checkListBoxes(listForm,false,"sel_");else if("viewed"==action)
rbf_checkViewedBoxes(listForm,"Y","sel_");else if("unviewed"==action)
rbf_checkViewedBoxes(listForm,"N","sel_");else if("flagged"==action)
rbf_checkFlaggedBoxes(listForm,"Y","sel_");else if("unflagged"==action)
rbf_checkFlaggedBoxes(listForm,"N","sel_");else if("allRec"==action)
rbf_selectAllBoxes(listForm,"sel_");else if("noneRec"==action)
rbf_clearSelectedBoxes(listForm,"sel_");listForm.selectorManager.value="";return false;}
function rbf_checkListBox(listForm,ch,prefix){var buff=ch.name.substring(prefix.length);rbf_saveSelectedBoxes(listForm,ch.checked,buff);}
function rbf_checkListBoxes(listForm,flag,prefix){var buff="";var len=listForm.elements.length;for(var k=0;k<len;k++){var ch=listForm.elements[k];if(ch.type=="checkbox"&&ch.name.indexOf(prefix)==0){ch.checked=flag;buff+=ch.name.substring(prefix.length)+",";}}
rbf_saveSelectedBoxes(listForm,flag,buff);}
function rbf_checkViewedBoxes(listForm,flag,prefix){var buff1="";var buff2="";var len=listForm.elements.length;for(var k=0;k<len;k++){var ch=listForm.elements[k];if(ch.type=="checkbox"&&ch.name.indexOf(prefix)==0){var objId=ch.name.substring(prefix.length);var row=document.getElementById('c'+objId);if(row==null)
continue;if(row.getAttribute("viewed")==flag){ch.checked=true;buff1+=ch.name.substring(prefix.length)+",";}
else{ch.checked=false;buff2+=ch.name.substring(prefix.length)+",";}}}
rbf_saveSelectedBoxes(listForm,true,buff1);rbf_saveSelectedBoxes(listForm,false,buff2);}
function rbf_checkFlaggedBoxes(listForm,flag,prefix){var buff1="";var buff2="";var len=listForm.elements.length;for(var k=0;k<len;k++){var ch=listForm.elements[k];if(ch.type=="checkbox"&&ch.name.indexOf(prefix)==0){var objId=ch.name.substring(prefix.length);var row=document.getElementById('c'+objId);if(row==null)
continue;if(row.getAttribute("flagged")==flag){ch.checked=true;buff1+=ch.name.substring(prefix.length)+",";}
else{ch.checked=false;buff2+=ch.name.substring(prefix.length)+",";}}}
rbf_saveSelectedBoxes(listForm,true,buff1);rbf_saveSelectedBoxes(listForm,false,buff2);}
function rbf_clearSelectedBoxes(listForm,prefix){var len=listForm.elements.length;for(var k=0;k<len;k++){var ch=listForm.elements[k];if(ch.type=="checkbox"&&ch.name.indexOf(prefix)==0){ch.checked=false;}}
var oid=listForm.objDefId.value;rbf_sendAjaxRequest("&cmd=clearSelRecs&objDefId="+oid);var selCell=document.getElementById("selCellT"+listForm.cellId.value);if(selCell){selCell.innerHTML="";}
selCell=document.getElementById("selCellB"+listForm.cellId.value);if(selCell){selCell.innerHTML="";}}
function rbf_selectAllBoxes(listForm,prefix){rbv_listForm=listForm;var len=listForm.elements.length;for(var k=0;k<len;k++){var ch=listForm.elements[k];if(ch.type=="checkbox"&&ch.name.indexOf(prefix)==0){ch.checked=true;}}
var query="&cmd=selectAllRecs&objDefId="+listForm.objDefId.value+'&listId='+listForm.listViews.value;if(listForm.id2)
query+="&id2="+listForm.id2.value;if(listForm.relId)
query+="&relId="+listForm.relId.value;var ajaxRreq=rbf_getXMLHTTPRequest();if(ajaxRreq){ajaxRreq.onreadystatechange=function(){rbf_showSelectedCallback(ajaxRreq)};ajaxRreq.open("GET",rbf_getAjaxURL()+query,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);}}
function rbf_saveSelectedBoxes(listForm,isChecked,buff){rbv_listForm=listForm;var oid=listForm.objDefId.value;var query="&cmd=setSelRecs&isChecked="+(isChecked==true?"true":"false")+"&objDefId="+oid+"&ids="+buff;var ajaxRreq=rbf_getXMLHTTPRequest();if(ajaxRreq){ajaxRreq.onreadystatechange=function(){rbf_showSelectedCallback(ajaxRreq)};ajaxRreq.open("GET",rbf_getAjaxURL()+query,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);}}
function rbf_showSelectedCallback(ajaxRreq){if(ajaxRreq.readyState==READY_STATE_COMPLETE){var counter=parseInt(ajaxRreq.responseText,10);var text=(isNaN(counter)||counter==0?"":"(<b>"+counter+"</b> "+rbv_listForm.selectedPrompt.value+")");var selCell=document.getElementById("selCellT"+rbv_listForm.cellId.value);if(selCell){selCell.innerHTML=text;}
selCell=document.getElementById("selCellB"+rbv_listForm.cellId.value);if(selCell){selCell.innerHTML=text;}}}
function rbf_countBoxes(listForm,prefix){var counter=0;var len=listForm.elements.length;for(var k=0;k<len;k++){var ch=listForm.elements[k];if(ch.type=="checkbox"&&ch.name.indexOf(prefix)==0&&ch.checked){counter++;}}
return counter;}
function rbf_checkSelection(listForm){var selCell=document.getElementById("selCellT"+listForm.cellId.value);if(selCell){var selText=selCell.innerHTML;if(selText==null||selText.length<5){rbf_showInfoMessage(listForm.noSelectionInfoMessage.value);return false;}}
return true;}
function rbf_doGroupAction(listForm,selAction){if(!selAction||selAction==null||selAction==''||selAction=='null'){rbf_hideInfoMessage();return false;}
if(selAction=='xls'||selAction=='csv'||selAction=='google'){var query='&format='+selAction+'&listId='+listForm.listViews.value+"&pageId="+listForm.pageId.value;if(listForm.id2&&listForm.id2.value!='')
query+='&id2='+listForm.id2.value;if(listForm.relId&&listForm.relId.value!='')
query+='&relId='+listForm.relId.value;window.open(rbf_getExportURL()+'&act=listView'+query,'export','WIDTH=650, HEIGHT=600, RESIZABLE=YES, SCROLLBARS=YES, TOOLBAR=YES, LEFT=20, TOP=20').focus();return true;}
if(rbf_checkSelection(listForm)==false){listForm.groupAction.value='';return false;}
if(selAction=='compareArr'){listForm.act.value=selAction;listForm.action='compare.jsp';}
else if(selAction=='convertArr'){listForm.act.value=selAction;listForm.action='convert.jsp';}
else if(selAction=='transferArr'){listForm.act.value=selAction;listForm.action='transferOwner.jsp';}
else if(selAction=='resetPasswordArr'){if(confirm(listForm.resetPasswordPrompt.value)){listForm.act.value=selAction;listForm.action='../servlet/Object';}
else
return false;}
else if(selAction=='mergeArr'){if(rbf_countBoxes(listForm,"sel_")<2){rbf_showInfoMessage(listForm.mergeMinInfoMessage.value);return false;}
listForm.act.value=selAction;listForm.action='merge.jsp';}
else if(selAction=='sendTo'){listForm.action='sendArr.jsp?act=clean';}
else if(selAction.indexOf('massUpdate_')==0){listForm.pageId.value=selAction.substring(11);listForm.action='main.jsp';}
else if(selAction.indexOf('gAction_')==0){var s1=selAction.substring(8);var ind1=s1.indexOf(".");listForm.pageId.value=s1.substring(0,ind1);listForm.actionId.value=s1.substring(ind1+1);listForm.action='main.jsp?isGroup=true';}
else if(selAction.indexOf('gNoPage_')==0){var ind1=selAction.indexOf("_");listForm.actionId.value=selAction.substring(ind1+1);listForm.act.value='statusSetArr';listForm.action='../servlet/Object';}
else if(selAction.indexOf('gDocAction_')==0){var ind1=selAction.indexOf("_");var templateId=selAction.substring(ind1+1);window.open(rbv_rootURL+"servlet/Template?hint=fileArr&objDefId="+listForm.objDefId.value+"&templateId="+templateId+'&listId='+listForm.listViews.value,'export','WIDTH=650, HEIGHT=600, RESIZABLE=YES, SCROLLBARS=YES, TOOLBAR=YES, MENUBAR=YES, LEFT=20, TOP=20').focus();listForm.groupAction.value='';return false;}
else if(selAction.indexOf('gMailAction_')==0){var ind1=selAction.indexOf("_");listForm.actionId.value=selAction.substring(ind1+1);listForm.action='sendArr.jsp?act=populate';}
else if(selAction.indexOf('gCreateAction_')==0){var ind1=selAction.indexOf("_");listForm.actionId.value=selAction.substring(ind1+1);listForm.action='convert2.jsp';}
else if(selAction.indexOf('gTriggersAction_')==0){var ind1=selAction.indexOf("_");listForm.actionId.value=selAction.substring(ind1+1);listForm.action='runTriggers.jsp';}
else if(selAction.indexOf('gApprAction_')==0){var ind1=selAction.indexOf("_");listForm.actionId.value=selAction.substring(ind1+1);listForm.action='startApproval.jsp';}
else{listForm.act.value=selAction;listForm.action='../servlet/Object';}
listForm.submit();return true;}
function rbf_doGroupDeleteConfirmed(){if(!rbv_listForm||!rbv_selAction){return false;}
rbv_listForm.act.value=rbv_selAction;rbv_listForm.action='../servlet/Object';rbv_listForm.submit();return true;}
function rbf_doGroupDelete(listForm,selAction,isSystem){rbv_listForm=listForm;rbv_selAction=selAction;if(rbf_checkSelection(listForm)==false){return false;}
var dc=rbv_listForm.groupDeletePrompt.value;var dt=rbv_listForm.groupDeletePromptTitle.value;if(isSystem){showPopWin('../dialog/confirmCheckDialog.jsp',500,180,rbf_doGroupDeleteConfirmed,true,dc,dt);}
else{showPopWin('../dialog/confirmDialog.jsp',500,130,rbf_doGroupDeleteConfirmed,true,dc,dt);}
return false;}
function rbf_doSingleDeleteConfirmed(){if(!rbv_listForm||!rbv_selAction||rbv_objId<0){return false;}
rbv_listForm.id.value=rbv_objId;rbv_listForm.act.value=rbv_selAction;rbv_listForm.action='../servlet/Object';rbv_listForm.submit();return true;}
function rbf_doSingleDelete(listForm,selAction,objId,isSystem){rbv_listForm=listForm;rbv_selAction=selAction;rbv_objId=objId;var dc=rbv_listForm.singleDeletePrompt.value;var dt=rbv_listForm.singleDeletePromptTitle.value;if(isSystem){showPopWin('../dialog/confirmCheckDialog.jsp',500,180,rbf_doSingleDeleteConfirmed,true,dc,dt);}
else{showPopWin('../dialog/confirmDialog.jsp',500,130,rbf_doSingleDeleteConfirmed,true,dc,dt);}
return false;}
function rbf_doNewObject(listForm,pgId,relatedId,relId){listForm.pageId.value=pgId;listForm.action='main.jsp'+(relatedId>0?'?relatedId='+relatedId+'&relId='+relId:'');listForm.submit();return true;}
function rbf_doDefaultView(listForm){listForm.act.value="defaultView";listForm.action='../servlet/Object';listForm.submit();return true;}
var rbv_quickObjectQuery=null;function rbf_doQuickCreate(listForm,pageId,quickObjectQuery,returnId,relId){if(listForm){rbv_listForm=listForm;rbv_quickObjectQuery=quickObjectQuery;if(listForm.listViews)
rbv_quickObjectQuery+='&listId='+listForm.listViews.value;var dt=listForm.quickCreateTitle.value;var buff='../dialog/objectQuickCreate.jsp?objDefId='+listForm.objDefId.value+"&pageId="+pageId;if(returnId>0)
buff+="&returnId="+returnId+'&relId='+relId;else if(listForm.returnId)
buff+="&returnId="+listForm.returnId.value;showPopWin(buff,700,0,null,true,'',dt);}
return false;}
function rbf_doQuickCreateCompleted(){rbv_listForm.submit();return true;}
function rbf_doFlag(listForm,objId){var row=document.getElementById("c"+objId);if(!row){rbf_showInfoMessage(listForm.noSelectionInfoMessage.value);return false;}
var isFlagged=(row.getAttribute("flagged")=="Y");rbf_sendAjaxRequest("&cmd=setFlagged&id="+objId+"&flag="+(isFlagged?"false":"true"));if(isFlagged){rbf_setImage("i"+objId,"../images/notflagged.gif",listForm.setFlagPrompt.value);row.setAttribute("flagged","N");rbf_showInfoMessage(listForm.unflaggedInfoMessage.value);}
else{rbf_setImage("i"+objId,"../images/flagged.gif",listForm.removeFlagPrompt.value);row.setAttribute("flagged","Y");rbf_showInfoMessage(listForm.flaggedInfoMessage.value);}
return false;}
function rbf_doGroupTag(listForm){rbv_listForm=listForm;if(rbf_checkSelection(listForm)==false){return false;}
var dc=rbv_listForm.searchTagPrompt.value;var dt=rbv_listForm.searchTagPromptTitle.value;showPopWin('../dialog/tagDialog.jsp',500,130,rbf_doGroupTagCallback,true,dc,dt);return false;}
function rbf_doGroupTagCallback(newTag){if(!rbv_listForm||newTag==null||newTag==''||newTag=='null'){return false;}
var objDefId=rbv_listForm.objDefId.value;var pageId=rbv_listForm.pageId.value;var cellId=rbv_listForm.cellId.value;var listId=rbv_listForm.listViews.value;var query="&cmd=searchTag&objDefId="+objDefId+"&pageId="+pageId+"&cellId="+cellId+"&listId="+listId+"&tag="+encodeURIComponent(newTag);rbf_showInfoMessage(rbv_listForm.tagInfoMessage.value+" "+newTag);var ajaxRreq=rbf_getXMLHTTPRequest();if(ajaxRreq){rbf_showLoadingMessage();ajaxRreq.onreadystatechange=function(){rbf_listCallback(ajaxRreq)};ajaxRreq.open("POST",rbf_getAjaxURL()+query,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);rbv_cellId=rbv_listForm.cellId.value;}
return false;}
function rbf_doReportExport(listForm,selAction){window.open(rbf_getExportURL()+'&act=report&format='+selAction+'&reportId='+listForm.reportId.value+'&pageId='+listForm.pageId.value,'export','WIDTH=650, HEIGHT=600, RESIZABLE=YES, SCROLLBARS=YES, TOOLBAR=YES, MENUBAR=YES, LEFT=20, TOP=20').focus();return false;}
function rbf_selectChart(chartdiv,chart){chart.render(chartdiv);}
function rbf_doList(cellId,query){var ajaxRreq=rbf_getXMLHTTPRequest();if(ajaxRreq){rbf_showLoadingMessage();ajaxRreq.onreadystatechange=function(){rbf_listCallback(ajaxRreq)};ajaxRreq.open("POST",rbf_getAjaxURL()+"&cmd=listData"+query,true);ajaxRreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ajaxRreq.send(null);rbv_cellId=cellId;}
return false;}
function rbf_listCallback(ajaxRreq){if(ajaxRreq.readyState==READY_STATE_COMPLETE){var data=ajaxRreq.responseText;if(!data||data==''||data.length<2){data="<table border=0 cellpadding=10 class='rbs_secondaryWide'><tr><td>Your session may have expired or there is a problem with your connection to Rollbase.<br><a href='../components/logout.jsp' target='_top'>Login again</a> or wait a few minutes and try again.</td></tr></table>";}
var cellDiv=document.getElementById('ld_'+rbv_cellId);if(cellDiv!=null){cellDiv.innerHTML=evalScript(data);}
rbv_cellId=null;rbf_hideLoadingMessage();}}
function evalScript(data){while(true){var scriptBegin1=data.indexOf("<script");if(scriptBegin1<0)
return data;var scriptBegin2=data.indexOf(">",scriptBegin1);if(scriptBegin2<0)
return data;var scriptEnd=data.indexOf("</script>",scriptBegin2);if(scriptEnd<0)
return data;var scriptText=data.substring(scriptBegin2+1,scriptEnd);eval(scriptText);data=data.substring(0,scriptBegin1)+data.substring(scriptEnd+9);}}
var rbv_listDelQuery=null;function rbf_doListDeleteConfirmed(){window.location.href='../servlet/Designer?'+rbv_listDelQuery;rbv_listDelQuery=null;}
function rbf_doListDelete(listDelQuery,listForm){var dc=listForm.listDeletePrompt.value;var dt=listForm.listDeletePromptTitle.value;showPopWin('../dialog/confirmCheckDialog.jsp',500,175,rbf_doListDeleteConfirmed,true,dc,dt);rbv_listDelQuery=listDelQuery+'&viewId='+listForm.listViews.value;return false;}
var rbv_relatedListQuery=null;function rbf_attachRelated(pageId,funcName,relatedListQuery,pageTitle){rbv_relatedListQuery=relatedListQuery;var selectorPopup='../dialog/relatedRecordCreate.jsp?act=clean&pageId='+pageId+'&funcName='+funcName;showPopWin(selectorPopup,700,0,null,true,'',pageTitle);return false;}
function rbf_doRelCreate(listForm,objId,actValue){rbv_listForm=listForm;listForm.id.value=objId;listForm.act.value=actValue;listForm.action='../servlet/Object';listForm.submit();return true;}
function rbf_doRelRemove(listForm,removeAction,objId){rbv_listForm=listForm;rbv_objId=objId;var dc=listForm.singleRemovePrompt.value;var dt=listForm.singleRemovePromptTitle.value;showPopWin('../dialog/confirmDialog.jsp',500,130,function(){rbf_doRelRemoveConfirmed(removeAction);},true,dc,dt);return false;}
function rbf_doRelRemoveConfirmed(removeAction){if(!rbv_listForm||rbv_objId<0){return false;}
rbv_listForm.id.value=rbv_objId;rbv_listForm.act.value=removeAction;rbv_listForm.action='../servlet/Object';rbv_listForm.submit();return true;}
function rbf_doAttachCompleted(){var cellId=rbv_listForm.cellId.value;rbf_doList(cellId,rbv_relatedListQuery);}
function rbf_showFilter(listForm,actValue){listForm.act.value=actValue;listForm.submit();return true;}
function rbf_applyFilter(listForm,actValue){listForm.action='../servlet/Search';listForm.act.value=actValue;if(actValue=="filterClear")
return true;var joinType=document.getElementById("rbe_joinType");if(!joinType)
return false;var expression=document.getElementById("rbe_expression");if(!expression)
return false;if(joinType.value=="3"&&isExpressionValid(expression.value)==false){rbf_showInfoMessage(listForm.expressionError.value,true);return false;}
listForm.submit();return true;}
function rbf_changeView(listForm,viewId){listForm.act.value="hideFilter";listForm.action='main.jsp?selListId='+viewId;listForm.submit();return true;}
