[ Mini Kiebo ]
Server: Windows NT DESKTOP-5B8S0D4 6.2 build 9200 (Windows 8 Professional Edition) i586
Path:
D:
/
xampp182
/
htdocs
/
simpeg
/
administrator
/
src
/
[
Home
]
File: window.js
/* * * Copyright (c) 2004-2005 by Zapatec, Inc. * http://www.zapatec.com * 1700 MLK Way, Berkeley, California, * 94709, U.S.A. * All rights reserved. * * */ Zapatec.windowPath = Zapatec.getPath("Zapatec.WindowWidget"); Zapatec.Button=function(objArgs){if(arguments.length==0){objArgs={};} Zapatec.Button.SUPERconstructor.call(this,objArgs);};Zapatec.Button.id="Zapatec.Button";Zapatec.inherit(Zapatec.Button,Zapatec.Widget);Zapatec.Button.prototype.init=function(objArgs){this.config.image=null;this.config.width=null;this.config.height=null;this.config.className=null;this.config.style=null;this.config.text="";this.config.preloadImages=true;this.config.overStyle=null;this.config.overClass=null;this.config.overImage=null;this.config.overAction=null;this.config.outAction=null;this.config.downStyle=null;this.config.downClass=null;this.config.downImage=null;this.config.downAction=null;this.config.downActionDelay=500;this.config.repeatAcceleration=0.8;this.config.repeatStartSpeed=55;this.config.repeatMaxSpeed=5;this.config.clickAction=null;this.config.idPrefix=null;this.config.themePath=Zapatec.zapatecPath+"../zpextra/themes/button/";Zapatec.Button.SUPERclass.init.call(this,objArgs);if(!this.config.idPrefix){this.config.idPrefix="zpButton"+this.id;} this.container=null;this.statusContainer=null;this.internalContainer=null;this.img=null;this.enabled=true;this.isPressed=false;this.createButton();};Zapatec.Button.prototype.createButton=function(){Zapatec.Utils.createProperty(this,'container',Zapatec.Utils.createElement("span"));this.container.id=this.config.idPrefix+"Container";Zapatec.Utils.createProperty(this,'statusContainer',Zapatec.Utils.createElement("span"));this.statusContainer.className="mouseOut";this.statusContainer.id=this.config.idPrefix+"Status";this.container.appendChild(this.statusContainer);Zapatec.Utils.createProperty(this,'internalContainer',Zapatec.Utils.createElement("span"));this.internalContainer.className="internalContainer";this.internalContainer.id=this.config.idPrefix+"Internal";this.statusContainer.appendChild(this.internalContainer);Zapatec.Utils.addClass(this.container,this.getClassName({prefix:"zpButton"+(this.config.image!=null?"Image":""),suffix:"Container"}));if(this.config.width!=null){this.internalContainer.style.width=this.config.width+"px";} if(this.config.height!=null){this.internalContainer.style.width=this.config.height+"px";} if(this.config.className!=null){Zapatec.Utils.addClass(this.internalContainer,this.config.className);} if(this.config.style!=null){this.applyStyle(this.config.style);} var self=this;Zapatec.Utils.createProperty(this.container,'onmouseover',function(ev){return self.onmouseover(ev,false);});Zapatec.Utils.createProperty(this.container,'onmouseout',function(ev){return self.onmouseout(ev);});Zapatec.Utils.createProperty(this.container,'onmousedown',function(ev){return self.onmousedown(ev);});Zapatec.Utils.createProperty(this.container,'onmouseup',function(ev){return self.onmouseover(ev,true);});Zapatec.Utils.addEvent(document,'mouseup',function(ev){self._mousedown=false;});Zapatec.Utils.createProperty(this.container,'onclick',function(ev){return self.onclick(ev);});if(this.config.image!=null){Zapatec.Utils.createProperty(this,'img',document.createElement("img"));this.img.src=this.config.image;this.img.alt=this.config.text;this.img.title=this.config.text;this.internalContainer.appendChild(this.img);}else{this.internalContainer.innerHTML=this.config.text;this.internalContainer.style.whiteSpace="nowrap";} if(this.config.preloadImages==true){this.preloadImages();}};Zapatec.Button.prototype.onmouseover=function(ev,mouseup){if(!this.isEnabled()){return false;} if(typeof(ev)=='undefined'){ev=window.event;} if(mouseup){this._mousedown=false;} this.toggleClass("mouseOver");if(this.config.image!=null&&this.config.overImage!=null){this.img.src=this.config.overImage;} if(this.config.overClass!=null){Zapatec.Utils.addClass(this.internalContainer,this.config.overClass);} if(this.config.overStyle!=null){this.applyStyle(this.config.overStyle);} if(this._timeoutId){clearTimeout(this._timeoutId);} if(this._mousedown){this._repeatDownAction();} if(this.config.overAction!=null){return this.config.overAction(ev,this);} return true;};Zapatec.Button.prototype.onmouseout=function(ev){if(!this.isEnabled()){return false;} if(typeof(ev)=='undefined'){ev=window.event;} if(!this.isPressed){this.toggleClass("mouseOut");if(this.config.image!=null){this.img.src=this.config.image;} if(this.config.outClass!=null){Zapatec.Utils.addClass(this.internalContainer,this.config.outClass);}} else{this.toggleClass("mouseDown");if(this.config.image!=null&&this.config.downImage!=null){this.img.src=this.config.downImage;} if(this.config.downClass!=null){Zapatec.Utils.addClass(this.internalContainer,this.config.downClass);}} if(this.config.style!=null){this.applyStyle(this.config.style);} if(this._mousedown){this._pauseRepeat();} if(this.config.outAction!=null){return this.config.outAction(ev,this);} return true;};Zapatec.Button.prototype.onmousedown=function(ev){if(!this.isEnabled()){return false;} var self=this;if(typeof(ev)=='undefined'){ev=window.event;} this._mousedown=true;this.toggleClass("mouseDown");if(this.config.image!=null&&this.config.downImage!=null){this.img.src=this.config.downImage;} if(this.config.downClass!=null){Zapatec.Utils.addClass(this.internalContainer,this.config.downClass);} if(this.config.downStyle!=null){this.applyStyle(this.config.downStyle);} if(this.config.downAction!=null){this._timeoutId=setTimeout(function(){self._repeatSpeed=self.config.repeatStartSpeed;self._repeatDownAction(ev);},this.config.downActionDelay);return this.config.downAction(ev,this);} return true;};Zapatec.Button.prototype.onclick=function(ev){if(!this.isEnabled()){return false;} if(typeof(ev)=='undefined'){ev=window.event;} if(this._timeoutId){clearTimeout(this._timeoutId);} this._timeoutId=null;this._mousedown=false;if(this.config.clickAction!=null){return this.config.clickAction(ev,this);} return true;};Zapatec.Button.prototype._repeatDownAction=function(ev){if(this.config.downAction!=null){this.config.downAction(ev,this);} if(this._repeatSpeed>this.config.repeatMaxSpeed){this._repeatSpeed=Math.round(this.config.repeatAcceleration*this._repeatSpeed);} var self=this;this._timeoutId=setTimeout(function(){self._repeatDownAction();},this._repeatSpeed);};Zapatec.Button.prototype._pauseRepeat=function(){if(this._timeoutId){clearTimeout(this._timeoutId);this._timeoutId=null;}};Zapatec.Button.prototype.preloadImages=function(){if(this.config.image!=null){var images=[this.config.image];if(this.config.overImage!=null){images.push(this.config.overImage);} if(this.config.downImage!=null){images.push(this.config.downImage);} Zapatec.Transport.preloadImages({urls:images});}};Zapatec.Button.prototype.setPressed=function(isPressed){this.isPressed=isPressed;if(isPressed){this.toggleClass('mouseDown');}else{this.toggleClass('mouseOut');}};Zapatec.Button.prototype.toggleClass=function(className){Zapatec.Utils.removeClass(this.statusContainer,"mouseOver");Zapatec.Utils.removeClass(this.statusContainer,"mouseOut");Zapatec.Utils.removeClass(this.statusContainer,"mouseDown");Zapatec.Utils.removeClass(this.statusContainer,"disabled");Zapatec.Utils.removeClass(this.internalContainer,this.config.overClass);Zapatec.Utils.removeClass(this.internalContainer,this.config.downClass);if(className!=null){Zapatec.Utils.addClass(this.statusContainer,className);}};Zapatec.Button.prototype.getContainer=function(){return this.container;};Zapatec.Button.prototype.applyStyle=function(style){Zapatec.Utils.applyStyle(this.internalContainer,style);};Zapatec.Button.prototype.isEnabled=function(){return this.enabled;};Zapatec.Button.prototype.enable=function(){this.enabled=true;this.toggleClass("mouseOut");};Zapatec.Button.prototype.disable=function(){this.enabled=false;this.toggleClass("disabled");};Zapatec.Button.prototype.setText=function(text){this.internalContainer.innerHTML=text;};Zapatec.Button.prototype.getText=function(){return this.internalContainer.innerHTML;};Zapatec.Button.setup=function(elRef,config){elRef=Zapatec.Widget.getElementById(elRef);if(elRef==null){return null;} if(config==null){config={};} var nodeName=elRef.nodeName.toLowerCase();var oldOverAction=config.overAction!=null?config.overAction:function(){return true;};config.overAction=function(ev){return((elRef.onmouseover!=null?elRef.onmouseover.call(ev):true)&&oldOverAction(ev));};var oldOutAction=config.outAction!=null?config.outAction:function(){return true;};config.outAction=function(ev){return((elRef.onmouseout!=null?elRef.onmouseout.call(ev):true)&&oldOutAction(ev));};var oldDownAction=config.downAction!=null?config.downAction:function(){return true;};config.downAction=function(ev){return((elRef.onmousedown!=null?elRef.onmousedown.call(ev):true)&&oldDownAction(ev));};var oldClickAction=config.clickAction!=null?config.clickAction:function(){return true;};config.clickAction=function(ev){return((elRef.onclick!=null?elRef.onclick.call(ev):true)&&oldClickAction(ev));};var submitAction=function(ev){if(elRef.form!=null&&elRef.zpHidden==null){var hidden=document.createElement("input");hidden.type='hidden';hidden.name=elRef.name;hidden.value=elRef.value;hidden.style.display='none';Zapatec.Utils.insertAfter(elRef,hidden);elRef.zpHidden=hidden;} if(elRef.form&&elRef.form.onSubmit!=null){elRef.form.onSubmit();} return((elRef.onclick!=null?elRef.onclick.call(ev):true)&&oldClickAction(ev)&&(elRef.form!=null?elRef.form.submit():true));};if(nodeName=='button'){config.text=elRef.value;}else if(nodeName=='img'){config.image=elRef.src;config.text=elRef.title||elRef.title;}else if(nodeName=='div'||nodeName=='span'){config.text=elRef.innerHTML;}else if(nodeName=='input'){config.text=elRef.value;if(elRef.type.toLowerCase()=='image'){config.image=elRef.src;config.clickAction=submitAction;}else if(elRef.type.toLowerCase()=='button'){}else if(elRef.type.toLowerCase()=='submit'){config.clickAction=submitAction;}else if(elRef.type.toLowerCase()=='reset'){config.clickAction=function(ev){(elRef.onclick!=null?elRef.onclick.call(ev):true)&&oldClickAction(ev)&&(elRef.form!=null?elRef.form.reset():true)};}else{return null;}}else{return null;} var button=new Zapatec.Button(config);Zapatec.Utils.insertAfter(elRef,button.getContainer());elRef.disabled=true;elRef.style.display='none';return button;};Zapatec.Button.setupAll=function(elRef,config){if(typeof(elRef)=='string'){elRef=document.getElementById(elRef);} if(elRef==null){return null;} var childs=elRef.all?elRef.all:elRef.getElementsByTagName("*");function cloneConfig(){var cfg={};for(var option in config){cfg[option]=config[option];} return cfg;} for(var ii=0;ii<childs.length;ii++){if(childs[ii].nodeType==1&&(childs[ii].nodeName.toLowerCase()=='button'||childs[ii].nodeName.toLowerCase()=='input'&&(childs[ii].type.toLowerCase()=='image'||childs[ii].type.toLowerCase()=='button'||childs[ii].type.toLowerCase()=='submit'||childs[ii].type.toLowerCase()=='reset'))){Zapatec.Button.setup(childs[ii],cloneConfig());}}};Zapatec.Button.prototype.destroy=function(){this.container.onmouseover=null;this.container.onmouseout=null;this.container.onmousedown=null;this.container.onmouseup=null;this.container.onclick=null;this.internalContainer=null;this.statusContainer=null;this.container=null;return null;};Zapatec.Array=function(arr){if(!Zapatec.isArray(arr)){var array=[];for(var i=0;i<arguments.length;++i){array.push(arguments[i]);} arr=array;} arr.clear=function(){Zapatec.Array.clear(this);};arr.compact=function(){var compact=Zapatec.Array.compact(this);return Zapatec.Array(compact);};arr.indexOf=function(value){return Zapatec.Array.indexOf(this,value);};arr.without=function(){var args=[].slice.call(arguments,0);args.unshift(this);var without=Zapatec.Array.without.apply(Zapatec.Array,args);return Zapatec.Array(without);};arr.remove=function(){var args=[].slice.call(arguments,0);args.unshift(this);var cut=Zapatec.Array.remove.apply(Zapatec.Array,args);return Zapatec.Array(cut);};arr.each=function(func,reverse){var result;for(var index=reverse?this.length-1:0;reverse?(index>=0):(index<this.length);reverse?--index:++index){if(typeof func=="function"){result=func(index,this[index],this);if(result=="break"){break;}}} if(result=="break"){return false;} return true;};arr.isZpArray=true;return arr;};Zapatec.Array.compact=function(arr){var newArr=[];for(var item=0;item<arr.length;++item){if(arr[item]!==null&&typeof arr[item]!="undefined"){newArr.push(arr[item]);}} return newArr;};Zapatec.Array.clear=function(arr){arr.length=0;};Zapatec.Array.indexOf=function(arr,value){for(var item=0;item<arr.length;++item){if(arr[item]===value){return item;}} return-1;};Zapatec.Array.without=function(arr){var newArr=[],without;for(var item=0;item<arr.length;++item){without=false;for(var value=1;value<arguments.length;++value){if(arr[item]===arguments[value]){without=true;break;}} if(!without){newArr.push(arr[item]);}} return newArr;};Zapatec.Array.remove=function(arr){var newArr=[],without,value,start=1;if(arguments[1]&&arguments[1].length&&typeof arguments[1]=="object"){args=arguments[1];start=0;}else{args=arguments;} for(var item=0;item<arr.length;++item){without=false;for(value=start;value<args.length;++value){if(item===args[value]){without=true;break;}} if(!without){newArr.push(arr[item]);}} return newArr;};Zapatec.Hash=function(hash){if(!hash||typeof hash!="object"){hash={};} hash.hashRemove=function(){var args=[].slice.call(arguments,0);args.unshift(this);var without=Zapatec.Hash.remove.apply(Zapatec.Hash,args);return Zapatec.Hash(without);};hash.hashEach=function(func){var result=null;for(var prop in this){if(prop=="hashRemove"||prop=="hashEach"||prop=="hashIsEmpty"||prop=="isZpHash"){continue;} if(typeof Object.prototype[prop]!="undefined"){continue;} result=func(prop,this[prop],this);if(result=="break"){break;}} if(result=="break"){return false;} return true;};hash.hashIsEmpty=function(){var empty=true;this.hashEach(function(){empty=false;return"break";});return empty;};hash.isZpHash=true;return hash;};Zapatec.Hash.remove=function(hash){var newHash={},without,value,start=1;if(arguments[1]&&arguments[1].length&&typeof arguments[1]=="object"){args=arguments[1];start=0;}else{args=arguments;} for(var item in hash){without=false;for(value=start;value<args.length;++value){if(item===args[value]){without=true;break;}} if(!without){newHash[item]=hash[item];}} return newHash;};Zapatec.Hash.getByPath=function(hash,path){if(!path||typeof path!="string"){Zapatec.Log({description:"Not a path passed to Zapatec.Hash.getByPath function!",type:"warning"});return{result:false};} var paths=path.split(".");if(!paths.length){Zapatec.Log({description:"Wrong path passed to Zapatec.Hash.getByPath function!",type:"warning"});return{result:false};} var item=0;var value=hash;var name="";var scope=null;while(paths[item]){if(value===null||typeof value=="undefined"){Zapatec.Log({description:"Incorrect path passed to Zapatec.Hash.getByPath function!",type:"warning"});return{result:false};} name=paths[item].replace(/(\(\)|\[[^\[\]]+\])+/,"");try{scope=value;value=value[name];}catch(e){Zapatec.Log({description:"Incorrect path passed to Zapatec.Hash.getByPath function!",type:"warning"});return{result:false};} paths[item]=paths[item].replace(name,"");while(paths[item]!=""){name=paths[item].match(/(\(\)|\[[^\[\]]+\])/)[1];if(name&&/\(\)$/.test(name)){try{value=value.call(scope||value);scope=null;}catch(e){Zapatec.Log({description:"Incorrect path passed to Zapatec.Hash.getByPath function!",type:"warning"});return{result:false};}}else if(name&&/\[["']?[^\[\]"']+["']?\]$/.test(name)){try{value=value[name.match(/\[["']?([^\[\]"']+)["']?\]/)[1]];scope=null;}catch(e){Zapatec.Log({description:"Incorrect path passed to Zapatec.Hash.getByPath function!",type:"warning"});return{result:false};}} paths[item]=paths[item].replace(name,"");} ++item;} if(typeof value=="undefined"){Zapatec.Log({description:"Incorrect path passed to Zapatec.Hash.getByPath function!",type:"warning"});return{result:false};} return{result:true,value:value};};Zapatec.Hash.setByPath=function(hash,path,val){if(!path||typeof path!="string"){Zapatec.Log({description:"Not a path passed to Zapatec.Hash.setByPath function!",type:"warning"});return false;} var paths=path.split(".");if(!paths.length){Zapatec.Log({description:"Wrong path passed to Zapatec.Hash.setByPath function!",type:"warning"});return false;} var lastItem=paths[paths.length-1];var obj=hash;var getPath=paths.slice(0,-1).join(".");var arrIndexReg=/\[[^\[\]]+\]$/;if(arrIndexReg.test(lastItem)){getPath+=(getPath==""?"":".")+lastItem.replace(arrIndexReg,"");lastItem=lastItem.match(/\[["']?([^\[\]"']+)["']?\]$/)[1];} if(getPath!=""){var obj=Zapatec.Hash.getByPath(hash,getPath).value;} try{obj[lastItem]=val;}catch(e){Zapatec.Log({description:"Incorrect path passed to Zapatec.Hash.setByPath function!",type:"warning"});return false;} return true;};Zapatec.isHtmlElement=function(el){if(!el||el.nodeType!=1){return false;} return true;};Zapatec.isSizableObj=function(obj){if(obj&&obj.hasInterface&&obj.hasInterface("Zapatec.Sizable")){return true;} return false;};Zapatec.isMovableObj=function(obj){if(obj&&obj.hasInterface&&obj.hasInterface("Zapatec.Movable")){return true;} return false;};Zapatec.isArray=function(arr){if(arr&&typeof arr=="object"&&arr.constructor==Array){return true;} return false;};Zapatec.isDate=function(date){if(date&&typeof date=="object"&&date.constructor==Date){return true;} return false;};Zapatec.SRProp=function(obj){this.obj=obj;this.savedProps=new Zapatec.Hash();Zapatec.Utils.createProperty(obj,"restorer",this);} Zapatec.SRProp.prototype.getSavedProps=function(){return this.savedProps;};Zapatec.SRProp.prototype.getObject=function(){return this.obj;};Zapatec.SRProp.prototype.saveProp=function(propName){if(typeof propName!="string"){return false;} var value=Zapatec.Hash.getByPath(this.getObject(),propName);if(value.result){if(typeof this.getProp(propName)!="undefined"){var prop=this.getSavedProps()[propName]=Zapatec.Array(this.getSavedProps()[propName]);prop.push(value.value);prop.combination=true;Zapatec.Log({description:"The property '"+propName+"' now contains more than one value!",type:"warning"});}else{this.getSavedProps()[propName]=value.value;} return true;}else{return false;}} Zapatec.SRProp.prototype.saveProps=function(){var result=[];for(var i=0;i<arguments.length;++i){if(this.saveProp(arguments[i])){result.push(arguments[i]);}} return result;} Zapatec.SRProp.prototype.restoreProp=function(propName){if(typeof propName!="string"||typeof this.getSavedProps()[propName]=="undefined"){return false;} var prop=this.getSavedProps()[propName];var combination=false,nextSibling=null;if(Zapatec.isArray(prop)&&prop.combination){prop=prop[prop.length-1];combination=true;} if(propName.match(/parentNode$/)!==null&&prop&&typeof prop=="object"&&prop.appendChild){nextSibling=this.getSavedProps()[propName.replace(/parentNode/,"nextSibling")]||null;if(nextSibling&&nextSibling.parentNode==prop){prop.insertBefore(this.getObject(),nextSibling);}else{prop.appendChild(this.getObject());} this.savedProps=this.getSavedProps().hashRemove(propName.replace(/parentNode/,"nextSibling"));}else{if(!Zapatec.Hash.setByPath(this.getObject(),propName,prop)){return false;}} if(!combination){this.savedProps=this.getSavedProps().hashRemove(propName);}else{prop=this.getSavedProps()[propName];this.getSavedProps()[propName]=Zapatec.Array.without(prop,prop.length-1);} return true;} Zapatec.SRProp.prototype.restoreProps=function(propName){var result=[];for(var i=0;i<arguments.length;++i){if(this.restoreProp(arguments[i])){result.push(arguments[i]);}} return result;} Zapatec.SRProp.prototype.restoreAll=function(){var self=this;this.getSavedProps().hashEach(function(i){self.restoreProp(i);});} Zapatec.SRProp.prototype.getProp=function(propName){return this.getSavedProps()[propName];} Zapatec.SRProp.prototype.isEmpty=function(){return this.getSavedProps().hashIsEmpty();};Zapatec.SRProp.prototype.destroy=function(){this.getObject().restorer=null;for(var iProp in this){this[iProp]=null;} return null;};Zapatec.CommandEvent={};Zapatec.CommandEvent.fireEvent=function(strEvent){if(!this.events[strEvent]){return;} var arrListeners=this.events[strEvent].listeners.slice();this._setReturnedValue(null);this._setEventPropagation(true);for(var iListener=0;iListener<arrListeners.length;iListener++){var arrArgs=[].slice.call(arguments,1);arrListeners[iListener].apply(this,arrArgs);var result=this._getReturnedValue();if(!this._getEventPropagation()){return result;} if(result=="re-execute"){this.fireEvent(strEvent);break;}else if(result=="parent-re-execute"){return result;}} return this._getReturnedValue();};Zapatec.CommandEvent.returnValue=function(val){this._setReturnedValue(val);};Zapatec.CommandEvent._setReturnedValue=function(val){this.returnedValue=val;};Zapatec.CommandEvent._getReturnedValue=function(){return this.returnedValue;};Zapatec.CommandEvent.stopPropagation=function(){this._setEventPropagation(false);};Zapatec.CommandEvent._setEventPropagation=function(on){this.eventPropagation=on;};Zapatec.CommandEvent._getEventPropagation=function(){return this.eventPropagation;};Zapatec.GlobalEvents=new Zapatec.EventDriven();Zapatec.implement(Zapatec.GlobalEvents,"Zapatec.CommandEvent");Zapatec.GlobalEvents.init();Zapatec.Utils.getWidth=function(el){if(!Zapatec.isHtmlElement(el)){return false;} return el.offsetWidth};Zapatec.Utils.getHeight=function(el){if(!Zapatec.isHtmlElement(el)){return false;} return el.offsetHeight};Zapatec.Utils.setWidth=function(el,width){width=Math.round(width);if(!Zapatec.isHtmlElement(el)||width<=0){return false;} var oldWidth=el.style.width,newWidth;el.style.width=width+"px";if(Zapatec.Utils.getWidth(el)!=width){newWidth=width-(Zapatec.Utils.getWidth(el)-width);if(newWidth>0){el.style.width=newWidth+"px";if(Zapatec.Utils.getWidth(el)!=width){el.style.width=oldWidth;Zapatec.Log({description:"Can't set the width - "+width+"px!",type:"warning"});return false;}}else{el.style.width=oldWidth;Zapatec.Log({description:"Can't set the width - "+width+"px!",type:"warning"});return false;}} return true;};Zapatec.Utils.setHeight=function(el,height){height=Math.round(height);if(!Zapatec.isHtmlElement(el)||height<=0){return false;} var oldHeight=el.style.height,newHeight;el.style.height=height+"px";if(Zapatec.Utils.getHeight(el)!=height){newHeight=height-(Zapatec.Utils.getHeight(el)-height);if(newHeight>0){el.style.height=newHeight+"px";if(Zapatec.Utils.getHeight(el)!=height){el.style.height=oldHeight;Zapatec.Log({description:"Can't set the height - "+height+"px!",type:"warning"});return false;}}else{el.style.height=oldHeight;Zapatec.Log({description:"Can't set the height - "+height+"px!",type:"warning"});return false;}} return true;};Zapatec.Utils.fixateWidth=function(el){return Zapatec.Utils.setWidth(el,Zapatec.Utils.getWidth(el));};Zapatec.Utils.fixateHeight=function(el){return Zapatec.Utils.setHeight(el,Zapatec.Utils.getHeight(el));};Zapatec.Utils.makeSafelySizable=function(el,restorer){if(el.sizable){return true;} if(!Zapatec.isHtmlElement(el)){return false;} if(!restorer){restorer=el.restorer;} if(!restorer||!restorer.getObject||restorer.getObject()!=el){restorer=new Zapatec.SRProp(el);} restorer.saveProps("style.width","style.height","style.overflow");Zapatec.Utils.fixateWidth(el);Zapatec.Utils.fixateHeight(el);var overflow=Zapatec.Utils.getStyleProperty(el,"overflow");if(overflow==""||overflow=="visible"){Zapatec.Log({description:"There is the chance that this element with overflow visible will not be sized correctly!",type:"warning"});} el.sizable=true;return true;};Zapatec.Utils.restoreOfSizing=function(el){if(!el||!el.restorer||!el.sizable){return false;} el.restorer.restoreProps("style.width","style.height","style.overflow");if(el.restorer.isEmpty()){el.restorer.destroy();} el.sizable=false;return true;};Zapatec.Utils.makeSafelyMovable=function(el,within,restorer){if(!Zapatec.isHtmlElement(el)){return false;} if(!within){within=document.body;} if(el.within==within){return true;} if(!restorer){restorer=el.restorer;} if(!restorer||!restorer.getObject||restorer.getObject()!=el){restorer=new Zapatec.SRProp(el);} el.within=within;if(within!=document.body&&within.style.position!="absolute"){restorer.saveProp("within.style.position");within.style.position="relative";} if(within!=document.body){var pos1=Zapatec.Utils.getElementOffset(within);}else{var pos1={x:0,y:0};} var pos2=Zapatec.Utils.getElementOffset(el);var x=pos2.x-pos1.x;var y=pos2.y-pos1.y;restorer.saveProps("style.left","style.top");el.style.left=x+"px";el.style.top=y+"px";if(el.style.position!="absolute"){restorer.saveProp("style.position");el.style.position="absolute";} if(el.parentNode!=within){restorer.saveProps("parentNode","nextSibling");within.appendChild(el);} restorer.saveProp("style.margin");el.style.margin="0px";return true;};Zapatec.Utils.moveTo=function(el,x,y){if(!Zapatec.isHtmlElement(el)){return false;} var pos=null;if(Zapatec.FixateOnScreen.isRegistered(el)){pos=Zapatec.FixateOnScreen.correctCoordinates(x,y);if(Zapatec.is_ie&&!Zapatec.is_ie7){el.style.setExpression("left",pos.x);el.style.setExpression("top",pos.y);return true;}}else{pos={x:parseInt(x,10)+"px",y:parseInt(y,10)+"px"};} if(x||x===0){el.style.left=pos.x;} if(y||y===0){el.style.top=pos.y;} return true;};Zapatec.Utils.getPos=function(el){if(!Zapatec.isHtmlElement(el)){return false;} var pos=null;if(pos=Zapatec.FixateOnScreen.parseCoordinates(el)){return pos;} return{x:el.offsetLeft,y:el.offsetTop}};Zapatec.Utils.moveFor=function(el,offsetX,offsetY){var oldPos=Zapatec.Utils.getPos(el);if(oldPos){return Zapatec.Utils.moveTo(el,oldPos.x+offsetX,oldPos.y+offsetY);}else{return false;}};Zapatec.Utils.restoreOfMove=function(el){if(!el.within)return false;el.restorer.restoreProps("style.position","parentNode","style.margin","nextSibling","within.style.position","style.left","style.top");if(el.restorer.isEmpty()){el.restorer.destroy();} el.within=null;return true;};Zapatec.Utils.getElementsByAttribute=function(attribute,value,within,recursive,match){if(!attribute){return false;} within=Zapatec.Widget.getElementById(within);within||(within=document.body);var element=within.firstChild;result=[];while(element){if(element[attribute]){if(typeof value=="undefined"||element[attribute]==value){result.push(element);}else if(match&&typeof element[attribute]=="string"&&element[attribute].indexOf(value)!=-1){result.push(element);}};if(recursive&&element.hasChildNodes()){result=result.concat(Zapatec.Utils.getElementsByAttribute(attribute,value,element,recursive,match));} element=element.nextSibling};return Zapatec.Array(result);};Zapatec.Utils.applyToElements=function(constructor,elements,config,configOption){if(typeof constructor!="function"||!Zapatec.isArray(elements)){return false;} elements=Zapatec.Array(elements);if(!configOption){configOption="container";} if(!config||typeof config!="object"){config={};} var result=Zapatec.Array();elements.each(function(index,element){config[configOption]=element;result.push(new constructor(config));});return result;};Zapatec.Utils.img2div=function(el){if(!Zapatec.isHtmlElement(el)){return null;} if((/img/i).test(el.nodeName)){var div=document.createElement('div');var objImage=new Image();objImage.onload=function(){div.style.width=objImage.width+'px';div.style.height=objImage.height+'px';div.style.fontSize='0px';objImage.onload=null;};objImage.src=el.src;div.style.backgroundImage='url('+el.src+')';div.style.backgroundColor='transparent';var id=el.id;var className=el.className;el.parentNode.replaceChild(div,el);div.id=id;div.className=className;return div}else{return el}};Zapatec.Utils.getElementPath=function(element,parent){if(!Zapatec.isHtmlElement(element)||!Zapatec.isHtmlElement(parent)){return false;} var res=[];var el=element;while(el&&el!=parent){var number=1;while(el.previousSibling){++number;el=el.previousSibling;} res.unshift(number);el=el.parentNode;} return res.join("-");};Zapatec.Utils.cover=Zapatec.Utils.createElement("div");Zapatec.Utils.cover.style.overflow="hidden";Zapatec.Utils.cover.style.backgroundImage="url("+Zapatec.zapatecPath+"zpempty.gif)";Zapatec.Utils.cover.style.display="none";Zapatec.Utils.cover.id="zpCoverControl";Zapatec.Utils.cover.show=function(zIndex,cursor,mouseMoveHandler,mouseUpHandler){if(!this.parentNode){document.body.appendChild(this);} if(this.style.display!="none"){this.hide();} this.style.display="block";Zapatec.Utils.makeSafelyMovable(this,null,document.body);var x=0;var y=0;y+=Zapatec.Utils.getPageScrollY();x+=Zapatec.Utils.getPageScrollX();Zapatec.Utils.moveTo(this,x,y);var dim=Zapatec.Utils.getWindowSize();this.style.width=dim.width+"px";this.style.height=dim.height+"px";Zapatec.FixateOnScreen.register(this);this.style.zIndex=zIndex;this.style.cursor=cursor;if(typeof mouseMoveHandler=="function"){Zapatec.Utils.addEvent(this,'mousemove',mouseMoveHandler);} if(typeof mouseUpHandler=="function"){Zapatec.Utils.addEvent(this,'mouseup',mouseUpHandler);} this.mouseMoveHandler=mouseMoveHandler;this.mouseUpHandler=mouseUpHandler;};Zapatec.Utils.cover.hide=function(){Zapatec.FixateOnScreen.unregister(this);if(typeof this.mouseMoveHandler=="function"){Zapatec.Utils.removeEvent(this,'mousemove',this.mouseMoveHandler);} if(typeof this.mouseUpHandler=="function"){Zapatec.Utils.removeEvent(this,'mouseup',this.mouseUpHandler);} this.mouseMoveHandler=null;this.mouseUpHandler=null;this.style.zIndex="";this.style.cursor="";this.style.display="none";};Zapatec.Movable={};Zapatec.Movable.setPosition=function(x,y){if(!this.isMovableSafely()){Zapatec.Log({description:"The object with ID '"+this.id+"' was not prepared for moving! Use obj.makeMovable() to do so!",type:"warning"});return false;} var msgValue=null,moveConfig=this.getMoveConfig();if(x||x===0){msgValue=x;x=this._parseCoordinate(x,"x",moveConfig.moveLayer);if(!x&&x!==0){Zapatec.Log({description:"The X coordinate "+msgValue+" can not be set for object with ID '"+this.id+"'!",type:"warning"});return false;}} if(y||y===0){msgValue=y;y=this._parseCoordinate(y,"y",moveConfig.moveLayer);if(!y&&y!==0){Zapatec.Log({description:"The Y coordinate "+msgValue+" can not be set for object with ID '"+this.id+"'!",type:"warning"});return false;}} var elements=Zapatec.Array(this.getMovableElements());if(this.fireEvent("beforePositionChange",x,y)===false){return false;} if(Zapatec.GlobalEvents.fireEvent("beforePositionChange",x,y,this)===false){return false;} this._proceedElementsCoords(x,y,elements);if(this.isMoving()){this.fireEvent("onMove",x||this.getPosition().x,y||this.getPosition().y);Zapatec.GlobalEvents.fireEvent("onMove",x||this.getPosition().x,y||this.getPosition().y,this);} this.fireEvent("onPositionChange",x||this.getPosition().x,y||this.getPosition().y);Zapatec.GlobalEvents.fireEvent("onPositionChange",x||this.getPosition().x,y||this.getPosition().y,this);return true;};Zapatec.Movable.setOrientedPosition=function(x,y){switch(this.getMoveConfig().orientation){case"vertical":{return this.setPosition(y,x);} case"horizontal":{return this.setPosition(x,y);}} return false;};Zapatec.Movable.setPagePosition=function(x,y){var moveConfig=this.getMoveConfig();if(moveConfig.moveLayer==document.body){return this.setPosition(x,y);} var msgValue=null;if(x||x===0){msgValue=x;x=this._parseCoordinate(x,"x",document.body);if(!x&&x!==0){Zapatec.Log({description:"The X page coordinate "+msgValue+" can not be set for object with ID '"+this.id+"'!",type:"warning"});return false;}} if(y||y===0){msgValue=y;y=this._parseCoordinate(y,"y",document.body);if(!y&&y!==0){Zapatec.Log({description:"The Y page coordinate "+msgValue+" can not be set for object with ID '"+this.id+"'!",type:"warning"});return false;}} var pos=Zapatec.Utils.getElementOffset(moveConfig.moveLayer);return this.setPosition((x||x===0)?(x-pos.x):x,(y||y===0)?(y-pos.y):y);};Zapatec.Movable.setScreenPosition=function(x,y){var moveConfig=this.getMoveConfig();var msgValue=null;if(x||x===0){msgValue=x;x=this._parseCoordinate(x,"x",window);if(!x&&x!==0){Zapatec.Log({description:"The X screen coordinate "+msgValue+" can not be set for object with ID '"+this.id+"'!",type:"warning"});return false;}} if(y||y===0){msgValue=y;y=this._parseCoordinate(y,"y",window);if(!y&&y!==0){Zapatec.Log({description:"The Y screen coordinate "+msgValue+" can not be set for object with ID '"+this.id+"'!",type:"warning"});return false;}} if(moveConfig.moveLayer!=document.body){var pos=Zapatec.Utils.getElementOffset(moveConfig.moveLayer);}else{var pos={x:0,y:0};} return this.setPosition((x||x===0)?(x-pos.x):x,(y||y===0)?(y-pos.y):y);};Zapatec.Movable.moveFor=function(offsetLeft,offsetTop){var pos=this.getPosition();return this.setPosition(offsetLeft==null?null:pos.x+offsetLeft,offsetTop==null?null:pos.y+offsetTop);};Zapatec.Movable.getPosition=function(){var el=this.getMovableMeasurement();if(Zapatec.isHtmlElement(el)||(el&&typeof el=="object"&&typeof el.x=="number"&&typeof el.y=="number")){return Zapatec.Utils.getPos(el)||el;} Zapatec.Log({description:"Can't calculate position for object with ID '"+this.id+"'!",type:"warning"});return false;};Zapatec.Movable.getPagePosition=function(){var el=this.getMovableMeasurement();if(Zapatec.isHtmlElement(el)||(el&&typeof el=="object"&&typeof el.x=="number"&&typeof el.y=="number")){return Zapatec.Utils.getElementOffset(el)||el;} Zapatec.Log({description:"Can't calculate screen position for object with ID '"+this.id+"'!",type:"warning"});return false;};Zapatec.Movable.getScreenPosition=function(){var pos=this.getPagePosition();pos.x-=Zapatec.Utils.getPageScrollX();pos.y-=Zapatec.Utils.getPageScrollY();return pos;};Zapatec.Movable.startMove=function(){if(!this.isMovableSafely()){Zapatec.Log({description:"The object with ID '"+this.id+"' was not prepared for moving! Use obj.makeMovable() to do so!",type:"warning"});return false;} this.fireEvent("moveStart");Zapatec.GlobalEvents.fireEvent("moveStart",this);this._setMovingState(true);return true;};Zapatec.Movable.endMove=function(){if(!this.isMoving()){Zapatec.Log({description:"The moving for object with ID '"+this.id+"' was not started!",type:"warning"});return false;} this.fireEvent("moveEnd");Zapatec.GlobalEvents.fireEvent("moveEnd",this);this._setMovingState(false);return true;};Zapatec.Movable.isMoving=function(){return this.movingState;};Zapatec.Movable._setMovingState=function(on){this.movingState=on;};Zapatec.Movable.isMovableSafely=function(){return this.safelyMovable;};Zapatec.Movable._setMovableSafely=function(on){this.safelyMovable=on;};Zapatec.Movable.makeMovable=function(){if(!this.requireInterface("Zapatec.CommandEvent")){return false;} if(this.isMovableSafely()){return true;} var elements=Zapatec.Array(this.getMovableElements()),self=this,moveConfig=this.getMoveConfig();success=elements.each(function(index,movable){if(Zapatec.isHtmlElement(movable)){if(moveConfig.preserveSizes&&!Zapatec.Utils.makeSafelySizable(movable)){return"break";} if(!Zapatec.Utils.makeSafelyMovable(movable,moveConfig.moveLayer)){return"break";} self.createProperty(movable,"moveObj",self);}else if(Zapatec.isMovableObj(movable)){if(!movable.makeMovable()){return"break";}}});if(!success){this.restoreOfMove();Zapatec.Log({description:"Can not make the object with ID '"+this.id+"' movable!"});return false;} this._setMovableSafely(true);return true;};Zapatec.Movable.restoreOfMove=function(){if(!this.isMovableSafely()){return true;} var elements=Zapatec.Array(this.getMovableElements());var self=this;elements.each(function(index,movable){if(Zapatec.isHtmlElement(movable)){Zapatec.Utils.restoreOfMove(movable);if(self.getMoveConfig().preserveSizes){Zapatec.Utils.restoreOfSizing(movable);} movable.moveObj=null;}else if(Zapatec.isMovableObj(movable)){movable.restoreOfMove();}},true);this._setMovableSafely(false);return true;};Zapatec.Movable.getMovableMeasurement=function(){return this.getContainer();};Zapatec.Movable.getMoveConfig=function(){return this.getConfiguration();};Zapatec.Movable.setMoveConfig=function(config){this.reconfigure(config);};Zapatec.Movable.getMovableElements=function(){return this.getContainer();};Zapatec.Movable.getContainer=function(){return this.getMoveConfig().container;};Zapatec.Movable._parseCoordinate=function(coord,dimension,within){switch(true){case(typeof coord=="number"):{if(within==window){coord+=Zapatec.Utils["getPageScroll"+dimension.toUpperCase()]();} break;} case((/^\d+px$/).test(String(coord))):{coord=parseInt(coord,10);if(within==window){coord+=Zapatec.Utils["getPageScroll"+dimension.toUpperCase()]();} break;} case((/^(left|top|bottom|right|center)$/i).test(String(coord))):{coord=this._parseWordCoordinate(coord,dimension,within);break;}} return this._canSetCoordinate(coord,dimension,within);};Zapatec.Movable._parseWordCoordinate=function(coord,dimension,within){if((/(left|right)/i).test(String(coord))&&dimension.toUpperCase()!="X"){return false;} if((/(top|bottom)/i).test(String(coord))&&dimension.toUpperCase()!="Y"){return false;} var dim=(dimension.toUpperCase()=="X")?"Left":"Top";var sizeDim=(dimension.toUpperCase()=="X")?"Width":"Height";var parsedCoord=0;var wSize=null;if(Zapatec.isHtmlElement(within)){parsedCoord=within["scroll"+dim];wSize=Zapatec.Utils["get"+sizeDim](within);}else if(within==window){parsedCoord=Zapatec.Utils["getPageScroll"+dimension.toUpperCase()]();wSize=Zapatec.Utils.getWindowSize()[sizeDim.toLowerCase()];}else if(within&&typeof within=="object"){parsedCoord+=within["scroll"+dim]||0;wSize=within[sizeDim.toLowerCase()];}else{return false;} var measurement=this.getMovableMeasurement();var mSize=null;if(Zapatec.isHtmlElement(measurement)){mSize=Zapatec.Utils["get"+sizeDim](measurement);}else if(measurement&&typeof measurement=="object"){mSize=measurement[sizeDim.toLowerCase()];} switch(coord){case"left":case"top":{break;} case"LEFT":case"TOP":{parsedCoord-=mSize;break;} case"right":case"bottom":{parsedCoord+=wSize-mSize;break;} case"RIGHT":case"BOTTOM":{parsedCoord+=wSize;break;} case"center":{parsedCoord+=Math.round((wSize-mSize)/2);break;} case"CENTER":{parsedCoord+=Math.round(wSize/2);break;} default:{parsedCoord=null;break;}} if(!parsedCoord&&parsedCoord!==0){return false;}else{return parsedCoord;}};Zapatec.Movable._canSetCoordinate=function(coord,dimension,within){if(typeof coord!="number"){return false;} var moveConfig=this.getMoveConfig();if(within!=moveConfig.moveLayer){return coord;} var limitObj=moveConfig.limit;var dim=dimension.toUpperCase();var direction=moveConfig.direction.toLowerCase();var correction=this._getMovableShape();if(dim=="X"&&direction=="vertical"){return this._handleCoordOverflow(this.getPosition().x);}else if(dim=="Y"&&direction=="horizontal"){return this._handleCoordOverflow(this.getPosition().y);} if((limitObj["min"+dim]||limitObj["min"+dim]===0)&&coord<limitObj["min"+dim]+correction["min"+dim]){return this._handleCoordOverflow(limitObj["min"+dim]+correction["min"+dim]);} if((limitObj["max"+dim]||limitObj["max"+dim]===0)&&coord>limitObj["max"+dim]+correction["max"+dim]){return this._handleCoordOverflow(limitObj["max"+dim]+correction["max"+dim]);} return coord;};Zapatec.Movable._handleCoordOverflow=function(limit,dimension){return false;};Zapatec.Movable._getMovableShape=function(){var measurement=this.getMovableMeasurement();var obj={minX:0,maxX:0,minY:0,maxY:0};switch(this.getMoveConfig().followShape){case(true):{if(!Zapatec.isHtmlElement(measurement)){return obj;} obj.maxX=-Zapatec.Utils.getWidth(measurement);obj.maxY=-Zapatec.Utils.getHeight(measurement);return obj} default:{return obj;}}};Zapatec.Movable.getMovingPoint=function(){return this.getScreenPosition();};Zapatec.Movable._proceedElementsCoords=function(x,y,elements){elements=Zapatec.Array(elements);var measurement=this.getMovableMeasurement();var pos=null;if(Zapatec.isHtmlElement(measurement)){pos=Zapatec.Utils.getPos(measurement);}else if(measurement&&typeof measurement=="object"){pos={x:(typeof measurement.x=="number")?measurement.x:null,y:(typeof measurement.y=="number")?measurement.y:null};if(!measurement.x||!measurement.y){pos=null;}} elements.each(function(index,movable){var mX=x,mY=y;if(pos){var mPos=null;if(Zapatec.isHtmlElement(movable)){mPos=Zapatec.Utils.getPos(movable);}else if(Zapatec.isMovableObj(movable)){mPos=movable.getPosition();}else{return;} if(x||x===0){mX=mPos.x+(x-pos.x);} if(y||y===0){mY=mPos.y+(y-pos.y);}} if(Zapatec.isHtmlElement(movable)){Zapatec.Utils.moveTo(movable,mX,mY);}else if(Zapatec.isMovableObj(movable)){movable.setPosition(mX,mY);}});};Zapatec.Movable.sortElementsByPath=function(elements){elements=Zapatec.Array(elements);elements.each(function(index,element){var path=Zapatec.Utils.getElementPath(element,document.body);if(!path){return;} path=Zapatec.Array(path.split("-"));for(var i=index;i<elements.length;++i){var compPath=Zapatec.Utils.getElementPath(elements[i],document.body);if(!compPath){continue;} compPath=Zapatec.Array(compPath.split("-"));path.each(function(k,pathPiece,whole){if(parseInt(pathPiece,10)>(parseInt(compPath[k],10)||0)){return"break";}else if(parseInt(pathPiece,10)<parseInt(compPath[k],10)){var el=elements[index] elements[index]=elements[i];elements[i]=el;path=compPath;return"break";}});}});return true;};Zapatec.Utils.Movable=function(config){Zapatec.Utils.Movable.SUPERconstructor.call(this,config);};Zapatec.Utils.Movable.id="Zapatec.Utils.Movable";Zapatec.inherit(Zapatec.Utils.Movable,Zapatec.Widget);Zapatec.implement(Zapatec.Utils.Movable,"Zapatec.CommandEvent");Zapatec.implement(Zapatec.Utils.Movable,"Zapatec.Movable");Zapatec.Utils.Movable.prototype.init=function(config){Zapatec.Utils.Movable.SUPERclass.init.call(this,config);var self=this;var elements=null;if(this.getConfiguration().makeMovable){this.makeMovable();}else{elements=Zapatec.Array(this.getMovableElements());elements.each(function(index,movable){if(Zapatec.isHtmlElement(movable)){self.createProperty(movable,"moveObj",self);}});}};Zapatec.Utils.Movable.prototype.configure=function(config){this.defineConfigOption("synchronize",[]);this.defineConfigOption("container",null);this.defineConfigOption("limit",{minX:null,maxX:null,minY:null,maxY:null});this.defineConfigOption("direction","both");this.defineConfigOption("moveLayer",document.body);this.defineConfigOption("followShape","LT");this.defineConfigOption("preserveSizes",true);this.defineConfigOption("makeMovable",true);this.defineConfigOption("theme",null);Zapatec.Utils.Movable.SUPERclass.configure.call(this,config);config=this.getConfiguration();if(!config.limit||typeof config.limit!="object"){config.limit={minX:null,maxX:null,minY:null,maxY:null};} var self=this;config.synchronize=Zapatec.Array(config.synchronize);config.synchronize.each(function(index,element){if(element===null){return;} element=Zapatec.Widget.getElementById(element);element=Zapatec.Utils.img2div(element);if(!element){Zapatec.Log({description:"Wrong element in synchronize array for the movable object with ID '"+self.id+"'!"});}else{config.synchronize[index]=element;}});config.container=Zapatec.Widget.getElementById(config.container);config.container=Zapatec.Utils.img2div(config.container);if(!Zapatec.isHtmlElement(config.container)){Zapatec.Log({description:"Wrong element passed as container for the movable object with ID '"+self.id+"'!"});} this.movableElements=Zapatec.Array(config.synchronize.concat(config.container));if(this.movableElements.length>1){this.sortElementsByPath(this.movableElements);} if(!Zapatec.isHtmlElement(config.moveLayer=Zapatec.Widget.getElementById(config.moveLayer))){config.moveLayer=document.body;}};Zapatec.Utils.Movable.prototype.reconfigure=function(config){Zapatec.Utils.Movable.SUPERclass.reconfigure.call(this,config);};Zapatec.Utils.Movable.prototype.getMovableElements=function(){return this.movableElements;};Zapatec.Draggable={};Zapatec.Draggable.makeDraggable=function(){if(!this.requireInterface("Zapatec.Movable")){return false;} if(!this.requireInterface("Zapatec.CommandEvent")){return false;} var draggables=Zapatec.Array(this.getDraggableElements());var hooks=Zapatec.Array(this._getDraggableHooks());var self=this,result=false;var config=this.getDragConfig();if(config.method!="cut"){this.setDragConfig({eventCapture:false});} var listenersObj=this._getRestorer().getSavedProps()["dragListeners"]={mousedown:function(ev){return self.dragStart(ev);},mousemove:function(ev){if(self.isDragging()){return self.dragMove(ev);}},mouseup:function(ev){if(self.isDragging()){return self.dragEnd(ev);}}};hooks.each(function(index,hook){if(!Zapatec.isHtmlElement(hook)){return;} result=true;if(Zapatec.is_gecko){hook.style.setProperty("-moz-user-select","none","");} Zapatec.Utils.addEvent(hook,'mousedown',listenersObj.mousedown);if(config.eventCapture){Zapatec.Utils.addEvent(hook,'mousemove',listenersObj.mousemove);Zapatec.Utils.addEvent(hook,'mouseup',listenersObj.mouseup);}});draggables.each(function(index,draggable){if(!Zapatec.isHtmlElement(draggable)){return;} self.createProperty(draggable,"dragObj",self);});return result;};Zapatec.Draggable.dragStart=function(ev){if(!this.canDrag()){return true;} ev=ev||window.event;var iButton=ev.button||ev.which;if(iButton>1){return false;} var self=this;var config=this.getDragConfig();if(this.fireEvent("beforeDragInit",ev)===false){return true;} if(Zapatec.GlobalEvents.fireEvent("beforeDragInit",ev,this)===false){return true;} this._setDragging(true);if(config.eventCapture&&(config.method=="dummy"||config.method=="copy")){var draggables=Zapatec.Array(this.getDraggableElements());draggables.each(function(index,draggable){draggable.restorer.saveProp("style.zIndex");draggable.style.zIndex=2000001;});} this._proceedDraggableElements("dragStart");var oPos=Zapatec.Utils.getMousePos(ev);var mouseX=oPos.pageX;var mouseY=oPos.pageY;this.makeMovable();this.startMove();var elements=Zapatec.Array(this.getMovableElements());elements.each(function(index,movable){if(Zapatec.isHtmlElement(movable)){movable.restorer.saveProp("style.zIndex");movable.style.zIndex=1000000+(parseInt(movable.style.zIndex,10)||0);self._proceedDragStyles(movable,"dragStart");if(config.eventCapture){movable.restorer.saveProp("style.cursor");movable.style.cursor="move";}}else if(Zapatec.isMovableObj(movable)){var elems=Zapatec.Array(movable.getMovableElements());elems.each(arguments.calee);}});Zapatec.Utils.cover.show(config.eventCapture?999999:2000000,"move",function(ev){return self.dragMove(ev);},function(ev){return self.dragEnd(ev);});this._setMovingPoint(mouseX,mouseY);this.fireEvent("onDragInit",ev);Zapatec.GlobalEvents.fireEvent("onDragInit",ev,this);if(config.stopEvent){return Zapatec.Utils.stopEvent(ev);}else{return true;}};Zapatec.Draggable.dragMove=function(ev){if(!this.isDragging()){return true;} ev=ev||window.event;if(this.fireEvent("beforeDragMove",ev)===false){return true;} if(Zapatec.GlobalEvents.fireEvent("beforeDragMove",ev,this)===false){return true;} if(Zapatec.Utils.cover.style.zIndex!=2000000){var config=this.getDragConfig();if(config.eventCapture&&(config.method=="dummy"||config.method=="copy")){var draggables=Zapatec.Array(this.getDraggableElements());draggables.each(function(index,draggable){draggable.restorer.restoreProp("style.zIndex");});} Zapatec.Utils.cover.style.zIndex=2000000;} var oPos=Zapatec.Utils.getMousePos(ev);var mouseX=oPos.pageX;var mouseY=oPos.pageY;var movePoint=this.getMovingPoint();this.moveFor(mouseX-movePoint.x,mouseY-movePoint.y);this._setMovingPoint(mouseX,mouseY);this.fireEvent("onDragMove",ev);Zapatec.GlobalEvents.fireEvent("onDragMove",ev,this);return Zapatec.Utils.stopEvent(ev);};Zapatec.Draggable.dragEnd=function(ev){if(!this.isDragging()){return true;} ev=ev||window.event;var self=this;if(this.fireEvent("beforeDragEnd",ev)===false){return true;} if(Zapatec.GlobalEvents.fireEvent("beforeDragEnd",ev,this)===false){return true;} var config=this.getDragConfig();if(config.eventCapture&&(config.method=="dummy"||config.method=="copy")){var draggables=Zapatec.Array(this.getDraggableElements());draggables.each(function(index,draggable){draggable.restorer.restoreProp("style.zIndex",true);});} var elements=Zapatec.Array(this.getMovableElements());elements.each(function(index,movable){if(Zapatec.isHtmlElement(movable)){movable.restorer.restoreProp("style.zIndex");movable.restorer.restoreProp("style.cursor");self._proceedDragStyles(movable,"dragEnd");}else if(Zapatec.isMovableObj(movable)){var elems=Zapatec.Array(movable.getMovableElements());elems.each(arguments.calee);}});this._proceedDraggableElements("dragEnd");Zapatec.Utils.cover.hide();this._setMovingPoint(null,null);this._setDragging(false);this.endMove();this.fireEvent("onDragEnd",ev);Zapatec.GlobalEvents.fireEvent("onDragEnd",ev,this);return Zapatec.Utils.stopEvent(ev);};Zapatec.Draggable.restorePos=function(){this.restoreOfMove();};Zapatec.Draggable.restoreOfDrag=function(){var listenersObj=this._getRestorer().getSavedProps()["dragListeners"];if(!listenersObj){return false;} this.restoreOfMove();var hooks=Zapatec.Array(this._getDraggableHooks());var draggables=Zapatec.Array(this.getDraggableElements());var self=this;var config=this.getDragConfig();hooks.each(function(index,hook){if(!Zapatec.isHtmlElement(hook)){return;} if(Zapatec.is_gecko){hook.style.setProperty("-moz-user-select","","");} Zapatec.Utils.removeEvent(hook,'mousedown',listenersObj.mousedown);if(config.eventCapture){Zapatec.Utils.removeEvent(hook,'mousemove',listenersObj.mousemove);Zapatec.Utils.removeEvent(hook,'mouseup',listenersObj.mouseup);}});draggables.each(function(index,draggable){if(!Zapatec.isHtmlElement(draggable)){return;} draggable.dragObj=null;});return true;};Zapatec.Draggable.getDraggableElements=function(){return this.getContainer();};Zapatec.Draggable._getDraggableHooks=function(){return this.getContainer();};Zapatec.Draggable.getContainer=function(){return this.getDragConfig().container;};Zapatec.Draggable.isDragging=function(){return this.dragging;};Zapatec.Draggable.canDrag=function(){return this.canDrag;};Zapatec.Draggable._setCanDrag=function(on){this.canDrag=on;};Zapatec.Draggable.getDragConfig=function(){return this.getConfiguration();};Zapatec.Draggable.setDragConfig=function(config){this.reconfigure(config);};Zapatec.Draggable._setDragging=function(on){this.dragging=on;};Zapatec.Draggable._handleCoordOverflow=function(limit,dimension){if(!this.isDragging()){Zapatec.Movable._handleCoordOverflow.call(this,limit,dimension);} return limit;};Zapatec.Draggable._getRestorer=function(){if(!this.restorer){this.restorer=new Zapatec.SRProp(this);} return this.restorer;};Zapatec.Draggable._proceedDraggableElements=function(dragState){var config=this.getDragConfig(),restorer=this._getRestorer(),copies=null,measurement=null,self=this,listenersObj=restorer.getProp("dragListeners");function toggleEvents(action,hooks,listenersObj){hooks.each(function(index,hook){Zapatec.Utils[action+"Event"](hook,"mousedown",listenersObj.mousedown);if(config.eventCapture){Zapatec.Utils[action+"Event"](hook,'mousemove',listenersObj.mousemove);Zapatec.Utils[action+"Event"](hook,'mouseup',listenersObj.mouseup);}});} switch(config.method){case"copy":case"dummy":{if(dragState=="dragStart"){var elements=Zapatec.Array(this.getDraggableElements());var hooks=Zapatec.Array(this._getDraggableHooks());copies=Zapatec.Array();toggleEvents("remove",hooks,listenersObj);elements.each(function(index,movable){if(Zapatec.isHtmlElement(movable)){var newNode=movable.cloneNode(config.copyChilds);newNode.dragObj=self;if(config.eventCapture){Zapatec.Utils.addEvent(newNode,'mousemove',listenersObj.mousemove);Zapatec.Utils.addEvent(newNode,'mouseup',listenersObj.mouseup);} movable.parentNode.insertBefore(newNode,movable);newNode.style.visibility="visible";copies.push(newNode);if(movable==self.getMovableMeasurement()){measurement=newNode;}}else if(Zapatec.isMovableObj(movable)){var elems=Zapatec.Array(movable.getMovableElements());elems.each(arguments.calee);}});toggleEvents("add",hooks,listenersObj);if(!measurement){measurement=this.getMovableMeasurement();} restorer.saveProp("getMovableElements");restorer.saveProp("isMovableSafely()");this._setMovableSafely(false);this.getMovableElements=function(resetArray){var arr=copies;copies=resetArray?null:copies;return arr;};restorer.saveProp("getMovableMeasurement");this.getMovableMeasurement=function(){return measurement;};}else if(dragState=="dragEnd"){var elements=Zapatec.Array(this.getMovableElements(true));elements.each(function(index,movable){if(config.method=="dummy"){movable.parentNode.removeChild(movable);} movable.dragObj=null;if(config.eventCapture){Zapatec.Utils.removeEvent(movable,'mousemove',listenersObj.mousemove);Zapatec.Utils.removeEvent(movable,'mouseup',listenersObj.mouseup);}});this.restoreOfMove();restorer.restoreProp("getMovableElements");this._setMovableSafely(restorer.getProp("isMovableSafely()"));restorer.restoreProp("isMovableSafely()");restorer.restoreProp("getMovableMeasurement");} break;} default:{break;}}};Zapatec.Draggable._proceedDragStyles=function(movable,dragState){var config=this.getDragConfig();if(config.overwriteCSS){if(dragState=="dragStart"){movable.restorer.saveProp("className");movable.className=config.overwriteCSS;}else if(dragState=="dragEnd"){movable.restorer.restoreProp("className");}} if(config.dragCSS){if(dragState=="dragStart"){Zapatec.Utils.addClass(movable,config.dragCSS);}else if(dragState=="dragEnd"){Zapatec.Utils.removeClass(movable,config.dragCSS);}}};Zapatec.Draggable._setMovingPoint=function(x,y){var movingPoint=this._getMovingPointObject();if(x===null||y===null){movingPoint.x=null;movingPoint.y=null;movingPoint.offsetX=null;movingPoint.offsetY=null;return;} if(movingPoint.x===null||movingPoint.y===null){var pos=this.getPagePosition();movingPoint.x=x;movingPoint.y=y;movingPoint.offsetX=x-pos.x;movingPoint.offsetY=y-pos.y;}else{var pos=this.getPagePosition();movingPoint.x=pos.x+movingPoint.offsetX;movingPoint.y=pos.y+movingPoint.offsetY;} return;};Zapatec.Draggable.getMovingPoint=function(){var movingPoint=this._getMovingPointObject();return{x:movingPoint.x,y:movingPoint.y};};Zapatec.Draggable._getMovingPointObject=function(){if(!this.movingPoint||typeof this.movingPoint!="object"){this.movingPoint={x:null,y:null,offsetX:null,offsetY:null};} return this.movingPoint;};Zapatec.Utils.Draggable=function(config){if(arguments.length>1){var args=arguments[1];args.container=config;config=args;} if(typeof config.left!="undefined"||typeof config.right!="undefined"||typeof config.top!="undefined"||typeof config.bottom!="undefined"){config.limit={minX:config.left,maxX:config.right,minY:config.top,maxY:config.bottom};} if(config.dragLayer){config.moveLayer=config.dragLayer;} if(!config.eventListeners){config.eventListeners={};} if(config.beforeDragInit){config.eventListeners.beforeDragInit=config.beforeDragInit;} if(config.beforeDragMove){config.eventListeners.beforeDragMove=config.beforeDragMove;} if(config.beforeDragEnd){config.eventListeners.beforeDragEnd=config.beforeDragEnd;} if(config.onDragInit){config.eventListeners.onDragInit=config.onDragInit;} if(config.onDragMove){config.eventListeners.onDragMove=config.onDragMove;} if(config.onDragEnd){config.eventListeners.onDragEnd=config.onDragEnd;} if(config.stopEv){config.stopEvent=config.stopEv;} config=Zapatec.Hash.remove(config,"left","top","right","bottom","dragLayer","beforeDragInit","beforeDragMove","beforeDragEnd","onDragInit","onDragMove","onDragEnd","stopEv");Zapatec.Utils.Draggable.SUPERconstructor.call(this,config);};Zapatec.Utils.Draggable.id="Zapatec.Utils.Draggable";Zapatec.inherit(Zapatec.Utils.Draggable,Zapatec.Utils.Movable);Zapatec.implement(Zapatec.Utils.Draggable,"Zapatec.Draggable");Zapatec.Utils.Draggable.prototype.init=function(config){Zapatec.Utils.Draggable.SUPERclass.init.call(this,config);this.makeDraggable();};Zapatec.Utils.Draggable.prototype.configure=function(config){this.defineConfigOption("method","cut");this.defineConfigOption("stopEvent",true);this.defineConfigOption("eventCapture",false);this.defineConfigOption("handler",null);this.defineConfigOption("dragCSS",null);this.defineConfigOption("overwriteCSS",null);this.defineConfigOption("copyChilds",true);this.defineConfigOption("makeMovable",false);Zapatec.Utils.Draggable.SUPERclass.configure.call(this,config);config=this.getConfiguration();if(Zapatec.is_opera){config.eventCapture=true;} config.handler=Zapatec.Widget.getElementById(config.handler);config.handler=Zapatec.Utils.img2div(config.handler);if(!Zapatec.isHtmlElement(config.handler)){config.handler=config.container;}};Zapatec.Utils.Draggable.prototype.reconfigure=function(config){Zapatec.Utils.Draggable.SUPERclass.reconfigure.call(this,config);};Zapatec.Utils.Draggable.prototype.getDraggableElements=function(){return this.movableElements;};Zapatec.Utils.Draggable.prototype._getDraggableHooks=function(){return this.getConfiguration().handler;};Zapatec.Utils.initDragObjects=function(className,el,recursive,config){if(!className)return;var elements=Zapatec.Utils.getElementsByAttribute('className',className,el,recursive,true);return Zapatec.Utils.applyToElements(Zapatec.Utils.Draggable,elements,config);} Zapatec.Sizable={};Zapatec.Sizable.setWidth=function(width){return this._setDimension(width,"width");};Zapatec.Sizable.setHeight=function(height){return this._setDimension(height,"height");};Zapatec.Sizable.setOrientedWidth=function(width){if(!this.getOrientation){return false;} switch(this.getOrientation()){case"vertical":return this._setDimension(width,"height");case"horizontal":return this._setDimension(width,"width");}};Zapatec.Sizable.setOrientedHeight=function(height){if(!this.getOrientation){return false;} switch(this.getOrientation()){case"vertical":return this._setDimension(height,"width");case"horizontal":return this._setDimension(height,"height");}};Zapatec.Sizable._setDimension=function(val,dimension){var evDim=dimension.charAt(0).toUpperCase()+dimension.slice(1);if(!this.isSizableSafely(dimension)){Zapatec.Log({description:"The object "+dimension+" ID '"+this.id+"' was not prepared for sizing! Use obj.makeSizable() to do so!",type:"warning"});return false;} var msgValue=val+"";val=this._parseSize(val,dimension);if(!val){Zapatec.Log({description:"The "+dimension+" "+msgValue+" can not be set for object with ID '"+this.id+"'!",type:"warning"});return false;} var elements=Zapatec.Array(this.getSizableElements(dimension));var toRestore=[],self=this;if(this.fireEvent("before"+evDim+"Change",val)===false){return false;} if(Zapatec.GlobalEvents.fireEvent("before"+evDim+"Change",val,this)===false){return false;} if(!this._proceedElementsSizes(val,dimension,elements,toRestore)){this._rollBackSizing(toRestore,dimension);this.fireEvent(dimension+"ChangeFailure",val) Zapatec.GlobalEvents.fireEvent(dimension+"ChangeFailure",val,this) Zapatec.Log({description:"Impossible to set the "+dimension+" "+msgValue+" for the object with ID '"+this.id+"'!",type:"warning"});return false;}else{if(this.isSizing()){if(dimension=="width"){this.fireEvent("onSizing",val,this.getHeight());Zapatec.GlobalEvents.fireEvent("onSizing",val,this.getHeight(),this);}else{this.fireEvent("onSizing",this.getWidth(),val);Zapatec.GlobalEvents.fireEvent("onSizing",this.getWidth(),val,this);}} this.fireEvent("on"+evDim+"Change",val);Zapatec.GlobalEvents.fireEvent("on"+evDim+"Change",val,this);} return true;};Zapatec.Sizable.startSizing=function(){if(!this.isSizableSafely()){Zapatec.Log({description:"The object with ID '"+this.id+"' was not prepared for sizing! Use obj.makeSizable() to do so!",type:"warning"});return false;} this.fireEvent("sizingStart");Zapatec.GlobalEvents.fireEvent("sizingStart",this);this._setSizingState(true);return true;};Zapatec.Sizable.endSizing=function(){if(!this.isSizing()){Zapatec.Log({description:"The sizing for object with ID '"+this.id+"' was not started!",type:"warning"});return false;} this.fireEvent("sizingEnd");Zapatec.GlobalEvents.fireEvent("sizingEnd",this);this._setSizingState(false);return true;};Zapatec.Sizable.isSizing=function(){return this.sizingState;};Zapatec.Sizable._setSizingState=function(on){this.sizingState=on;};Zapatec.Sizable.getWidth=function(){var el=this.getSizableMeasurement("width");if(Zapatec.isHtmlElement(el)||typeof el=="number"){return Zapatec.Utils.getWidth(el)||el;} Zapatec.Log({description:"Can't calculate width for object with ID '"+this.id+"'!",type:"warning"});return false;};Zapatec.Sizable.getHeight=function(){var el=this.getSizableMeasurement("height");if(Zapatec.isHtmlElement(el)||typeof el=="number"){return Zapatec.Utils.getHeight(el)||el;} Zapatec.Log({description:"Can't calculate height for object with ID '"+this.id+"'!",type:"warning"});return false;};Zapatec.Sizable.isSizableSafely=function(dimension){return this.safelySizable;};Zapatec.Sizable.makeSizable=function(){if(!this.hasInterface("Zapatec.CommandEvent")){Zapatec.Log({description:"The object with ID '"+this.id+"' has no Zapatec.CommandEvent interface!"});return false;} if(this.isSizableSafely()){return true;} var elements=Zapatec.Array(this.getSizableElements()),success=true,self=this;elements.each(function(index,sizable){sizable=Zapatec.Array(sizable);sizable.each(function(index,sizable){if(Zapatec.isHtmlElement(sizable)){if(!Zapatec.Utils.makeSafelySizable(sizable)){success=false;return"break";} self.createProperty(sizable,"sizingObj",self);}else if(Zapatec.isSizableObj(sizable)){if(!sizable.makeSizable()){success=false;return"break";}}});});if(!success){this.restoreOfSizing();Zapatec.Log({description:"Can not make the object with ID '"+this.id+"' sizable!"});return false;} this._setSizableSafely(true);return true;};Zapatec.Sizable.restoreOfSizing=function(){if(!this.isSizableSafely()){return true;} var elements=Zapatec.Array(this.getSizableElements());elements.each(function(index,sizable){sizable=Zapatec.Array(sizable);sizable.each(function(index,sizable){if(Zapatec.isHtmlElement(sizable)){Zapatec.Utils.restoreOfSizing(sizable);sizable.sizingObj=null;}else if(Zapatec.isSizableObj(sizable)){sizable.restoreOfSizing();}});});this._setSizableSafely(false);return true;};Zapatec.Sizable.replaceWithSizable=function(element,withEl){if(!Zapatec.isHtmlElement(element)||!Zapatec.isHtmlElement(withEl)){return false;} var width=Zapatec.Utils.getWidth(element);var height=Zapatec.Utils.getHeight(element);element.parentNode.insertBefore(withEl,element.nextSibling);element.parentNode.removeChild(element);if(!Zapatec.Utils.makeSafelySizable(withEl)){return false;} if(Zapatec.Utils.setWidth(withEl,width)&&Zapatec.Utils.setHeight(withEl,height)){return true;} return false;};Zapatec.Sizable._setSizableSafely=function(on){this.safelySizable=on;};Zapatec.Sizable._parseSize=function(size,dimension){switch(true){case(size=="auto"):{size=this._parseAutoSize(dimension);break;} case((/^\d+px$/).test(String(size))):{size=parseInt(size,10);break;} case((/^\d+%$/).test(String(size))):{size=this._parsePercentSize(size,dimension);break;} case(typeof size=="number"):{break;}} return this._canSetSize(size,dimension);};Zapatec.Sizable._parseAutoSize=function(dimension){var measurement=this.getSizableMeasurement(dimension);var autoSizable=this._getAutoSizableElement(dimension);if(!Zapatec.isHtmlElement(autoSizable)){return null;} var dim=dimension.charAt(0).toUpperCase()+dimension.slice(1).toLowerCase();var diff=0;if(Zapatec.isHtmlElement(measurement)||typeof measurement=="number"){diff=(Zapatec.Utils["get"+dim](measurement)||measurement)-Zapatec.Utils["get"+dim](autoSizable);} var el=autoSizable;if(el.tagName.toLowerCase()=="iframe"){try{if(el.contentDocument!=null){el=el.contentDocument.body;}else if(el.contentWindow.document!=null){el=el.contentWindow.document.body;} if(!Zapatec.isHtmlElement(el)){throw"No element to calculate auto size!";}}catch(e){Zapatec.Log({description:"Can't calculate auto size for the IFRAME in the object with ID '"+this.id+"'!",type:"warning"});return null;}} return el["scroll"+dim]+diff;};Zapatec.Sizable._parsePercentSize=function(value,dimension){var sizableParent=this._getSizableParent(dimension);if(!Zapatec.isHtmlElement(sizableParent)){return null;} var dim=dimension.charAt(0).toUpperCase()+dimension.slice(1).toLowerCase();value=parseInt(value,10);return Math.round((value/100)*Zapatec.Utils["get"+dim](sizableParent));};Zapatec.Sizable._canSetSize=function(value,dimension){if(typeof value!="number"){return false;} var dim=dimension.charAt(0).toUpperCase()+dimension.slice(1).toLowerCase();var sizingConfig=this.getSizingConfig();var limit=sizingConfig.limit;var direction=sizingConfig.direction;if(dim=="Width"&&direction=="vertical"){return this._handleSizeOverflow(this.getWidth());} if(dim=="Height"&&direction=="horizontal"){return this._handleSizeOverflow(this.getHeight());} if(typeof limit["min"+dim]=="number"&&value<limit["min"+dim]){return this._handleSizeOverflow(limit["min"+dim]);} if(typeof limit["max"+dim]=="number"&&value>limit["max"+dim]){return this._handleSizeOverflow(limit["max"+dim]);} return value;};Zapatec.Sizable._handleSizeOverflow=function(limit,dimension){return false;};Zapatec.Sizable.getSizingConfig=function(){return this.getConfiguration();};Zapatec.Sizable.setSizingConfig=function(config){this.reconfigure(config);};Zapatec.Sizable._getAutoSizableElement=function(dimension){return this.getContainer();};Zapatec.Sizable._getSizableParent=function(dimension){return this.getContainer().parentNode;};Zapatec.Sizable.getSizableMeasurement=function(dimension){return this.getContainer();};Zapatec.Sizable.getSizableElements=function(dimension){return this.getContainer();};Zapatec.Sizable.getContainer=function(){return this.getSizingConfig().container;};Zapatec.Sizable._setElementSize=function(size,sizable,dimension){var dim=dimension.charAt(0).toUpperCase()+dimension.slice(1).toLowerCase();if(Zapatec.isHtmlElement(sizable)){if(Zapatec.Utils["set"+dim](sizable,size)){return true;}else{return false;}}else if(Zapatec.isSizableObj(sizable)){if(sizable["set"+dim](size)){return true;}else{return false;}} return true;};Zapatec.Sizable._proceedElementsSizes=function(value,dimension,elArr,restArr){var diff=null,self=this,sizes=Zapatec.Array();var measurement=this.getSizableMeasurement(dimension);var dim=dimension.charAt(0).toUpperCase()+dimension.slice(1).toLowerCase();if(typeof measurement=="number"||Zapatec.isHtmlElement(measurement)){diff=value-(Zapatec.Utils["get"+dim](measurement)||measurement);} elArr=Zapatec.Array(elArr);elArr.each(function(row,val){var oneDiff=diff,size=value;val=Zapatec.Array(val);if(diff){oneDiff=Math.round(oneDiff/val.length);}else{size=Math.round(size/val.length);} sizes[row]=[];val.each(function(index,sizable){var setSize=null;var elSize=null;if(Zapatec.isHtmlElement(sizable)){elSize=Zapatec.Utils["get"+dim](sizable)}else if(Zapatec.isSizableObj(sizable)){elSize=sizable["get"+dim]();}else{return;} if(oneDiff||oneDiff===0){if(index!=val.length-1){setSize=elSize+oneDiff;}else{setSize=elSize+(diff-oneDiff*index);}}else{if(index!=val.length-1){setSize=size;}else{setSize=value-size*index;}} sizes[row][index]={setSize:setSize,elSize:elSize};});});var res=elArr.each(function(row,val){val=Zapatec.Array(val);var res=val.each(function(index,sizable){if(!sizes[row][index]){return;} var res=self._setElementSize(sizes[row][index].setSize,sizable,dimension);if(!res&&res===false){return"break";}else{restArr.push({sizable:sizable,oldSize:sizes[row][index].elSize});}});if(!res&&res===false){return"break";}});return res;};Zapatec.Sizable._rollBackSizing=function(rollBackArr,dimension){var dim=dimension.charAt(0).toUpperCase()+dimension.slice(1).toLowerCase();rollBackArr=Zapatec.Array(rollBackArr);rollBackArr.each(function(index,obj){if(Zapatec.isHtmlElement(obj.sizable)){Zapatec.Utils["set"+dim](obj.sizable,obj.oldSize);}else if(Zapatec.isSizableObj(obj.sizable)){obj.sizable["set"+dim](obj.oldSize);}});};Zapatec.Utils.Sizable=function(config){Zapatec.Utils.Sizable.SUPERconstructor.call(this,config);};Zapatec.Utils.Sizable.id="Zapatec.Utils.Sizable";Zapatec.inherit(Zapatec.Utils.Sizable,Zapatec.Widget);Zapatec.implement(Zapatec.Utils.Sizable,"Zapatec.CommandEvent");Zapatec.implement(Zapatec.Utils.Sizable,"Zapatec.Sizable");Zapatec.Utils.Sizable.prototype.init=function(config){Zapatec.Utils.Sizable.SUPERclass.init.call(this,config);this.makeSizable();};Zapatec.Utils.Sizable.prototype.configure=function(config){this.defineConfigOption("syncVertically",[]);this.defineConfigOption("syncHorizontally",[]);this.defineConfigOption("container",null);this.defineConfigOption("direction","both");this.defineConfigOption("limit",{minWidth:10,maxWidth:null,minHeight:10,maxHeight:null});this.defineConfigOption("theme",null);Zapatec.Utils.Sizable.SUPERclass.configure.call(this,config);config=this.getConfiguration();if(!config.limit||typeof config.limit!="object"){config.limit={minWidth:null,maxWidth:null,minHeight:null,maxHeight:null};} var self=this;config.syncVertically=Zapatec.Array(config.syncVertically);config.syncVertically.each(function(index,subArr){config.syncVertically[index]=Zapatec.Array(subArr);config.syncVertically[index].each(function(elIndex,element){if(element===null){return;} element=Zapatec.Widget.getElementById(element);if(!element){Zapatec.Log({description:"Wrong element in syncVertically array for the sizable object with ID '"+self.id+"'!"});}else{config.syncVertically[index][elIndex]=element;}});});config.syncHorizontally=Zapatec.Array(config.syncHorizontally);config.syncHorizontally.each(function(index,subArr){config.syncHorizontally[index]=Zapatec.Array(subArr);config.syncHorizontally[index].each(function(elIndex,element){if(element===null){return;} element=Zapatec.Widget.getElementById(element);if(!element){Zapatec.Log({description:"Wrong element in syncHorizontally array for the sizable object with ID '"+self.id+"'!"});}else{config.syncHorizontally[index][elIndex]=element;}});});if(!Zapatec.isHtmlElement(config.container=Zapatec.Widget.getElementById(config.container))){config.container=null;}};Zapatec.Utils.Sizable.prototype.reconfigure=function(config){Zapatec.Utils.Sizable.SUPERclass.reconfigure.call(this,config);};Zapatec.Utils.Sizable.prototype.getSizableElements=function(dimension){var config=this.getConfiguration();if(dimension&&dimension.toLowerCase()=="width"){return config.syncHorizontally.concat(config.container);}else if(dimension&&dimension.toLowerCase()=="height"){return config.syncVertically.concat(config.container);}else{return config.syncVertically.concat(config.syncHorizontally).concat(config.container);}};Zapatec.Resizable={};Zapatec.Resizable.makeResizable=function(){if(!this.requireInterface("Zapatec.Sizable")){return false;} if(!this.requireInterface("Zapatec.CommandEvent")){return false;} var hooks=Zapatec.Array(this._getResizableHooks());var measurement=this.getSizableMeasurement();var self=this,result=false;var config=this.getResizeConfig();if(/(vertical|horizontal|top|left|all)/.test(config.direction)&&!this.hasInterface("Zapatec.Movable")){Zapatec.Log({description:"The object with ID '"+this.id+"' has no Zapatec.Movable interface so can not be resizable!"});return false;} var listenersObj=this._getRestorer().getSavedProps()["resizeListeners"]={mousedown:function(ev){return self.resizeStart(ev);},hover:function(ev){if(!self.isResizing()&&self.canResize()){self._toggleResizeCursor(ev);}},mouseover:function(ev){if(self.hasInterface("Zapatec.Draggable")){self._setCanDrag(false);}},mouseout:function(ev){if(self.hasInterface("Zapatec.Draggable")){self._setCanDrag(true);}}};hooks.each(function(index,hook){if(!Zapatec.isHtmlElement(hook)){return;} result=true;if(Zapatec.is_gecko){hook.style.setProperty("-moz-user-select","none","");} Zapatec.Utils.addEvent(hook,'mousedown',listenersObj.mousedown);Zapatec.Utils.addEvent(hook,'mouseover',listenersObj.mouseover);Zapatec.Utils.addEvent(hook,'mouseout',listenersObj.mouseout);});if(!result){if(!Zapatec.isHtmlElement(measurement)){return false;} result=true;Zapatec.Utils.addEvent(measurement,'mousedown',listenersObj.mousedown);Zapatec.Utils.addEvent(measurement,'mousemove',listenersObj.hover);} return result;};Zapatec.Resizable._toggleResizeCursor=function(ev){ev=ev||window.event;var el=this.getSizableMeasurement();var config=this.getResizeConfig();var oPos=Zapatec.Utils.getMousePos(ev);var posX=oPos.pageX;var posY=oPos.pageY;var pos=Zapatec.Utils.getElementOffset(el);var left=pos.x,right=pos.x+Zapatec.Utils.getWidth(el);var top=pos.y,bottom=pos.y+Zapatec.Utils.getHeight(el);var borderThickness=config.borderThickness;var cornerThickness=config.cornerThickness;function inRect(x,y,left,top,right,bottom){if((x>left)&&(x<right)&&(y>top)&&(y<bottom)){return true;} return false;} function inRange(value,minVal,maxVal){if((value>minVal)&&(value<maxVal)){return true;} return false;} var self=this;function toggleResizing(cursor){el.style.cursor=cursor;if(self.hasInterface("Zapatec.Draggable")){self._setCanDrag((cursor==="")?true:false);}} switch(true){case(inRect(posX,posY,left,top,left+borderThickness,top+borderThickness)):{toggleResizing("nw-resize");break;} case(inRect(posX,posY,right-cornerThickness,bottom-cornerThickness,right,bottom)):{toggleResizing("se-resize");break;} case(inRect(posX,posY,right-cornerThickness,top,right,top+borderThickness)):{toggleResizing("ne-resize");break;} case(inRect(posX,posY,left,bottom-cornerThickness,left+cornerThickness,bottom)):{toggleResizing("sw-resize");break;} case(inRange(posX,left,left+borderThickness)):{toggleResizing("w-resize");break;} case(inRange(posX,right-borderThickness,right)):{toggleResizing("e-resize");break;} case(inRange(posY,top,top+borderThickness)):{toggleResizing("n-resize");break;} case(inRange(posY,bottom-borderThickness,bottom)):{toggleResizing("s-resize");break;} default:{toggleResizing("");break;}} el.style.cursor=this._correctDirection(el.style.cursor);if(el.style.cursor==""){if(this.hasInterface("Zapatec.Draggable")){this._setCanDrag(true);}}};Zapatec.Resizable._correctDirection=function(direction){var config=this.getResizeConfig();direction=direction.replace("-resize","");for(var i=0;i<direction.length;++i){switch(direction.charAt(i)){case"n":{if(!/(all|vertical|top)/.test(config.direction)){direction=direction.replace("n","");}} case"s":{if(!/(all|vertical|bottom)/.test(config.direction)){direction=direction.replace("s","");}} case"w":{if(!/(all|horizontal|left)/.test(config.direction)){direction=direction.replace("w","");}} case"e":{if(!/(all|horizontal|right)/.test(config.direction)){direction=direction.replace("e","");}}}} if(direction!=""){return direction+"-resize";} return"";};Zapatec.Resizable.resizeStart=function(ev,deb){if(!this.canResize()){return true;} ev=ev||window.event;var iButton=ev.button||ev.which;if(iButton>1){return true;} var self=this;var config=this.getResizeConfig();var target=ev.currentTarget||ev.srcElement;while(target!=document.body&&target.style.cursor.indexOf("resize")==-1){target=target.parentNode;} if(target.style.cursor.indexOf("resize")==-1){return true;} var direction=this._correctDirection(target.style.cursor);if(direction==""){return true;} if(this.fireEvent("beforeResizeInit",ev)===false){return true;} if(Zapatec.GlobalEvents.fireEvent("beforeResizeInit",ev,this)===false){return true;} this._setResizing(true);this._proceedResizableElements("resizeStart");var oPos=Zapatec.Utils.getMousePos(ev);var mouseX=oPos.pageX;var mouseY=oPos.pageY;this.makeSizable();this.startSizing();if(/(vertical|horizontal|top|left|all)/.test(config.direction)){this.makeMovable();this.startMove();} Zapatec.Utils.cover.show(1000001,direction,function(ev){return self.resizeMove(ev);},function(ev){return self.resizeEnd(ev);});this._setResizingPoint(mouseX,mouseY,direction.replace("-resize",""));this.fireEvent("onResizeInit",ev);Zapatec.GlobalEvents.fireEvent("onResizeInit",ev,this);if(config.stopEvent){return Zapatec.Utils.stopEvent(ev);}else{return true;}};Zapatec.Resizable.resizeMove=function(ev){if(!this.isResizing()){return true;} ev=ev||window.event;if(this.fireEvent("beforeResize",ev)===false){return true;} if(Zapatec.GlobalEvents.fireEvent("beforeResize",ev,this)===false){return true;} var oPos=Zapatec.Utils.getMousePos(ev);var x=oPos.pageX;var y=oPos.pageY;var movePoint=this.getResizingPoint();var direction=Zapatec.Utils.cover.style.cursor;direction=direction.replace("-resize","");if(direction.indexOf("w")>-1){var width=this.getWidth();this.setWidth(width+(movePoint.x-x));if(width!=this.getWidth()){this.moveFor(width-this.getWidth(),null);}} if(direction.indexOf("e")>-1){this.setWidth(this.getWidth()+(x-movePoint.x));} if(direction.indexOf("n")>-1){var height=this.getHeight();this.setHeight(height+(movePoint.y-y));if(height!=this.getHeight()){this.moveFor(null,height-this.getHeight());}} if(direction.indexOf("s")>-1){this.setHeight(this.getHeight()+(y-movePoint.y));} this._setResizingPoint(x,y,direction);this.fireEvent("onResize",ev);Zapatec.GlobalEvents.fireEvent("onResize",ev,this);return Zapatec.Utils.stopEvent(ev);};Zapatec.Resizable.resizeEnd=function(ev){if(!this.isResizing()){return true;} ev=ev||window.event;var self=this;var config=this.getResizeConfig();if(this.fireEvent("beforeResizeEnd",ev)===false){return true;} if(Zapatec.GlobalEvents.fireEvent("beforeResizeEnd",ev,this)===false){return true;} this._proceedResizableElements("resizeEnd");Zapatec.Utils.cover.hide();this._setResizingPoint(null,null);this._setResizing(false);this.endSizing();if(/(vertical|horizontal|top|left|all)/.test(config.direction)){this.endMove();} this.fireEvent("onResizeEnd",ev);Zapatec.GlobalEvents.fireEvent("onResizeEnd",ev,this);return Zapatec.Utils.stopEvent(ev);};Zapatec.Resizable.restoreOfResize=function(){var config=this.getResizeConfig();this.restoreOfSizing();if(/(vertical|horizontal|top|left|all)/.test(config.direction)){this.restoreOfMove();} var hooks=Zapatec.Array(this._getResizableHooks());var self=this;var result=false;var listenersObj=this._getRestorer().getSavedProps()["resizeListeners"];hooks.each(function(index,hook){if(!Zapatec.isHtmlElement(hook)){return;} result=true;if(Zapatec.is_gecko){hook.style.setProperty("-moz-user-select","","");} Zapatec.Utils.removeEvent(hook,'mousedown',listenersObj.mousedown);Zapatec.Utils.removeEvent(hook,'mouseover',listenersObj.mouseover);Zapatec.Utils.removeEvent(hook,'mouseout',listenersObj.mouseout);});if(!result){var measurement=this.getSizableMeasurement();if(!Zapatec.isHtmlElement(measurement)){return false} Zapatec.Utils.removeEvent(measurement,'mousedown',listenersObj.mousedown);Zapatec.Utils.removeEvent(measurement,'mousemove',listenersObj.hover);} return true;};Zapatec.Resizable._getResizableHooks=function(){if(this.getContainer){return this.getContainer();}else{return null;}};Zapatec.Resizable.isResizing=function(){return this.resizing;};Zapatec.Resizable.canResize=function(){return this.canResize;};Zapatec.Resizable._setCanResize=function(on){this.canResize=on;};Zapatec.Resizable.getResizeConfig=function(){return this.getConfiguration();};Zapatec.Resizable.setResizeConfig=function(config){this.reconfigure(config);};Zapatec.Resizable._setResizing=function(on){this.resizing=on;};Zapatec.Resizable._handleSizeOverflow=function(limit,dimension){if(!this.isResizing()){Zapatec.Sizable._handleSizeOverflow.call(this,limit,dimension);} return limit;};Zapatec.Resizable._getRestorer=function(){if(!this.restorer||this.restorer.constructor!=Zapatec.SRProp){this.restorer=new Zapatec.SRProp(this);} return this.restorer;};Zapatec.Resizable._proceedResizableElements=function(resizeState){var config=this.getResizeConfig(),copy=null,measurement=null,self=this;switch(config.method){case"copy":{if(resizeState=="resizeStart"){var measurement=this.getSizableMeasurement();if(!Zapatec.isHtmlElement(measurement)){return false;} copy=measurement.cloneNode(false);measurement.parentNode.insertBefore(copy,measurement);this._getRestorer().saveProp("getSizableElements");this.getSizableElements=function(){return copy;};this._getRestorer().saveProp("getSizableMeasurement");this.getSizableMeasurement=function(){return copy;};if(/(vertical|horizontal|top|left|all)/.test(config.direction)){this._getRestorer().saveProp("getMovableElements");this.getMovableElements=function(resetArray){return copy;};this._getRestorer().saveProp("getMovableMeasurement");this.getMovableMeasurement=function(){return copy;};}}else if(resizeState=="resizeEnd"){copy=this.getMovableElements();var width=this.getWidth();var height=this.getHeight();var pos=null;if(/(vertical|horizontal|top|left|all)/.test(config.direction)){pos=this.getPosition();} copy.parentNode.removeChild(copy);this._getRestorer().restoreProp("getSizableElements");this._getRestorer().restoreProp("getSizableMeasurement");this._getRestorer().restoreProp("getMovableElements");this._getRestorer().restoreProp("getMovableMeasurement");this.setWidth(width);this.setHeight(height);if(pos){this.setPosition(pos.x,pos.y);}} break;} default:{break;}}};Zapatec.Resizable._setResizingPoint=function(x,y,direction){var resizingPoint=this._getResizingPointObject();if(x===null||y===null){resizingPoint.x=null;resizingPoint.y=null;resizingPoint.offsetX=null;resizingPoint.offsetY=null;return;} if(resizingPoint.x===null||resizingPoint.y===null){resizingPoint.x=x;resizingPoint.y=y;var width=this.getWidth();var height=this.getHeight();if(direction.match(/(n|w)/)){var pos=this.getScreenPosition();} if(direction.indexOf("n")!=-1){resizingPoint.offsetY=y-pos.y;} if(direction.indexOf("w")!=-1){resizingPoint.offsetX=x-pos.x;} if(direction.indexOf("e")!=-1){resizingPoint.offsetX=x-width;} if(direction.indexOf("s")!=-1){resizingPoint.offsetY=y-height;} resizingPoint.offsetX=resizingPoint.offsetX||0;resizingPoint.offsetY=resizingPoint.offsetY||0;}else{var diffX=0;var diffY=0;var width=this.getWidth();var height=this.getHeight();if(direction.match(/(n|w)/)){var pos=this.getScreenPosition();} if(direction.indexOf("n")!=-1){diffY=pos.y;} if(direction.indexOf("w")!=-1){diffX=pos.x;} if(direction.indexOf("e")!=-1){diffX=width;} if(direction.indexOf("s")!=-1){diffY=height;} resizingPoint.x=diffX+resizingPoint.offsetX;resizingPoint.y=diffY+resizingPoint.offsetY;} return;};Zapatec.Resizable.getResizingPoint=function(){var resizingPoint=this._getResizingPointObject();return{x:resizingPoint.x,y:resizingPoint.y};};Zapatec.Resizable._getResizingPointObject=function(){if(!this.resizingPoint||typeof this.resizingPoint!="object"){this.resizingPoint={x:null,y:null,offsetX:null,offsetY:null};} return this.resizingPoint;};Zapatec.Utils.Resizable=function(config){Zapatec.Utils.Resizable.SUPERconstructor.call(this,config);};Zapatec.Utils.Resizable.id="Zapatec.Utils.Resizable";Zapatec.inherit(Zapatec.Utils.Resizable,Zapatec.Utils.Sizable);Zapatec.implement(Zapatec.Utils.Resizable,"Zapatec.Movable");Zapatec.implement(Zapatec.Utils.Resizable,"Zapatec.Resizable");Zapatec.Utils.Resizable.prototype.init=function(config){Zapatec.Utils.Resizable.SUPERclass.init.call(this,config);this.restoreOfSizing();this.makeResizable();};Zapatec.Utils.Resizable.prototype.configure=function(config){this.defineConfigOption("method","self");this.defineConfigOption("stopEvent",true);this.defineConfigOption("handlers",null);this.defineConfigOption("borderThickness",10);this.defineConfigOption("cornerThickness",10);this.defineConfigOption("direction","all");Zapatec.Utils.Resizable.SUPERclass.configure.call(this,config);config=this.getConfiguration();config.handlers=Zapatec.Array(config.handlers);config.handlers.each(function(index,handler){handler=Zapatec.Widget.getElementById(handler);handler=Zapatec.Utils.img2div(handler);config.handlers[index]=handler;});};Zapatec.Utils.Resizable.prototype.reconfigure=function(config){Zapatec.Utils.Resizable.SUPERclass.reconfigure.call(this,config);};Zapatec.Utils.Resizable.prototype._getResizableHooks=function(){return this.getConfiguration().handlers;};Zapatec.Modal=function(config){if(arguments.length==0){config={};} this.visible=false;Zapatec.Modal.SUPERconstructor.call(this,config);} Zapatec.Modal.id="Zapatec.Indicator";Zapatec.inherit(Zapatec.Modal,Zapatec.Widget);Zapatec.Modal.prototype.init=function(config){Zapatec.Modal.SUPERclass.init.call(this,config);};Zapatec.Modal.prototype.configure=function(config){this.defineConfigOption("zIndex",1000);this.defineConfigOption("x",null);this.defineConfigOption("y",null);this.defineConfigOption("width",null);this.defineConfigOption("height",null);this.defineConfigOption("container",window);this.defineConfigOption("fixed",false);Zapatec.Modal.SUPERclass.configure.call(this,config);config=this.getConfiguration();if(config.container!=window){config.x=null;config.y=null;config.width=null;config.height=null;config.fixed=false;}};Zapatec.Modal.prototype.create=function(){var config=this.getConfiguration();config.container=Zapatec.Widget.getElementById(config.container)||window;this.WCH=Zapatec.Utils.createWCH();if(Zapatec.windowLoaded){this.container=Zapatec.Utils.createElement("div",document.body);}else{document.write('<div id="zpModalContainer"></div>');this.container=document.getElementById('zpModalContainer');} this.container.className=this.getClassName({prefix:"zpModal"+(Zapatec.is_opera?"Opera":"")}) var st=this.container.style;st.dispaly="none";st.position="absolute";st.zIndex=config.zIndex;};Zapatec.Modal.prototype.show=function(zIndex){if(!this.container){this.create();} zIndex=zIndex||this.config.zIndex;this.container.style.zIndex=zIndex;if(this.WCH){this.WCH.style.visibility="";this.WCH.style.zIndex=zIndex-1;} this.container.style.display="block";this.visible=true;var config=this.getConfiguration();if(config.container!=window){var self=this;var update=function(){self.update();} if(!this.interval){this.interval=setInterval(update,100);} this.update();}else{var dim=Zapatec.Utils.getWindowSize();var width=config.width||dim.width;var height=config.height||dim.height;var x=config.x||Zapatec.Utils.getPageScrollX();var y=config.y||Zapatec.Utils.getPageScrollY();this.setWidth(width);this.setHeight(height);this.setPosition(x,y);} if(this.config.fixed==true){Zapatec.FixateOnScreen.register(this.container);if(this.WCH){Zapatec.FixateOnScreen.register(this.WCH);}}};Zapatec.Modal.prototype.update=function(){var config=this.getConfiguration();if(config.container!=window&&this.visible){var offs=Zapatec.Utils.getElementOffset(config.container);this.setWidth(offs.width);this.setHeight(offs.height);this.setPosition(offs.x,offs.y);}};Zapatec.Modal.prototype.hide=function(destroy){var config=this.getConfiguration();if(config.fixed==true){Zapatec.FixateOnScreen.unregister(this.container);if(this.WCH){Zapatec.FixateOnScreen.unregister(this.WCH);}} if(config.container!=window){clearInterval(this.interval);this.interval=null;} if(this.container)this.container.style.display="none";Zapatec.Utils.hideWCH(this.WCH);if(destroy){if(this.WCH){if(this.WCH.outerHTML){this.WCH.outerHTML="";}else{Zapatec.Utils.destroy(this.WCH);}} if(this.container.outerHTML){this.container.outerHTML="";}else{Zapatec.Utils.destroy(this.container);} this.WCH=null;this.container=null;} this.visible=false;};Zapatec.Modal.prototype.setWidth=function(width){if(!this.container){return;} if(Zapatec.Utils.setWidth){Zapatec.Utils.setWidth(this.container,width);Zapatec.Utils.setWidth(this.WCH,width);}else{this.container.style.width=width+"px";if(this.WCH){this.WCH.style.width=width+"px";}}};Zapatec.Modal.prototype.setHeight=function(height){if(!this.container){return;} if(Zapatec.Utils.setHeight){Zapatec.Utils.setHeight(this.container,height);Zapatec.Utils.setHeight(this.WCH,height);}else{this.container.style.height=height+"px";if(this.WCH){this.WCH.style.height=height+"px";}}};Zapatec.Modal.prototype.setPosition=function(x,y){if(!this.container){return;} if(Zapatec.Utils.moveTo){Zapatec.Utils.moveTo(this.container,x,y);Zapatec.Utils.moveTo(this.WCH,x,y);}else{this.container.style.left=x+"px";this.container.style.top=y+"px";if(this.WCH){this.WCH.style.left=x+"px";this.WCH.style.top=y+"px";}}};Zapatec.Indicator=function(config){if(arguments.length==0){config={};} this.active=false;Zapatec.Indicator.SUPERconstructor.call(this,config);} Zapatec.Indicator.id="Zapatec.Indicator";Zapatec.inherit(Zapatec.Indicator,Zapatec.Modal);Zapatec.Indicator.prototype.init=function(config){Zapatec.Indicator.SUPERclass.init.call(this,config);};Zapatec.Indicator.prototype.configure=function(config){this.defineConfigOption("themePath",Zapatec.zapatecPath+"../zpextra/themes/indicator/");Zapatec.Indicator.SUPERclass.configure.call(this,config);};Zapatec.Indicator.prototype.create=function(){Zapatec.Indicator.SUPERclass.create.call(this);this.indicator=Zapatec.Utils.createElement("div",this.container);this.indicator.className="zpIndicator";var st=this.indicator.style;st.position="absolute";st.zIndex=this.getConfiguration().zIndex;st.backgroundColor="#aaaaaa";};Zapatec.Indicator.prototype.setWidth=function(width){if(!this.container){return;} Zapatec.Indicator.SUPERclass.setWidth.call(this,width);var left=Math.round((this.container.offsetWidth-this.indicator.offsetWidth)/2);this.indicator.style.left=left+"px";};Zapatec.Indicator.prototype.setHeight=function(height){if(!this.container){return;} Zapatec.Indicator.SUPERclass.setHeight.call(this,height);var top=Math.round((this.container.offsetHeight-this.indicator.offsetHeight)/2);this.indicator.style.top=top+"px";};Zapatec.Indicator.prototype.hide=function(destroy){if(destroy){this.indicator=null;} Zapatec.Indicator.SUPERclass.hide.call(this,destroy);};Zapatec.Indicator.prototype.start=function(message){this.active=true;if(!this.indicator){this.create();} this.indicator.innerHTML=message;this.show();};Zapatec.Indicator.prototype.stop=function(){this.active=false;this.hide(true);};Zapatec.Indicator.prototype.isActive=function(){return this.active;};Zapatec.Pane=function(objArgs){this.config={};if(arguments.length==0){objArgs={};} this.widgetType="pane";this.ready=false;this.loading=false;this.prepared=false;Zapatec.Utils.createProperty(this,"container",null);Zapatec.Utils.createProperty(this,"contentElement",null);Zapatec.Utils.createProperty(this,"iframeDocument",null);Zapatec.Pane.SUPERconstructor.call(this,objArgs);} Zapatec.Pane.id="Zapatec.Pane";Zapatec.inherit(Zapatec.Pane,Zapatec.Widget);Zapatec.Pane.prototype.init=function(objArgs){Zapatec.Utils.createProperty(this.config,"parent",document.body);this.config.theme=null;this.config.width=null;this.config.height=null;this.config.containerType="div";this.config.sourceType=null;this.config.source=null;this.config.autoContentWidth=false;this.config.autoContentHeight=false;this.config.onlyInit=false;this.config.showLoadingIndicator=false;this.config.overflow="auto";this.config.id=null;Zapatec.Pane.SUPERclass.init.call(this,objArgs);if(this.config.containerType==null){this.config.containerType="div";} if(!this.config.onlyInit){this.create(this.config.width,this.config.height);} var self=this;function update(){if(self.loader){self.loader.update();}} this.addEventListener("fetchSourceStart",update);this.addEventListener("fetchSourceEnd",update);} Zapatec.Pane.prototype.prepareHtml=function(){if(this.config.containerType.toLowerCase()=='iframe'){var iframe=document.createElement("iframe");iframe.src=Zapatec.zapatecPath+"pane_files/blank.html#"+this.id;this.container=iframe;iframe=null;}else if(this.config.containerType.toLowerCase()=='div'){this.container=document.createElement("div");if(this.config.id){this.container.id=this.config.id;} this.contentElement=this.container;}else if(this.config.parent&&this.config.parent.nodeType==1){this.container=this.config.parent;this.contentElement=this.container;} this.prepared=true;};Zapatec.Pane.prototype.create=function(width,height){if(!this.prepared){this.prepareHtml();} if(!(this.config.parent=Zapatec.Widget.getElementById(this.config.parent))){Zapatec.Log({description:"No reference to parent element."});return null;} if(this.config.parent.requestParentFor&&!(this.config.parent=this.config.parent.requestParentFor(this))){Zapatec.Log({description:"No reference to parent element after request to the Parent Widget!"});return null;} if(this.config.containerType.toLowerCase()=='div'||this.config.containerType.toLowerCase()=='iframe'){this.ready=false;this.config.parent.appendChild(this.container);if(this.config.containerType.toLowerCase()!='iframe'){this.initPane();}}else if(this.config.containerType.toLowerCase()=='current'){this.container=this.config.parent;this.contentElement=this.container;this.initPane();}else{Zapatec.Log({description:"Unknown container type: "+this.config.containerType+". Possible values: iframe|div"})} Zapatec.Utils.addClass(this.container,this.getClassName({prefix:"zpPane"}));if(width||this.config.width){this.setWidth(width||this.config.width);} if(height||this.config.height){this.setHeight(height||this.config.height);} this.getContainer().style.display="block";this.setPaneContent();};Zapatec.Pane.prototype.initPane=function(){if(this.config.containerType.toLowerCase()=='iframe'){var doc=null;var sameDomain=true;var url=this.getContainer().src;var anchorEl=document.createElement("a");var protocolSeparatorPos=url.indexOf("://");if(protocolSeparatorPos!=-1){var domainSeparatorPos=url.indexOf("/",protocolSeparatorPos+3);var domain=url.substring((protocolSeparatorPos>0?protocolSeparatorPos+3:0),(domainSeparatorPos>0?domainSeparatorPos:url.length));if(domain!=window.location.host){sameDomain=false;}} if(sameDomain){if(this.container.contentDocument!=null){doc=this.container.contentDocument;}else if(this.container.contentWindow&&this.container.contentWindow.document!=null){doc=this.container.contentWindow.document;} var self=this;anchorEl.href=url;url=anchorEl.href;if(doc==null||doc.body==null||(Zapatec.is_gecko&&url!=this.container.contentWindow.location.href)){setTimeout(function(){self.initPane()},50);return false;} this.iframeDocument=doc;this.contentElement=doc.body;if(typeof this.container.contentWindow.Zapatec!="object"&&typeof this.container.contentWindow.Zapatec!="function"){this.container.contentWindow.Zapatec={};this.container.contentWindow.Zapatec.windowLoaded=typeof(doc.readyState)!='undefined'?(doc.readyState=='loaded'||doc.readyState=='complete'):doc.getElementsByTagName!=null&&typeof(doc.getElementsByTagName('body')[0])!='undefined';Zapatec.Utils.addEvent(this.container.contentWindow,"load",function(){self.container.contentWindow.Zapatec.windowLoaded=true;});} if(!this.container.contentWindow.Zapatec||!this.container.contentWindow.Zapatec.windowLoaded){setTimeout(function(){self.initPane()},50);return false;} doc=null;}} if(this.config.overflow){this.getContainer().style.overflow=this.config.overflow;} this.ready=true;this.fireEvent("onReady",this);this.hideIndicator();this.loading=false;this.removeEvent("onReady");} Zapatec.Pane.prototype.getContainer=function(){return this.container;} Zapatec.Pane.prototype.getIframeDocument=function(){return this.iframeDocument;} Zapatec.Pane.prototype.getContentElement=function(){return this.contentElement;} Zapatec.Pane.prototype.isReady=function(){return this.ready;} Zapatec.Pane.prototype.loadDataJson=function(objSource){return objSource!=null?this.setContent(objSource.content):null;} Zapatec.Pane.prototype.setContent=function(content){if(!this.isReady()){var self=this;setTimeout(function(){self.setContent(content)},50);return null;} this.loading=false;if(!this.getContentElement()){this.hideIndicator();return false;} if(content===null){this.hideIndicator();return null;}else{if(this.config.containerType.toLowerCase()!="iframe"){var oldOverflow=this.getContainer().style.overflow;if(this.config.autoContentWidth){this.getContainer().style.overflow="visible";this.getContainer().style.width="auto";} if(this.config.autoContentHeight){this.getContainer().style.overflow="visible";this.getContainer().style.height="auto";}} if(typeof(content)=='string'){Zapatec.Transport.setInnerHtml({container:this.getContentElement(),html:content});}else{try{if((Zapatec.is_ie||Zapatec.is_opera)&&this.config.containerType.toLowerCase()=="iframe"){Zapatec.Transport.setInnerHtml({container:this.getContentElement(),html:content.outerHTML});}else{if(content.parentNode!=this.getContentElement()){this.getContentElement().innerHTML="";this.getContentElement().appendChild(content);}}}catch(ex){this.hideIndicator();return null;}} if(this.config.containerType.toLowerCase()!="iframe"){var newWidth=this.getWidth();var newHeight=this.getHeight();}else{var newWidth=this.getContentElement().scrollWidth+5;var newHeight=this.getContentElement().scrollHeight+5;} if(typeof oldOverflow!="undefined")this.getContainer().style.overflow=oldOverflow;if(this.config.autoContentWidth){this.setWidth(newWidth);} if(this.config.autoContentHeight){this.setHeight(newHeight);}} this.fireEvent("contentLoaded",this);this.hideIndicator();return true;} Zapatec.Pane.prototype.loadDataHtml=Zapatec.Pane.prototype.loadDataXml=Zapatec.Pane.prototype.setContent;Zapatec.Pane.prototype.loadDataHtmlText=function(content){this.setContent(content);};Zapatec.Pane.prototype.setWidth=function(width){var self=this;this.fireWhenReady(function(){self.getContainer().style.width=width+"px";if(self.getContainer().offsetWidth!=width){var newWidth=width-(self.getContainer().offsetWidth-width);if(newWidth<0)newWidth=0;self.getContainer().style.width=newWidth+"px";}});} Zapatec.Pane.prototype.getWidth=function(){return this.getContainer().offsetWidth;} Zapatec.Pane.prototype.setHeight=function(height){var self=this;this.fireWhenReady(function(){self.getContainer().style.height=height+"px";if(self.getContainer().offsetHeight!=height){var newHeight=height-(self.getContainer().offsetHeight-height);if(newHeight<0)newHeight=0;self.getContainer().style.height=newHeight+"px";}});} Zapatec.Pane.prototype.getHeight=function(){return this.getContainer().offsetHeight;} Zapatec.Pane.prototype.removeBorder=function(){if(this.config.containerType.toLowerCase()!="iframe"){return false;} var self=this;this.fireWhenReady(function(){if(!Zapatec.is_ie){self.getContainer().style.border="none";}else{if(self.getContentElement()){self.getContentElement().style.border="none";}}});};Zapatec.Pane.prototype.setPaneContent=function(content,type){if(!content&&content!==""){content=this.config.source;} if(!type){type=this.config.sourceType;} this.config.source=content;this.config.sourceType=type;var self=this;if(this.config.showLoadingIndicator){this.showIndicator();this.loading=true;} if(this.config.containerType.toLowerCase()=="iframe"&&type=="html/url"){this.ready=false;this.fireWhenReady(function(){if(self.getContentElement()){try{var newWidth=self.getContentElement().scrollWidth;var newHeight=self.getContentElement().scrollHeight;if(self.config.autoContentWidth){self.setWidth(newWidth);} if(self.config.autoContentHeight){self.setHeight(newHeight);}}catch(e){}} self.fireEvent("contentLoaded",self);if(self.events["contentLoaded"]){self.events["contentLoaded"].listeners=[];}});this.getContainer().src=content;setTimeout(function(){self.initPane()},50);return true;} if(this.config.containerType.toLowerCase()=="iframe"&&this.getContainer().src.indexOf((Zapatec.zapatecPath+"pane_files/blank.html#"+this.id).replace(/\.\.\//g,""))<0){this.ready=false;this.getContainer().src=Zapatec.zapatecPath+"pane_files/blank.html#"+this.id;} this.loadData();return true;};Zapatec.Pane.prototype.show=function(){this.getContainer().style.display="";if(this.loading){this.showIndicator();}};Zapatec.Pane.prototype.hide=function(){this.getContainer().style.display="none";if(this.loading){this.hideIndicator();}};Zapatec.Pane.prototype.showIndicator=function(message){if(Zapatec.Indicator){this.hideIndicator();if(!this.loader){this.loader=new Zapatec.Indicator({container:this.container,themePath:Zapatec.zapatecPath+"../zpextra/themes/indicator/"});} this.loader.start(message||'loading');}};Zapatec.Pane.prototype.hideIndicator=function(){if(this.loader&&this.loader.isActive()){this.loader.stop();}};Zapatec.Pane.prototype.fireWhenReady=function(func){if(!this.isReady()){this.addEventListener("onReady",func);}else{func.call(this,this);}} Zapatec.Pane.prototype.destroy=function(){this.hideIndicator();this.config.parent=null;this.contentElement=null;this.iframeDocument=null;if(Zapatec.is_ie&&this.config.containerType.toLowerCase()=='iframe'){this.container.src="javascript:void(0)";} if(this.container.outerHTML){this.container.outerHTML="";}else{Zapatec.Utils.destroy(this.container);} this.container=null;this.ready=false;this.prepared=false;} Zapatec.Window=function(config){this.container=null;this.titleArea=null;this.titleText=null;this.minButton=null;this.maxButton=null;this.closeButton=null;this.content=null;this.statusText=null;this.modal=null;this.resizing=false;this.widgetType="window";this.widgetModes={};this.highPriorityEvents=[];this.delayedEvents=[];this.widgetState="created";this.priorities={count:7,destroyed:0,created:1,inited:2,loaded:3,ready:4,hidden:5,shown:6};this.setDefaultState();if(!config.eventListeners){config.eventListeners={};} if(config.onClose){config.eventListeners.onClose=config.onClose;} if(config.onRestore){config.eventListeners.onRestore=config.onRestore;} if(config.onMaximize){config.eventListeners.onMaximize=config.onMaximize;} if(config.onMinimize){config.eventListeners.onMinimize=config.onMinimize;} if(config.onShow){config.eventListeners.onShow=config.onShow;} if(config.onHide){config.eventListeners.onHide=config.onHide;} if(config.onResize){config.eventListeners.onResize=config.onResize;} if(config.onRaise){config.eventListeners.onRaise=config.onRaise;} if(config.onContentLoad){config.eventListeners.onContentLoad=config.onContentLoad;} config=Zapatec.Hash.remove(config,"onClose","onRestore","onMaximize","onMinimize","onShow","onHide","onResize","onRaise","onContentLoad");Zapatec.Window.SUPERconstructor.call(this,config);this.restorer=new Zapatec.SRProp(this);};Zapatec.Window.id="Zapatec.Window";Zapatec.inherit(Zapatec.Window,Zapatec.Widget);Zapatec.implement(Zapatec.Window,"Zapatec.CommandEvent");Zapatec.implement(Zapatec.Window,"Zapatec.Movable");Zapatec.implement(Zapatec.Window,"Zapatec.Draggable");Zapatec.implement(Zapatec.Window,"Zapatec.Sizable");Zapatec.implement(Zapatec.Window,"Zapatec.Resizable");Zapatec.Window.prototype.init=function(config){Zapatec.Window.SUPERclass.init.call(this,config);this.addEventListener("privileged_execution_on",function(){this.highPriorityEvents=[];});this.addEventListener("privileged_execution_off",function(){for(var ii=this.highPriorityEvents.length-1;ii>=0;--ii){if(this.highPriorityEvents[ii]&&!this.highPriorityEvents[ii].executed){this.addEventListener(this.highPriorityEvents[ii].state,this.highPriorityEvents[ii].listener,true);}} this.highPriorityEvents=[];});this.addEventListener("delayed_execution_on",function(){this.delayedEvents=[];});this.addEventListener("delayed_execution_off",function(){for(var ii=this.delayedEvents.length-1;ii>=0;--ii){if(!this.fireOnState(this.delayedEvents[ii].state,this.delayedEvents[ii].listener)){continue;} this.delayedEvents[ii].listener();}});this.addEventListener("beforeDragInit",function(){this.activate();if(this.getConfiguration().method=="cut"){this.setStatus(this.getMessage('windowOnBeforeDragStatusMessage'),'temp');}});var pos=null;this.addEventListener("beforeDragEnd",function(){if(this.getConfiguration().method!="cut"){pos=this.getPosition();}});this.addEventListener("onDragEnd",function(){if(this.getConfiguration().method=="cut"){this.setStatus('','restore');}else{this.setPosition(pos.x,pos.y);}});this.addEventListener("onResizeInit",function(){this.activate();this.setStatus(this.getMessage('windowOnResizeStatusMessage'),'temp');});this.addEventListener("onResizeEnd",function(){this.setStatus('','restore');});this.changeState("inited");this.loadData({object:this,action:"loadTemplate"});};Zapatec.Window.prototype.configure=function(config){this.defineConfigOption("showTitle",true);this.defineConfigOption("showMinButton",true);this.defineConfigOption("showMaxButton",true);this.defineConfigOption("showCloseButton",true);this.defineConfigOption("showStatus",true);this.defineConfigOption("canResize",true);this.defineConfigOption("resizeDirection","all");this.defineConfigOption("raiseOnlyOnTitle",false);this.defineConfigOption("canDrag",true);this.defineConfigOption("dragMethod","cut");this.defineConfigOption("addDragCSS",null);this.defineConfigOption("newDragCSS",null);this.defineConfigOption("modal",false);this.defineConfigOption("limit",{minWidth:120,maxWidth:null,minHeight:120,maxHeight:null,minX:null,maxX:null,minY:null,maxY:null});this.defineConfigOption("iframeContent",false);this.defineConfigOption("hideOnClose",false);this.defineConfigOption("dragMin",false);this.defineConfigOption("bottomMinimize",true);this.defineConfigOption("fixed",false);this.defineConfigOption("theme","winxp");this.defineConfigOption("template",Zapatec.Window.path+"struc.html");this.defineConfigOption("callbackSource",function(args){var win=args.object;if(!win||win.widgetType!="window"){return null;} switch(args.action){case"loadTemplate":{return{source:win.getConfiguration().template,sourceType:"html/url"};}} return null;});this.defineConfigOption('langId',Zapatec.Window.id);this.defineConfigOption('lang',"eng");Zapatec.Window.SUPERclass.configure.call(this,config);config=this.getConfiguration();if(config.dragMethod=="copy"||config.dragMethod=="dummy"){config.dragMethod="dummy";config.newDragCSS="zpWinDummy";}};Zapatec.Window.prototype.reconfigure=function(config){Zapatec.Window.SUPERclass.reconfigure.call(this,config);};Zapatec.Window.prototype.loadDataHtml=function(el){if(this.parseDom(el)){this.changeState("loaded");}};Zapatec.Window.prototype.create=function(x,y,width,height){if(x!="center"){x=parseInt(x,10)||0;} if(y!="center"){y=parseInt(y,10)||0;} if(width!="auto"){width=parseInt(width,10)||0;} if(height!="auto"){height=parseInt(height,10)||0;} if(!this.fireOnState("body_loaded",function(){this.create(x,y,width,height);})||!this.fireOnState("loaded",function(){this.create(x,y,width,height);})){return;} document.body.appendChild(this.getContainer());Zapatec.Utils.addClass(this.getContainer(),this.getClassName({prefix:"zpWin",suffix:"Container"}));function replaceButton(but,idPrefix,func){var button=new Zapatec.Button({className:but.className,style:but.style.cssText,theme:null,idPrefix:idPrefix,clickAction:func});var nxtSbl=but.nextSibling;var par=but.parentNode;if(but.outerHTML){but.outerHTML="";}else{par.removeChild(but);} par.insertBefore(button.getContainer(),nxtSbl);return button;} var self=this;this.minButton=replaceButton(this.minButton,"zpWin"+self.id+"MinButton",function(){self.minimize();});this.maxButton=replaceButton(this.maxButton,"zpWin"+self.id+"MaxButton",function(){self.maximize();});this.closeButton=replaceButton(this.closeButton,"zpWin"+self.id+"CloseButton",function(){self.close();});this.restoreButton=replaceButton(this.restoreButton,"zpWin"+self.id+"RestoreButton",function(){self.restore();});this.setModeOn("immediate_execution");this.reconfig();this.setModeOff("immediate_execution");var contentWidth=Zapatec.Utils.getWidth(this.content);var pane=new Zapatec.Pane({containerType:(this.config.iframeContent?"iframe":"div")});this.content.getContainer=function(){return this;};if(width=="auto"){width=0;this.addEventListener("onContentLoad",function(){this.setWidth("auto");this.removeEventListener("onContentLoad",arguments.callee);});} if(height=="auto"){height=0;this.addEventListener("onContentLoad",function(){this.setHeight("auto");this.removeEventListener("onContentLoad",arguments.callee);});} pane.getContainer().className=this.content.className;pane.fireWhenReady(function(){if(this.getContentElement()){if(this.config.containerType.toLowerCase()=="iframe"){this.getContentElement().style.padding="0px";} this.getContentElement().style.margin="0px";} var width=Zapatec.Utils.getWidth(this.getContainer());this.removeBorder();Zapatec.Utils.setWidth(this.getContainer(),width);});this.createProperty(this,"WCH",Zapatec.Utils.createWCH());if(this.WCH){this.WCH.style.zIndex=Zapatec.Window.maxNumber++;Zapatec.Utils.setWidth(this.WCH,Zapatec.Utils.getWidth(this.getContainer()));Zapatec.Utils.setHeight(this.WCH,Zapatec.Utils.getHeight(this.getContainer()));var pos=Zapatec.Utils.getElementOffset(this.getContainer());Zapatec.Utils.moveTo(this.WCH,pos.x,pos.y);} this.container.style.zIndex=Zapatec.Window.maxNumber++;this.makeMovable();this.makeSizable();this.makeDraggable();this.makeResizable();var content=this.content;this.content=pane;this.replaceWithSizable(content,this.content.getContainer());this.content.addEventListener("contentLoaded",function(){self.fireEvent('onContentLoad');});this.titleArea.buttonType="title";this.content.getContainer().buttonType="content";this.getContainer().buttonType="container";this.addEvents();this.setModeOn("immediate_execution");this.setSize(width>this.getConfiguration().limit.minWidth?width:this.getConfiguration().limit.minWidth,height>this.getConfiguration().limit.minHeight?height:this.getConfiguration().limit.minHeight);if(this.getConfiguration().fixed){Zapatec.FixateOnScreen.register(this.getContainer());Zapatec.FixateOnScreen.register(this.WCH);} this.setScreenPosition(x,y);this.hide();this.setModeOff("immediate_execution");this.changeState("ready");};Zapatec.Window.prototype.getContainer=function(){return this.container;};Zapatec.Window.prototype.setDefaultState=function(){this.state={};this.state.state="simple";this.state.left=0;this.state.top=0;this.state.width=0;this.state.height=0;this.state.contentType="";this.state.content="";};Zapatec.Window.prototype._updateState=function(){var pos=null;if(!this.getConfiguration().fixed){pos=this.getPosition();}else{pos=this.getScreenPosition();} this.state.left=pos.x;this.state.top=pos.y;if(this.state.state!="min"){this.state.width=this.getWidth();this.state.height=this.getHeight();}};Zapatec.Window.prototype.getState=function(){var state={};state.x=this.state.left;state.y=this.state.top;state.width=this.state.width;state.height=this.state.height;state.zIndex=this.getContainer().style.zIndex;switch(this.state.contentType){case"html/text":state.text=this.state.content;break;case"html":state.div=this.state.content;break;case"html/url":state.url=this.state.content;break;} return state;};Zapatec.Window.prototype.setState=function(state){if(!this.fireOnState("ready",function(){this.setState(state);})){return;} if(state.x||state.y||state.width||state.height){this.setPosAndSize(state.x,state.y,state.width,state.height);} if(state.zIndex){this.container.style.zIndex=state.zIndex;if(state.zIndex>Zapatec.Window.maxNumber){Zapatec.Window.maxNumber=state.zIndex+1;} if(this.WCH){this.WCH.style.zIndex=state.zIndex-1;} if(this.config.modal){this.modal.container.style.zIndex=state.zIndex-2;}} if(state.url||state.div||state.text){this.setContent("");if(state.url){this.setContentUrl(state.url);}else if(state.div){this.setDivContent(state.div);}else if(state.text){this.setContent(state.text);}} return true;};Zapatec.Window.prototype.setPos=function(left,top){this.setScreenPosition(left,top);};Zapatec.Window.prototype.setPosition=function(left,top){if(!this.fireOnState("shown",function(){this.setPosition(left,top);})){return;} Zapatec.Movable.setPosition.call(this,left,top);this._updateState();};Zapatec.Window.prototype.setScreenPosition=function(left,top){if(!this.fireOnState("shown",function(){this.setScreenPosition(left,top);})){return;} Zapatec.Movable.setScreenPosition.call(this,left,top);};Zapatec.Window.prototype.setPagePosition=function(left,top){if(!this.fireOnState("shown",function(){this.setPagePosition(left,top);})){return;} Zapatec.Movable.setPagePosition.call(this,left,top);};Zapatec.Window.prototype.setWidth=function(width){if(!this.fireOnState("shown",function(){this.setWidth(width);})){return;} if(this.state.state!="simple"){return false;} Zapatec.Sizable.setWidth.call(this,width);this._updateState();};Zapatec.Window.prototype.setHeight=function(height){if(!this.fireOnState("shown",function(){this.setHeight(height);})){return;} if(this.state.state!="simple"){return false;} Zapatec.Sizable.setHeight.call(this,height);this._updateState();};Zapatec.Window.prototype.setSize=function(width,height){this.setWidth(width);this.setHeight(height);};Zapatec.Window.prototype.setPosAndSize=function(left,top,width,height){this.setSize(width,height);this.setPos(left,top);};Zapatec.Window.prototype.setTitle=function(text){if(!this.fireOnState("ready",function(){this.setTitle(text);})){return;} if(text!==''){this.titleText.innerHTML=text;} return true;};Zapatec.Window.prototype.setStatus=function(message,mode){if(!this.fireOnState("ready",function(){this.setStatus(message,mode);})){return;} if(this.config.showStatus&&Zapatec.isHtmlElement(this.statusText)){switch(mode){case"temp":{this.prevStText=this.statusText.innerHTML;break;} case"restore":{message=this.prevStText||message;delete this.prevStText;break;}} this.statusText.innerHTML=message;} return true;} Zapatec.Window.prototype.setContent=function(text){if(!this.fireOnState("shown",function(){this.setContent(text);}))return;this.content.setPaneContent(text,"html/text");this.state.contentType="html/text";this.state.content=text;} Zapatec.Window.prototype.setDivContent=function(div){if(!this.fireOnState("shown",function(){this.setDivContent(div);}))return;this.content.setPaneContent(div,"html");this.state.contentType="html";if(typeof div=="string"){this.state.content=div;}else{this.state.content=null;}} Zapatec.Window.prototype.setContentUrl=function(url){if(!this.fireOnState("shown",function(){this.setContentUrl(url);}))return;this.content.setPaneContent(url,"html/url");this.state.contentType="html/url";this.state.content=url;} Zapatec.Window.prototype.activate=function(){if(!this.fireOnState("shown",function(){this.activate();})){return;} if(this.face.className.indexOf("zpWinFront")!=-1){return true;} Zapatec.Window.activating=this;if(Zapatec.Window.currentWindow){Zapatec.Window.currentWindow.deactivate();} Zapatec.Window.currentWindow=this;Zapatec.Utils.removeClass(this.face,'zpWinBack');Zapatec.Utils.addClass(this.face,'zpWinFront');if(this.WCH)this.WCH.style.zIndex=Zapatec.Window.maxNumber++;if(this.modal)this.modal.container.style.zIndex=Zapatec.Window.maxNumber++;this.getContainer().style.zIndex=Zapatec.Window.maxNumber++;this.fireEvent("onRaise",this);Zapatec.Window.activating=null;};Zapatec.Window.prototype.deactivate=function(){if(!this.fireOnState("shown",function(){this.deactivate();})){return;} if(this.face.className.indexOf("zpWinBack")!=-1){return true;} var prevWin=Zapatec.Window.currentWindow;Zapatec.Utils.removeClass(this.face,'zpWinFront');Zapatec.Utils.addClass(this.face,'zpWinBack');Zapatec.Window.activateFreeWindow(this);Zapatec.Window.lastActive=this;};Zapatec.Window.prototype.canActivate=function(){if(!this.stateReached("ready")){return false;} if(this.state.state=="min"){return"min";} return true;};Zapatec.Window.prototype.isVisible=function(){return this.widgetState=="shown"?true:false;};Zapatec.Window.prototype.show=function(){if(!this.fireOnState("ready",function(){this.show();})){return;} this.getContainer().style.display="block";if(this.content){this.content.show();} if(this.config.modal==true&&this.modal){var zIndex=null;if(this.WCH){zIndex=this.WCH.style.zIndex;}else{zIndex=this.getContainer().style.zIndex;} this.modal.show(zIndex-1);} if(this.WCH){this.WCH.style.visibility="";} this.activate();if(this.getConfiguration().fixed){this._updateState();} if(this.stateReached("ready")){this.changeState("shown");} this.fireEvent("onShow",this);return true;} Zapatec.Window.prototype.hide=function(){if(!this.fireOnState("ready",function(){this.hide();}))return;this.content.hide();this.getContainer().style.display="none";if(this.config.modal==true&&this.modal){this.modal.hide();} Zapatec.Utils.hideWCH(this.WCH);this.deactivate();if(this.stateReached("ready")){this.changeState("hidden");} this.fireEvent("onHide",this);return true;} Zapatec.Window.prototype.showAtElement=function(el,opts){if(!this.fireOnState("ready",function(){this.showAtElement(el,opts);})){return;} var p=Zapatec.Utils.getElementOffset(el);if(!opts||typeof opts!="string"){this.showAt(p.x,p.y+el.offsetHeight);return true;} this.getContainer().style.display="block";var w=this.getWidth();var h=this.getHeight();this.getContainer().style.display="none";var valign=opts.substr(0,1);var halign="l";if(opts.length>1){halign=opts.substr(1,1);} switch(valign){case"T":p.y-=h;break;case"B":p.y+=el.offsetHeight;break;case"C":p.y+=(el.offsetHeight-h)/2;break;case"t":p.y+=el.offsetHeight-h;break;case"b":break;} switch(halign){case"L":p.x-=w;break;case"R":p.x+=el.offsetWidth;break;case"C":p.x+=(el.offsetWidth-w)/2;break;case"l":p.x+=el.offsetWidth-w;break;case"r":break;} p.width=w;p.height=h;this.showAt(p.x,p.y);return true;} Zapatec.Window.prototype.showAt=function(x,y){if(!this.fireOnState("ready",function(){this.showAt(x,y);})){return;} this.setPagePosition(x,y);this.show();return true;} Zapatec.Window.prototype.minimize=function(){if(!this.config.showMinButton){return false;} if(!this.fireOnState("ready",function(){this.minimize();}))return;if(this.state.state!="min"&&this.titleArea){var self=this;function hideExcept(el,exc){if(el!=self.container){var first=el.firstChild;while(first){if(first&&first.style&&first!=exc){if(!first.restorer){first.restorer=new Zapatec.SRProp(first);} first.restorer.saveProp("style.display");first.style.display="none";} first=first.nextSibling;} hideExcept(el.parentNode,el);}} if(this.state.state!="simple"){this.restore();} hideExcept(this.titleArea.parentNode,this.titleArea);this.content.hide();this.restorer.saveProps("_updateState","content","statusText","getConfiguration().limit.minHeight");this.content=this.statusText=this.getConfiguration().limit.minHeight=null;this._updateState=function(){};this.setHeight(Zapatec.Utils.getHeight(this.face));if(this.config.bottomMinimize){this.setWidth(Zapatec.Window.minWinWidth);this.setScreenPosition(Zapatec.Window.minimizeLeft,"bottom");Zapatec.Window.minimizeLeft+=Zapatec.Window.minWinWidth+5;} if(!this.config.dragMin){this._setCanDrag(false);}else{this._setCanDrag(true);this.restorer.restoreProp("_updateState");} this._setCanResize(false);if(this.state.state=="max"){this.showButton("maxButton");}else{this.showButton("restoreButton");} this.hideButton("minButton");this.state.prevState=this.state.state;this.state.state="min";if(!this.getConfiguration().fixed){Zapatec.FixateOnScreen.register(this.getContainer());Zapatec.FixateOnScreen.register(this.WCH);} this.deactivate();}else{return false;} this.fireEvent("onMinimize",this);return true;} Zapatec.Window.prototype.maximize=function(){if(!this.config.showMaxButton){return false;} var self=this;if(!this.fireOnState("ready",function(){self.maximize();}))return;if(this.state.state!="max"){var sizes=Zapatec.Utils.getWindowSize();if(this.state.state=="min"){this.restore();} this.showButton("restoreButton");this.hideButton("maxButton");this._setCanDrag(false);this._setCanResize(false);this.restorer.saveProp("_updateState");this._updateState=function(){};this.setHeight(this.getHeight());this.setScreenPosition(0,0);this.setSize(sizes.width,sizes.height);this.state.prevState="simple";this.state.state="max";if(!this.getConfiguration().fixed){Zapatec.FixateOnScreen.register(this.getContainer());Zapatec.FixateOnScreen.register(this.WCH);} this.activate();}else{return false;} this.fireEvent("onMaximize",this);return true;} Zapatec.Window.prototype.restore=function(){if(!this.config.showMaxButton&&!this.config.showMinButton){return false;} var self=this;if(!this.fireOnState("ready",function(){self.restore();}))return;if(this.state.prevState=="max"){return this.maximize();} if(this.state.state!="simple"){var self=this;function showAll(el){if(el!=self.container){var first=el.firstChild;while(first){if(first&&first.restorer){first.restorer.restoreProp("style.display");first.restorer=null;} first=first.nextSibling;} showAll(el.parentNode);}} if(this.config.showMaxButton){this.showButton("maxButton");} if(this.config.showMinButton){this.showButton("minButton");} this.hideButton("restoreButton");var wasState=this.state.state;this.state.state="simple";if(wasState=="min"&&this.config.bottomMinimize){Zapatec.Window.sortMin(this);} if(!this.getConfiguration().fixed){Zapatec.FixateOnScreen.unregister(this.getContainer());Zapatec.FixateOnScreen.unregister(this.WCH);this.setPosition(this.state.left,this.state.top);}else{this.setScreenPosition(this.state.left,this.state.top);} this.setSize(this.state.width,this.state.height);this._setCanDrag(true);this._setCanResize(true);if(wasState=="min"){showAll(this.titleArea);} this.restorer.restoreProps("_updateState","content","statusText","getConfiguration().limit.minHeight");if(wasState=="min"){this.content.show();} this.activate();} this.fireEvent("onRestore",this);return true;} Zapatec.Window.prototype.close=function(){var self=this;if(!this.fireOnState("ready",function(){self.close();}))return;this.restore();this.deactivate();this.fireEvent("onClose",this);if(!this.config.hideOnClose){if(this.content.destroy)this.content.destroy();this.content=null;this.restoreOfDrag();this.restoreOfResize();if(this.minButton.destroy)this.minButton=this.minButton.destroy();if(this.maxButton.destroy)this.maxButton=this.maxButton.destroy();if(this.closeButton.destroy)this.closeButton=this.closeButton.destroy();if(this.restoreButton.destroy)this.restoreButton=this.restoreButton.destroy();for(var iEl in this){if(this[iEl]&&typeof this[iEl]=="object"&&this[iEl].nodeType&&iEl!="container"&&iEl!="WCH"){this[iEl]=null;}} if(this.config.modal==true&&this.modal){this.modal.hide(true);delete this.modal;} this.config=null;this.restorer=this.restorer.destroy();if(this.container.outerHTML){this.container.outerHTML="";}else{Zapatec.Utils.destroy(this.container);} if(this.WCH&&this.WCH.outerHTML){this.WCH.outerHTML="";}else if(this.WCH){Zapatec.Utils.destroy(this.WCH);} delete this.container;delete this.WCH;this.changeState("destroyed");this.removeEvent("onRestore");this.removeEvent("onMinimize");this.removeEvent("onMaximize");this.removeEvent("onShow");this.removeEvent("onHide");this.removeEvent("onRaise");this.removeEvent("onContentLoad");this.removeEvent("privileged_execution_on");this.removeEvent("privileged_execution_off");this.removeEvent("delayed_execution_on");this.removeEvent("delayed_execution_off");}else{this.hide();} return true;} Zapatec.Window.maxNumber=5;Zapatec.Window.currentWindow=null;Zapatec.Window.minimizeLeft=0;Zapatec.Window.minWinWidth=120;Zapatec.Window.lastActive=null;Zapatec.Window.sortMin=function(raised){var place=raised.getScreenPosition().x,win=null,left=0;for(var i=0;i<Zapatec.Widget.all.length;++i){if(Zapatec.Widget.all[i].widgetType=="window"){win=Zapatec.Widget.all[i];if(win&&win.state.state=="min"){left=win.getScreenPosition().x;if(left>place){left-=Zapatec.Window.minWinWidth+5;win.setScreenPosition(left-(Zapatec.Utils.bodyOffset?Zapatec.Utils.bodyOffset.left:0),null);}}}} win=null;Zapatec.Window.minimizeLeft-=Zapatec.Window.minWinWidth+5;};Zapatec.Window.activateFreeWindow=function(me){if(Zapatec.Window.activating){return false;} var win=Zapatec.Window.lastActive;Zapatec.Window.lastActive=me;if(win&&win!=me&&win.canActivate()===true){win.activate();return true;} var allW=Zapatec.Widget.all;var minimized=null;for(var iWidget=0;iWidget<allW.length;++iWidget){win=allW[iWidget];if(win&&win.widgetType=="window"&&win!=me){if(win.canActivate()===true){win.activate();return true;}else if(win.canActivate()=="min"&&!minimized){minimized=win;}}} if(minimized){minimized.activate();return true;}else{Zapatec.Window.currentWindow=null;return false;}};Zapatec.Window.activating=null;Zapatec.Window.mouseDown=function(ev,win,target){if(!win.config.raiseOnlyOnTitle){win.activate();}else if(target&&target.buttonType=="title"){win.activate();} if(target&&target.buttonType!="content"){return Zapatec.Utils.stopEvent(ev);}};Zapatec.Window.mouseMove=function(ev,win,target){};Zapatec.Window.mouseUp=function(ev,win,target){};Zapatec.Window.dblClick=function(ev,win,target){if(target){switch(target.buttonType){case"title":{switch(win.state.state){case"min":{win.restore();break;} case"max":{win.restore();break;} case"simple":{win.maximize();break;}} break;}} win.dragEnd(ev);if(target.buttonType!="content"){return Zapatec.Utils.stopEvent(ev);}}} Zapatec.Window.prototype.parseDom=function(el){var classes="";if(!el||typeof el!="object"||!el.nodeType){return false;} if(el.className){classes=el.className.match(/area(\w+)/);el.win=true;if(classes){el.id="zpWin"+this.id+classes[1];classes[1]=classes[1].charAt(0).toLowerCase()+classes[1].substring(1);this.createProperty(this,classes[1],el);Zapatec.Utils.removeClass(el,classes[0]);}} var child=el.firstChild;while(child){this.parseDom(child);child=child.nextSibling;} return true;};Zapatec.Window.prototype.showButton=function(button){this.restorer.restoreProp(button+".getContainer().parentNode.style.display");};Zapatec.Window.prototype.hideButton=function(button){this.restorer.saveProp(button+".getContainer().parentNode.style.display");this[button].getContainer().parentNode.style.display="none";};Zapatec.Window.prototype.reconfig=function(){if(!this.fireOnState("ready",function(){this.reconfig();})){return;} var config=this.getConfiguration();if(!config.showTitle){this.restorer.saveProp("titleArea.style.display");this.titleArea.style.display="none";}else{this.restorer.restoreProp("titleArea.style.display");if(!config.showMinButton||this.state.state=="min"){this.hideButton("minButton");}else{this.showButton("minButton");} if(!config.showMaxButton||this.state.state=="max"){this.hideButton("maxButton");}else{this.showButton("maxButton");} if(this.state.state!="max"&&this.state.state!="min"){this.hideButton("restoreButton");}else{this.showButton("restoreButton");} if(!config.showCloseButton){this.hideButton("closeButton");}else{this.showButton("closeButton");}} if(!config.showStatus){this.restorer.saveProp("statusText.style.display");this.statusText.style.display="none";}else{this.restorer.restoreProp("statusText.style.display");} if(config.modal&&!this.modal){this.modal=new Zapatec.Modal({themePath:Zapatec.zapatecPath+"../zpextra/themes/indicator/"});this.modal.create();}};Zapatec.Window.prototype.addEvents=function(){var self=this,target=null;Zapatec.Utils.addEvent(this.container,"mousedown",function(ev){ev=ev||window.event;target=Zapatec.Utils.getTargetElement(ev);while(!target.buttonType&&(target!=self.container)){target=target.parentNode;} if(!target.buttonType){target=null;} var result=Zapatec.Window.mouseDown(ev,self,target);target=null;return result;});if(Zapatec.is_gecko){Zapatec.Utils.addEvent(this.container,"click",function(ev){var result=null;ev=ev||window.event;if(ev.detail>1){target=Zapatec.Utils.getTargetElement(ev);while(!target.buttonType&&(target!=self.container)){target=target.parentNode;} if(!target.buttonType){target=null;} result=Zapatec.Window.dblClick(ev,self,target);} target=null;return result;});}else{Zapatec.Utils.addEvent(this.container,"dblclick",function(ev){ev=ev||window.event;target=Zapatec.Utils.getTargetElement(ev);while(!target.buttonType&&(target!=self.container)){target=target.parentNode;} if(!target.buttonType){target=null;} var result=Zapatec.Window.dblClick(ev,self,target);target=null;return result;});}};Zapatec.Window.prototype._getDraggableHooks=function(){return this.titleText;};Zapatec.Window.prototype.canDrag=function(){return this.getConfiguration().canDrag;};Zapatec.Window.prototype._setCanDrag=function(on){if(!on){if(typeof this.restorer.getProp("getConfiguration().canDrag")=="undefined"){this.restorer.saveProp("getConfiguration().canDrag");} this.getConfiguration().canDrag=on;}else{if(typeof this.restorer.getProp("getConfiguration().canDrag")!="undefined"){this.restorer.restoreProp("getConfiguration().canDrag");}}};Zapatec.Window.prototype.getDragConfig=function(){var config=this.getConfiguration();return{method:config.dragMethod,dragCSS:config.addDragCSS,overwriteCSS:config.newDragCSS,copyChilds:false,stopEvent:false,eventCapture:true};};Zapatec.Window.prototype.setDragConfig=function(config){};Zapatec.Window.prototype.getSizableElements=function(dim){if(dim=="width"){return[this.titleText,this.content?this.content.getContainer():null,this.getConfiguration().showStatus?this.statusText:null,this.getContainer(),this.WCH];}else if(dim=="height"){return[this.content?this.content.getContainer():null,this.getContainer(),this.WCH];}else{return[this.titleText,this.content?this.content.getContainer():null,this.getConfiguration().showStatus?this.statusText:null,this.getContainer(),this.WCH];}};Zapatec.Window.prototype._getAutoSizableElement=function(){return this.content.getContainer();};Zapatec.Window.prototype.getSizingConfig=function(){return{limit:this.getConfiguration().limit,direction:"both"};};Zapatec.Window.prototype.setSizingConfig=function(config){if(typeof config.limit=="object"){this.getConfiguration().limit.minWidth=config.limit.minWidth;this.getConfiguration().limit.maxWidth=config.limit.maxWidth;this.getConfiguration().limit.minHeight=config.limit.minHeight;this.getConfiguration().limit.maxHeight=config.limit.maxHeight;}};Zapatec.Window.prototype.getMovableElements=function(){return[this.getContainer(),this.WCH];};Zapatec.Window.prototype.getMoveConfig=function(){return{limit:this.getConfiguration().limit,moveLayer:document.body,direction:"both",preserveSizes:true,followShape:false};};Zapatec.Window.prototype.setMoveConfig=function(config){if(typeof config.limit=="object"){this.getConfiguration().limit.minX=config.limit.minX;this.getConfiguration().limit.maxX=config.limit.maxX;this.getConfiguration().limit.minY=config.limit.minY;this.getConfiguration().limit.maxY=config.limit.maxY;}};Zapatec.Window.prototype._getResizableHooks=function(){return null;};Zapatec.Window.prototype.canResize=function(){return this.getConfiguration().canResize;};Zapatec.Window.prototype._setCanResize=function(on){if(!on){if(typeof this.restorer.getProp("getConfiguration().canResize")=="undefined"){this.restorer.saveProp("getConfiguration().canResize");} this.getConfiguration().canResize=on;}else{if(typeof this.restorer.getProp("getConfiguration().canResize")!="undefined"){this.restorer.restoreProp("getConfiguration().canResize");}}};Zapatec.Window.prototype.getResizeConfig=function(){return{stopEvent:false,eventCapture:true,direction:this.getConfiguration().resizeDirection,borderThickness:10,cornerThickness:10};};Zapatec.Window.prototype.setResizeConfig=function(config){if(typeof config.direction=="string"&&config.direction.length>2){this.getConfiguration().resizeDirection=config.direction;}};Zapatec.Window.prototype.setModeOn=function(mode){if(typeof mode!="string"){return false;} if(!this.widgetModes[mode]){this.widgetModes[mode]={};} this.widgetModes[mode].on=true;this.widgetModes[mode].caller=this.setModeOn.caller;this.fireEvent(mode+"_on",this);return true;};Zapatec.Window.prototype.setModeOff=function(mode){if(typeof mode!="string"||!this.widgetModes[mode]){return false;} this.widgetModes[mode].on=false;this.widgetModes[mode].caller=null;this.fireEvent(mode+"_off",this);return true;};Zapatec.Window.prototype.modeOn=function(mode){if(this.widgetModes[mode]&&this.widgetModes[mode].on===true){return true;} return false;};Zapatec.Window.prototype.modeSameCaller=function(mode,caller){while(caller){if(caller.caller==this.widgetModes[mode].caller){return true;} caller=caller.caller;} return false;};Zapatec.Window.prototype.fireOnState=function(state,func){var self=this;if(this.modeOn("immediate_execution")&&this.modeSameCaller("immediate_execution",this.fireOnState)){return true;} if(state=="body_loaded"){if(!this.stateReached("created")){return false;} if(!Zapatec.windowLoaded){setTimeout(function(){func.call(self);},50);return false;} return true;} if(!this.stateReached(state)){if(!this.stateReached("created")){return false;} if(this.modeOn("privileged_execution")&&this.modeSameCaller("privileged_execution",this.fireOnState)){this.highPriorityEvents.push({"state":state,"listener":func,"executed":false});return false;} if(this.modeOn("delayed_execution")){this.delayedEvents.push({"state":state,"listener":func});return false;} this.addEventListener(state,func);return false;}else{return true;}};Zapatec.Window.prototype.changeState=function(state){if(this.modeOn("delayed_execution")){this.addEventListener("delayed_execution_off",function(){this.changeState(state);});} if(this.modeOn("privileged_execution")){this.setModeOff("privileged_execution");} this.widgetState=state;if(!this.isEvent(state)){return;} var listeners=this.getEventListeners(state);for(var ii=0;ii<listeners.length;++ii){if(!this.modeOn("delayed_execution")){listeners[ii].apply(this);}else{this.addEventListener("delayed_execution_off",listeners[ii]);}} this.removeEvent(state);return true;};Zapatec.Window.prototype.stateReached=function(state){var currentState=this.priorities[this.widgetState]||(this.priorities[this.widgetState]!==0?this.priorities.count:0);state=this.priorities[state]||(this.priorities[state]!==0?this.priorities.count:0);if(state>currentState){return false;} return true;};Zapatec.Window.setup=function(config){var winConfig=Zapatec.Hash.remove(config,"popup","triggerEvent","align","width","height","left","top","title","content","divContent","urlContent","initialState")||{},win=null;if(config.popup){winConfig.hideOnClose=true;win=new Zapatec.Window(winConfig);win.create(0,0,config.width||win.config.minWidth,config.height||win.config.minHeight);if(typeof config.popup=="string"){config.popup=document.getElementById(config.popup);} if(!config.popup){alert(win.getMessage('setupWrongTriggerError'));win.close();return;} if(!config.triggerEvent){config.triggerEvent="click";} if(!config.align){config.align=null;} el=config.popup;el["on"+config.triggerEvent]=function(ev){win.show();win.restore();win.setWidth(config.width||win.config.minWidth);win.setHeight(config.height||win.config.minHeight);win.hide();if(!win.config.visible){win.showAtElement(this,config.align);} if(config.title){win.setTitle(config.title);} if(config.content){win.setContent(config.content);} if(config.divContent){win.setDivContent(config.divContent);} if(config.urlContent){win.setContentUrl(config.urlContent);} return false;};}else{win=new Zapatec.Window(winConfig);win.create(config.left||0,config.top||0,config.width||win.config.minWidth,config.height||win.config.minHeight);if(config.initialState!="hidden"){win.show();} if(config.title){win.setTitle(config.title);} if(config.content){win.setContent(config.content);} if(config.divContent){win.setDivContent(config.divContent);} if(config.urlContent){win.setContentUrl(config.urlContent);}} return win;};Zapatec.Utils.createNestedHash(Zapatec,["Langs","Zapatec.Window","eng"],{'windowOnResizeStatusMessage':'resize the window','windowOnBeforeDragStatusMessage':'drag the window','alertOkButtonLabel':"Ok",'confirmCancelButtonLabel':"Cancel",'confirmOkButtonLabel':"OK",'setupWrongTriggerError':"You specified wrong trigger element!"}); Zapatec.Utils.addEvent(window, 'load', Zapatec.Utils.checkActivation);