function Toggler(id,name,inFavorite,inIcon,notInIcon,linkId,request,sessionId,processor,sizeSpace){this.id=id;this.name=name;this.proc=processor;this.toggleLinkId=linkId;this.isFavorite=inFavorite;this.addIcon=inIcon;this.removeIcon=notInIcon;this.uri=request;this.sessId=sessionId;this.ajax=null;this.useIcons=true;this.sizeSpace=sizeSpace;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.isFavorite=!this.controller.isFavorite;this.controller.updateImage();}if(responseArray[1]=="alert"){alert(responseArray[2]);}else if(responseArray[1]=="json"){var data=eval('('+responseArray[2]+')');printMsg(data.message);if(data.datasize){var ss=document.getElementById(this.controller.sizeSpace);if(ss)ss.innerHTML=data.datasize;}}else if(responseArray[1]=="print"){printMsg(responseArray[2]);}else if(responseArray[1]=="login"){var thisObj=this.controller;var logon=showLogon(thisObj.uri,thisObj.sessId,responseArray[2]);logon.logonCallback=function(){thisObj.sendToggle();}}else if(responseArray[1]=="redirect"){window.location=responseArray[2];}}}};this.sendToggle=function(){var reqFile=this.uri+"/ajaxservlet;jsessionid="+this.sessId;this.ajax=new sack(reqFile);this.ajax.setVar("id",this.id);if(this.isFavorite)this.ajax.setVar("op","remove");if(!this.isFavorite)this.ajax.setVar("op","add");this.ajax.setVar("proc_class","nfm.core.entity.ajax."+this.proc);this.ajax.method="POST";this.ajax.onCompletion=this.ajaxresponse;this.ajax.controller=this;this.ajax.runAJAX();};this.clickhandler=function(evt){var thisObj=this;var event=(evt)?evt:window.event;if(event){var source=et_findEventSource(evt,true);thisObj=source.controller;}thisObj.sendToggle();};this.updateImage=function(){var link=document.getElementById(this.toggleLinkId);if(this.useIcons){var oldImg=et_findImage(link);var imagepath=this.removeIcon;if(!this.isFavorite){imagepath=this.addIcon;}var newImg=et_createImage(imagepath);link.removeChild(oldImg);link.appendChild(newImg);}else{var oldText=et_findText(link);if(!this.isFavorite){oldText.nodeValue=this.addIcon;}else{oldText.nodeValue=this.removeIcon;}}};this.initialize=function(){if(!document.getElementById(this.toggleLinkId)){var thisObj=this;window.setTimeout(function(){thisObj.initialize()},100);return;}et_setupLink(this.toggleLinkId,this,this.clickhandler);this.useIcons=this.addIcon.indexOf("/")!=-1&&this.removeIcon.indexOf("/")!=-1;};this.initialize();}