iKnowBase={Version:"@app.version@",locations:{ikbViewer:"/ikbViewer",resource:"/ressurs"},ensures:{facebox:{js:"/ressurs/iknowbase/libs/jquery-plugins/facebox/facebox.js",css:"/ressurs/iknowbase/libs/jquery-plugins/facebox/facebox.css"},ikbPopup:{js:["/ressurs/iknowbase/libs/jquery-plugins/ikbPopup/ikbPopup.js","/ressurs/iknowbase/libs/jquery-plugins/jquery.bgiframe.js"],css:"/ressurs/iknowbase/libs/jquery-plugins/ikbPopup/ikbPopup.css"},form:{js:"/ressurs/iknowbase/libs/jquery-plugins/jquery.form.js"}}};iKnowBase.errorPopup=function(A){jQuery("<div class='ikbErrorPopup' onclick='jQuery(this).slideUp();' />").hide().append(A).prependTo("body").slideDown();iKnowBase.log(A)};iKnowBase.log=function(A){if(window.console&&console.log){console.log(A)}else{if(window.opera&&opera.postError){opera.postError(A)}}};iKnowBase.nvl=function(A,B){if(A!=null){return A}else{return B}};iKnowBase.assert=function(A,B){if(!A){alert("iKnowBase.assert",B)}};iKnowBase.setCookie=function(B,D,A,F,C,E){document.cookie=B+"="+escape(D)+((A)?"; expires="+A.toGMTString():"")+((F)?"; path="+F:"")+((C)?"; domain="+C:"")+((E)?"; secure":"")};iKnowBase.getCookie=function(C){var B=document.cookie;var E=C+"=";var D=B.indexOf("; "+E);if(D==-1){D=B.indexOf(E);if(D!=0){return null}}else{D+=2}var A=document.cookie.indexOf(";",D);if(A==-1){A=B.length}return unescape(B.substring(D+E.length,A))};iKnowBase.deleteCookie=function(A,C,B){if(getCookie(A)){document.cookie=A+"="+((C)?"; path="+C:"")+((B)?"; domain="+B:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT"}};iKnowBase.toggleClassForClass=function(A,B){var C=document.getElementsByClassName(A);for(i=0;i<C.length;i++){this.toggleClassForElement("toggle",C[i],B)}};iKnowBase.toggleClassForElement=function(D,E,B,A){switch(D){case"toggle":return this.toggleClassForElement("check",E,B)?this.toggleClassForElement("remove",E,B):this.toggleClassForElement("add",E,B);case"swap":E.className=!this.toggleClassForElement("check",E,B)?E.className.replace(A,B):E.className.replace(B,A);break;case"add":if(!this.toggleClassForElement("check",E,B)){E.className+=E.className?" "+B:B}break;case"remove":var C=E.className.match(" "+B)?" "+B:B;E.className=E.className.replace(C,"");break;case"check":return new RegExp("\\b"+B+"\\b").test(E.className)}return E.className!=null?E.className:""};iKnowBase.ensure=function(A,B){jQuery.ensure(A,B)};iKnowBase.withFacebox=function(A){iKnowBase.ensure(iKnowBase.ensures.facebox,A)};iKnowBase.withIkbPopup=function(A){iKnowBase.ensure(iKnowBase.ensures.ikbPopup,A)};iKnowBase.withForm=function(A){iKnowBase.ensure(iKnowBase.ensures.form,A)};function ikbPopup(A,C,D){var B=(typeof A==="string"?A:A.href);window.open(B,C,D).focus();return false}function ikbGoTargetParams(C,D){var B=iKnowBase.locations.ikbViewer+"/go/target";var A=Array.prototype.slice.call(arguments);jQuery.each(A,function(E,F){B=B+"/"+(F||"")});iKnowBase.log("ikbGoTargetParams: url="+B);ikbGoTarget(B)}function ikbGoTarget(C,B){if(B&&(B.altKey||B.ctrlKey||B.shiftKey)){return true}var A=(typeof C==="string")?C:C.href;jQuery.ajax({url:A,data:"_ikbHeaderAccept=application/json",dataType:"json",error:function(F,E,D){iKnowBase.log("Error loading location info from "+A);window.location=A},success:function(D){if(D.data.windowFeatures!=null){iKnowBase.log("Link: "+D.data.url+" in "+D.data.windowName);window.open(D.data.url,D.data.windowName,D.data.windowFeatures)}else{iKnowBase.log("Link: "+D.data.url);window.location=D.data.url}}});return false}iKnowBaseDevelopment={Version:"@app.version@"};iKnowBaseDevelopment.showPortletCacheStatus=function(A,C){var D="ikb.showPortletCacheStatus."+A;var B=iKnowBase.getCookie(D);if(B==null){style="ikbPortletCacheUnknown";status="unknown status"}else{if(B==C){style="ikbPortletCacheCached";status="from cache"}else{style="ikbPortletCacheNotCached";status="not from cache"}}document.write("<div class='"+style+"'>");document.write("<!-- ");document.write("name="+D);document.write("; renderTime="+C);document.write("; cookieTime="+B);document.write(" -->");document.write("Cache");document.write(": delta="+(C-B));document.write("; "+status);document.writeln("</div>");iKnowBase.setCookie(D,C)};jQuery(function(){jQuery(".ikbComponentInformation .ikbHeader").bind("click",function(){jQuery(this).next().toggle()})});(function(A){A.ContentViewer={};function E(J,G,I){if(J){I=jQuery.extend({_rtarget:J,_ikbController:G,portlet:J},I||{})}var H=(J?location.href.match(/[^\?]*/)[0]:A.locations.ikbViewer+G);if(I!=null&&I!="undefined"){H=H+"?"+jQuery.param(I)}return H}function D(J,G,I){J=null;var H=E(J,G,I);A.log("Request: "+H);A.withIkbPopup(function(){jQuery.ikbPopup({post:H})});return false}function C(J,H){var G=jQuery("#"+J);var I=jQuery("<div class='ikbContentViewerLoading'></div>").prependTo(G);G.load(H,{ikbRender:J},function(L,K){if(K!="success"){I.remove();A.errorPopup("refreshComponent error: id="+J+"; status="+K)}});return false}function F(I,H,G){var J=jQuery("<form method='post'>");J.append("<input type='hidden' name='ikbAction' value='"+I+"' />");J.append("<input type='hidden' name='"+I+".operation' value='"+H+"' />");J.append("<input type='hidden' name='"+I+".arg' value='"+G+"' />");J.appendTo("body").submit();return false}function B(I,H,G){var J=jQuery("<form method='post'>");J.append("<input type='hidden' name='"+I+".operation' value='"+H+"' />");if(H=="startrow"||H=="sortinfo"){J.append("<input type='hidden' name='"+I+".arg' value='"+G+"' />")}else{if(H=="checkin"||H=="checkout"){J.append("<input type='hidden' name='"+I+".document_id' value='"+G+"' />")}}J.appendTo("body").submit();return false}jQuery.extend(A.ContentViewer,{getUrl:E,navigatePage:F,navigatePortal:B,reloadComponent:C,deleteDocument:function(H,G,I){return D(I,"/private/document/delete/request",{docid:H,version:(G||0)})},deleteDocumentConfirm:function(H,G,J,I){return D(I,"/private/document/delete/confirm",{docid:H,version:(G||0),mode:J})},changeDocumentType:function(G,H,I){return D(I,"/private/document/changeDocumentType/request",{docid:G,quickLinkGuid:H})},changeDocumentTypeConfirm:function(G,H,I){return D(I,"/private/document/changeDocumentType/confirm",{docid:G,formGuid:H})},copyDocument:function(G,H,I){return D(I,"/private/document/copy/request",{docid:G,quickLinkGuid:H})},copyDocumentConfirm:function(G,H,I){return D(I,"/private/document/copy/confirm",{docid:G,formGuid:H})},selectPersonalAcl:function(I,H,G){return D(I,"/private/personalAcl/popup",{cbFunction:H,cbClosure:G})},set_new_version:function(J,G,I){var H="/ikbViewer/pls/ikb_ce_custom_editor_portlet.switch_version?p_document_id="+encodeURIComponent(J)+"&p_site_id="+encodeURIComponent(I)+"&p_version_no="+encodeURIComponent(G);var K=jQuery.ajax({url:H,async:false}).responseText;if(K!="OK"){alert(K)}else{window.location.reload()}}})})(iKnowBase);iKnowBase.ContentViewer.EditOpenOfficeDocument=function(M,L,C,E,F){if(C==null){C=""}try{var B="";if(M=="INDIRECT"){var D=jQuery.ajax({type:"GET",async:false,url:encodeURI(L),beforeSend:function(N){N.setRequestHeader("x-iknowbase-getcontent-url",L)}});if(D.status!=200){iKnowBase.errorPopup("XMLHTTPError: "+D.status+"="+D.statusText+" (url="+L+")");return }L=D.getResponseHeader("x-iknowbase-content-url");B=D.getResponseHeader("x-iknowbase-content-filename")}var G=new ActiveXObject("com.sun.star.ServiceManager");var A=G.createInstance("com.sun.star.reflection.CoreReflection");var I=G.createInstance("com.sun.star.frame.Desktop");var K=new Array();var H=I.loadComponentFromURL(L,"_blank",0,K)}catch(J){iKnowBase.errorPopup("Error opening document. Error= "+J.name+"; description="+J.message)}};iKnowBase.ContentViewer.EditMSOfficeDocument=function(J,I,C,E,F){if(!window.ActiveXObject){iKnowBase.errorPopup("This function requires support for ActiveXObject (typically Microsoft Internet Explorer)");return }if(C==null){C=""}var D=null;var K=null;try{var A="";if(J=="INDIRECT"){var B=jQuery.ajax({type:"GET",async:false,url:encodeURI(I),beforeSend:function(L){L.setRequestHeader("x-iknowbase-getcontent-url",I)}});if(B.status!=200){iKnowBase.errorPopup("XMLHTTPError: "+B.status+"="+B.statusText+" (url="+I+")");return }I=B.getResponseHeader("x-iknowbase-content-url");A=B.getResponseHeader("x-iknowbase-content-filename")}if(window.ikbCustomEditWindowsDocument){var G=ikbCustomEditWindowsDocument("PREOPEN",null,I,C,A,F);if(!G){return }}D=new ActiveXObject("iKnowBase.RemoteDocument");K=D.OpenDocument("",I,C,E,A);if(K){if(window.ikbCustomEditWindowsDocument){var G=ikbCustomEditWindowsDocument("POSTOPEN-SUCCESS",K,I,C,A,F);if(!G){return }}}else{if(window.ikbCustomEditWindowsDocument){var G=ikbCustomEditWindowsDocument("POSTOPEN-FAILURE",K,I,C,A,F);if(!G){return }}window.open(I,"_blank")}D=null;K=null}catch(H){iKnowBase.errorPopup("Error opening document. Error= "+H.name+"; description="+H.message);D=null;K=null}};function openOODoc(D,B,E,A,C){iKnowBase.ContentViewer.EditOpenOfficeDocument(D,B,E,A,C)}function ikbEditWindowsDocument(D,B,E,A,C){iKnowBase.ContentViewer.EditMSOfficeDocument(D,B,E,A,C)}function ikbOfficeSetProperty(D,A,B){try{D.CustomDocumentProperties(A).Value=B}catch(C){D.CustomDocumentProperties.Add(A,false,4,B)}}(function(A){var E;function D(F,H){var G=(A.locations.ikbViewer+F);if(H!==E){G=(G.match(/\?/)?"&":"?")+jQuery.param(H)}return G}function C(F){return jQuery("<div class='ikbContentViewerLoading'></div>").prependTo(F)}function B(G,F){if(typeof G==="string"){G=jQuery("#"+G)}F=jQuery.extend({ikbRender:G.attr("id")},F);var H=C(G);G.load(location.href,F,function(J,I){if(I!="success"){H.remove();A.errorPopup("reloadComponent error: id="+G.attr("id")+"; status="+I)}});return false}A.PageEngine={showLoading:C,reloadComponent:B}})(iKnowBase)
