var WJGuiSettings=Object.extend({windowBaseTitle:"Windmill CMS"},WJGuiSettings||{});var WJWindow=Class.create({DEFAULT_PARENT:document.body,initialize:function(callback,parent,translate){this._loading=false;this._basetitle=this._title="";this._theme="default";this._parent=parent||WJWindow.DEFAULT_PARENT||document.body;this._listeners=new Hash();this.translate=translate||this.translate;this._createWindow();this._addDefaultListeners();this._addCloseButton();this.setCallback(callback);this.setBaseTitle(WJGuiSettings.windowBaseTitle);},_createWindow:function(){var classname=this._getBaseClassname();this._windowElement=new Element("div");this._windowElement.addClassName(classname);this._windowElement.setStyle({"display":"none"});this._createWindowRows(["title","main","buttons","bottom"],classname);this._windowElementId=this._windowElement.identify();this._parent.insert(this._windowElement);this._absolutizeTopLeft();this.hide();this._outerElement=this._windowElement;this.setTheme();},insertWindowRowBefore:function(rowname,newrowname){if(rowname==="title"){return;}
var classname=this._getBaseClassname();var row=this._windowElement.select("."+classname+"_"+rowname)
row=row.first();var newrowhtml=this._createRow(newrowname,classname," "+classname+"_body");var div=new Element("div");div.update(newrowhtml);var toprow=row.parentNode;var newrow=toprow.insertBefore(div.firstChild,row);newrow=Element.extend(newrow);newrow=newrow.select("."+classname+"_content");this._contentElements[newrowname]=newrow.first();return newrow;},replaceWindowRow:function(oldrow,newrow){var inserted=this.insertWindowRowBefore(oldrow,newrow);var toremove=this.getContentElement(oldrow);this._contentElements[oldrow]=this._contentElements[newrow];return toremove.remove();},removeWindowRow:function(oldrow){var toremove=this.getContentElement(oldrow);delete(this._contentElements[oldrow]);return toremove.remove();},_addCloseButton:function(){var title=this.getContentElement("title");var titlediv=new Element("div",{"onclick":"this.parentNode.getWJWindowObject().fireClose(this)","title":this.translate("CLOSE_WINDOW")});titlediv.addClassName(this._getBaseClassname()+"_closebutton");title.insert(titlediv);},fireClose:function(element){element=$(element);var func=function(){this.destroy();Event.stopObserving(document,"wjgui:close",arguments.callee.observerFunction);}
var bound=func.bindAsEventListener(this);func.observerFunction=bound;Event.observe(document,"wjgui:close",bound);element.fire("wjgui:close");Event.stopObserving.defer(document,"wjgui:close",bound);},_addDefaultListeners:function(element){this.addListener("true",this.windowResult.bindAsEventListener(this,true));this.addListener("false",this.windowResult.bindAsEventListener(this,false));this.addListener("close",this.windowResult.bindAsEventListener(this,false));this.addListener("save",this.windowResult.bindAsEventListener(this));this.addListener("delete",this.windowResult.bindAsEventListener(this));this.addListener("cancel",this.windowResult.bindAsEventListener(this));this._addDefaultKeyListener();},_addDefaultKeyListener:function(){var element=element||this._windowElement;Event.observe(element,"keydown",this.keyHandle.bindAsEventListener(this));},keyHandle:function(event){var element=event.element();if(Object.isElement(element.up(".wjgui_window"))){switch(event.keyCode){case Event.KEY_RETURN:if(this.isVisible()){element.fire("wjgui:true");}
break;case Event.KEY_ESC:if(this.isVisible()){element.fire("wjgui:close");}
break;default:return;}}},addListener:function(eventName,callback,element){WJDebugger.log(WJDebugger.INFO,"Adding listener in WJWindow",eventName,callback);var callback=callback||this.windowResult.bindAsEventListener(this);var element=element||this._windowElement;Event.observe(element,"wjgui:"+eventName,callback);this._setListener(eventName,{"element":element,"callback":callback});return this;},_setListener:function(key,elementAndCallback){this._listeners.set(key,elementAndCallback);},removeListener:function(key){var listener=this.getListener(key);Event.stopObserving(listener.element,"wjgui:"+key,listener.callback);this._listeners.unset(key);return this;},removeListeners:function(){this._listeners.each(function(info){this.removeListener(info.key);}.bind(this));return this;},windowResult:function(event){this._callback.apply(this,arguments);},getListeners:function(){return this._listeners;},getListener:function(key){return this._listeners.get(key);},_getBaseClassname:function(){return"wjgui_window";},_getWindowRowTemplate:function(){return new Template("<div class='#{classprefix}_#{rowname} #{classprefix}_row#{body}'><div class='#{classprefix}_left #{classprefix}_column'><div class='#{classprefix}_right #{classprefix}_column'><div class='#{classprefix}_center #{classprefix}_column'><div class='#{classprefix}_content'>&#160;</div></div></div></div></div>");},_createWindowRows:function(rows,classprefix,windowElement){var windowElement=windowElement||this._windowElement;rows.each(function(windowElement,classprefix,rowname,index){var body=" "+classprefix+"_body";if(index==0||index==(rows.length-1)){body="";}
windowElement.innerHTML+=this._createRow(rowname,classprefix,body);}.bind(this,windowElement,classprefix));this._saveRows(rows,classprefix,windowElement);this._addWindowObjectGetters();},_addWindowObjectGetters:function(){var test=[$H(this._contentElements).values(),this._windowElement].flatten();test.each(function(el){el.getWJWindowObject=function(){return this;}.bind(this);},this);return test;},_saveRows:function(rows,classprefix,windowElement){var windowElement=windowElement||this._windowElement;this._contentElements={};rows.each(function(windowElements,rowname,index){this._contentElements[rowname]=windowElements[index];}.bind(this,windowElement.select("."+classprefix+"_content")));return this;},_createRow:function(rowname,classprefix,body){var row=this._getWindowRowTemplate();return row.evaluate({"rowname":rowname,"classprefix":classprefix,"body":body});},getContentElement:function(rowname){return this._contentElements[rowname];},evalContentElement:function(rowname){var element=this.getContentElement(rowname);element.innerHTML.evalScripts();return this;},_absolutizeTopLeft:function(element){var element=element||this._windowElement;element.absolutize();element.setStyle({height:"",width:""});this.setX(0,element);this.setY(0,element);},_checkMaxHeight:function(element){var element=element||this.getContentElement("main");if(this.getY()+this.getHeight()>document.viewport.getHeight()){this.setHeight(document.viewport.getHeight()-this.getY(),element,false);}
else{element.setStyle({"maxHeight":""});}},show:function(element){var element=element||this._outerElement||this._windowElement;element.style.display="block";try{element.focus()}catch(e){}
return this;},hide:function(element){var element=element||this._outerElement||this._windowElement;element.style.display="none";return this;},destroy:function(element){var element=element||this._outerElement||this._windowElement;if(element.parentNode){element.remove();}
return this;},_callback:function(){if(Object.isFunction(this._callbackFunction)){var args=$A(arguments);args.unshift(this);return this._callbackFunction.apply(this._callbackFunction,args);}},_close:function(event){this.hide();},setBaseTitle:function(title){this._basetitle=title;this.setTitle(this.getTitle());return this;},setTitle:function(title){this._title=title;var headers=this.getContentElement("title").getElementsByTagName("h1");if(headers.length<1){this.getContentElement("title").innerHTML="<h1>&#160;</h1>"+this.getContentElement("title").innerHTML;return this.setTitle(this._title);}
headers[0].innerHTML=this._getComposedTitle();return this;},_getComposedTitle:function(){return this._title+((this._basetitle!=""&&this._basetitle!=this._title)?((this._title!="")?" - ":"")+this._basetitle:"");},setContent:function(content){if(Object.isString(content)){this.getContentElement("main").innerHTML=content;}
if(Object.isElement(content)){this.getContentElement("main").appendChild(content);}
this._content=content;return this;},addButton:function(caption,eventHandler,defaultButton){WJDebugger.log(WJDebugger.INFO,"Adding button to window",caption,eventHandler,this);var button=WJButton.create(caption,eventHandler,defaultButton,this.getContentElement("buttons"));this._checkMaxHeight();return button;},addStatusbar:function(){WJDebugger.log(WJDebugger.INFO,"Adding statusbar to window",this);this._statusbar=new Element("div");this._statusbar.addClassName("wjgui_statusbar");this.getContentElement("buttons").insert(this._statusbar);this._checkMaxHeight();},setStatusbar:function(content,fade){var fade=fade||-1;if(this._statusbar){this._statusbar.update(content);if(fade>0){this.hideStatusbar.bind(this).delay(fade);}}},hideStatusbar:function(){Effect.Fade(this._statusbar,{duration:3.0});this.clearAndShowStatusbar.bind(this).delay(3.5);},clearAndShowStatusbar:function(){this._statusbar.update("");this._statusbar.show();},setCallback:function(callback){if(Object.isFunction(callback)){this._callbackFunction=callback;}
return this;},setX:function(x,element){this._x=x||0;var element=element||this._windowElement;element.style.left=x+"px";return this;},setY:function(y,element){this._y=y||0;var element=element||this._windowElement;element.style.top=y+"px";this._checkMaxHeight(element);return this;},setZ:function(z,element){this._z=z||10000;var element=element||this._windowElement;element.style.zIndex=z;return this;},setWidth:function(width,element){this._width=width;var element=element||this._windowElement;element.setStyle({"width":width+"px"});element.fire("wjgui:resize");return this;},setHeight:function(height,element,checkHeight){this._height=height;var element=element||this.getContentElement("main");var wasVisible=this.isVisible();var origX=this.getX();var origY=this.getY();if(!wasVisible){this.setX(-10000);this.setY(-10000);this.show();}
var otherRowsHeight=0;for(var key in this._contentElements){if(key!="main"){otherRowsHeight+=this._contentElements[key].getHeight();}}
var height=(Object.isNumber(height)==false)?height:(height-otherRowsHeight)+"px";element.setStyle({"height":height});if(!wasVisible){this.hide();this.setX(origX);this.setY(origY);}
if(checkHeight!=false){this._checkMaxHeight(element);}
if(!checkHeight){element.fire("wjgui:resize");}
return this;},getBaseTitle:function(){return this._basetitle;},getTitle:function(){return this._title;},getType:function(){return this._type;},getContent:function(){return this._content;},getContenttype:function(){},getCallback:function(){return this._callbackFunction;},isVisible:function(){var xInLow=(this.getX()<0&&(this.getX()+this.getWidth())>0);var xInHigh=(this.getX()>=0&&this.getX()<document.viewport.getWidth());var yInLow=(this.getY()<0&&(this.getY()+this.getHeight())>0);var yInHigh=(this.getY()>=0&&this.getY()<document.viewport.getHeight());if((xInLow||xInHigh)&&(yInLow||yInHigh)&&this._windowElement.visible()){return true;}
return false;},getX:function(element){var element=element||this._windowElement;return parseInt(element.style.left);},getY:function(element){var element=element||this._windowElement;return parseInt(element.style.top);},getZ:function(){var element=element||this._windowElement;return element.style.zIndex;},getWidth:function(element){var element=element||this._windowElement;return element.getWidth();},getHeight:function(element){var element=element||this._windowElement;return element.getHeight();},getContentHeight:function(){return this.getContentElement("main").getHeight();},getContentWidth:function(){return this.getContentElement("main").getWidth();},getWindowElement:function(){return this._windowElement;},center:function(element){var element=element||this._windowElement;var remainsX=document.viewport.getWidth()-this.getWidth(element);var remainsY=document.viewport.getHeight()-this.getHeight(element);this.setX(remainsX/2,element).setY(remainsY/2,element);return this;},keepCentered:function(element){if(!this._centerObserver){var element=element||this._windowElement;this._centerObserver=this.center.bind(this,element);Event.observe(window,"resize",this._centerObserver);}},stopCentered:function(){Event.stopObserving(window,"resize",this._centerObserver);this._centerObserver=null;},maximize:function(paddingTop,paddingRight,paddingBottom,paddingLeft,noScroll){var paddingTop=paddingTop||0;var paddingRight=paddingRight||paddingTop;var paddingBottom=paddingBottom||paddingTop;var paddingLeft=paddingLeft||paddingTop;var noScroll=noScroll||false;this.setX(paddingLeft).setY(paddingTop);if(noScroll){this.setWidth(0).setHeight(0);}
this.setWidth(document.viewport.getWidth()-(paddingLeft+paddingRight)).setHeight(document.viewport.getHeight()-(paddingTop+paddingBottom));return this;},keepMaximized:function(){if(!this._maximizedObserver){var paddingTop=this.getY();var paddingLeft=this.getX();var paddingRight=document.viewport.getWidth()-this.getWidth()-paddingLeft;var paddingBottom=document.viewport.getHeight()-this.getHeight()-paddingTop;this._maximizedObserver=this.maximize.bind(this,paddingTop,paddingRight,paddingBottom,paddingLeft,true);Event.observe(window,"resize",this._maximizedObserver);}},stopMaximized:function(){Event.stopObserving(window,"resize",this._maximizedObserver);this._maximizedObserver=null;},setLoading:function(loading,loadCallback){var loadCallback=loadCallback||false;if(loading&&!this.getLoading()){this.getWindowElement().addClassName("wjgui_window_loading");if(!loadCallback){this.getContentElement("main").setStyle({"visibility":"hidden"});}
else{loadCallback(this,loading);}}
else if(!loading&&this.getLoading()){this.getWindowElement().removeClassName("wjgui_window_loading");if(!loadCallback){this.getContentElement("main").setStyle({"visibility":"visible"});}
else{loadCallback(this,loading);}}
this._loading=loading;return this;},getLoading:function(){return this._loading;},setTheme:function(theme){if(theme==this.getTheme()){return;}
this._removeOldTheme();this._setTheme(theme);this._addNewTheme();},_setTheme:function(theme){this._theme=theme||"default";},_removeOldTheme:function(){this.getWindowElement().removeClassName(this._getBaseClassname()+"theme_"+this.getTheme());},_addNewTheme:function(){this.getWindowElement().addClassName(this._getBaseClassname()+"theme_"+this.getTheme());},getTheme:function(){return this._theme;},translate:function(key){if(this._translations[key]){return this._translations[key];}
return key.charAt(0).toUpperCase()+key.replace("_"," ").substr(1).toLowerCase();},_translations:{OK:"Ok",CANCEL:"Annuleren",YES:"Ja",NO:"Nee",CLOSE_WINDOW:"Venster sluiten"}});WJWindow._messagedialog=function(type,message,callback,show,translate,allowHTML){var win=new WJWindow(callback,null,translate);var mwin=new window[type](win);mwin.setMessage(message,allowHTML);if(show){mwin.show();}
return mwin;};WJWindow.alert=function(message,callback,translate,allowHTML){return WJWindow._messagedialog("WJWindowAlert",message,callback,true,translate,allowHTML);};WJWindow.notice=function(message,callback,translate,allowHTML){return WJWindow._messagedialog("WJWindowNotice",message,callback,true,translate,allowHTML);};WJWindow.confirm=function(message,callback,translate,allowHTML){return WJWindow._messagedialog("WJWindowConfirm",message,callback,true,translate,allowHTML);};WJWindow.booleanConfirm=function(message,callback,translate,allowHTML){return WJWindow._messagedialog("WJWindowBooleanConfirm",message,callback,true,translate,allowHTML);};WJWindow.prompt=function(message,callback,translate,allowHTML){return WJWindow._messagedialog("WJWindowPrompt",message,callback,true,translate,allowHTML);};var WJWindowGooglemaps=Class.create({initialize:function(toDecorate,kmlname,sitename){this._decorate(toDecorate);this._addClassNames(kmlname,sitename);if(typeof(kmlname)!="undefined"){this.setTheme(kmlname);}
this._addPushpinWindowConnector();this._saveStyleSettings();},_addPushpinWindowConnector:function(){this._pushpinwindowconnector=new Element("div",{"style":"position: absolute;"});this._pushpinwindowconnector.addClassName("pushpinwindowconnector");this.getWindowElement().insert(new Element("div",{"style":"position: relative; overflow: visible; height: 0px; width: 0px;"}).insert(this._pushpinwindowconnector));},getPushpinWindowConnectorElement:function(){return this._pushpinwindowconnector;},_saveStyleSettings:function(){var wasVisible=this.isVisible();var origX=this.getX();var origY=this.getY();if(!wasVisible){this.setX(-10000);this.setY(-10000);this.show();}
this._stylesettings=new Hash();var top=(this._pushpinwindowconnector.getStyle("top")!=null)?parseInt(this._pushpinwindowconnector.getStyle("top")):0;this._stylesettings.set("pushpinwindowconnector-top",top);this._stylesettings.set("pushpinwindowconnector-left",parseInt(this._pushpinwindowconnector.getStyle("left")));this._stylesettings.set("pushpinwindowconnector-height",this._pushpinwindowconnector.getHeight());if(!wasVisible){this.hide();this.setX(origX);this.setY(origY);}},getStyleSetting:function(setting){return this._stylesettings.get(setting);},_addClassNames:function(kmlname,sitename){var classname=this._getBaseClassname()+"_googlemaps";var element=this.getWindowElement()
element.addClassName(classname);if(typeof(sitename)!="undefined"){element.addClassName(classname+"_"+sitename);}},_decorate:function(toDecorate){this._decorated=toDecorate;for(property in this._decorated){if(!Object.isFunction(this[property])){this[property]=this._decorated[property];}}},fireClose:function(element){this.hide();},getFullHeight:function(){return this.getHeight()+(this._stylesettings.get("pushpinwindowconnector-height")+this._stylesettings.get("pushpinwindowconnector-top"));}});var WJComponent=Class.create({initialize:function(id){this.id=id;this.value=null;this.componentType="WJComponent";this.components=new Array();this.label=null;this.group=false;},setHtmlelement:function(element){this.htmlelement=element;},observe:function(event,callback){if(Object.isArray(this.htmlelement)){this.htmlelement.each(function(s){s.observe(event,callback);});}
else if(this.htmlelement){this.htmlelement.observe(event,callback);}},addComponent:function(comp){WJDebugger.log(WJDebugger.DEBUG,"Adding component to "+this.componentType+" "+this.id,comp);this.components.push(comp);},getComponents:function(){return this.components;},valueChanged:function(){var oldValue=this.value;this.getValue();var changed=(oldValue==null&&this.value==null)?false:(oldValue!=this.getValue());this.value=oldValue;return changed;},getValue:function(nochange){var usesDijit=(typeof(dijit)!="undefined")?true:false;var nochange=nochange||false;var oldvalue=this.value;if(this.htmlelement&&usesDijit&&dijit.byId(this.htmlelement.id)&&dijit.byId(this.htmlelement.id).getValue){this.value=dijit.byId(this.htmlelement.id).attr("value");}
else if(this.htmlelement&&(this.htmlelement.value!=null)){this.value=this.htmlelement.value;}
if(nochange){var newval=this.value;this.value=oldvalue;return newval;}
else{return this.value;}},setValue:function(value){var usesDijit=(typeof(dijit)!="undefined")?true:false;this.value=value;if(this.htmlelement&&usesDijit&&dijit.byId(this.htmlelement.id)&&dijit.byId(this.htmlelement.id).setValue){dijit.byId(this.htmlelement.id).setValue(this.value);}
else if(this.htmlelement&&this.htmlelement.value){this.htmlelement.value=this.value;}},getId:function(){return this.id;},toString:function(){if(this.componentType===null){return"Uninitialized WJComponent";}
return this.componentType+" instance '"+this.id+"'";}});var WJRestrictedInput=Class.create(WJComponent,{initialize:function($super,id){$super(id);this.componentType="WJRestrictedInput";}});var WJSinglevalueInput=Class.create(WJRestrictedInput,{initialize:function($super,id){$super(id);this.componentType="WJSinglevalueInput";}});var WJMultivalueInput=Class.create(WJRestrictedInput,{initialize:function($super,id){$super(id);this.componentType="WJMultivalueInput";}});WJGroup=Class.create(WJComponent,{initialize:function($super,id){$super(id);this.componentType="WJGroup";this.region="center";this.group=true;},setRegion:function(region){this.region=region;}});var WJText=Class.create(WJComponent,{initialize:function($super,id){$super(id);this.componentType="WJText";}});WJLabel=Class.create(WJComponent,{initialize:function($super,id,text,image){$super(id);this.componentType="WJLabel",this.text=text;this.image=image;}});var WJTab=Class.create(WJComponent,{initialize:function($super,id){$super(id);this.componentType="WJTab";},setTitle:function(title){if(this.htmlelement&&this.htmlelement["class"]=="dijitContentPane"){this.htmlelement.controlButton.containerNode.innerHTML=title;}}});var WJFile=Class.create(WJComponent,{initialize:function($super,id){$super(id);this.componentType="WJFile";}});var WJImage=Class.create(WJFile,{initialize:function($super,id){$super(id);this.componentType="WJImage";this.changed=false;},valueChanged:function(){return this.changed;},selectImage:function(image,path,section){this.changed=true;this.setValue("/var/mediamanager/images/"+path+"/"+image);this.showThumbnail();},showThumbnail:function(){if($(this.htmlelement.id+"_thumbnail")){var src=$(this.htmlelement.id+"_thumbnail").src;var basepath=src.match(/(\/images\/thumbs(\/__[^\/]*)*)\/?/);if(basepath){$(this.htmlelement.id+"_thumbnail").src=basepath[1]+this.value;}
else{$(this.htmlelement.id+"_thumbnail").src="/images/thumbs/__lw50h50"+this.value;}
if($(this.htmlelement.id+"_thumbnail").up(".aeroplane_nothumb")){$(this.htmlelement.id+"_thumbnail").up(".aeroplane_nothumb").removeClassName("aeroplane_nothumb");}}},setValue:function(val){this.value=val;if(this.htmlelement.type=="hidden"){this.htmlelement.value=this.value;}},getValue:function(){if(this.htmlelement){if(this.htmlelement.type=="file"){try{var body=this.htmlelement.up().previous("iframe").contentWindow.document.body;if(!body){return this.value;}
if(body.textContent){var obj=body.textContent.evalJSON(true);}
else{var obj=body.innerHTML.stripTags().replace(/\r\n/g,"").evalJSON(true);}
if(obj.newname){this.value=obj.newname;}
else if(obj[0]&&obj[0].newname){this.value="/var/mediamanager/images/"+document.forms[this.id+"_form"]["path"].value+"/"+obj[0].newname;}}
catch(e){if(e.name!="SyntaxError"){throw e;}}}
else if(this.htmlelement.type=="hidden"){this.value=this.htmlelement.value;}}
return this.value;},uploadSingleFile:function(event){if(this.htmlelement.up().previous("iframe")){this._loadObserver=this.handleResponse.bindAsEventListener(this);this.htmlelement.up().previous("iframe").observe("load",this._loadObserver);}
document.forms[this.id+"_form"].submit();},handleResponse:function(event){this.changed=true;this.htmlelement.up().previous("iframe").stopObserving("load",this._loadObserver);var img=this.htmlelement.previous("img");if(!img){var img=new Image();$(img);this.htmlelement.up().insertBefore(img,this.htmlelement);this.htmlelement.up().insertBefore(new Element("br"),this.htmlelement);}
img.src="/images/thumbs/__lw50h50"+this.getValue();img.show();try{this.htmlelement.value="";}
catch(e){}},clearImage:function(event){this.setValue("");this.changed=true;this.showThumbnail();},_activateSelectOptions:function(){if($("clear_"+this.htmlelement.id)){$("clear_"+this.htmlelement.id).observe("click",this.clearImage.bind(this));}
if($("upload_"+this.htmlelement.id)){$("upload_"+this.htmlelement.id).observe("change",this.directUpload.bind(this));}
if($("downloadbutton_"+this.htmlelement.id)){$("downloadbutton_"+this.htmlelement.id).observe("click",this.directDownload.bind(this));}
if(dijit.byId("mediamanager_"+this.htmlelement.id)){dijit.byId("mediamanager_"+this.htmlelement.id).setObserver(function(){aeroplane.openApplication("Mediamanager",this.selectImage.bind(this),{section:WJMediamanagerInterface.IMAGES,path:"."});}.bind(this));}},directDownload:function(){var fileurl=$("download_"+this.htmlelement.id).value;if(fileurl==""){WJWindow.alert("Please supply an URL to download the image from.",function(){},aeroplane.translateGui);}
else{var url=new WJUrl({},"/index.php");url.setCt("wmdynamic");url.addParameter("module","Wmmediamanager");url.addParameter("type","json");url.addParameter("uploadsection","2100");var spin=new WJSpin();spin.update(url,"Wmmediamanager","directdownload",{fileurl:fileurl},[this.directDownloadResponse.bind(this)]);}},directDownloadResponse:function(response){this.setValue(response[0]);this.changed=true;this.showThumbnail();$("frame_"+this.htmlelement.id).stopObserving("load",this._loadObserver);},directUploadResponse:function(){var iframedoc=($("frame_"+this.htmlelement.id).contentDocument||$("frame_"+this.htmlelement.id).contentWindow.document);if(iframedoc.body.textContent){var data=iframedoc.body.textContent.evalJSON(true);}
else{var data=iframedoc.body.innerHTML.stripTags().replace(/\r\n/g,"").evalJSON(true);}
this.setValue(data[0]);this.changed=true;this.showThumbnail();},directUpload:function(){if($("frame_"+this.htmlelement.id)){this._loadObserver=this.directUploadResponse.bindAsEventListener(this);$("frame_"+this.htmlelement.id).observe("load",this._loadObserver);$("upload_"+this.htmlelement.id).up("form").submit();}},setHtmlelement:function($super,elem){if(dijit.byId("mediamanager_"+elem.id)){$super(elem);this._activateSelectOptions();}
else if(elem.type=="file"){$super(elem);this.htmlelement.observe("change",this.uploadSingleFile.bindAsEventListener(this));}
else{this.setHtmlelement.bind(this,elem).delay(0.1);}}});var WJButtonComponent=Class.create(WJComponent,{initialize:function($super,id){$super(id);this.componentType="WJButtonComponent";},disable:function(){if(dijit.byId(this.htmlelement.id)){dijit.byId(this.htmlelement.id).button.disable();}
else{this.disable.bind(this).delay(0.25);}},enable:function(){if(dijit.byId(this.htmlelement.id)){dijit.byId(this.htmlelement.id).button.enable();}
else{this.disable.bind(this).delay(0.25);}}});var WJFlashVideo=Class.create(WJFile,{initialize:function($super,id){$super(id);this.componentType="WJFlashVideo";this.changed=false;},valueChanged:function(){return this.changed;},selectVideo:function(video,path,section){this.changed=true;this.setValue("/var/mediamanager/videos/"+path+"/"+video);this.showThumbnail();},showThumbnail:function(){if($(this.htmlelement.id+"_thumbnail")||$(this.htmlelement.id.replace(/(.*)-.*/,"$1")+"_thumbnail")){var thumb=$(this.htmlelement.id+"_thumbnail")||$(this.htmlelement.id.replace(/(.*)-.*/,"$1")+"_thumbnail");var src=thumb.src;var basepath=src.match(/(\/images\/thumbs(\/__[^\/]*)*)\/?/);if(basepath){thumb.src=basepath[1]+this.value+".png";}
else{thumb.src="/images/thumbs/__lw50h50"+this.value+".png";}
if(thumb.up(".aeroplane_nothumb")){thumb.up(".aeroplane_nothumb").removeClassName("aeroplane_nothumb");}}},setValue:function(val){this.value=val;if(this.htmlelement.type=="hidden"){this.htmlelement.value=this.value;}},getValue:function(){if(this.htmlelement){if(this.htmlelement.type=="file"){try{var body=this.htmlelement.up().previous("iframe").contentWindow.document.body;if(!body){return this.value;}
if(body.textContent){var obj=body.textContent.evalJSON(true);}
else{var obj=body.innerHTML.stripTags().replace(/\r\n/g,"").evalJSON(true);}
if(obj.newname){this.value=obj.newname;}
else if(obj[0]&&obj[0].newname){this.value="/var/mediamanager/videos/"+document.forms[this.id+"_form"]["path"].value+"/"+obj[0].newname;}}
catch(e){if(e.name!="SyntaxError"){throw e;}}}
else if(this.htmlelement.type=="hidden"){this.value=this.htmlelement.value;}}
return this.value;},uploadSingleFile:function(event){if(this.htmlelement.up().previous("iframe")){this._loadObserver=this.handleResponse.bindAsEventListener(this);this.htmlelement.up().previous("iframe").observe("load",this._loadObserver);}
document.forms[this.id+"_form"].submit();},handleResponse:function(event){this.changed=true;this.htmlelement.up().previous("iframe").stopObserving("load",this._loadObserver);var img=this.htmlelement.previous("img");if(!img){var img=new Video();$(img);this.htmlelement.up().insertBefore(img,this.htmlelement);this.htmlelement.up().insertBefore(new Element("br"),this.htmlelement);}
img.src="/images/thumbs/__lw50h50"+this.getValue();img.show();try{this.htmlelement.value="";}
catch(e){}},clearVideo:function(event){this.setValue("");this.changed=true;this.showThumbnail();},_activateSelectOptions:function(){if($("clear_"+this.htmlelement.id)){$("clear_"+this.htmlelement.id).observe("click",this.clearVideo.bind(this));}
if($("upload_"+this.htmlelement.id)){$("upload_"+this.htmlelement.id).observe("change",this.directUpload.bind(this));}
if($("downloadbutton_"+this.htmlelement.id)){$("downloadbutton_"+this.htmlelement.id).observe("click",this.directDownload.bind(this));}
if(dijit.byId("mediamanager_"+this.htmlelement.id)){dijit.byId("mediamanager_"+this.htmlelement.id).setObserver(function(){aeroplane.openApplication("Mediamanager",this.selectVideo.bind(this),{section:WJMediamanagerInterface.VIDEOS,path:"."});}.bind(this));}},directDownload:function(){var fileurl=$("download_"+this.htmlelement.id).value;if(fileurl==""){WJWindow.alert("Please supply an URL to download the video from.",function(){},aeroplane.translateGui);}
else{var url=new WJUrl({},"/index.php");url.setCt("wmdynamic");url.addParameter("module","Wmmediamanager");url.addParameter("type","json");url.addParameter("uploadsection",WJMediamanagerInterface.VIDEOS);var spin=new WJSpin();spin.update(url,"Wmmediamanager","directdownload",{fileurl:fileurl},[this.directDownloadResponse.bind(this)]);}},directDownloadResponse:function(response){this.setValue(response[0]);this.changed=true;this.showThumbnail();$("frame_"+this.htmlelement.id).stopObserving("load",this._loadObserver);},directUploadResponse:function(){var iframedoc=($("frame_"+this.htmlelement.id).contentDocument||$("frame_"+this.htmlelement.id).contentWindow.document);if(iframedoc.body.textContent){var data=iframedoc.body.textContent.evalJSON(true);}
else{var data=iframedoc.body.innerHTML.stripTags().replace(/\r\n/g,"").evalJSON(true);}
this.setValue(data[0]);this.changed=true;this.showThumbnail();},directUpload:function(){if($("frame_"+this.htmlelement.id)){this._loadObserver=this.directUploadResponse.bindAsEventListener(this);$("frame_"+this.htmlelement.id).observe("load",this._loadObserver);$("upload_"+this.htmlelement.id).up("form").submit();}},setHtmlelement:function($super,elem){if(dijit.byId("mediamanager_"+elem.id)){$super(elem);this._activateSelectOptions();}
else if(elem.type=="file"){$super(elem);this.htmlelement.observe("change",this.uploadSingleFile.bindAsEventListener(this));}
else{this.setHtmlelement.bind(this,elem).delay(0.1);}}});var WJDir=Class.create(WJComponent,{initialize:function($super,id){$super(id);this.componentType="WJDir";this.changed=false;},setHtmlelement:function($super,elem){$super(elem);if(dijit.byId(this.htmlelement.id)){dijit.byId(this.htmlelement.id).setObserver(function(){aeroplane.openApplication("Mediamanager",this.selectDir.bind(this),{section:WJMediamanagerInterface.IMAGES,path:".",type:"dir"});}.bind(this));}
else if(dijit.byId("mediamanager_"+this.htmlelement.id)){dijit.byId("mediamanager_"+this.htmlelement.id).setObserver(function(){aeroplane.openApplication("Mediamanager",this.selectDir.bind(this),{section:WJMediamanagerInterface.IMAGES,path:".",type:"dir"});}.bind(this));}},valueChanged:function(){return this.changed;},selectDir:function(dir,section){if(section==WJMediamanagerInterface.IMAGES){dir="/var/mediamanager/images/"+dir;}
else if(section==WJMediamanagerInterface.FILES){dir="/var/mediamanager/files/"+dir;}
else if(section==WJMediamanagerInterface.VIDEOS){dir="/var/mediamanager/videos/"+dir;}
this.changed=true;this.value=dir;this.htmlelement.up().down("label").update(this.value);this.htmlelement.value=this.value;}});var WJLongText=Class.create(WJText,{initialize:function($super,id){$super(id);this.componentType="WJLongText";}});var WJAccordion=Class.create(WJTab,{initialize:function($super,id){$super(id);this.componentType="WJAccordion";}});var WJDate=Class.create(WJComponent,{initialize:function($super,id){$super(id);this.componentType="WJDate";},getValue:function($super){var value=$super();if(value){this.value=value.toString();}
else{this.value="";}
return this.value;}});var WJFlash=Class.create(WJFile,{initialize:function($super,id){$super(id);this.componentType="WJFlash";this.changed=false;},selectFlash:function(swf,path,section){this.changed=true;this.value="/var/mediamanager/flash/"+path+"/"+swf;if($(this.htmlelement.id+"_filename")){$(this.htmlelement.id+"_filename").update(this.value);}},getValue:function(){if(this.value==null&&$(this.htmlelement.id+"_filename")){this.value=$(this.htmlelement.id+"_filename").getTextContent();}
return this.value;},valueChanged:function(){return this.changed;},setHtmlelement:function($super,elem){if(dijit.byId(elem.id)){$super(elem);dijit.byId(elem.id).setObserver(function(){aeroplane.openApplication("Mediamanager",this.selectFlash.bind(this),{section:2500,path:"."});}.bind(this));}
else{this.setHtmlelement.bind(this,elem).delay(0.1);}}});var WJHtml=Class.create(WJGroup,{initialize:function($super,id){$super(id);this.componentType="WJHtml";this.group=0;}});var WJLinkButton=Class.create(WJButtonComponent,{initialize:function($super,id){$super(id);this.componentType="WJLinkButton";}});var WJLink=Class.create(WJGroup,{initialize:function($super,id){$super(id);this.componentType="WJLink";this.region="top";this.group=0;}});var WJListbox=Class.create(WJMultivalueInput,{initialize:function($super,id){$super(id);this.componentType="WJListbox";}});var WJList=Class.create(WJComponent,{initialize:function($super,id){$super(id);this.componentType="WJList";}});var WJNormalButton=Class.create(WJButtonComponent,{initialize:function($super,id){$super(id);this.componentType="WJNormalButton";}});var WJOption=Class.create({initialize:function(value,label){this.label=label;this.value=value;this.componentType="WJOption";}});var WJPassword=Class.create(WJText,{initialize:function($super,id){$super(id);this.componentType="WJPassword";}});var WJReview=Class.create(WJComponent,{initialize:function($super,id){$super(id);this.componentType="WJReview";}});var WJRichtext=Class.create(WJText,{initialize:function($super,id){$super(id);this.componentType="WJRichtext";},setHtmlelement:function($super,element){$super(element);if(tinyMCE.editors[this.htmlelement.id]){tinyMCE.execCommand("mceRemoveControl",false,this.htmlelement.id);}
tinyMCE.execCommand("mceAddControl",true,this.htmlelement.id);this.originalContent=null;tinymce.EditorManager.get(this.htmlelement.id).onInit.add(function(){if(!this.originalContent){this.originalContent=tinymce.EditorManager.get(this.htmlelement.id).getContent();}}.bind(this));},valueChanged:function($super){var usesTinyMCE=(typeof(tinyMCE)!="undefined")?true:false;if(this.htmlelement&&usesTinyMCE&&tinymce.EditorManager.get(this.htmlelement.id)&&tinymce.EditorManager.get(this.htmlelement.id).getContent){if(this.originalContent==null){return false;}
else{return tinymce.EditorManager.get(this.htmlelement.id).getContent()!=this.originalContent;}}
else{return $super();}},getValue:function($super){var usesTinyMCE=(typeof(tinyMCE)!="undefined")?true:false;if(this.htmlelement&&usesTinyMCE&&tinymce.EditorManager.get(this.htmlelement.id)&&tinymce.EditorManager.get(this.htmlelement.id).getContent){this.value=tinymce.EditorManager.get(this.htmlelement.id).getContent();}
else{this.value=$super();}
return this.value;}});var WJSelect=Class.create(WJSinglevalueInput,{initialize:function($super,id){$super(id);this.componentType="WJSelect";},getValue:function($super,nochange){var nochange=nochange||false;var oldvalue=this.value;if(this.htmlelement.options){this.value=this.htmlelement.options[this.htmlelement.selectedIndex].value;this.htmlelement.value=this.value;if(nochange){var newval=this.value;this.value=oldvalue;return newval;}
else{return this.value;}}
return $super(nochange);}});WJTabGroup=Class.create(WJGroup,{initialize:function($super,id){$super(id);this.componentType="WJTabGroup";}});var WJTree=Class.create(WJLabel,{initialize:function($super,id){$super(id);this.componentType="WJTree";}});var WJUrltext=Class.create(WJText,{initialize:function($super,id){$super(id);this.componentType="WJUrltext";}});var WJAlbumComponent=Class.create(WJComponent,{initialize:function($super,id){$super(id);this.componentType="WJAlbumComponent";this.value={};this.counter=0;},getValue:function(){var entries=this.htmlelement.select(".wjalbumcomponententry");var value=new Array();entries.each(function(entry){if(entry.id!="wjalbumcomponententry_template"){var inputs=entry.select("input");var title="";for(var i=0;i<inputs.length;i++){if($(inputs[i]).readAttribute("name")&&$(inputs[i]).readAttribute("name").endsWith("title")){title=$(inputs[i]).getValue();}}
var albumimage={imgsrc:entry.down("img").src,title:title,description:tinymce.EditorManager.get(entry.down("textarea").id).getContent()};this.push(albumimage);}}.bind(value));return value;},addAlbumImage:function(components){var albumimage=[]
components.each(function(component,s){if((s.id=="user")||(s.id=="added")){s.componentType="WJComponent";}
s.id=s.id+"_"+component.counter;this.push(s);}.bind(albumimage,this));this.value["albumimage_"+this.counter]=albumimage;this.counter++;},setHtmlelement:function($super,element){$super(element);element.select(".aeroplane_wjalbumcomponent_removebutton").each(function(button){this.addRemoveButtonListener(button);}.bind(this));element.select("textarea").each(function(area){tinyMCE.execCommand("mceAddControl",true,area.id);});this.addAddButtonListener("addbutton_"+element.id);},addAddButtonListener:function(buttonid){if(dijit.byId(buttonid)){dijit.byId(buttonid).setObserver(this.openMediamanager.bind(this));}
else{this.addAddButtonListener.bind(this,buttonid).delay(0.1);}},openMediamanager:function(){aeroplane.openApplication("Mediamanager",this.selectMedia.bind(this),{multiple:true});},selectMedia:function(media){var counter=this.htmlelement.select(".wjalbumcomponententry").length+1;for(var i=0;i<media.length;i++){var mediaElem=$("wjalbumcomponententry_template").cloneNode(true);var fileaddition=(WJMediamanagerInterface.getSectionDir(media[i].section)=="videos")?".png":"";mediaElem.id=null;mediaElem.down("img").src=mediaElem.down("img").src+"/var/mediamanager/"+WJMediamanagerInterface.getSectionDir(media[i].section)+"/"+media[i].path+"/"+media[i].file+fileaddition;mediaElem.setStyle({"display":"block"});mediaElem.down(".aeroplane_wjalbumcomponent_removebutton").setAttribute("dojoType","aeroplanedijit.WJButton");mediaElem.down(".aeroplane_wjtext").down("input").setAttribute("dojoType","dijit.form.TextBox");mediaElem.down("textarea").addClassName("aeroplane_wjrichtext");mediaElem.down("textarea").id="wjrichtext_"+counter;this.htmlelement.insert({top:mediaElem});dojo.parser.parse(mediaElem);tinymce.EditorManager.execCommand("mceAddControl",false,"wjrichtext_"+counter);counter++;}},addRemoveButtonListener:function(button){if(dijit.byId(button.id)){dijit.byId(button.id).setObserver(function(e){button.up(".wjalbumcomponententry").remove();}.bindAsEventListener(button));}
else{this.addRemoveButtonListener.bind(this,button).delay(0.1);}}});var WJCheckbox=Class.create(WJMultivalueInput,{initialize:function($super,id){$super(id);this.componentType="WJCheckbox";},getValue:function($super){if(this.htmlelement.tagName.toUpperCase()=="INPUT"){if(this.htmlelement.checked){return $super();}}
else{var checkboxes=this.htmlelement.select("input");this.value=[];for(var i=0;i<checkboxes.length;i++){if(checkboxes[i].checked){this.value.push(checkboxes[i].value);}}
return this.value;}}});WJConditionalGroup=Class.create(WJGroup,{initialize:function($super,id,testid,testvalue){$super(id);this.componentType="WJConditionalGroup";this.testId=testid;this.testValue=testvalue;},setHtmlelement:function($super,element,gui){$super(element);this.gui=gui;this.updateDisplay.bind(this).defer();this.addChangeObserverToTestId.bind(this).defer();},addChangeObserverToTestId:function(){this.gui.getComponentForField(this.testId).observe("change",this.updateDisplay.bind(this));},getValue:function($super){if(this.gui){return this.gui.getComponentForField(this.testId).getValue(true);}
else{return $super();}},updateDisplay:function(){if(this.getValue()==this.testValue){this.htmlelement.setStyle({display:"block"});}
else{this.htmlelement.setStyle({display:"none"});}}});WJExtendibleGroup=Class.create(WJGroup,{initialize:function($super,id){$super(id);this.componentType="WJExtendibleGroup";},setHtmlelement:function($super,element){$super(element);this._addRemoveListeners();this._addAddListener();this._toggleRemoveButtons();},_addRemoveListeners:function(removebuttons){var removebuttons=removebuttons||this.htmlelement.select("div.aeroplane_removewjextendiblegroupcomponent");removebuttons.invoke("observe","click",this.removeItem.bindAsEventListener(this));},_addAddListener:function(){this.htmlelement.down("div.aeroplane_addwjextendiblegroupcomponent").observe("click",this.addItem.bindAsEventListener(this));},removeItem:function(event){var element=event.element();var item=element.up("div.aeroplane_wjextendiblegroup_component").remove();this._toggleRemoveButtons();return item;},addItem:function(event){var addbutton=this.htmlelement.down("div.aeroplane_addwjextendiblegroupcomponent");var item=addbutton.previous("div.aeroplane_wjextendiblegroup_component");var newItem=$(addbutton.up().insertBefore(item.cloneNode(true),addbutton));this._resetFields(newItem);this._addRemoveListeners([newItem.down("div.aeroplane_removewjextendiblegroupcomponent")]);this._toggleRemoveButtons();return newItem;},_resetFields:function(element){WJExtendibleGroup.cloneCounter++;element.select("label").each(function(label){if(label.htmlFor){label.htmlFor="";}
else if(label["for"]){label["for"]="";}});element.select("input, select, textarea").each(function(el){el.name=el.name.replace(/^([^\[]*\[)[^\]]*(\].*)$/,"$1"+"new"+WJExtendibleGroup.cloneCounter+"$2");el.id+="new"+WJExtendibleGroup.cloneCounter;switch(el.tagName.toLowerCase()){case"input":switch(el.type.toLowerCase()){case"text":el.clear();break;}
break;case"select":el.selectedIndex=0;break;case"textarea":el.update("");break;}});},_toggleRemoveButtons:function(){var removebuttons=this.htmlelement.select("div.aeroplane_removewjextendiblegroupcomponent");removebuttons.invoke("setStyle",{"visibility":(removebuttons.length==1?"hidden":"visible")});},getValue:function(){this.value=this.htmlelement.select("input, select, textarea").inject({},function(result,el){var name=el.name;if(name==""){name=el.id;}
if(el.type=="radio"){if(!result[name]){result[name]=null;}
if(el.checked){result[name]=el.value;}}
else{result[name]=el.getValue();}
return result;});return this.value;}});WJExtendibleGroup.cloneCounter=0;var WJFileUploader=Class.create(WJComponent,{initialize:function($super,id){$super(id);this.componentType="WJFileUploader";this._totalSize=0;},_initUploaderWidget:function(){window.uploaderEvent=this.eventHandler.bind(this);this.uploader=new SWFObject("uploaderObject","/lib/plugin/aeroplane/flash/uploader.swf","100%","100%","transparent",{settings:Object.toJSON({eventHandler:"uploaderEvent",allowMultipleFiles:true,buttonImage:"/lib/wjgui/skins/lucid/images/contentbuttons.png",buttonText:"Bestanden zoeken",buttonTextStyle:{font:"Arial",fontSize:"12",color:"F40D75",fontWeight:"bold"}})});swfloader.loadSWFObject(this.htmlelement,this.uploader);},eventHandler:function(reference,event){switch(event.type){case"resize":this.htmlelement.setStyle({width:event.width,height:event.height});break;case"fileSelect":this.fileSelect(event);break;case"uploadCompleteData":this.markUploadComplete(event);break;case"uploadError":case"uploadCancel":this.markUploadCancel(event);break;}},setNextButton:function(button){this.nextbutton=button;this.nextbutton.disable();},markUploadCancel:function(e){$(e.id+"_inforow").down(".aeroplane_uploadcancelled").show();$(e.id+"_inforow").down(".aeroplane_uploadcancelled").title="De upload werd geannulleerd";$(e.id+"_inforow").down("a.aeroplane_delete").hide();this.handleUploadCompleted(e.id);},handleUploadCompleted:function(id){delete this.files[id];if($H(this.files).size()==0){this.componentdiv.down(".aeroplane_fileselector").down("div").hide();this.componentdiv.down(".aeroplane_fileselector").insert(new Element("h2").update("De upload is voltooid"));this.componentdiv.down("thead").down(".aeroplane_delete").firstDescendant().hide();this.uploadbutton.getButton().setStyle({visibility:"hidden"});aeroplane.loadingCursor(false);}},markUploadComplete:function(e){$(e.id+"_inforow").down("a.aeroplane_delete").hide();var finfo=e.data.evalJSON()[0];WJDebugger.log(WJDebugger.NOTICE,"Marking '%s' as uploaded",e.id,finfo);if(finfo.error==0){$(e.id+"_inforow").down(".aeroplane_complete").show();if(finfo.errormessage){$(e.id+"_inforow").down(".aeroplane_complete").title=finfo.errormessage;}
if(this.nextbutton){this.nextbutton.enable();}}
else{$(e.id+"_inforow").down(".aeroplane_error").show();if(finfo.errormessage){$(e.id+"_inforow").down(".aeroplane_error").title=finfo.errormessage;}}
this.handleUploadCompleted(e.id);},fileSelect:function(e){this._updateListing(e.fileList);},_updateListing:function(files){this.componentdiv.down("thead").hide();if(this.uploadbutton){this.uploadbutton.getButton().setStyle({visibility:"visible"});}
this.componentdiv.down("tbody").update("");this.componentdiv.down(".aeroplane_wjfileuploader_tablewrapper").setStyle({"height":($(this.componentdiv.parentNode).getHeight()-100)+"px","overflow-y":"auto"});this.componentdiv.down(".aeroplane_total").update("");aeroplane.windowmanager.cleanUpDijitWidgets();this._totalSize=0;this.files=files;var filescollection=[];for(var file in this.files){filescollection.push(file);}
if(filescollection.length===0){this.componentdiv.down(".aeroplane_wjfileuploader_tablewrapper").setStyle({"height":0});}
filescollection.reverse().each(function(file){this._handleFileSelect(this.files[file]);}.bind(this));if($H(this.files).size()>0){this.componentdiv.siblings().invoke("remove");this.componentdiv.down(".aeroplane_total").update("Totaal"+": <strong>"+this._formatFileSize(this._totalSize)+"</strong>");this.componentdiv.down("thead").show();$(this.uploader.getAttribute("swfname")).setTextStyle(Object.toJSON({font:"Arial",fontSize:"12",color:"01A1C1",fontWeight:"normal",textDecoration:"underline",cursor:"pointer"}));$(this.uploader.getAttribute("swfname")).setText("Bestanden toevoegen");$(this.uploader.getAttribute("swfname")).hideButtonImage();this._showUploadButton();}
else{if(this.uploader){$(this.uploader.getAttribute("swfname")).setTextStyle(Object.toJSON({font:"Arial",fontSize:"12",color:"F40D75",fontWeight:"bold",textDecoration:"none",cursor:"default"}));$(this.uploader.getAttribute("swfname")).setText("Bestanden zoeken");$(this.uploader.getAttribute("swfname")).showButtonImage();this.uploadbutton.getButton().setStyle({visibility:"hidden"});}}},removeFile:function(fileID){WJDebugger.log(WJDebugger.NOTICE,"Removing file '%s'",fileID);var files={};for(var id in this.files){if(id!=fileID){files[id]=this.files[id];}}
$(this.uploader.getAttribute("swfname")).removeFile(fileID);this._updateListing(files);},_showUploadButton:function(){if(!this.uploadbutton){this.uploadbutton=new WJButton("Upload starten",this.startUpload.bind(this),false,this.componentdiv.down("div.aeroplane_start"));}
this.uploadbutton.getButton().setStyle({visibility:"visible"});},startUpload:function(){aeroplane.loadingCursor(true);var cookie=new WJCookie();var sessionid=cookie.get("PHPSESSID",false);this.uploadInfo["PHPSESSID"]=sessionid;WJDebugger.log(WJDebugger.INFO,"Upload files",this.uploadInfo,this.files);$(this.uploader.getAttribute("swfname")).uploadAll("/index.php","POST",this.uploadInfo);},setUploadInformation:function(info){this.uploadInfo=info;},_handleFileSelect:function(file){WJDebugger.log(WJDebugger.NOTICE,"Selecting file",file);if(!this.pastetable){this.pastetable=new Element("table");}
var info=info={id:file.id,file:file.name,size:this._formatFileSize(file.size)};this.pastetable.update(this.rowtemplate.evaluate(info));$A(this.pastetable.rows).each(function(row){this.componentdiv.down("tbody").appendChild(row);},this);this.componentdiv.select("a.aeroplane_delete").last().observe("click",function(event,fileID){this.removeFile(fileID);}.bindAsEventListener(this,file.id));dojo.parser.parse(this.componentdiv);this._totalSize+=file.size;},_formatFileSize:function(bytesize){if(bytesize>=1073741824){bytesize=(Math.round((bytesize*100)/1073741824)/100)+" "+"GB";}
else if(bytesize>=1048576){bytesize=(Math.round((bytesize*100)/1048576)/100)+" "+"MB";}
else if(bytesize>=1024){bytesize=(Math.round((bytesize*100)/1024)/100)+" "+"KB";}
else{bytesize=bytesize+" "+"b";}
return bytesize;},alternativeUpload:function(){this.alternativeUploader.form.submit();$(this.alternativeUploader.form.target).observe("load",function(){this.nextbutton.enable();this.componentdiv.down(".aeroplane_fileselector").down("div").hide();this.componentdiv.down(".aeroplane_fileselector").insert(new Element("h2").update("De upload is voltooid"));}.bind(this));},setHtmlelement:function($super,element){$super(element);this.componentdiv=this.htmlelement.up(".aeroplane_wjfileuploader")
var templaterows=this.componentdiv.select("tr.aeroplane_listingtemplate");this.rowtemplate=new Template(templaterows.collect(function(row){return"<tr id='"+row.id+"row' class='"+row.className+"'>"+row.innerHTML+"</tr>";}).join(""));templaterows.invoke("remove");this._updateListing({});this._initUploaderWidget();if($("alternative_"+element.id)){this.alternativeUploader=$("alternative_"+element.id);this.alternativeUploader.observe("change",this.alternativeUpload.bind(this));if($("alternativelink_"+element.id)){$("alternativelink_"+element.id).observe("click",function(){$("alternativediv_"+element.id).setStyle({"display":"block"});});}}}});var WJOptionGroup=Class.create({initialize:function(){this.options=new Array();this.componentType="WJOptionGroup";},getOptions:function(){return this.options;},addOption:function(option){this.options.push(option);}});var WJRadio=Class.create(WJSinglevalueInput,{initialize:function($super,id){$super(id);this.componentType="WJRadio";this.htmlelement=[];},setHtmlelement:function(element){this.htmlelement.push(element);},getValue:function(nochange){var nochange=nochange||false;var oldvalue=this.value;for(var i=0;i<this.htmlelement.length;i++){if(this.htmlelement[i]&&dijit.byId(this.htmlelement[i].id)&&dijit.byId(this.htmlelement[i].id).getValue){if(dijit.byId(this.htmlelement[i].id).checked){this.value=dijit.byId(this.htmlelement[i].id).getValue();}}
else if(this.htmlelement[i]){if(this.htmlelement[i].checked){this.value=this.htmlelement[i].getAttribute("value");}}}
if(nochange){var newval=this.value;this.value=oldvalue;return newval;}
else{return this.value;}}});WJRichtextLabel=Class.create(WJLabel,{initialize:function($super,id,html){$super(id);this.componentType="WJRichtextLabel",this.html=html;},setLabel:function($super,label,force){var force=force||false;if(force){$super(label);}}});var WJTagCloud=Class.create(WJText,{initialize:function($super,id){$super(id);this.componentType="WJTagCloud";}});var WJThumbnail=Class.create(WJImage,{initialize:function($super,id){$super(id);this.componentType="WJThumbnail";}});var WJTime=Class.create(WJComponent,{initialize:function($super,id){$super(id);this.componentType="WJTime";}});var WJCloseableTab=Class.create(WJTab,{initialize:function($super,id){$super(id);this.componentType="WJCloseableTab";}});var WJSlider=Class.create(WJSinglevalueInput,{initialize:function($super,id){$super(id);this.componentType="WJSlider";}});var WJCBAction=Class.create({initialize:function(name,func,properties){this.name=name;this.cbfunc=func;this.components=[];this.properties=properties||{update:true};},execute:function(data){var spin=new WJSpin();var url=new WJUrl({ct:"wmdynamic",dt:"wmcontentblock",module:"Wmcb",id:this.cbfunc.getId(),action:this.name,"wmtrigger[]":["requestufts"],"uft[]":["contentblock"]});this.components.each(function(s){this.addParameter("args["+s.getId()+"]",s.getValue());}.bind(url));for(var key in data){url.addParameter(key,data[key]);}
$(document.body).setStyle({"cursor":"wait"});if(this.properties.update){var elem=this.cbfunc.getElement();elem.ajaxUpdateType=this.cbfunc.getUpdateMethod();spin.content(url,[elem,function(){$(document.body).setStyle({"cursor":"default"});}],{"406":this.handleNotAcceptable.bind(this)});}
else{spin.content(url,[function(){$(document.body).setStyle({"cursor":"default"});}],{"406":this.handleNotAcceptable.bind(this)});}},handleNotAcceptable:function(){$(document.body).setStyle({"cursor":"auto"});if(this.cbfunc.specifics){this.cbfunc.specifics.handleNotAcceptable();}},addComponent:function(comptype,compname,compgroup){comptype=comptype.substr(0,3).toUpperCase()+comptype.substr(3);if(!window[comptype]){comptype="WJComponent";}
var id=compname;if(!$(id)){id=compname+"_"+this.cbfunc.getId();}
if(!$(id)&&compgroup!=undefined){id=compgroup+"_"+compname+"_"+this.cbfunc.getId();compname=compgroup+"_"+compname;}
if($(id)){var comp=new window[comptype](compname);comp.setHtmlelement($(id));this.components.push(comp);}}});var WJCBFunctionalityHistoryManager=Class.create({initialize:function(func){this.func=func;if(!ProtoHistoryManager){WJDebugger.log(WJDebugger.WARNING,"Unable to use history manager functionality without prototype.historyManager, will continue without");}
else{this.historyKey=this.func.cb+"-"+this.func.id;this.historyManager=new ProtoHistoryManager();this.history=this.historyManager.register(this.historyKey,[""],function(values){this.recallAction(values[0]);}.bind(this),function(values){if(Object.isString(values[0])){return this.historyKey+"-"+values[0];}
else{return this.historyKey+"-"+$H(values[0]).toQueryString();}}.bind(this),this.historyKey+'-(.+)');this.historyManager.start.bind(this.historyManager).delay(1.5);}},recallAction:function(query){if(query==""){return;}
var query=query.toQueryParams();var action=query.action;delete query.action;this.func.callAction(action,query);},callAction:function(action,data){if(this.history){data.action=action;this.history.setValue(0,data);}}});var WJCBFunctionality=Class.create({initialize:function(id,cb,htmlid,cbdata,collection){this.id=id;this.element=$(htmlid);this.cb=cb;this.actions={};this.cbdata=cbdata;this.collection=collection;this.updateMethod="replaceElement";},createSpecifics:function(){if(window["WJCBFunctionality"+this.cb]){this.specifics=new window["WJCBFunctionality"+this.cb](this);}},getUpdateMethod:function(){return this.updateMethod;},getData:function(key){return this.cbdata[key];},setData:function(key,value){this.cbdata[key]=value;},callAction:function(action,data){var data=data||{};if(data.isTrusted||Object.isFunction(data.stop)){data={};}
if(this.actions[action]){this.actions[action].execute(data);}
if(this.specifics&&this.specifics.callAction){this.specifics.callAction(action,data);}},getId:function(){return this.id;},getElement:function(){return this.element;},addAction:function(name,action){this.actions[name]=action;}});var WJCBGooglemapsdirections=Class.create({initialize:function(elementid,settings){this._settings=new Hash(settings);this._maperrorparent=false;$(this._settings.get("from")).hide();$(this._settings.get("submit")).up().hide();this._routeelement=$(elementid);this._mapcanvas=this._routeelement.down(".googlemapscanvas");this._maperrors=this._routeelement.appendChild(new Element("div")).addClassName("googlemapsdirectionserror").hide();this._printbutton=this._routeelement.appendChild(new Element("a",{"href":"#"})).hide().update(this._settings.get("printlabel")).observe("click",this.print.bindAsEventListener(this));this._mapdirections=this._routeelement.appendChild(new Element("div",{"class":"googlemapsdirections"})).hide();this._map=new GMap2(this._mapcanvas);this._geocoder=new GClientGeocoder();this._geocoder.getLatLng(this._settings.get("to"),this.centerMap.bind(this));this._directions=new GDirections(this._map,this._mapdirections);GEvent.addListener(this._directions,"error",this._displayError.bindAsEventListener(this));GEvent.addListener(this._directions,"load",this._displayDirections.bindAsEventListener(this));this._addControls();this._addPlanObserver();},_displayError:function(){if(this._maperrorparent!=false&&this._maperrors.up()!=this._maperrorparent){if(Object.isElement(this._maperrorparent)){this._maperrorparent.appendChild(this._maperrors);}
else{$$(this._maperrorparent).first().appendChild(this._maperrors);this._maperrorparent=$$(this._maperrorparent).first();}}
this._maperrors.update(this._settings.get("errortext")).show();this._mapdirections.hide();this._printbutton.hide();},_addPlanObserver:function(){$(this._settings.get("submit")).observe("click",this.planRoute.bindAsEventListener(this));},planRoute:function(event){this._maperrors.update("");var from=$(this._settings.get("from")).down("input").value;this._directions.load("from: "+from+" to: "+this._glatlng.lat()+","+this._glatlng.lng(),this._mapdirections);},appendErrortextTo:function(elementOrSelector){this._maperrorparent=elementOrSelector;},_displayDirections:function(event){this._mapdirections.show();},centerMap:function(glatlng){if(glatlng){this._glatlng=glatlng;this._map.setCenter(this._glatlng,parseInt(this._settings.get("zoom")));this._tomarker=new GMarker(this._glatlng);this._map.addOverlay(this._tomarker);this._tomarker.openInfoWindowHtml("<div class='InfoWindowContent'>"+this._settings.get("text")+"<div id='searchfields' class='searchfields'>&#160;</div></div>");GEvent.addListener(this._tomarker,"infowindowopen",function(){$("searchfields").appendChild($(this._settings.get("from"))).show();$("searchfields").appendChild($(this._settings.get("submit")).up()).show();$("searchfields").id=null;this._infowindowopen=true;}.bindAsEventListener(this));return true;}
return false;},_addControls:function(){this._map.addControl(new GSmallZoomControl());this._map.addControl(new GMapTypeControl());},print:function(event){var from=$(this._settings.get("from")).down("input").value;var directions="from: "+from+" to: "+this._glatlng.lat()+","+this._glatlng.lng();var scriptsrc="<script language='JavaScript' type='text/javascript' src='"+this._settings.get("jssrc")+"'> </script>";var src="<html><head><title>"+this._settings.get("to")+"</title>"+scriptsrc+"</head><body><div id='canvas' style='height: "+this._mapcanvas.getHeight()+"px; width: "+this._mapcanvas.getWidth()+"px;'>&#160;</div><div id='directions'>&#160;</div></body></html>";var script="<script language='JavaScript' type='text/javascript'>";script+="map = new GMap2(document.getElementById('canvas') );";script+="map.setCenter(new GLatLng("+this._glatlng.lat()+","+this._glatlng.lng()+"), "+parseInt(this._settings.get("zoom"))+" );";script+="directions = new GDirections(map, document.getElementById('directions') );";script+="GEvent.addListener(directions, 'load', function() {window.print();});";script+="directions.load('"+directions+"');";script+="</script>";var printwindow=window.open("about:blank","printdialog","scrollbars=yes,height="+(this._mapcanvas.getHeight()+150)+",width="+(this._mapcanvas.getWidth()+40));printwindow.document.write(src);printwindow.document.close()}});var WJAlbumCB=Class.create({initialize:function(func,properties){this.albumimages=new Array();this.current="";this.effect=null;this.func=func;this.properties=properties||{};if(this.properties.slide){this.viewNextAlbumImage.bind(this).repeat(properties.slide);}},setTransitionEffect:function(effect,properties){var properties=properties||{};this.effect=effect;this.mediaTransition=new WJMediaTransition(properties);this.mediaTransition.setFromElement($(document.body).down(".contentblockalbum_view").down());this.effect.init(this.mediaTransition,{});},registerImage:function(url,title,user,extrainfo){this.albumimages.push({type:"image",url:url,title:title,user:user,extrainfo:extrainfo});},registerVideo:function(url,title,user,extrainfo){this.albumimages.push({type:"video",url:url,title:title,user:user,extrainfo:extrainfo});},setCurrentAlbumimage:function(url){this.current=url;for(var i=0;i<this.albumimages.length;i++){if(this.albumimages[i].url==this.current){for(var id in this.properties.update){if($(id)){$(id).update(this.albumimages[i][this.properties.update[id]]);}}}}},viewAlbumimage:function(url){this.mediaTransition.setToImage(url);this.effect.transit();this.setCurrentAlbumimage(url);if(this.func.specifics.history){this.func.specifics.history.setValue(0,{action:"details","args[thumbsrc]":url});}},viewNextAlbumImage:function(){if(this.effect){for(var i=0;i<this.albumimages.length-1;i++){if(this.albumimages[i].url==this.current){this.viewAlbumimage(this.albumimages[i+1].url);return;}}
this.viewAlbumimage(this.albumimages[0].url);}},viewPreviousAlbumImage:function(){for(var i=1;i<this.albumimages.length;i++){if(this.albumimages[i].url==this.current){this.viewAlbumimage(this.albumimages[i-1].url);return;}}
this.viewAlbumimage(this.albumimages[this.albumimages.length-1].url);}});var WJCBFunctionalityalbum=Class.create(WJCBFunctionalityHistoryManager,{initialize:function($super,func){func.element=$(func.collection+"_container");func.updateMethod="replaceContent";$super(func);}});var WJCBFunctionalityform=Class.create({initialize:function(func){this.func=func;},handleNotAcceptable:function(){if($(this.func.id+"_missing")){$(this.func.id+"_missing").setStyle({"display":"block"});}}});var WJCBFunctionalitynewsletter=Class.create({initialize:function(func){this.func=func;},handleNotAcceptable:function(){if($(this.func.id+"_missing")){$(this.func.id+"_missing").setStyle({"display":"block"});}}});var WJCBFunctionalityrating=Class.create({initialize:function(func){this.func=func;if(this.func.getElement()){this._attachObservers();this._setDefaults();}},_attachObservers:function(){var fullbar=this._getBar("fullbar")
this._voteObserver=this.vote.bindAsEventListener(this);fullbar.observe("click",this._voteObserver);this._moveObserver=this.mouseMove.bindAsEventListener(this);fullbar.observe("mousemove",this._moveObserver);this._outObserver=this.restoreWidth.bindAsEventListener(this);fullbar.observe("mouseout",this._outObserver);},_getBar:function(className){return this.func.getElement().select("."+className).first();},mouseMove:function(e){var bar=this._getBar("percentage");if(bar){if(this._originalWidth==null){this._originalWidth=bar.getStyle("width");}
var elemloc=bar.cumulativeOffset();var relmouseloc={x:e.pointerX()-elemloc[0],y:e.pointerY()-elemloc[1]};if(relmouseloc.x<this._getBar("fullbar").getWidth()){bar.setStyle({width:relmouseloc.x+"px"});}}},restoreWidth:function(e){var bar=this._getBar("percentage");if(bar&&this._originalWidth!=null){bar.setStyle({width:this._originalWidth});}},_setDefaults:function(){this.func.setData("boundaries",{x:0,y:0,width:this._getBar("fullbar").getWidth(),height:this._getBar("fullbar").getHeight()});},vote:function(e){var elemloc=this._getBar("fullbar").cumulativeOffset();var relclickloc={x:e.pointerX()-elemloc[0],y:e.pointerY()-elemloc[1]};var boundaries=this.func.getData("boundaries");if((relclickloc.x>boundaries.x)&&(relclickloc.x<(boundaries.x+boundaries.width))&&(relclickloc.y>boundaries.y)&&(relclickloc.y<(boundaries.y+boundaries.height))){var limits={min:parseInt(this.func.getData("min")),max:parseInt(this.func.getData("max"))};var stepwidth=boundaries.width/(1+limits.max-limits.min);var vote=Math.ceil((relclickloc.x-boundaries.x)/stepwidth);$("vote_"+this.func.getId()).value=vote;this.func.callAction("vote");this._getBar("fullbar").stopObserving("click",this._voteObserver);this._getBar("fullbar").stopObserving("mousemove",this._moveObserver);this._getBar("fullbar").stopObserving("mouseout",this._outObserver);}}});var WJCBFunctionalityreview=Class.create({initialize:function(func){this.func=func;},handleNotAcceptable:function(){if($(this.func.id+"_missing")){$(this.func.id+"_missing").setStyle({"display":"block"});}}});var WJCBFunctionalitysend=Class.create({initialize:function(func){this.func=func;},handleNotAcceptable:function(){if($(this.func.id+"_missing")){$(this.func.id+"_missing").setStyle({"display":"block"});}}});var WJCBGooglemaps=Class.create({_overlays:new Hash(),_forms:new Hash(),_filterlists:new Hash(),_selectobservers:new Hash(),_loader:null,initialize:function(elementid,latitude,longitude,zoom,sitename){this._mapelement=$(elementid);this._mapelement.style.backgroundImage="";this._center=new GLatLng(latitude,longitude);this._zoom=zoom;this._sitename=sitename;this._zoomtobounds=false;this._bounds=new GLatLngBounds();this._addpositioncontrol=true;this._positioncontrol=(this._mapelement.getHeight()<300)?new GSmallMapControl:new GLargeMapControl();this._map=new GMap2(this._mapelement);this._map.addMapType(G_PHYSICAL_MAP);var hierarchy=new GHierarchicalMapTypeControl();hierarchy.addRelationship(G_SATELLITE_MAP,G_HYBRID_MAP,null,true);this._addtypecontrol=true;this._typecontrol=hierarchy;this._enabledoubleclickzoom=true;this._enablecontinuouszoom=true;this.currentrequests=0;this.requests=new Array();},setLoader:function(element){this._loader=element;},getLoader:function(){return this._loader;},loaderShowHide:function(){if(this.getLoader()&&Object.isElement(this.getLoader())){if(this.currentrequests>0){this.getLoader().addClassName("maploadershow");}
else{this.getLoader().removeClassName.bind(this.getLoader()).defer("maploadershow");}}},changeSettings:function(settings){for(key in settings){this[key]=settings[key];}},applySettings:function(){this._map.setCenter(this._center,this._zoom);if(this._enabledoubleclickzoom){this._map.enableDoubleClickZoom();}
if(this._enablecontinuouszoom){this._map.enableContinuousZoom();}
if(this._addpositioncontrol){this._map.addControl(this._positioncontrol);}
if(this._addtypecontrol){this._map.addControl(this._typecontrol);}
this._addZoomListener();},_addZoomListener:function(){GEvent.addListener(this._map,"zoomend",function(){this._overlays.findAll(function(overlay){return(typeof(overlay.value.infowindow)!="undefined"&&overlay.value.infowindow.isVisible());}).each(function(overlay){this.positionInfowindowRelativeToMarker(overlay.value);}.bind(this));}.bind(this));},pushOverlay:function(key,overlay,active,parser,filterable,checkable){var active=(active==1)?true:false;this.setOverlay(key,{"baseurl":overlay,"url":overlay,"active":active,"parser":parser,"filterable":filterable,"checkable":checkable});},setOverlay:function(key,value){this._overlays.set(key,value);},getOverlay:function(key){return this._overlays.get(key);},addOverlays:function(readform){var readform=(readform!==false);if(readform){this._fillFormsValues();}
this._overlays.each(function(overlay){if(typeof(overlay.value.geoxml)=="undefined"){this.getNewGeoXml(overlay);}
else if(overlay.value.active){this.addOverlay(overlay)}}.bind(this));},addOverlay:function(overlay){this._map.addOverlay(overlay.value.geoxml);overlay.value.lasturl=overlay.value.url;},getNewGeoXml:function(overlay){if(overlay.value.active){if(overlay.value.parser=="GGeoXml"){overlay.value.geoxml=new GGeoXml(overlay.value.url);this.addOverlay(overlay);}
else{this.parseOverlay(overlay);var handle=GEvent.addListener(overlay.value.geoxml,"parsed",function(overlay){if(overlay.value.active){this.addOverlay(overlay);}
this.currentrequests--;this.loaderShowHide();this.zoomToBounds();GEvent.removeListener(handle);}.bind(this,overlay));}}},hideInfoWindows:function(){this._overlays.findAll(function(overlay){return(typeof(overlay.value.infowindow)!="undefined");}).each(function(overlay){overlay.value.infowindow.hide();});},createInfoWindow:function(overlay,map){var callback=function(wjwindow,event,answer){wjwindow.hide();event.stop();};var infowindow=new WJWindowGooglemaps(new WJWindow(callback,$(map.getPane(G_MAP_FLOAT_PANE))),overlay.key,this._sitename);var infowindowelement=infowindow.getWindowElement();var stopInfowindowEvents=function(event,evtype){var eventelem=Event.findElement(event);if(evtype=="mousedown"){switch(eventelem.tagName.toLowerCase()){case"input":eventelem.focus();case"a":break;default:Event.stop(event);break;}}
else{Event.stop(event);}}
GEvent.bindDom(infowindowelement,"mousedown",this,stopInfowindowEvents.bindAsEventListener(infowindowelement,"mousedown"));GEvent.bindDom(infowindowelement,"dblclick",this,stopInfowindowEvents.bindAsEventListener(infowindowelement,"dblclick"));return infowindow;},removeOverlays:function(){this._overlays.each(function(overlay){if(typeof(overlay.value.geoxml)!="undefined"&&overlay.value.filterable){if(typeof(overlay.value.infowindow)!="undefined"){overlay.value.infowindow.hide();}
this._map.removeOverlay(overlay.value.geoxml);}
if(overlay.value.lasturl!=overlay.value.url&&overlay.value.filterable){this.getNewGeoXml(overlay);}}.bind(this));},removeOverlay:function(key){var overlay=this._overlays.get(key);if(overlay.active){overlay.active=false;this._map.removeOverlay(overlay.geoxml);}},zoomToBounds:function(){if(this._zoomtobounds&&!(this.currentrequests>0)){this._bounds=new GLatLngBounds();this._overlays.each(function(overlay){if(overlay.value.active==true){if(typeof(overlay.value.data.gmarkers)!="undefined"){overlay.value.data.gmarkers.each(function(gmarker){this._bounds.extend(gmarker.getLatLng());}.bind(this));}
if(typeof(overlay.value.data.gpolygons)!="undefined"){overlay.value.data.gpolygons.each(function(gpolygon){var bounds=gpolygon.getBounds();this._bounds.extend(bounds.getNorthEast());this._bounds.extend(bounds.getSouthWest());}.bind(this));}}}.bind(this));if(!this._bounds.isEmpty()){this._map.setZoom(this._map.getBoundsZoomLevel(this._bounds));this._map.setCenter(this._bounds.getCenter());}}},addMainFormObserver:function(elementid){var mainform=$(elementid);mainform.getInputs().each(function(element){$(element).observe("click",function(event){this._handleMainFormChange(event);}.bind(this));}.bind(this));this._mainform=mainform;},addFormObserver:function(formname){var additionalform=$(document.forms[formname]);if(Object.isElement(additionalform)){additionalform.getElements().each(function(element){if(element.tagName.toLowerCase()=="select"){this._selectobservers.set(element.name,Form.Element.getValue(element));}
$(element).observe("click",function(event){var eventelement=Event.findElement(event,"select");if(eventelement!=document&&eventelement){var value=Form.Element.getValue(eventelement);if(value!=this._selectobservers.get(eventelement.name)){this._selectobservers.set(eventelement.name,value);this._handleChange(event);}}
else{this._handleChange(event);}}.bind(this));}.bind(this));Event.observe(additionalform,"submit",this._handleSubmit.bind(this));this.setForm(additionalform.name,additionalform);}},addFilterlistObservers:function(filterlistwrappersid,id,module){var filterwrapper=$(filterlistwrappersid+"_filters");if(filterwrapper){filterwrapper.observe("click",this._handleFilterChange.bindAsEventListener(this));}
var activefilterwrapper=$(filterlistwrappersid+"_activefilters");if(activefilterwrapper){activefilterwrapper.observe("click",this._handleFilterChange.bindAsEventListener(this));}
this._filterlists.set(id,new Hash({filterwrapper:filterwrapper,activefilterwrapper:activefilterwrapper,module:module}));},_handleFilterChange:function(event){if(this.currentrequests>0){this._handleFilterChange.bind(this,event).delay(1);event.stop();}
else{var link=event.findElement("a");if(link){var list=[link.up("ul.filter_filter"),link.up("ul.filter_activefilters")].compact().first();if(list){var filter=Object.toQueryString(link.href.toQueryParams());this._applyFilter(filter);this.redrawOverlays(false);this._updateFilterLists(filter);event.stop();link.fire("filter:changed",{cbgooglemaps:this});}}}},_updateFilterLists:function(filter){this._filterlists.values().each(function(filter,filterinfo){var query=Object.extend({ct:"wmdynamic",dt:"filter",contenttype:"xml","__type":"xml",module:filterinfo.get("module"),"wmtrigger[]":"requestufts",savecriteria:"true","count":1},filter.toQueryParams());new WJSpin().content(new WJUrl(query,"/index.php"),[this._updateFilterListElements.bind(this,filterinfo)]);}.curry(filter),this);},_updateFilterListElements:function(filterinfo,response){filterinfo.get("activefilterwrapper").update("");filterinfo.get("filterwrapper").update("");$A(response.documentElement.childNodes).each(function(listwrapper){if(listwrapper.getAttribute("id")=="activefilters"){if(listwrapper.childNodes[0]){$A(listwrapper.childNodes[0].childNodes).each(function(filtercontent){if(filterinfo.get("activefilterwrapper").ownerDocument.importNode){filtercontent=filterinfo.get("activefilterwrapper").ownerDocument.importNode(filtercontent,true);filterinfo.get("activefilterwrapper").appendChild(filtercontent);}
else if(filtercontent.xml){filterinfo.get("activefilterwrapper").update(filterinfo.get("activefilterwrapper").innerHTML+filtercontent.xml);}
else{filterinfo.get("activefilterwrapper").appendChild(filtercontent);}});}}
else if(listwrapper.getAttribute("id")=="filters"){if(listwrapper.childNodes[0]){$A(listwrapper.childNodes[0].childNodes).each(function(filtercontent){if(filterinfo.get("filterwrapper").ownerDocument.importNode){filtercontent=filterinfo.get("filterwrapper").ownerDocument.importNode(filtercontent,true);filterinfo.get("filterwrapper").appendChild(filtercontent);}
else if(filtercontent.xml){filterinfo.get("filterwrapper").update(filterinfo.get("filterwrapper").innerHTML+filtercontent.xml);}
else{filterinfo.get("filterwrapper").appendChild(filtercontent);}});}}});filterinfo.get("filterwrapper").innerHTML=filterinfo.get("filterwrapper").innerHTML;filterinfo.get("activefilterwrapper").innerHTML=filterinfo.get("activefilterwrapper").innerHTML;},_handleSubmit:function(event){this._handleChange(event);Event.stop(event);},_handleChange:function(event){if(this.currentrequests>0){this._handleChange.bind(this).delay(1,event);}
else{this._fillFormsValues();this.redrawOverlays();}},_fillFormsValues:function(){var filter=this._forms.values().invoke("serialize").join("&");this._applyFilter(filter);},_applyFilter:function(filter){this._overlays.values().each(function(filter,overlay){if(overlay.filterable&&filter!=""){overlay.url=overlay.baseurl+((overlay.baseurl.indexOf("?")==-1)?"?":"&")+filter;}
else{overlay.url=overlay.baseurl;}}.bind(this,filter));},redrawOverlays:function(readform){this.removeOverlays();this.addOverlays(readform);},_handleMainFormChange:function(event){var checkbox=Event.element(event);this.hideInfoWindows();this._overlays.each(function(checkbox,overlay){if(checkbox.name==overlay.key){if(checkbox.checked){overlay.value.active=true;if(typeof(overlay.value.geoxml)=="undefined"){this.getNewGeoXml(overlay);}
else if((overlay.value.url!=overlay.value.lasturl)&&overlay.value.filterable){this.removeOverlay(checkbox.name);this.getNewGeoXml(overlay);}
else{this.addOverlay(overlay);}}
else{this.removeOverlay(checkbox.name);overlay.value.active=false;}}}.bind(this,checkbox));},setForm:function(key,value){this._forms.set(key,value);},getForm:function(key){return this._forms.get(key);},parseOverlay:function(overlay){overlay.value.data={};overlay.value.styles={};overlay.value.geoxml={};overlay.value.geoxml.prototype=new GOverlay();overlay.value.geoxml.initialize=this.addOverlayToMap.bind(this,overlay);overlay.value.geoxml.remove=this.removeOverlayFromMap.bind(this,overlay);overlay.value.geoxml.redraw=this.redrawOverlayOnMap.bind(this,overlay);overlay.value.geoxml.copy=this.copyOverlayOfMap.bind(this,overlay);this.currentrequests++;this.loaderShowHide();this.zoomToBounds();this.stackRequest(overlay);if(this.currentrequests==1){this.downloadKML();}},stackRequest:function(overlay){this.requests.push(overlay);},downloadKML:function(){var overlay=this.requests.shift();if(typeof(overlay)!="undefined"){GDownloadUrl(overlay.value.url,this.handleKMLRequest.bind(this,overlay));}},showInfowindow:function(m,overlayvalue,name,desc,url){overlayvalue.infowindow.setContent(desc);if(m.chkmlClassName!=""){overlayvalue.infowindow.setTheme(m.chkmlClassName);}
overlayvalue.lastmarker=m;if(m.chkmlDirections!=false){this.handleDirections(m,overlayvalue);}
if(typeof(url)!="undefined"){var spincomplete=function(overlayvalue,content){overlayvalue.infowindow.setContent(content);overlayvalue.infowindow.setLoading(false);overlayvalue.infowindow.setHeight(450);var point=this.positionInfowindowRelativeToMarker(overlayvalue);this._map.panTo(this._map.fromDivPixelToLatLng(point));};var spin=new WJSpin();overlayvalue.infowindow.setLoading(true);spin.content(url,[spincomplete.bind(this,overlayvalue)]);}
overlayvalue.infowindow.setHeight("auto");overlayvalue.infowindow.show();var point=this.positionInfowindowRelativeToMarker(overlayvalue);if(typeof(url)=="undefined"){this._map.panTo(this._map.fromDivPixelToLatLng(point));}},handleDirections:function(m,overlayvalue){if(!this._directions){this.createDirections();}
if(typeof(overlayvalue.infowindow.getContentElement("directions"))!="undefined"){overlayvalue.infowindow.removeWindowRow("directions");}
if(m.chkmlDirections!=false){var directionsrow=overlayvalue.infowindow.insertWindowRowBefore("bottom","directions");var directionsrowcontent=overlayvalue.infowindow.getContentElement("directions");directionsrowcontent.update(m.chkmlDirections.getHtml());var formelement=directionsrowcontent.down("form");if(m.chkmlDirections.addTo===false&&m.chkmlDirections.addFrom===true){this._directionsdirection="from";}
else{this._directionsdirection="to";}
formelement.addClassName("infowindowdirection_"+this._directionsdirection);formelement.addClassName("infowindowdirection_hidden");formelement.observe("submit",function(event,formelement,overlayvalue){var formvalues=formelement.serialize(true);var latlng=overlayvalue.lastmarker.getLatLng().toUrlValue();if(this._directionsdirection=="to"){var searchstring="from: "+formvalues.address+" to: "+latlng;}
else{var searchstring="from: "+latlng+" to: "+formvalues.address;}
this._directions.load(searchstring,this._mapdirections);Event.stop(event);}.bindAsEventListener(this,formelement,overlayvalue));formelement.select("a").each(function(formelement,element,key){element.observe("click",function(event,formelement){var eventelem=Event.element(event);if(eventelem.hasClassName("back")){formelement.addClassName("infowindowdirection_hidden");var point=this.positionInfowindowRelativeToMarker(overlayvalue);this._map.panTo(this._map.fromDivPixelToLatLng(point));}
else if(eventelem.hasClassName("link_to")){this._directionsdirection="to";formelement.removeClassName("infowindowdirection_from");formelement.addClassName("infowindowdirection_to");}
else if(eventelem.hasClassName("link_from")){this._directionsdirection="from";formelement.removeClassName("infowindowdirection_to");formelement.addClassName("infowindowdirection_from");}
else if(eventelem.hasClassName("directionsactivator")){formelement.removeClassName("infowindowdirection_hidden");var point=this.positionInfowindowRelativeToMarker(overlayvalue);this._map.panTo(this._map.fromDivPixelToLatLng(point));}}.bindAsEventListener(this,formelement));}.bind(this,formelement));}},createDirections:function(){this._mapdirections=this._mapelement.up().appendChild(new Element("div",{"class":"googlemapsdirections"})).hide();if(Object.isElement($("googlemapsdirectionserror"))){this._directionerrors=$("googlemapsdirectionserror");}
else{this._directionerrors=this._mapelement.up().appendChild(new Element("div",{"class":"googlemapsdirectionserror"}));}
this._directionerrors.hide();this._directions=new GDirections(this._map,this._mapdirections);GEvent.addListener(this._directions,"error",this._displayDirectionsError.bindAsEventListener(this));GEvent.addListener(this._directions,"load",this._displayDirections.bindAsEventListener(this));},_displayDirections:function(event){if(Object.isElement($("googlemapsdirectionserror"))){$("googlemapsdirectionserror").hide();}
else{this._directionerrors.update("");}
this.hideInfoWindows();this._mapdirections.show();},_displayDirectionsError:function(){if(Object.isElement($("googlemapsdirectionserror"))){$("googlemapsdirectionserror").show();}
else{this._directionerrors.update("Route could not be found").show();}
this._mapdirections.hide();},addOverlayToMap:function(overlay,map){WJDebugger.log(WJDebugger.NOTICE,"Adding overlay "+overlay[0],overlay[1]);var data=overlay.value.data;if(typeof(overlay.value.infowindow)=="undefined"){overlay.value.infowindow=this.createInfoWindow(overlay,map);}
this.removeOverlayFromMap(overlay);data.gpolygons=[];data.gpolylines=[];data.gmarkers=[];if(typeof(data.polylines)!="undefined"){data.polylines.each(function(map,overlay,polyline,key){this.createPolyline(polyline,overlay);}.bind(this,map,overlay));}
if(typeof(data.polygons)!="undefined"){data.polygons.each(function(map,overlay,polygon,key){this.createPolygon(polygon,overlay);}.bind(this,map,overlay));}
if(typeof(data.markers)!="undefined"){data.markers.each(function(map,overlay,marker,key){this.createMarker(marker,overlay);}.bind(this,map,overlay));}},removeOverlayFromMap:function(overlay){var data=overlay.value.data;if(typeof(data.gpolylines)!="undefined"){data.gpolylines.each(function(polyline,key){this._map.removeOverlay(polyline);}.bind(this));}
if(typeof(data.gpolygons)!="undefined"){data.gpolygons.each(function(polygon,key){this._map.removeOverlay(polygon);}.bind(this));}
if(typeof(data.gmarkers)!="undefined"){data.gmarkers.each(function(marker,key){this._map.removeOverlay(marker);}.bind(this));}},redrawOverlayOnMap:function(overlay,force){},copyOverlayOfMap:function(){},createMarker:function(data,overlay){var overlayvalue=overlay.value;var point=data.point;var name=data.name;var desc=data.desc;var style=data.styleInfo;var url;if(data.spin!=""){url=new WJUrl(data.spin.toQueryParams(),"/index.php");}
var icon=overlayvalue.styles[style];var marker=new GMarker(point,icon);marker.chkmlClassName=data.chkmlClassName;marker.chkmlDirections=data.chkmlDirections;if(name!=""&&desc!=""){GEvent.addListener(marker,"click",function(m,overlayvalue,name,desc,url){if(m==overlayvalue.lastmarker){overlayvalue.infowindow.show();var point=this.positionInfowindowRelativeToMarker(overlayvalue);this._map.panTo(this._map.fromDivPixelToLatLng(point));}
else{this.hideInfoWindows();overlayvalue.infowindow.setBaseTitle("");overlayvalue.infowindow.setContent("");overlayvalue.infowindow.setBaseTitle(name);var wrapper=new Element("div").update(desc);var contentimages=wrapper.select("img");overlayvalue.infowindow.contentimagescounter=contentimages.size();if(overlayvalue.infowindow.contentimagescounter>0){var countdown=function(event,m,html,iwoptions,name,desc,url){overlayvalue.infowindow.contentimagescounter--;if(overlayvalue.infowindow.contentimagescounter==0){this.showInfowindow(m,overlayvalue,name,wrapper,url);}}.bindAsEventListener(this,m,overlayvalue,name,wrapper,url);contentimages.invoke("observe","load",countdown).invoke("observe","error",countdown);}
else{this.showInfowindow(m,overlayvalue,name,desc,url);}}}.bind(this,marker,overlayvalue,name,desc,url));}
this._map.addOverlay(marker);overlayvalue.data.gmarkers.push(marker);},createPolyline:function(data,overlay){var overlayvalue=overlay.value;var points=data.points;var color=data.color;var width=data.width;var opacity=data.opacity;var pbounds=data.pbounds;var name=data.name;var desc=data.desc;var p=new GPolyline(points,color,width,opacity);this._map.addOverlay(p);overlayvalue.data.gpolylines.push(p);},createPolygon:function(data,overlay){var overlayvalue=overlay.value;var pbounds=data.pbounds;var name=data.name;var desc=data.desc;var p=new GPolygon(data.points,data.color,data.width,data.opacity,data.fillcolor,data.fillopacity);if(name!=""&&desc!=""){GEvent.addListener(p,"click",function(p,pbounds,overlayvalue,name,desc,clicked){this.hideInfoWindows();overlayvalue.infowindow.setBaseTitle("");overlayvalue.infowindow.setContent("");overlayvalue.infowindow.setBaseTitle(name);var wrapper=new Element("div").update(desc);var contentimages=wrapper.select("img");overlayvalue.infowindow.contentimagescounter=contentimages.size();if(overlayvalue.infowindow.contentimagescounter>0){var countdown=function(event,p,pbounds,overlayvalue,name,desc){overlayvalue.infowindow.contentimagescounter--;if(overlayvalue.infowindow.contentimagescounter==0){this.positionInfowindowRelativeToPoint(overlayvalue,clicked);overlayvalue.infowindow.setContent(wrapper);overlayvalue.infowindow.show();this._map.panTo(clicked);}}.bindAsEventListener(this,p,pbounds,overlayvalue,name,wrapper);contentimages.invoke("observe","load",countdown).invoke("observe","error",countdown);}
else{this.positionInfowindowRelativeToPoint(overlayvalue,clicked);overlayvalue.infowindow.setContent(wrapper);overlayvalue.infowindow.show();this._map.panTo(clicked);}}.bind(this,p,pbounds,overlayvalue,name,desc));}
overlayvalue.data.gpolygons.push(p);this._map.addOverlay(p);},handleKMLRequest:function(overlay,doc,responseCode){if(responseCode==200){this.processKML(GXml.parse(doc),overlay);}else if(responseCode==-1){WJDebugger.log(WJDebugger.ERROR,"Data request timed out. Please try later.");}else{WJDebugger.log(WJDebugger.ERROR,"Request resulted in error. Check XML file is retrievable.");}
this.downloadKML();},processKML:function(xmlDoc,overlay){if(xmlDoc.text!=""){WJDebugger.log(WJDebugger.NOTICE,"Processing "+overlay[0]+" overlay");overlay.value.styles=this.readStyles(xmlDoc.documentElement.getElementsByTagName("Style"));overlay.value.data=this.readData(xmlDoc.documentElement.getElementsByTagName("Placemark"),overlay.value.styles);overlay.value.groundoverlays=this.readGroundOverlays(xmlDoc.documentElement.getElementsByTagName("GroundOverlay"));GEvent.trigger(overlay.value.geoxml,"parsed");WJDebugger.log(WJDebugger.NOTICE,"Processed "+overlay[0]+" overlay");}},readData:function(placemarks,styles){var data={};data.polylines=[];data.polygons=[];data.markers=[];for(var i=0;i<placemarks.length;i++){var chkmlClassName="";var name=this.readKMLValue(placemarks[i].getElementsByTagName("name")[0]);var desc=this.readKMLValue(placemarks[i].getElementsByTagName("description")[0]);if(typeof(placemarks[i].getElementsByTagNameNS)!="undefined"){var spin=this.readKMLValue(placemarks[i].getElementsByTagNameNS("http://www.connectholland.nl/kml/","spin")[0]);}
else{var spin=this.readKMLValue(placemarks[i].getElementsByTagName("chkml:spin").item(0));}
var style=this.readKMLValue(placemarks[i].getElementsByTagName("styleUrl")[0]);var coords=GXml.value(placemarks[i].getElementsByTagName("coordinates")[0]);coords=coords.replace(/\s+/g," ");coords=coords.replace(/^ /,"");coords=coords.replace(/ $/,"");coords=coords.replace(/, /,",");var path=coords.split(" ");if(path.length>1){var points=[];var pbounds=new GLatLngBounds();for(var p=0;p<path.length-1;p++){var bits=path[p].split(",");if(bits[1]!=""){var point=new GLatLng(parseFloat(bits[1]),parseFloat(bits[0]));points.push(point);this._bounds.extend(point);pbounds.extend(point);}}
var linestring=placemarks[i].getElementsByTagName("LineString");if(linestring.length){if(!!styles[style]){var chkmlClassName=styles[style].chkmlClassName;var width=styles[style].width;var color=styles[style].color;var opacity=styles[style].opacity;}else{var width=5;var color="#0000ff";var opacity=0.45;}
data.polylines.push({points:points,width:width,color:color,opacity:opacity,pbounds:pbounds,name:name,desc:desc,chkmlClassName:chkmlClassName});}
var polygons=placemarks[i].getElementsByTagName("Polygon");if(polygons.length){if(!!styles[style]){var chkmlClassName=styles[style].chkmlClassName;var width=styles[style].width;var color=styles[style].color;var opacity=styles[style].opacity;var fillopacity=styles[style].fillopacity;var fillcolor=styles[style].fillcolor;}else{var width=5;var color="#0000ff";var opacity=0.45;var fillopacity=0.25;var fillcolor="#0055ff";}
data.polygons.push({points:points,color:color,width:width,opacity:opacity,fillcolor:fillcolor,fillopacity:fillopacity,pbounds:pbounds,name:name,desc:desc,chkmlClassName:chkmlClassName});}}else{var bits=path[0].split(",");if(!!styles[style]){var chkmlClassName=styles[style].chkmlClassName;}
var chkmlDirections=this.readDirections(placemarks[i]);if(bits[1]!=""&&typeof(bits[1])!="undefined"){var point=new GLatLng(parseFloat(bits[1]),parseFloat(bits[0]));this._bounds.extend(point);data.markers.push({point:point,name:name,desc:desc,styleInfo:style,spin:spin,chkmlClassName:chkmlClassName,chkmlDirections:chkmlDirections});}}}
return data;},readDirections:function(placemark){if(typeof(placemark.getElementsByTagNameNS)!="undefined"){var directionsnode=placemark.getElementsByTagNameNS("http://www.connectholland.nl/kml/","directions")[0];}
else{var directionsnode=placemark.getElementsByTagName("chkml:directions").item(0);}
if(!directionsnode){return false;}
var html=this.readKMLValue(directionsnode);var addTo=(directionsnode.getAttribute("to")=="true");var addFrom=(directionsnode.getAttribute("from")=="true");return{getHtml:function(){return html;},addTo:addTo,addFrom:addFrom}},readGroundOverlays:function(grounds){var parsedGroundOverlays=[];for(var i=0;i<grounds.length;i++){var url=this.readKMLValue(grounds[i].getElementsByTagName("href")[0]);var north=parseFloat(this.readKMLValue(grounds[i].getElementsByTagName("north")[0]));var south=parseFloat(this.readKMLValue(grounds[i].getElementsByTagName("south")[0]));var east=parseFloat(this.readKMLValue(grounds[i].getElementsByTagName("east")[0]));var west=parseFloat(this.readKMLValue(grounds[i].getElementsByTagName("west")[0]));var sw=new GLatLng(south,west);var ne=new GLatLng(north,east);var ground=new GGroundOverlay(url,new GLatLngBounds(sw,ne));this._bounds.extend(sw);this._bounds.extend(ne);parsedGroundOverlays.push(ground);}
return parsedGroundOverlays;},readStyles:function(styles){var parsedStyles={};for(var i=0;i<styles.length;i++){var styleID=styles[i].getAttribute("id");var iconstyle=styles[i].getElementsByTagName("IconStyle");var iconsizeX=32;var iconsizeY=32;var shadowWidth=59;var scale=1;if(iconstyle.length>0){var scalestyle=iconstyle[0].getElementsByTagName("scale");if(scalestyle.length>0){var scale=this.readKMLValue(scalestyle[0]);var iconsizeX=iconsizeX*scale;var iconsizeY=iconsizeY*scale;var shadowWidth=shadowWidth*scale;}
var anchorX=iconsizeX*0.5;var anchorY=iconsizeY;var iwanchorX=iconsizeX*0.5;var iwanchorY=0;var hotspot=iconstyle[0].getElementsByTagName("hotSpot");if(hotspot.length>0){var hotspotpos=this.calculateHotSpot(hotspot[0],iconsizeX,iconsizeY,anchorX,anchorY);anchorX=hotspotpos.x;anchorY=hotspotpos.y;}
if(typeof(iconstyle[0].getElementsByTagNameNS)!="undefined"){var iwhotspot=iconstyle[0].getElementsByTagNameNS("http://www.connectholland.nl/kml/","infowindowHotSpot");var chkmlClassName=this.readKMLValue(iconstyle[0].getElementsByTagNameNS("http://www.connectholland.nl/kml/","infowindowClassName")[0]);var imagemapnode=iconstyle[0].getElementsByTagNameNS("http://www.connectholland.nl/kml/","area");}
else{var iwhotspot=iconstyle[0].getElementsByTagName("chkml:infowindowHotSpot");var chkmlClassName=this.readKMLValue(iconstyle[0].getElementsByTagName("chkml:infowindowClassName").item(0));}
if(iwhotspot.length>0){var iwhotspotpos=this.calculateHotSpot(iwhotspot[0],iconsizeX,iconsizeY,iwanchorX,iwanchorY);iwanchorX=iwhotspotpos.x;iwanchorY=iwhotspotpos.y;}
if((typeof(imagemapnode)!="undefined")&&(imagemapnode.length>0)){var imageMapType=imagemapnode.item(0).getAttribute("shape");var imageMap=imagemapnode.item(0).getAttribute("coords").split(",");}}
var icons=styles[i].getElementsByTagName("Icon");if(icons.length>0){var href=this.readKMLValue(icons[0].getElementsByTagName("href")[0]);if(!!href){var basehref=href.replace(/\.(png|gif)$/i,"");parsedStyles["#"+styleID]=new GIcon(G_DEFAULT_ICON,href);parsedStyles["#"+styleID].iconSize=new GSize(iconsizeX,iconsizeY);parsedStyles["#"+styleID].shadowSize=new GSize(shadowWidth,iconsizeY);parsedStyles["#"+styleID].iconAnchor=new GPoint(anchorX,anchorY);parsedStyles["#"+styleID].dragCrossAnchor=new GPoint(2,8);parsedStyles["#"+styleID].infoWindowAnchor=new GPoint(iwanchorX,iwanchorY);parsedStyles["#"+styleID].shadow=basehref+"-shadow.png";parsedStyles["#"+styleID].printImage=basehref+".gif";parsedStyles["#"+styleID].mozPrintImage=basehref+".gif";if(typeof(imagemapnode)!="undefined"){parsedStyles["#"+styleID].imageMapType=imageMapType;parsedStyles["#"+styleID].imageMap=imageMap;}}}
var linestyles=styles[i].getElementsByTagName("LineStyle");if(linestyles.length>0){var width=parseInt(this.readKMLValue(linestyles[0].getElementsByTagName("width")[0]));if(width<1){width=5;}
var color=this.readKMLValue(linestyles[0].getElementsByTagName("color")[0]);var opacity=parseInt(color.substr(0,2),16)/256;color="#"+color.substr(6,2)+color.substr(4,2)+color.substr(2,2);if(!parsedStyles["#"+styleID]){parsedStyles["#"+styleID]={};}
parsedStyles["#"+styleID].color=color;parsedStyles["#"+styleID].width=width;parsedStyles["#"+styleID].opacity=opacity;}
var polystyles=styles[i].getElementsByTagName("PolyStyle");if(polystyles.length>0){if(!parsedStyles["#"+styleID]){parsedStyles["#"+styleID]={};}
var fill=parseInt(GXml.value(polystyles[0].getElementsByTagName("fill")[0]));if(polystyles[0].getElementsByTagName("fill").length==0){fill=1;}
var outline=parseInt(GXml.value(polystyles[0].getElementsByTagName("outline")[0]));if(polystyles[0].getElementsByTagName("outline").length==0){outline=1;}
var color=this.readKMLValue(polystyles[0].getElementsByTagName("color")[0]);var opacity=parseInt(color.substr(0,2),16)/256;color="#"+color.substr(6,2)+color.substr(4,2)+color.substr(2,2);parsedStyles["#"+styleID].fillcolor=color;parsedStyles["#"+styleID].fillopacity=opacity;if(!fill){parsedStyles["#"+styleID].fillopacity=0;}
if(!outline){parsedStyles["#"+styleID].opacity=0;}}
parsedStyles["#"+styleID].chkmlClassName=chkmlClassName;}
return parsedStyles;},calculateHotSpot:function(hotspot,iconsizeX,iconsizeY,anchorX,anchorY){var xunits=hotspot.getAttribute("xunits");var yunits=hotspot.getAttribute("yunits");var xval=hotspot.getAttribute("x");var yval=hotspot.getAttribute("y");var anchorX=(xunits=="fraction")?(iconsizeX*xval):anchorX;var anchorX=(xunits=="pixels")?xval:anchorX;var anchorX=(xunits=="insetPixels")?(iconsizeX-xval):anchorX;var anchorY=(yunits=="fraction")?(iconsizeY*yval):anchorY;var anchorY=(yunits=="pixels")?yval:anchorY;var anchorY=(yunits=="insetPixels")?(iconsizeY-yval):anchorY;return{x:anchorX,y:anchorY};},readKMLValue:function(node){return GXml.value(node).replace(/^\s*/,"").replace(/\s*$/,"");},positionInfowindowRelativeToMarker:function(overlayvalue){if(typeof(overlayvalue.lastmarker)=="undefined"){return;}
var fullheight=overlayvalue.infowindow.getFullHeight();if(fullheight>this._map.getContainer().getHeight()){var newheight=overlayvalue.infowindow.getContentHeight()-(fullheight-this._map.getContainer().getHeight());fullheight=overlayvalue.infowindow.setHeight(newheight,null,false).getFullHeight();}
var p=this._map.fromLatLngToDivPixel(overlayvalue.lastmarker.getLatLng());var icon=overlayvalue.lastmarker.getIcon();var halfwidth=(overlayvalue.infowindow.getWidth()/2);var offsety=(icon.iconAnchor.y-icon.infoWindowAnchor.y);p.y-=offsety;p.x-=(icon.iconAnchor.x-icon.infoWindowAnchor.x);p.y-=fullheight;p.x-=halfwidth;overlayvalue.infowindow.setX(p.x);overlayvalue.infowindow.setY(p.y);overlayvalue.infowindow.getPushpinWindowConnectorElement().setStyle({"left":((halfwidth+overlayvalue.infowindow.getStyleSetting("pushpinwindowconnector-left"))-offsety)+"px"});var newy=p.y+((overlayvalue.infowindow.getFullHeight()+icon.iconSize.height)/2);var newx=p.x+halfwidth;return new GPoint(newx,newy);},positionInfowindowRelativeToPoint:function(overlayvalue,point){var p=this._map.fromLatLngToDivPixel(point);var halfwidth=(overlayvalue.infowindow.getWidth()/2);p.y-=overlayvalue.infowindow.getFullHeight();p.x-=halfwidth;overlayvalue.infowindow.setX(p.x);overlayvalue.infowindow.setY(p.y);overlayvalue.infowindow.getPushpinWindowConnectorElement().setStyle({"left":(halfwidth+overlayvalue.infowindow.getStyleSetting("pushpinwindowconnector-left"))+"px"});var newy=p.y;var newx=p.x+halfwidth;return new GPoint(newx,newy);}});var WJChapCB=Class.create({initialize:function(chapid,chaptarget){this._chapid=chapid;this._target=$(chaptarget);this._load();},_load:function(){var spin=new WJSpin();var url=new WJUrl({"ct":"wmdynamic","blockid":this._chapid,"module":"Wmchapblock","wmtrigger[]":["requestufts"],"uft[]":["sideblock"]});spin.content(url,[this._target,this.updateBlock.bind(this)]);},updateBlock:function(response){if(this._target){var title=this._target.select(".chap_rsstitle").first();if(title){this._target.up(".chap_block").select(".chap_title .chap_content h1").first().update(title.innerHTML);}
var icon=this._target.select(".chap_rssicon").first();if(icon){this._target.up(".chap_block").select(".chap_title .chap_content .chap_icon").first().update(icon.innerHTML);}}}});var WJImageBannerCB=Class.create({initialize:function(img,newsrc){img=$(img);if(img.tagName.toLowerCase()!="img"){if(img.down("img")){img=img.down("img");}
else{img=false;}}
if(!img){return;}
this._img=img;var src=this._img.src;src=src.replace(/(^[^\/]+\/\/[^\/]+\/)/,"/");this._basepath="";var basepath=src.match(/(\/images\/thumbs(\/__[^\/]*)*)\/?/);if(basepath){this._basepath=basepath[1];src=src.replace(/(^([^\/]+\/\/[^\/]+)?\/images\/thumbs(\/+__[^\/]*)*)\/*/,"/");}
this._src=src;this._newsrc=newsrc;this._newimg=new Image();Event.observe(this._newimg,"load",function(){this._img.observe("mouseover",this.swap.bindAsEventListener(this,this._newsrc));this._img.observe("mouseout",this.swap.bindAsEventListener(this,this._src));}.bind(this));this._newimg.src=this._basepath+this._newsrc;},swap:function(event,src){this._img.src=this._basepath+src;}});var WJTransition=Class.create({initialize:function(){},init:function(elementTransition,properties){this.elementTransition=elementTransition;this.properties=this._getProperties(properties);},_getProperties:function(properties){return properties;},transit:function(){var from=this.elementTransition.getFromElement();var to=this.elementTransition.getToElement();if(from&&to){this._doTransition(from,to);}
else{WJDebugger.log(WJDebugger.ERROR,"Transition not ready, to and from should both be set but at least one isn't, logging both, to first then from",to,from);}
this.elementTransition.notifyDone();},_doTransition:function(from,to){from.replace(to);}});var WJElementTransition=Class.create({initialize:function(properties){var properties=properties||{};this.properties=this._getProperties(properties);},_getProperties:function(properties){return properties;},setFromElement:function(from){this.from=from;},setToElement:function(to){this.to=to;},getFromElement:function(from){return this.from},getToElement:function(to){return this.to;},notifyDone:function(){this.from=this.to;}});var WJBackgroundImage=Class.create();WJBackgroundImage.prototype={_started:false,initialize:function(backgroundimage,element){if(Object.isString(backgroundimage)&&!backgroundimage.strip().empty()){this.backgroundimage=backgroundimage;this.element=element||document.body;this.sizeelement=element||document.viewport;Element.extend(this.element);Event.observe(window,"resize",this.resizeImage.bindAsEventListener(this),false);this._started=true;}
else{WJDebugger.log(WJDebugger.ERROR,"Trying to run",this,"without a source, you have to overwrite the backgroundImageImgSrc template in your UFT");}},toString:function(){return"WJBackgroundImage";},resizeImage:function(resize_x,resize_y){if(this._started){var sizeelement=this.sizeelement.getDimensions();var height=(sizeelement.height-(sizeelement.height%25))+25+100;var width=(sizeelement.width-(sizeelement.width%25))+25;var image=new Image();Event.observe(image,"load",this.setBackgroundImage.bindAsEventListener(this,image));Event.observe(image,"error",this.noBackgroundImage.bindAsEventListener(this,image));if(resize_x&&resize_y){image.src="/images/thumbs/__rw"+width+"h"+height+this.backgroundimage;}
else if(resize_x&&!resize_y){image.src="/images/thumbs/__lw"+width+"h"+(height+3000)+this.backgroundimage;}
else if(!resize_x&&resize_y){image.src="/images/thumbs/__lw"+(width+5000)+"h"+height+this.backgroundimage;}
else{image.src="/images/thumbs/"+this.backgroundimage;}}},setBackgroundImage:function(event,image){WJDebugger.log(WJDebugger.INFO,"Adding a backgroundimage",image,"to",this.element);this.element.setStyle({backgroundImage:"url(\""+image.src+"\")"});},noBackgroundImage:function(event,image){WJDebugger.log(WJDebugger.ERROR,"Trying to add a backgroundimage that doesn't exist",image,event);}};var WJMediaTransition=Class.create(WJElementTransition,{initialize:function($super,properties){$super(properties);},_getProperties:function(properties){var defaults={width:500,height:500,background:"ffffff",backgroundResize:true,crop:false};for(var key in defaults){var properties_keys=Object.keys(properties);if(properties_keys.include(key)){defaults[key]=properties[key];}}
return defaults;},_getOperations:function(){var sizeinfo="w"+this.properties.width+"h"+this.properties.height;if(this.properties.backgroundResize){return"__bc"+this.properties.background+sizeinfo;}
else if(this.properties.crop){return"__r"+sizeinfo+"/__c"+sizeinfo;}
else{return"__l"+sizeinfo;}},setToImage:function(image){this.setToElement(new Element("img",{src:"/images/thumbs/"+this._getOperations()+image}));},setToVideo:function(video){this.setToElement(new Element("img",{src:"/images/thumbs/"+this._getOperations()+video+".png"}));}});var WJTransitionAppear=Class.create(WJTransition,{initialize:function(){},_doTransition:function(from,to){to.setStyle({"display":"none"});from.up().insert(to);from.up().setStyle({"height":from.getHeight()+"px"});Effect.Fade(from,{duration:1});Effect.Appear.bind(Effect,to).delay(1);from.remove.bind(from).delay(1.5);}});var WJTransitionBlind=Class.create(WJTransition,{initialize:function(){},_doTransition:function(from,to){to.setStyle({"display":"none"});from.up().insert(to);Effect.BlindUp(from,{duration:1});Effect.BlindDown.bind(Effect,to).delay(1);from.remove.bind(from).delay(1);}});