/*
 *
 * Copyright (c) 2004-2005 by Zapatec, Inc.
 * http://www.zapatec.com
 * 1700 MLK Way, Berkeley, California,
 * 94709, U.S.A.
 * All rights reserved.
 *
 *
 */
Zapatec.panesetPath = Zapatec.getPath("Zapatec.PaneSetWidget");

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.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.PaneSet=function(config){this.widgetType="paneset";this.widgetState="created";this.priorities={count:8,destroyed:0,created:1,inited:2,prepared:3,loaded:4,ready:5,hidden:6,shown:7};this.panes=[];this.dividers=[];this.systemEventsOn=false;this.state={};Zapatec.PaneSet.SUPERconstructor.call(this,config);};Zapatec.PaneSet.id="Zapatec.PaneSet";Zapatec.inherit(Zapatec.PaneSet,Zapatec.Widget);Zapatec.PaneSet.prototype.init=function(config){Zapatec.PaneSet.SUPERclass.init.call(this,config);this.loadData({object:this,action:"loadTemplate"});var self=this;Zapatec.PaneSet.loadPanesObject({from:this.config.panes,type:this.config.dataType,paneSet:this,onSuccess:function(data){self.config.panes=data;self.config.dataType="json";self.initChildPanes();},onFailure:function(){Zapatec.Log({description:"Can't load the data for PaneSet with ID - '"+this.id+"'!"});}});};Zapatec.PaneSet.prototype.configure=function(config){this.defineConfigOption("orientation","horizontal");this.defineConfigOption("panes",null);this.defineConfigOption("dataType","json");this.defineConfigOption("breadth",null);this.defineConfigOption("parent",null);this.defineConfigOption("id",null);this.defineConfigOption("reuseContainer",null);this.defineConfigOption("length",null);this.defineConfigOption("prefix","zpPaneSet");this.defineConfigOption("resizable",false);this.defineConfigOption("template",Zapatec.PaneSet.path+"h-divider.html");this.defineConfigOption("callbackSource",function(args){var paneSet=args.object;if(!paneSet||paneSet.widgetType!="paneset"){return null;}
switch(args.action){case"loadTemplate":{return{source:paneSet.getConfiguration().template,sourceType:"html/url"};}}
return null;});Zapatec.PaneSet.SUPERclass.configure.call(this,config);if(this.config.orientation!="horizontal"){this.config.template=Zapatec.PaneSet.path+"v-divider.html";}};Zapatec.PaneSet.prototype.reconfigure=function(config){Zapatec.PaneSet.SUPERclass.reconfigure.call(this,config);};Zapatec.PaneSet.prototype.initChildPanes=function(){if(!this.config.panes){Zapatec.Log({description:"No Pane objects passed!"});return null;}else if(this.config.panes.length<2){Zapatec.Log({description:"There must be at least two Panes! You should use Pane in such case."});return null;}
var item,i,pWidth,pHeight;for(i=0;i<this.config.panes.length;++i){item=this.config.panes[i];if(item.panes){item.orientation=this.config.orientation=="vertical"?"horizontal":"vertical";item.parent=this;item.length=this.config.breadth;item.resizable=this.config.resizable;item.eventListeners=this.config.eventListeners;this.panes.push(new this.constructor(item));}else{if(item.containerType!="current"){item.el=null;}
if(this.config.orientation=="vertical"){pWidth=this.config.breadth;pHeight=item.breadth;}else{pHeight=this.config.breadth;pWidth=item.breadth;}
var oPaneset=this;this.panes.push(new Zapatec.Pane({containerType:item.containerType,source:item.content,sourceType:item.contentType,onlyInit:true,width:pWidth,height:pHeight,parent:item.el||this,eventListeners:{onReady:function(){oPaneset.fireEvent('paneInitialized',this.container.id);}}}));this.panes[this.panes.length-1].config.id=item.id;this.panes[this.panes.length-1].config.breadth=item.breadth;this.panes[this.panes.length-1].config.length=this.config.breadth;}}
this.changeState("inited");};Zapatec.PaneSet.prototype.prepareHtml=function(){if(!this.fireOnState("inited",function(){this.prepareHtml();})){return;}
if(!this.config.reuseContainer){this.container=document.createElement("div");}else if(this.config.reuseContainer=Zapatec.Widget.getElementById(this.config.reuseContainer)){this.container=this.config.reuseContainer;}
for(var i=0;i<this.panes.length;++i){if(this.panes[i].prepareHtml){this.panes[i].prepareHtml();}}
this.changeState("prepared");};Zapatec.PaneSet.prototype.loadDataHtml=function(el){if(!this.fireOnState("prepared",function(){this.loadDataHtml(el);})){return;}
if(this.parseDom(el)){this.changeState("loaded");}};Zapatec.PaneSet.prototype.create=function(breadth,length){if(!this.fireOnState("loaded",function(){this.create(breadth,length);})||!this.fireOnState("body_loaded",function(){this.create(breadth,length);})){return;}
var parent=Zapatec.Widget.getElementById(this.config.parent);if(!parent){Zapatec.Log({description:"No reference to parent element."});return null;}
this.config.parent=parent;if(parent.requestParentFor&&!(parent=parent.requestParentFor(this))){Zapatec.Log({description:"No reference to parent element after request to the Parent Widget!"});return null;}
if(this.config.reuseContainer&&(!this.container||!(this.contianer=Zapatec.Widget.getElementById(this.config.reuseContainer)))){Zapatec.Log({description:"No container element found!"+this.config.reuseContainer});return null;}
if(!this.container.parentNode||this.container.parentNode!=parent){parent.appendChild(this.container);}
if(this.container.style.position==""||this.container.style.position=="static"){this.container.style.position=="relative";}
Zapatec.Utils.addClass(this.container,this.getClassName({prefix:this.config.prefix,suffix:"Container"}));Zapatec.Utils.addClass(this.container,"zpPaneSetMarker");this.container.style.display="block";this.container.style.overflow="hidden";this.systemEventsOn=true;this.createPanes(breadth,length);this.setContainerSizes();this.systemEventsOn=false;this.changeState("ready");this.container.style.overflow="visible";};Zapatec.PaneSet.prototype.createPanes=function(breadth,length){if(!this.fireOnState("inited",function(){this.createPanes(breadth,length);})){return;}
var pos={x:0,y:0},i,maxLength,compLength,maxBreadth,compBreadth,pBreadth,pLength;maxLength=length||this.config.length||null;if(!maxLength){compLength=this.getCompoundLength();}
maxBreadth=breadth||this.config.breadth||null
if(!maxBreadth){compBreadth=this.getCompoundBreadth();}
for(i=0;i<this.panes.length;++i){if(maxLength!==0){pBreadth=null;pLength=maxBreadth||compBreadth;if(maxLength&&maxLength-(this.panes[i].config.breadth+this.getDividerLength())<=0){pBreadth=maxLength;maxLength=0;}else if(maxLength){maxLength-=this.panes[i].config.breadth;pBreadth=this.panes[i].config.breadth;if(i===this.panes.length-1&&maxLength!==0){pBreadth+=maxLength;maxLength=0;}}
this.createPane(this.panes[i],pos.x,pos.y,pBreadth,pLength);this.incCoords(pos,pBreadth||this.panes[i].config.breadth);if(i!==this.panes.length-1&&maxLength!==0){this.createDivider(this.panes[i],pos.x,pos.y,pLength);this.incCoords(pos,this.getDividerLength());if(maxLength){maxLength-=this.getDividerLength();}}}else{this.panes[i].getContainer().style.display="none";this.panes[i].disabled=true;}}
this.config.length=length||this.config.length||compLength+(this.getDividerLength()*this.dividers.length);this.config.breadth=breadth||this.config.breadth||compBreadth;};Zapatec.PaneSet.prototype.createPane=function(pane,x,y,breadth,length){if(!this.fireOnState("prepared",function(){this.createPane(pane,x,y,breadth,length);})){return;}
if(!pane){return false;}
if(pane.widgetType=="pane"){if(pane.config.containerType!="iframe"){Zapatec.Utils.addClass(pane.getContainer(),"zpPaneMarker");}
if(this.config.orientation=="vertical"){pane.create(length,breadth);pane.config.breadth=breadth||pane.config.height;pane.config.length=length||pane.config.width;}else{pane.create(breadth,length);pane.config.breadth=breadth||pane.config.width;pane.config.length=length||pane.config.height;}}else if(pane.widgetType=="paneset"){pane.create(breadth,length);}
this.movePane(pane,x,y);pane.disabled=false;};Zapatec.PaneSet.prototype.createDivider=function(after,x,y,length){var self=this;if(!this.fireOnState("loaded",function(){this.createDivider(after,x,y,length);})||(after.widgetType=="paneset"&&!after.fireOnState("ready",function(){self.createDivider(after,x,y,length);}))){return;}
var divider=this.config.orientation=="vertical"?Zapatec.PaneSet.vDivider.cloneNode(true):Zapatec.PaneSet.hDivider.cloneNode(true);this.dividers.push(divider);this.requestParentFor(divider).insertBefore(divider,after.getContainer().nextSibling);this.setDividerBreadth(divider,length||this.config.breadth);this.moveDivider(divider,x,y);if(this.config.resizable){this.makeDragable(divider);if(this.config.orientation=="vertical"){Zapatec.Utils.addClass(divider,"zpPaneSetVResizable");}else{Zapatec.Utils.addClass(divider,"zpPaneSetHResizable");}}};Zapatec.PaneSet.prototype.setContainerWidth=function(width){if(!this.fireOnState("ready",function(){this.setContainerWidth(width);})){return;}
Zapatec.Utils.setWidth(this.getContainer(),width);};Zapatec.PaneSet.prototype.setContainerHeight=function(height){if(!this.fireOnState("ready",function(){this.setContainerHeight(height);})){return;}
Zapatec.Utils.setHeight(this.getContainer(),height);};Zapatec.PaneSet.prototype.setDividerBreadth=function(divider,breadth){if(!this.fireOnState("ready",function(){this.setDividerBreadth(divider,breadth);})){return;}
if(!this.isChildDivider(divider)){return;}
if(this.config.orientation=="vertical"){Zapatec.Utils.setWidth(divider,breadth);}else{Zapatec.Utils.setHeight(divider,breadth);}};Zapatec.PaneSet.prototype.setContainerSizes=function(length,breadth){this.config.breadth=parseInt(breadth,10)||this.config.breadth;this.config.length=parseInt(length,10)||this.config.length;if(this.config.orientation=="vertical"){this.setContainerWidth(this.config.breadth);this.setContainerHeight(this.config.length);}else{this.setContainerWidth(this.config.length);this.setContainerHeight(this.config.breadth);}};Zapatec.PaneSet.prototype.movePane=function(pane,x,y){var self=this,paneCont=null;if(!this.fireOnState("ready",function(){this.movePane(pane,x,y);})||(pane.widgetType=="paneset"&&!pane.fireOnState("ready",function(){self.movePane(pane,x,y);}))){return;}
if(typeof this.isChildPane(pane)=="number"){paneCont=pane.getContainer();Zapatec.Utils.makeSafelyMovable(paneCont,this.getContainer(),null);Zapatec.Utils.moveTo(paneCont,x,y);}};Zapatec.PaneSet.prototype.moveDivider=function(divider,x,y){if(!this.fireOnState("ready",function(){this.moveDivider(divider,x,y);})){return;}
if(this.isChildDivider(divider)){Zapatec.Utils.makeSafelyMovable(divider,this.getContainer(),null);Zapatec.Utils.moveTo(divider,x,y);}};Zapatec.PaneSet.prototype.setPaneLength=function(pane,length){var self=this,diff,position,nextPane,divider,availSpace,dividerPos,nextPos;length=parseInt(length,10);if(!this.fireOnState("ready",function(){this.setPaneLength(pane,length);})){return;}
if(typeof pane=="string"){pane=this.getPaneById(pane);}else if(typeof pane=="number"){pane=this.panes[pane-1];}else if(!pane||!pane.widgetType){Zapatec.Log({description:"No Pane/PaneSet found when calling setPaneLength!"});return;}
position=this.isChildPane(pane);if(!position&&position!==0){Zapatec.Log({description:"Not a child Pane or PaneSet object passed when calling setPaneLength!"});return;}
if(pane.disabled){return;}
if(typeof position=="number"){nextPane=this.panes[position+1];divider=this.dividers[position];if(nextPane&&nextPane.widgetType=="paneset"&&!nextPane.fireOnState("ready",function(){self.setPaneLength(pane,length);})){return;}
if(pane.widgetType=="paneset"&&!pane.fireOnState("ready",function(){self.setPaneLength(pane,length);})){return;}
diff=length-pane.config.breadth;if(diff>0&&divider){if(nextPane.widgetType=="paneset"){availSpace=nextPane.getAvailableBreadth(false);}else{availSpace=nextPane.config.breadth-1;}
length-=diff;if(availSpace<diff){diff=availSpace;}
length+=diff;}else if(diff<0&&divider){if(pane.widgetType=="paneset"){availSpace=pane.getAvailableBreadth(true);}else{availSpace=pane.config.breadth-1;}
length-=diff;if(availSpace<Math.abs(diff)){diff=-availSpace;}
length+=diff;}else{length=pane.config.breadth;}
this.sizePane(pane,null,length,true);this.config.panes[position].breadth=length;if(nextPane&&divider){dividerPos=Zapatec.Utils.getPos(divider);nextPos=Zapatec.Utils.getPos(nextPane.getContainer());this.incCoords(dividerPos,diff);this.incCoords(nextPos,diff);this.config.panes[position+1].breadth=nextPane.config.breadth-diff;this.moveDivider(divider,dividerPos.x,dividerPos.y);this.movePane(nextPane,nextPos.x,nextPos.y);this.sizePane(nextPane,null,nextPane.config.breadth-diff,false);}
this.bubleEvent("paneLengthChanged",pane,nextPane);}else if(position&&position.widgetType=="paneset"){position.setPaneLength(pane,length);return;}else{Zapatec.Log({description:"Can't find position of a child Pane or PaneSet object\n passed when calling setPaneLength!"});return;}};Zapatec.PaneSet.prototype.sizePane=function(pane,breadth,length,end){breadth=parseInt(breadth,10);length=parseInt(length,10);if(!this.fireOnState("ready",function(){this.sizePane(pane,breadth,length,end);})){return;}
if(this.config.orientation=="vertical"){if(breadth){pane.setWidth(breadth,end);pane.config.length=breadth;}
if(length){pane.setHeight(length,end);pane.config.breadth=length;}}else{if(breadth){pane.setHeight(breadth,end);pane.config.length=breadth;}
if(length){pane.setWidth(length,end);pane.config.breadth=length;}}};Zapatec.PaneSet.prototype.setWidth=function(width,end){if(this.config.orientation=="vertical"){this.setBreadth(width,end);}else{this.setLength(width,end);}};Zapatec.PaneSet.prototype.setHeight=function(height,end){if(this.config.orientation=="horizontal"){this.setBreadth(height,end);}else{this.setLength(height,end);}};Zapatec.PaneSet.prototype.setBreadth=function(breadth,end){var i;breadth=parseInt(breadth,10);if(!this.fireOnState("ready",function(){this.setBreadth(breadth,end);})){return;}
for(i=0;i<this.panes.length;++i){this.sizePane(this.panes[i],breadth,null,end);}
for(i=0;i<this.dividers.length;++i){this.setDividerBreadth(this.dividers[i],breadth);}
if(this.config.orientation=="vertical"){this.setContainerWidth(breadth);}else{this.setContainerHeight(breadth);}};Zapatec.PaneSet.prototype.setLength=function(length,end){var i,diff,pos=0,panePos,nextPane,breadth,res;length=parseInt(length,10);if(!this.fireOnState("ready",function(){this.setLength(length,end);})){return;}
diff=length-this.config.length;if(diff===0){return;}
pos=this.getFirstOrLastIndex(end);if(diff>0){if(!end){this.moveAllAfter(pos,diff);}
breadth=this.panes[pos].config.breadth+diff;diff=breadth-this.config.panes[pos].breadth;if(this.getPrevPane(this.panes[pos],end)&&diff>0){if(!end){panePos={x:0,y:0};this.incCoords(panePos,diff);this.movePane(this.panes[pos],panePos.x,panePos.y);this.decCoords(panePos,this.config.panes[pos].breadth);}else{panePos=Zapatec.Utils.getElementPos(this.panes[pos].getContainer());this.incCoords(panePos,this.config.panes[pos].breadth);}
this.sizePane(this.panes[pos],null,this.config.panes[pos].breadth,end);this.showDisabled(pos,panePos,diff,end);}else{this.sizePane(this.panes[pos],null,breadth,end);}}else{res=this.disablePanes(pos,diff,end);diff+=res.diff;pos=res.position;this.sizePane(this.panes[pos],null,this.panes[pos].config.breadth+diff,end);if(!end){this.movePane(this.panes[pos],0,0);this.moveAllAfter(pos,diff);}}
if(this.config.orientation=="vertical"){this.setContainerHeight(length);}else{this.setContainerWidth(length);}};Zapatec.PaneSet.prototype.moveAllAfter=function(position,diff){var i,divPos,panePos;if(!this.fireOnState("ready",function(){this.moveAllAfter(position,diff);})){return;}
for(i=position;this.panes[i+1]&&!this.panes[i+1].disabled;++i){divPos=Zapatec.Utils.getPos(this.dividers[i]);panePos=Zapatec.Utils.getPos(this.panes[i+1].getContainer());this.incCoords(divPos,diff);this.incCoords(panePos,diff);this.moveDivider(this.dividers[i],divPos.x,divPos.y);this.movePane(this.panes[i+1],panePos.x,panePos.y);}};Zapatec.PaneSet.prototype.showDisabled=function(pane,position,diff,end){var nextPane,breadth;position=this.getNextIndex(position,end);nextPane=this.getNextIndex(position,end);if(!this.panes[position]){return;}
if(this.panes[nextPane]&&diff>this.config.panes[position].breadth){this.createPane(this.panes[position],panePos.x,panePos.y,this.config.panes[position].breadth,this.config.length);if(!end){this.decCoords(panePos,this.config.panes[position].breadth);}else{this.incCoords(panePos,this.config.panes[position].breadth);}
if(this.dividers[position]){this.dividers[position].style.display="block";if(!end){this.decCoords(panePos,this.getDividerlength());}else{this.incCoords(panePos,this.getDividerlength());}}else{this.createDivider(this.panes[position],panePos.x,panePos.y,this.config.breadth);if(!end){this.decCoords(panePos,this.getDividerlength());}else{this.incCoords(panePos,this.getDividerlength());}}
this.showDisabled(position,panePos,diff,end);}else{this.createPane(this.panes[position],panePos.x,panePos.y,diff,this.config.length);}};Zapatec.PaneSet.prototype.disablePanes=function(position,diff,end){var oldDiff=Math.abs(diff);while(oldDiff>this.panes[position].config.breadth){this.panes[position].getContainer().style.display="none";this.panes[position].disabled=true;oldDiff-=this.panes[position].config.breadth;if(this.dividers[position]){this.dividers[position].style.display="none";oldDiff-=this.getDividerLength();}
position=this.getNextIndex(position,end);}
return{"diff":Math.abs(diff)-oldDiff,"position":position};};Zapatec.PaneSet.prototype.parseDom=function(el){if(this.config.orientation=="vertical"){if(!Zapatec.PaneSet.vDivider){Zapatec.PaneSet.vDivider=el;}}else{if(!Zapatec.PaneSet.hDivider){Zapatec.PaneSet.hDivider=el;}}
return true;};Zapatec.PaneSet.prototype.getContainer=function(){return this.container;};Zapatec.PaneSet.prototype.requestParentFor=function(pane){return this.getContainer();};Zapatec.PaneSet.prototype.getDividerLength=function(){var divider=null;if(!this.state.dividerLength){divider=(this.config.orientation=="vertical")?Zapatec.PaneSet.vDivider:Zapatec.PaneSet.hDivider;divider=divider.cloneNode(true);this.getContainer().appendChild(divider);divider.style.position="absolute";this.state.dividerLength=(this.config.orientation=="vertical")?divider.offsetHeight:divider.offsetWidth;this.getContainer().removeChild(divider);divider=null;}
return this.state.dividerLength;};Zapatec.PaneSet.prototype.getCompoundLength=function(){if(this.config.length){return this.config.length;}
var i,length=0;for(i=0;i<this.panes.length;++i){if(this.panes[i].widgetType=="pane"){length+=(this.config.orientation=="vertical")?this.panes[i].getHeight():this.panes[i].getWidth();}else if(this.panes[i].widgetType=="paneset"){length+=this.panes[i].getCompoundBreadth();}}
return length;};Zapatec.PaneSet.prototype.getCompoundBreadth=function(){if(this.config.breadth){return this.config.breadth;}
var i,breadth=0,pLength;for(i=0;i<this.panes.length;++i){if(this.panes[i].widgetType=="pane"){pLength=(this.config.orientation=="horizontal")?this.panes[i].getHeight():this.panes[i].getWidth();}else if(this.panes[i].widgetType=="paneset"){pLength=this.panes[i].getCompoundLength();}
if(breadth<pLength){breadth=pLength;}}
return breadth||100;};Zapatec.PaneSet.prototype.isChildPane=function(pane){var i,position=null;for(i=0;i<this.panes.length;++i){if(this.panes[i]==pane){return i;}}
for(i=0;i<this.panes.length;++i){if(this.panes[i].widgetType=="paneset"){position=this.panes[i].isChildPane(pane);if(typeof position=="number"){return this.panes[i];}else if(position&&position.widgetType=="paneset"){return position;}}}
return null;};Zapatec.PaneSet.prototype.isChildDivider=function(divider){var i;for(i=0;i<this.dividers.length;++i){if(this.dividers[i]==divider){return true;}}
return false;};Zapatec.PaneSet.prototype.getPaneById=function(id){var i,pane;for(i=0;i<this.panes.length;++i){if(this.panes[i].config.id==id){return this.panes[i];}}
for(i=0;i<this.panes.length;++i){if(this.panes[i].widgetType=="paneset"){pane=this.panes[i].getPaneById(id);if(pane){return pane;}}}
return null;};Zapatec.PaneSet.prototype.getAvailableBreadth=function(end){var pos=this.getFirstOrLastIndex(),breadth=this.config.breadth;while(this.panes[pos]&&this.panes[pos]!=this.panes[this.getFirstOrLastIndex(true)+1]){if(this.panes[pos].widgetType=="paneset"){if(this.panes[pos].getAvailableLength(end)<breadth){breadth=this.panes[pos].getAvailableLength(end);}}else{if(this.panes[pos].config.length-1<breadth){breadth=this.panes[pos].config.length-1;}}
++pos;}
return breadth;};Zapatec.PaneSet.prototype.getAvailableLength=function(end){var pos=this.getFirstOrLastIndex(end);if(this.panes[pos].widgetType=="paneset"){return this.panes[pos].getAvailableBreadth(end);}else{return this.panes[pos].config.breadth-1;}};Zapatec.PaneSet.prototype.getFirstOrLastIndex=function(last){if(last){return this.getLastEnabledIndex();}else{return this.getFirstEnabledIndex();}};Zapatec.PaneSet.prototype.getLastEnabledIndex=function(){var pos=this.panes.length-1;while(this.panes[pos]&&this.panes[pos].disabled){--pos;}
return pos;};Zapatec.PaneSet.prototype.getFirstEnabledIndex=function(){var pos=0;while(this.panes[pos]&&this.panes[pos].disabled){++pos;}
return pos;};Zapatec.PaneSet.prototype.getFirstPane=function(){return this.panes[this.getFirstEnabledIndex()];};Zapatec.PaneSet.prototype.getLastPane=function(){return this.panes[this.getLastEnabledIndex()];};Zapatec.PaneSet.prototype.getNextIndex=function(pos,end){if(end){--pos;}else{++pos;}
return pos;};Zapatec.PaneSet.prototype.getPrevIndex=function(pos,end){if(end){++pos;}else{--pos;}
return pos;};Zapatec.PaneSet.prototype.getPaneIndex=function(pane){var i;if(!pane||!pane.widgetType){return null;}
for(i=0;i<this.panes.length;++i){if(this.panes[i]==pane){return i;}}
return null;};Zapatec.PaneSet.prototype.getNextPane=function(pane,end){var pos;pos=this.getPaneIndex(pane);return this.panes[this.getNextIndex(pos,end)];};Zapatec.PaneSet.prototype.getPrevPane=function(pane,end){var pos;pos=this.getPaneIndex(pane);return this.panes[this.getPrevIndex(pos,end)];};Zapatec.PaneSet.prototype.getNextEnabledPane=function(pane,end){var pos;pos=this.getPaneIndex(pane);pos=this.getNextIndex(pos);if(this.panes[pos].disabled){return this.panes[pos];}else{return null;}};Zapatec.PaneSet.prototype.getPrevEnabledPane=function(pane,end){var pos;pos=this.getPaneIndex(pane);pos=this.getNextIndex(pos);if(this.panes[pos].disabled){return this.panes[pos];}else{return null;}};Zapatec.PaneSet.prototype.incCoords=function(pos,breadth){if(this.config.orientation=="vertical"){pos.y+=breadth;}else{pos.x+=breadth;}};Zapatec.PaneSet.prototype.decCoords=function(pos,breadth){if(this.config.orientation=="vertical"){pos.y-=breadth;}else{pos.x-=breadth;}};Zapatec.PaneSet.prototype.makeDragable=function(divider){var self=this,start,draggable=new Zapatec.Utils.Draggable({container:divider,direction:this.config.orientation,followShape:false,moveLayer:this.getContainer(),method:"dummy",dragCSS:"zpDummyDivider",eventListeners:{onDragInit:function(){self.restrictDivider(divider);var pos=Zapatec.Utils.getPos(this.getMovableElements()[0]);if(self.config.orientation=="vertical"){start=pos.y;}else{start=pos.x;}},beforeDragEnd:function(){var index=self.getDividerIndex(divider),pos=Zapatec.Utils.getPos(this.getMovableElements()[0]),diff=0;if(self.config.orientation=="vertical"){diff=pos.y-start;}else{diff=pos.x-start;}
self.setPaneLength(self.panes[index],self.panes[index].config.breadth+diff);}}});};Zapatec.PaneSet.prototype.restrictDivider=function(divider){var index=this.getDividerIndex(divider),availLeft=this.panes[index].getAvailableBreadth?this.panes[index].getAvailableBreadth(true):this.panes[index].config.breadth-1,availRight=this.panes[index+1].getAvailableBreadth?this.panes[index+1].getAvailableBreadth():this.panes[index+1].config.breadth-1,pos=Zapatec.Utils.getPos(divider);if(this.config.orientation=="vertical"){divider.dragObj.reconfigure({limit:{minY:pos.y-availLeft,maxY:pos.y+availRight}});}else{divider.dragObj.reconfigure({limit:{minX:pos.x-availLeft,maxX:pos.x+availRight}});}};Zapatec.PaneSet.prototype.getDividerIndex=function(divider){for(var i=0;i<this.dividers.length;++i){if(this.dividers[i]==divider){return i;}}};Zapatec.PaneSet.prototype.bubleEvent=function(eventName){this.fireEvent.apply(this,arguments);if(!Zapatec.isHtmlElement(this.config.parent)){this.config.parent.bubleEvent.apply(this.config.parent,arguments);}};Zapatec.PaneSet.prototype.fireOnState=function(state,func){var self=this;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;}
first=this.systemEventsOn;this.addEventListener(state,func,first);return false;}else{return true;}};Zapatec.PaneSet.prototype.changeState=function(state){this.widgetState=state;this.fireEvent(state);return true;};Zapatec.PaneSet.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.PaneSet.vDivider=null;Zapatec.PaneSet.hDivider=null;Zapatec.PaneSet.loadPanesObject=function(params){if(typeof params!="object"){return false;}
switch(params.type){case"html":{return Zapatec.PaneSet.loadHtml(params);}
case"html/text":{return Zapatec.PaneSet.loadHtmlText(params);}
case"html/url":{return Zapatec.PaneSet.loadHtmlUrl(params);}
case"json":{return Zapatec.PaneSet.loadJsonObject(params);}
case"json/url":{return Zapatec.PaneSet.loadJsonUrl(params);}
case"xml":{return Zapatec.PaneSet.loadXml(params);}
case"xml/url":{return Zapatec.PaneSet.loadXmlUrl(params);}
default:{return null;}}};Zapatec.PaneSet.loadHtml=function(params){var data=params.from;var paneSet=params.paneSet;data=Zapatec.Widget.getElementById(data);if(!data||data.nodeType!==1){if(!Zapatec.windowLoaded&&!data){setTimeout(function(){Zapatec.PaneSet.loadHtml(params);},50);return;}else{Zapatec.Log({description:"No element to parse panes object found!"});if(typeof params.onFailure=="function"){params.onFailure();}
return;}}
if(!data.parentNode||data.parentNode.nodeType!=1){if(document.body){document.body.insertBefore(data,document.body.firstChild);}else{setTimeout(function(){Zapatec.PaneSet.loadHtml(params);},50);return;}}
var panesObj=[];var pane=data.firstChild;while(pane){if(pane.className&&pane.className.indexOf("zpPaneMarker")>=0){var paneConfig={};paneConfig.containerType="current";paneConfig.el=pane;paneConfig.id=pane.id;if(paneSet.config.orientation=="vertical"){paneConfig.breadth=pane.offsetHeight;}else{paneConfig.breadth=pane.offsetWidth;}
panesObj.push(paneConfig);pane=pane.nextSibling;}else if(pane.className&&pane.className.indexOf("zpPaneSetMarker")>=0){var paneSetConfig={};paneSetConfig.panes=pane;paneSetConfig.dataType="html";paneSetConfig.orientation=(paneSet.config.orientation=="vertical")?"horizontal":"vertical";paneSetConfig.parent=paneSet;paneSetConfig.reuseContainer=pane;paneSetConfig.id=pane.id
if(paneSet.config.orientation=="vertical"){if(pane.style.height!==""||pane.style.height!=="auto"){paneSetConfig.breadth=pane.offsetHeight;}
if(pane.style.width!==""||pane.style.width!=="auto"){paneSetConfig.length=pane.offsetWidth;}}else{if(pane.style.height!==""||pane.style.height!=="auto"){paneSetConfig.length=pane.offsetHeight;}
if(pane.style.width!==""||pane.style.width!=="auto"){paneSetConfig.breadth=pane.offsetWidth;}}
panesObj.push(paneSetConfig);pane=pane.nextSibling;}else{var notPane=pane;pane=pane.nextSibling;notPane.parentNode.removeChild(notPane);}}
data=panesObj;if(typeof params.onSuccess=="function"){params.onSuccess(data);}};Zapatec.PaneSet.loadHtmlText=function(params){var data=Zapatec.Transport.parseHtml(params.from);data=data.firstChild;while(data&&data.className.indexOf("zpPaneSetMarker")==-1){data=data.nextSibling;}
if(data){data=data.parentNode.removeChild(data);paneSet.config.reuseContainer=data;}else{Zapatec.Log({description:"No root PaneSet element found!"});if(typeof params.onFailure=="function"){params.onFailure();}
return;}
params.from=data;Zapatec.PaneSet.loadHtml(params);};Zapatec.PaneSet.loadHtmlUrl=function(params){Zapatec.Transport.fetch({url:params.from,async:true,onLoad:function(objRequest){params.from=objRequest.responseText;Zapatec.PaneSet.loadHtmlText(params);},onError:function(objError){Zapatec.Log({description:"Couldn't load the data for PaneSet from the following URL: "+params.from});if(typeof params.onFailure=="function"){params.onFailure();}}});};Zapatec.PaneSet.loadJsonObject=function(params){if(typeof params.from!="object"){params.from=Zapatec.Transport.parseJson({strJson:params.from});}
if(typeof params.from=="object"){if(typeof params.onSuccess=="function"){params.onSuccess(params.from);}}else{Zapatec.Log({description:"Not a valid JSON object passed!"});if(typeof params.onFailure=="function"){params.onFailure();}}};Zapatec.PaneSet.loadJsonUrl=function(params){Zapatec.Transport.fetch({url:params.from,async:true,onLoad:function(objRequest){params.from=objRequest.responseText;Zapatec.PaneSet.loadJsonObject(params);},onError:function(objError){Zapatec.Log({description:"Couldn't load the data for PaneSet from the following URL: "+params.from});if(typeof params.onFailure=="function"){params.onFailure();}}});};Zapatec.PaneSet.loadXml=function(params){if(typeof params.from!='object'){params.from=Zapatec.Transport.parseXml({strXml:params.from});}
if(typeof params.from=="object"){if(typeof params.onSuccess=="function"){params.onSuccess(params.from);}}else{Zapatec.Log({description:"Not a valid XML passed!"});if(typeof params.onFailure=="function"){params.onFailure();}}};Zapatec.PaneSet.loadXmlUrl=function(params){Zapatec.Transport.fetch({url:params.from,async:true,onLoad:function(objRequest){params.from=objRequest.responseText;Zapatec.PaneSet.loadXml(params);},onError:function(objError){Zapatec.Log({description:"Couldn't load the data for PaneSet from the following URL: "+params.from});if(typeof params.onFailure=="function"){params.onFailure();}}});};Zapatec.PaneSet.setup=function(config){var paneSet=new Zapatec.PaneSet(config);paneSet.prepareHtml();paneSet.create();return paneSet;};