function DescriptionSubmitter(resource,resourceId,request,sessionId){this.descAdd='descriptionAdd';this.descEnter='descriptionEnter';this.res=resource;this.enterDesc=null;this.showDesc=null;this.subs=null;this.terms=null;this.viewTerms=null;this.add=null;this.retry=0;this.minLength=50;this.descWidth=null;this.request=request;this.sessId=sessionId;this.resId=resourceId;this.ajax=null;this.ajaxresponse=function(){if(this.responseStatus[0]==200||this.responseStatus[1]=="OK"){var responseArray=this.response.split("|");if(responseArray.length==3){if(responseArray[0]=="true"){this.controller.subs.style.display='none';}if(responseArray[1]=="alert"){alert(responseArray[2]);}else if(responseArray[1]=="print"){printMsg(responseArray[2]);}else if(responseArray[1]=="login"){var thisObj=this.controller;thisObj.toggleLoginSend();}}}};this.setupSubComponents=function(root){this.subs=root;var checkDiv=et_findChild(root,'DIV','check');var addDiv=et_findChild(root,'DIV','button');var textDiv=et_findChild(root,'DIV','text');if(checkDiv&&addDiv&&textDiv){this.terms=et_findChild(checkDiv,'INPUT');this.terms.controller=this;this.add=et_findChild(addDiv,'A');this.add.onclick=this.submitEntry;this.add.controller=this;if(!this.terms||!this.add){alert('initialization error, required components not found');}}else{alert('initialization error, required components not found');}};this.setupComponents=function(){var add=document.getElementById(this.descAdd);var enter=document.getElementById(this.descEnter);this.showDesc=et_findChild(add,'A','showDescription');this.enterDesc=et_findChild(et_findChild(enter,'DIV'),'TEXTAREA');var subs=et_findChild(enter,'DIV','termsContainer');if(this.showDesc&&this.enterDesc&&subs){et_setupLink(this.showDesc,this,this.showEntryClick);this.enterDesc.controller=this;this.setupSubComponents(subs);}else{alert('initialization error 1, required components not found');}};this.initialize=function(){if(!document.getElementById(this.descAdd)){thisObj=this;if(this.retry<20){window.setTimeout(function(){thisObj.initialize()},100);this.retry++;}}else{this.setupComponents();}};this.showEntry=function(){var add=document.getElementById(this.descAdd);var enter=document.getElementById(this.descEnter);add.style.display='none';enter.style.display='block';this.enterDesc.focus();this.descWidth=this.enterDesc.clientWidth;sizer();};this.toggleLoginShow=function(){var message='You must be logged in to submit descriptions';var logon=showLogon(thisObj.request,thisObj.sessId,message);logon.logonCallback=function(){thisObj.showEntry();}};this.toggleLoginSend=function(){var message='You must be logged in to submit descriptions';var logon=showLogon(thisObj.request,thisObj.sessId,message);logon.logonCallback=function(){thisObj.sendDesc();}};this.showEntryClick=function(evt){var event=(evt)?evt:window.event;var source=(event.target)?event.target:event.srcElement;var thisObj=et_findControllerNode(source).controller;var reqFile=thisObj.request+"/ajaxservlet;jsessionid="+thisObj.sessId;var lc=new LogonChecker(reqFile,function(){thisObj.showEntry();},function(){thisObj.toggleLoginShow();});lc.check();};this.showTerms=function(evt){var event=(evt)?evt:window.event;var source=(event.target)?event.target:event.srcElement;var thisObj=et_findControllerNode(source).controller;};this.sendDesc=function(){var reqFile=this.request+"/ajaxservlet;jsessionid="+this.sessId;this.ajax=new sack(reqFile);this.ajax.setVar("description",this.enterDesc.value);this.ajax.setVar("id",this.resId);this.ajax.setVar("proc_class","nfm.core.entity.ajax."+this.res);this.ajax.method="POST";this.ajax.onCompletion=this.ajaxresponse;this.ajax.controller=this;this.ajax.runAJAX();};this.submitEntry=function(evt){var event=(evt)?evt:window.event;var source=(event.target)?event.target:event.srcElement;var thisObj=et_findControllerNode(source).controller;var text=trim(thisObj.enterDesc.value);if(!thisObj.terms.checked){alert('You must agree to the terms and conditions before submitting');}else if(text.length<thisObj.minLength){alert('The description must be at least '+thisObj.minLength+' characters long.');}else{thisObj.sendDesc();}};this.initialize();}