if(typeof pln=='undefined'){alert("nvi\nThis file required the PLN Javascript Library(pln.js)and it need to be loaded before this file.");}else{if(!pln.isset(nvi)){var nvi=new function(){var _defaultWaitingPanelId="nvi_modules_default_waiting_panel";var _defaultWaitingPanelPrefixId="default_waiting__";this.toString=function(){return "Nvi Core";};this.CreateModal=function(id,width,height,contentCollection,dragCollection,openCollection,closeCollection,maximizeCollection,minimizeCollection,scrollPane,disable,init){var modal=nvi.panelManager.createInstance(id,class_nvi_modal_panel,true);void modal.setDimension(width,height);void modal.pushContent(id);for(var i=0;i<contentCollection.length;i++)void modal.pushContent(contentCollection[i]);for(var i=0;i<dragCollection.length;i++)void modal.registerIdAsDragHandle(dragCollection[i]);for(var i=0;i<openCollection.length;i++)void modal.registerIdAsOpenButton(openCollection[i]);for(var i=0;i<closeCollection.length;i++)void modal.registerIdAsCloseButton(closeCollection[i]);for(var i=0;i<maximizeCollection.length;i++)void modal.registerIdAsMaximizeButton(maximizeCollection[i]);for(var i=0;i<minimizeCollection.length;i++)void modal.registerIdAsMinimizeButton(minimizeCollection[i]);if(pln.isString(scrollPane))void modal.registerIdAsScrollPane(scrollPane);if(disable)void modal.disableOverlayInteraction();if(init)void modal.initialize();};this.CreateIframe=function(id,url){var iframe=nvi.panelManager.createInstance(id,class_nvi_iframe_panel);void iframe.setUrl(url);};this.CreateToggle=function(id,viewCollection,triggerEvent,animateFunction,groupId,isDefault,enableCookie,enableCloseAllView,init){var toggle=nvi.panelManager.createInstance(id,class_toggle_control,true);for(var i=0;i<viewCollection.length;i++){var viewObject=pln.decode(viewCollection[i]);void toggle.assignView(viewObject.viewId,viewObject.enableAjaxUpdate,viewObject.updateAjaxUrl,viewObject.updateFrequency);}if(pln.isString(triggerEvent))void toggle.setTriggerEvent(triggerEvent);if(pln.isFunction(animateFunction))toggle.animate=animateFunction;if(pln.isString(groupId))void toggle.registerToGroup(groupId);if(isDefault)void toggle.setAsDefault();if(enableCookie)void toggle.enableCookieState(true);if(pln.isString(enableCloseAllView)){void class_toggle_control.enableCloseAllView(enableCloseAllView);}if(init)void toggle.initialize();};var NLM=new function(){var _messageCollection=[];var _console;var _list;var _consoleEnabled=false;var _mainConsole=window.location.href==top.location.href;if(/ENABLE-NVI-CONSOLE/gi.test(top.location.href)){_consoleEnabled=true;void pln.events.addListener(document,'__documentReady',null,initializeConsole);}var set=pln.node.setProperty;this.toString=function(){return "Nvi Log Manager";};function generateConsole(){_console=pln.node.add(pln.node.create('div'),document.body);var head=pln.node.add(pln.node.create('div'),_console);var btn=pln.node.add(pln.node.create('span'),head);var title=pln.node.add(pln.node.create('span'),head);void set(title,'innerHTML','<strong>NVI DEBUG CONSOLE</strong>~ Version 1.00');void set(btn,'innerHTML','[minimize]');void set(btn,'cursor','pointer');void set(btn,'marginRight','10px');_list=pln.node.add(pln.node.create('div'),_console);void set(_console,'display','none');void set(_console,'zIndex','999999');void set(_console,'position','absolute');void set(_console,'width','800px');void set(_console,'background','#444444');void set(_console,'color','#ffffff');void set(_console,'fontFamily','Verdana,Arial');void set(_console,'fontSize','10px');void set(_console,'right','2px');void set(_console,'top','2px');void set(_console,'border','2px solid #000000');void set(head,'padding','5px');void set(_list,'padding','5px');void set(_list,'overflow','auto');void set(_list,'height','600px');void pln.events.addListener(btn,'click',null,toggle,btn);};function toggle(eventObject,control){var display=pln.node.getProperty(_list,'display');var displaying=display=='none';void set(_list,'display',displaying?'block':'none');void set(control,'innerHTML',displaying?'[minimize]':'[maximize]');};function addMessageToConsole(message){var item=pln.node.add(pln.node.create('div'),_list);void set(item,'borderBottom','1px solid #000000');void set(item,'padding','5px 0px');void set(item,'innerHTML',message);};this.log=function(message,type,className,methodName){if(_consoleEnabled){try{var outputMessage='';if(pln.isString(type)){var typeColor="#000000";if(type=='Event')typeColor="#228B22";if(type=='Error')typeColor="#CC0000";if(type=='Core')typeColor="#000000";if(type=='Instanciation')typeColor="#0099CC";if(type=='Warning')typeColor="#FF6905";if(type=='Report')typeColor="#8B008B";outputMessage+="<span style='padding:2px 5px;margin-right:5px;background:"+typeColor+";'>["+type+"]</span>";}if(pln.isString(className))outputMessage+=className+" ";if(pln.isString(methodName))outputMessage+='.'+methodName+"()<br />";if(outputMessage.indexOf('<br />')!=-1)outputMessage+='&nbsp;&nbsp;&nbsp;->&nbsp;';outputMessage+=message;void _messageCollection.push("::"+outputMessage);var newMessage=_messageCollection[_messageCollection.length-1];_mainConsole?void addMessageToConsole(newMessage):void top.nvi.logManager.log(newMessage);}catch(error){return null;}}return null;};function initializeConsole(){if(_console)return;try{if(_mainConsole){void generateConsole();while(_messageCollection.length>0)void addMessageToConsole(_messageCollection.shift());void set(_console,'display','block');}else{while(_messageCollection.length>0)void top.nvi.logManager.log(_messageCollection.shift());}}catch(error){}};this.log('Nvi Log Manager initiated','Core');};var NSRM=new function(){var _ressources={};this.toString=function(){return "Nvi Shared Ressources Manager";};this.registerToGroup=function(groupId){var items=pln.argsToArray(arguments,1);var group=_ressources[groupId]||(_ressources[groupId]={});var i=0;while(items.length>0){group[i]=items.shift();i++;}};this.unregisterFromGroup=function(groupId){try{var items=pln.argsToArray(arguments,1);while(items.length>0){delete _ressources[groupId][items.shift()];}}catch(error){}};this.getRessources=function(groupId,exceptionObject){try{var collection=[];var group=_ressources[groupId];for(var i in group){var instance=NPM.getInstance(group[i]);var ressources=(instance)?instance.getSharedRessources():null;if(ressources){if((exceptionObject&&exceptionObject.id!=ressources.id)||!exceptionObject)void collection.push(ressources);}}return collection.length>0?collection:null;}catch(error){return null;}};this.getGroupByRessourceId=function(ressourceId){try{var collection=[];for(var i in _ressources){var group=_ressources[i];for(var j in group){if(group[j]==ressourceId){collection.push(i);break;}}}return collection;}catch(error){return null;}};void NLM.log('Nvi Shared Ressources Manager','Core');};var NEM=new function(){var _eventCollection={};var _host=this;var _events={__updating:'updating',__ready:'ready',__success:'success',__failed:'failed',__opened:'opened',__closed:'closed',__changed:'changed',__moved:'moved',__resized:'resized',__stopped:'stopped',__rating:'rating',__dateSelected:'date_selected',__validationFailed:'validation_fail',__validationSucceeded:'validation_succeeded',__triggered:'triggered',__beforeChanged:'before_changed',__pageInitialized:'page_initialized'};this.events=_events;this.dispatchEvent=function(identifier,eventName,eventObject){if(eventName==_events.__ready)void displayWaitingPanel(identifier,false);if(eventName==_events.__updating)void displayWaitingPanel(identifier,true);void pln.events.dispatchEvent(identifier,eventName,eventObject);void NLM.log('Dispatching '+eventName+' event for the '+identifier+' element','Event','Nvi Event Manager','dispatchEvent');};function displayWaitingPanel(id,display){try{var instance=NPM.getInstance(id);var customWaitingPanel=instance.getCustomWaitingPanel();if(!pln.isNull(customWaitingPanel)){void pln.node.setProperty(customWaitingPanel,'display',display?'block':'none');}else{var element=instance.getElement();var defaultPanelId=_defaultWaitingPanelPrefixId+id;var _get=pln.node.getProperty;var width=_get(element,'offsetWidth');var height=_get(element,'offsetHeight');var borderTop=_get(defaultPanelId,'border-top-width')||0;var borderRight=_get(defaultPanelId,'border-right-width')||0;var borderBottom=_get(defaultPanelId,'border-bottom-width')||0;var borderleft=_get(defaultPanelId,'border-left-width')||0;var paddingLeft=_get(defaultPanelId,'padding-left')||0;var paddingRight=_get(defaultPanelId,'padding-right')||0;var paddingBottom=_get(defaultPanelId,'padding-bottom')||0;var paddingTop=_get(defaultPanelId,'padding-top')||0;void pln.node.setProperty(defaultPanelId,'width',(width-borderRight-borderleft-paddingLeft-paddingRight)+'px');void pln.node.setProperty(defaultPanelId,'height',(height-borderTop-borderBottom-paddingTop-paddingBottom)+'px');}void pln.node.setProperty(defaultPanelId,'display',display?'block':'none');void NLM.log((display?'Displaying':'Hidding')+' the default waiting panel for the '+id+' panel','Event','Nvi Event Manager','displayWaitingPanel');}catch(error){}};this.addListener=function(identifier,eventName,scopeObject,eventHandler){var identifier=pln.events.sanitizeIdentifier(identifier);void pln.events.addListener.apply(null,pln.argsToArray(arguments));if(identifier!="all")void pln.events.addListener.apply(null,[identifier,eventName,null,ALLTrigger,eventName]);};this.removeListener=function(identifier,eventName,scopeObject,eventHandler){var identifier=pln.events.sanitizeIdentifier(identifier);void pln.events.removeListener(identifier,eventName,scopeObject,eventHandler);if(identifier!="all")void pln.events.removeListener(identifier,eventName,null,ALLTrigger);};function ALLTrigger(eventObject,eventName){void pln.events.dispatchEvent('all',eventName,eventObject);};void NLM.log('Nvi Event Manager initiated','Core');};var NACM=new function(){var _connectionCollection={};this.getConnection=function(id){try{if(!NPM.instanceExist(id)){void NLM.log('There is no panel instance with the selected id:'+id,'Error','Nvi Ajax Connection Manager','getConnection');}else{var href=window.location.href;var hash=window.location.hash;var url=href.replace(pln.isEmpty(hash)?'#':hash,'');var instance=NPM.getInstance(id);if(pln.isObject(instance)){try{var overwritingUrl=instance.getCustomUpdateViewUrl();if(pln.isString(overwritingUrl))url=overwritingUrl;}catch(error){}}var connectionUrl=url+(url.indexOf('?')!=-1?'&':'?')+"render_only="+id;var connectionObject=_connectionCollection[id]||(_connectionCollection[id]={inUsage:false,connection:null});if(!connectionObject.inUsage)connectionObject.connection=new pln.server.connection(connectionUrl,'POST');return connectionObject;}}catch(error){}};this.clearConnection=function(id){if(!NPM.instanceExist(id)){void NLM.log('There is no panel instance with the selected id:'+id,'Error','Nvi Ajax Connection Manager','clearConnection');}else{var connectionObject=_connectionCollection[id];if(pln.isObject(connectionObject)){void connectionObject.connection.abort();delete _connectionCollection[id];}}};void NLM.log('Nvi Ajax Connection Manager initiated','Core');};var NMIM=new function(){var _collection={};this.find=function(id){try{return pln.isset(_collection[id]);}catch(error){return false;}};this.findByParentId=function(parentId){var collection=[];try{for(var i in _collection){var item=_collection[i];if(item.parentId==parentId)void collection.push(item.id);}}catch(error){}return collection;};this.add=function(item){if(!pln.isObject(item))return;_collection[item.id]=item;};this.remove=function(item){if(!pln.isObject(item))return;delete _collection[item.id];};this.clear=function(){_collection={};};void NLM.log('Nvi Memory Id Manager','Core');};var NPM=new function(){var _instanceCollection={};var _strictMode=false;var _count=0;var _host=this;function copyDefaultWaitingPanel(id,injectInsideTarget){var injectInsideTarget=pln.isBoolean(injectInsideTarget)?injectInsideTarget:false;var newId=_defaultWaitingPanelPrefixId+id;if(pln.isHtmlElement(pln.node.getById(newId))){void NLM.log('There is already a default waiting panel for the '+id+' panel','Report','Nvi Panel Manager','copyDefaultWaitingPanel');}else{var target=pln.node.getById(_defaultWaitingPanelId);if(!pln.isHtmlElement(target)){void NLM.log('There is no default waiting panel rendered in the current html page','Warning','Nvi Panel Manager','copyDefaultWaitingPanel');}else{var clone=pln.node.clone(target);var panel=pln.node.getById(id);void pln.node.setProperty(clone,'id',newId);if(injectInsideTarget){return pln.node.add(clone,panel);}else{return pln.node.add(clone,pln.node.getParent(1,panel),panel,false);}}}return null;};this.copyDefaultWaitingPanel=copyDefaultWaitingPanel;function cleanupId(id){try{return id.replace(/\s+/gi,'');}catch(error){return null;}};this.getInstance=function(id){try{id=cleanupId(id);var instance=this.instanceExist(id)?_instanceCollection[id]:null;if(pln.isNull(instance)){return window.location.href!=parent.location.href?parent.nvi.panelManager.getInstance(id):null;}else{return instance;}}catch(error){return null;}};this.instanceExist=function(id){try{return pln.isObject(_instanceCollection[cleanupId(id)]);}catch(error){return null;}};this.deleteInstance=function(id){id=cleanupId(id);var instance=this.getInstance(id);try{void instance.deleteInstance();delete _instanceCollection[id];}catch(error){}};this.createInstance=function(id,Constructor,isVirtual){var id=cleanupId(id);var isVirtual=pln.isBoolean(isVirtual)?isVirtual:false;var constructorName=pln.getFunctionName(Constructor);if(this.instanceExist(id)){void NLM.log('There is already a panel instance with the selected id:'+id+' of type '+constructorName+'. Id must be unique!The first instance with the selected id will be returned','Warning','Nvi Panel Manager','createInstance');var instance=this.getInstance(id);try{if(instance.isContentRemovalEnabled()){if(constructorName=='class_nvi_tooltip_panel'||constructorName=='class_nvi_modal_panel'){void instance.removeAllContent(true);}}}catch(error){}if(!isVirtual)void copyDefaultWaitingPanel(instance.getId());return instance;}else{if(_strictMode&&!pln.isHtmlElement(pln.node.getById(id))&&!NMIM.find(id)){if(Constructor==class_nvi_tooltip_panel||Constructor==class_nvi_modal_panel){void NMIM.add({id:id,parentId:null});}else{void NLM.log('The html element linked to tho this class instance cannot be found in the current html document.(id='+id+').','Error','Nvi Panel Manager','createInstance');return;}}var instance=pln.compiler.createClass(Constructor,id);_count++;void NLM.log('Instanciation of '+id+'('+instance+')','Instanciation');if(!pln.isObject(instance)){void NLM.log('Unable to instanciate the '+id+' panel of type '+constructorName,'Error','Nvi Panel Manager','createInstance');return;}else{if(!isVirtual){var waiting=copyDefaultWaitingPanel(id);if(!pln.isHtmlElement(waiting)){void NLM.log('Unable to copy the default waiting panel for the '+id+' panel','Warning','Nvi Panel Manager','createInstance');}}return(_instanceCollection[id]=instance);}}};this.updateView=function(id,data){try{var instance=this.getInstance(id);if(!pln.isObject(instance)){void NLM.log('The instance is not a valid instance of a panel','Error','Nvi Panel Manager','updateView');return;}}catch(error){return;}var connectionObject=NACM.getConnection(id);if(connectionObject.inUsage)return;connectionObject.inUsage=true;connectionObject.connection.onLoad=function(success,serverData,message){connectionObject.inUsage=false;var response=null;try{response=_host.parseServerResponse(success,serverData,message,true);}catch(error){void NLM.log(error.message+",("+id+")",'Error','Nvi Panel Manager','updateView');}try{void pln.node.setProperty(id,'innerHTML',response.source);}catch(error){return;}void pln.node.setProperty(id,'display','');void NEM.dispatchEvent(id,NEM.events.__ready);var instance=_host.getInstance(id);void pln.dispatch(instance,instance.onUpdatedView,success,response.dataObject,message);void pln.evalScriptCollection(response.scripts);void NISM.runtimeActivation();};void NEM.dispatchEvent(id,NEM.events.__updating);void pln.node.setProperty(id,'display','none');var data=pln.isset(data)?data:null;var groups=NSRM.getGroupByRessourceId(id);var sharedData=[];while(groups.length>0){var ressources=NSRM.getRessources(groups.shift(),data);if(!pln.isNull(ressources))sharedData=sharedData.concat(ressources);}void connectionObject.connection.sendAndLoad(pln.encode({data:data,sharedData:(sharedData.length==0?null:sharedData)}));};this.parseServerResponse=function(success,serverData,message,removeFirstNode){var removeFirstNode=pln.isBoolean(removeFirstNode)?removeFirstNode:true;if(!success){throw new Error("Ajax connection failed,error message="+message);}if(!pln.isset(serverData)){throw new Error("The server returned no data or null");}else{var dataObject=null;try{dataObject=pln.decode(serverData);}catch(error){throw new Error("The data returned from the server is not a valid JSON encoded string.");}var html=dataObject.dataHtml;if(pln.isString(html)){html=html.replace(/\/\*(\s|.)*?\*\//gi,'').replace(/(^|\s+)\/\/.*/gi,'');html=html.replace(/<!--(\s|.)*?-->/gi,'');html=html.replace(/<link(\s|\w)*[^>]*>/gi,'');var extractedObject=pln.extractScriptFromSource(html,true);var source=extractedObject.source;var scripts=extractedObject.scripts;if(removeFirstNode){var startRegexp=/^\s*<(\w*)\b[^<]*>/;void source.match(startRegexp);var name=RegExp.$1;try{var endRegexp=new RegExp("<\\s?\/\\s?"+name+">\\s*$","i");if(!pln.isNull(source.match(endRegexp))){source=source.replace(startRegexp,'');source=source.replace(endRegexp,'');}}catch(error){}}return{source:source,scripts:scripts,dataObject:dataObject};}}};this.cancelUpdateView=function(instance){try{var id=instance.getId();}catch(error){void NLM.log('The instance is not a valid instance of a panel','Error','Nvi Panel Manager','cancelUpdateView');return;}void NACM.clearConnection(id);void pln.node.setProperty(id,'display','');void NEM.dispatchEvent(id,NEM.events.__ready);};this.getNumberOfInstances=function(){return _count;};void NLM.log('Nvi Panel Manager initiated','Core');};var NISM=new function(){var _collection={};function initialize(){void populateCollection();void manageEventsRegistration(true);};function populateCollection(){var collection=[];var inputCollection=pln.node.getByName('input');if(pln.isNull(inputCollection))inputCollection=[];for(var i=0;i<inputCollection.length;i++){var input=inputCollection[i];if(input.type.toLowerCase()=='image')void collection.push(input);}for(var i=0;i<document.images.length;i++)void collection.push(document.images[i]);for(var i=0;i<collection.length;i++){var item=collection[i];var name=item.className;if(!pln.isString(name)||pln.isNull(name.match(/\brollover\b/i)))continue;var src=item.src;var id=!pln.isEmpty(item.id)?item.id:'NISM_'+pln.getUniqueId();if(!pln.isObject(_collection[id])||_collection[id].id!=id){var buttonCollection=pln.node.getByName('button');if(pln.isNull(buttonCollection))buttonCollection=[];var button=null;for(var j=0;j<buttonCollection.length;j++){var buttonItem=buttonCollection[j];if(pln.node.isChildOf(item,buttonItem)){button=buttonItem;break;}}var extension=src.match(/\.\w{3,4}$/i);var path=src.replace(/\.\w{3,4}$/i,'');path=path.replace('_on','');item.id=id;_collection[id]={item:item,normal:src,over:path+'_on'+extension,className:name,id:id,active:false,button:button};var tempImg=new Image();tempImg.src=_collection[id].over;}}};function manageEventsRegistration(enable,id,remove){var id=pln.isString(id)&&!pln.isEmpty(id)?id:null;var remove=pln.isBoolean(remove)?remove:false;for(var i in _collection){var imgObject=_collection[i];if(!imgObject.item||!imgObject.normal||!imgObject.over||!pln.isBoolean(imgObject.active))continue;if(id!=null&&id==imgObject.id){void changeState(null,imgObject,'normal');if(remove)delete _collection[id];break;}if(!pln.isNull(imgObject.className.match(/\bactivate\b/i))){void changeState(null,imgObject,'over');continue;}if(!enable==imgObject.active){_collection[i].active=enable;void pln.events[enable?'addListener':'removeListener'](!pln.isNull(imgObject.button)?imgObject.button:imgObject.item,'mouseover',null,changeState,imgObject,'over');void pln.events[enable?'addListener':'removeListener'](!pln.isNull(imgObject.button)?imgObject.button:imgObject.item,'mouseout',null,changeState,imgObject,'normal');}}};function changeState(eventObject,imgObject,state){try{imgObject.item.src=imgObject[state];}catch(error){}};this.runtimeActivation=function(){void populateCollection();void manageEventsRegistration(true);};this.runtimeDeactivation=function(){void populateCollection();void manageEventsRegistration(false);};this.removeSpecific=function(id,remove){void manageEventsRegistration(false,id,remove);};void pln.events.addListener(document,'__documentReady',null,initialize);};this.logManager=NLM;this.eventManager=NEM;this.panelManager=NPM;this.sharedRessourcesManager=NSRM;this.memoryIdManager=NMIM;this.imageStateManager=NISM;this.getDefaultWaitingPanelPrefixId=function(){return _defaultWaitingPanelPrefixId;};}}}
