LITBox=Class.create();
LITBox.prototype={initialize:function(_1){
this.mes=_1;
this.options=Object.extend({width:600,height:500,type:"window",func:null,draggable:true,resizable:true,overlay:true,opacity:1,left:false,top:false},arguments[1]||{});
this.setup();
},setup:function(){
this.rn=(Math.floor(Math.random()*100000000+1));
this.getWindow();
switch(this.options.type){
case "window":
this.d4.innerHTML=this.getAjax(this.mes);
break;
case "alert":
this.d4.innerHTML=this.mes;
break;
case "confirm":
this.d4.innerHTML="<p>"+this.mes+"</p>";
this.button_y=document.createElement("input");
this.button_y.type="button";
this.button_y.value="Yes";
this.d4.appendChild(this.button_y);
this.button_y.d=this.d;
this.button_y.d2=this.d2;
this.button_y.temp=this.options.func;
this.button_y.onclick=this.remove;
this.button_n=document.createElement("input");
this.button_n.type="button";
this.button_n.value="No";
this.d4.appendChild(this.button_n);
this.button_n.d=this.d;
this.button_n.d2=this.d2;
this.button_n.onclick=this.remove;
}
this.display();
},getWindow:function(){
this.over=null;
if(this.options.overlay==true){
this.d=document.createElement("div");
document.body.appendChild(this.d);
this.d.style.display="block";
}
this.d2=document.createElement("div");
document.body.appendChild(this.d2);
this.d2.className="LB_window";
this.d2.style.height=parseInt(this.options.height)+"px";
this.d3=document.createElement("div");
this.d2.appendChild(this.d3);
this.d3.className="LB_closeAjaxWindow";
this.d3.d2=this.d2;
this.d3.over=this.over;
this.d3.options=this.options;
this.d3.onmouseover=this.getDraggable;
this.d3.onmouseout=this.dropDraggable;
this.close=document.createElement("a");
this.d3.appendChild(this.close);
this.close.d=this.d;
this.close.d2=this.d2;
this.close.onclick=this.remove;
this.close.href="#";
this.close.innerHTML="Close";
this.d4=document.createElement("div");
this.d4.className="LB_content";
this.d4.style.height=parseInt(this.options.height)-30+"px";
this.d4.style.width=parseInt(this.options.width)+"px";
this.d2.appendChild(this.d4);
this.clear=document.createElement("div");
this.d2.appendChild(this.clear);
this.clear.style.clear="both";
if(this.options.resizable){
this.d5=document.createElement("div");
this.d2.appendChild(this.d5);
this.d5.className="LB_resize";
this.d5.d2=this.d2;
this.d5.d2.d4=this.d4;
this.d5.over=this.over;
this.d5.options=this.options;
this.d5.onmouseover=this.getResizer;
this.d5.onmouseout=this.dropResizer;
}
if(this.options.overlay==true){
this.d.d=this.d;
this.d.d2=this.d2;
}
},getDraggable:function(){
if(this.options.draggable){
if(this.resize){
this.resize.destroy();
}
if(!this.drag||(this.drag&&!this.drag.dragging)){
this.drag=new Draggable(this.d2,{});
}
}
},getResizer:function(){
if(this.options.resizable){
if(this.drag){
this.drag.destroy();
}
if(!this.resize||(this.resize&&!this.resize.dragging)){
this.resize=new Resizer(this.d2,{});
}
}
},dropDraggable:function(){
if(this.options.draggable){
if(!this.drag.dragging&&this.drag){
this.drag.destroy();
}
}
},dropResizer:function(){
if(this.options.resizable){
if(!this.resize.dragging&&this.resize){
this.resize.destroy();
}
}
},display:function(){
Element.setOpacity(this.d2,0);
this.position();
new Effect.Opacity(this.d2,{from:0,to:this.options.opacity,duration:0.5});
},position:function(){
var de=document.documentElement;
var w=self.innerWidth||(de&&de.clientWidth)||document.body.clientWidth;
var h=self.innerHeight||(de&&de.clientHeight)||document.body.clientHeight;
if(window.innerHeight&&window.scrollMaxY){
yScroll=window.innerHeight+window.scrollMaxY;
}else{
if(document.body.scrollHeight>document.body.offsetHeight){
yScroll=document.body.scrollHeight;
}else{
yScroll=document.body.offsetHeight;
}
}
this.d2.style.width=this.options.width+"px";
this.d2.style.display="block";
if(!this.options.left||this.options.left<0){
this.d2.style.left=((w-this.options.width)/2)+"px";
}else{
this.d2.style.left=parseInt(this.options.left)+"px";
}
var _5=this.getPageSize();
var _6=this.getPageScrollTop();
if(this.d2.offsetHeight>h-100){
if(!this.options.top||this.options.top<0){
this.d2.style.top="45px";
}else{
this.d2.style.top=parseInt(this.options.top)+"px";
}
this.d2.style.height=h-100+"px";
this.d4.style.overflow="auto";
}else{
if(!this.options.top||this.options.top<0){
this.d2.style.top=(_6[1]+((_5[1]-this.d2.offsetHeight)/2))+"px";
}else{
this.d2.style.top=parseInt(this.options.top)+"px";
}
}
if(this.d){
}
},remove:function(){
if(this.temp){
this.temp();
}
new Effect.Opacity(this.d2,{from:1,to:0,duration:0.5});
if(this.d){
new Effect.Opacity(this.d,{from:0.6,to:0,duration:0.5});
Element.remove(this.d);
}
Element.remove(this.d2);
return false;
},parseQuery:function(_7){
var _8=new Object();
if(!_7){
return _8;
}
var _9=_7.split(/[;&]/);
for(var i=0;i<_9.length;i++){
var _b=_9[i].split("=");
if(!_b||_b.length!=2){
continue;
}
var _c=unescape(_b[0]);
var _d=unescape(_b[1]);
_d=_d.replace(/\+/g," ");
_8[_c]=_d;
}
return _8;
},getPageScrollTop:function(){
var _e;
if(self.pageYOffset){
_e=self.pageYOffset;
}else{
if(document.documentElement&&document.documentElement.scrollTop){
_e=document.documentElement.scrollTop;
}else{
if(document.body){
_e=document.body.scrollTop;
}
}
}
arrayPageScroll=new Array("",_e);
return arrayPageScroll;
},getPageSize:function(){
var de=document.documentElement;
var w=self.innerWidth||(de&&de.clientWidth)||document.body.clientWidth;
var h=self.innerHeight||(de&&de.clientHeight)||document.body.clientHeight;
arrayPageSize=new Array(w,h);
return arrayPageSize;
},getAjax:function(url){
var _13=false;
if(!_13&&typeof XMLHttpRequest!="undefined"){
_13=new XMLHttpRequest();
}
if(_13.overrideMimeType){
_13.overrideMimeType("text/xml");
}
if(url!=""){
_13.open("GET",url,false);
_13.send(null);
return _13.responseText;
}
}};
var Resizers={drags:[],observers:[],register:function(_14){
if(this.drags.length==0){
this.eventMouseUp=this.endDrag.bindAsEventListener(this);
this.eventMouseMove=this.updateDrag.bindAsEventListener(this);
this.eventKeypress=this.keyPress.bindAsEventListener(this);
Event.observe(document,"mouseup",this.eventMouseUp);
Event.observe(document,"mousemove",this.eventMouseMove);
Event.observe(document,"keypress",this.eventKeypress);
this.drags.push(_14);
}
},unregister:function(_15){
this.drags=this.drags.reject(function(d){
return d==_15;
});
if(this.drags.length==1){
this.drags.pop();
}
if(this.drags.length==0){
Event.stopObserving(document,"mouseup",this.eventMouseUp);
Event.stopObserving(document,"mousemove",this.eventMouseMove);
Event.stopObserving(document,"keypress",this.eventKeypress);
}
},activate:function(_17){
window.focus();
this.activeDraggable=_17;
},deactivate:function(){
this.activeDraggable=null;
},updateDrag:function(_18){
if(!this.activeDraggable){
return;
}
var _19=[Event.pointerX(_18),Event.pointerY(_18)];
if(this._lastPointer&&(this._lastPointer.inspect()==_19.inspect())){
return;
}
this._lastPointer=_19;
this.activeDraggable.updateDrag(_18,_19);
},endDrag:function(_1a){
if(!this.activeDraggable){
return;
}
this._lastPointer=null;
this.activeDraggable.endDrag(_1a);
this.activeDraggable=null;
},keyPress:function(_1b){
if(this.activeDraggable){
this.activeDraggable.keyPress(_1b);
}
},addObserver:function(_1c){
this.observers.push(_1c);
this._cacheObserverCallbacks();
},removeObserver:function(_1d){
this.observers=this.observers.reject(function(o){
return o.element==_1d;
});
this._cacheObserverCallbacks();
},notify:function(_1f,_20,_21){
if(this[_1f+"Count"]>0){
this.observers.each(function(o){
if(o[_1f]){
o[_1f](_1f,_20,_21);
}
});
}
},_cacheObserverCallbacks:function(){
["onStart","onEnd","onDrag"].each(function(_23){
Resizers[_23+"Count"]=Resizers.observers.select(function(o){
return o[_23];
}).length;
});
}};
var Resizer=Class.create();
Resizer.prototype={initialize:function(_25){
this.offset=Array();
var _26=Object.extend({handle:false,reverteffect:function(_27,_28,_29){
var dur=Math.sqrt(Math.abs(_28^2)+Math.abs(_29^2))*0.02;
_27._revert=new Effect.Move(_27,{x:-_29,y:-_28,duration:dur});
},zindex:1000,revert:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,snap:false},arguments[1]||{});
this.element=$(_25);
if(_26.handle&&(typeof _26.handle=="string")){
var h=Element.childrenWithClassName(this.element,_26.handle,true);
if(h.length>0){
this.handle=h[0];
}
}
if(!this.handle){
this.handle=$(_26.handle);
}
if(!this.handle){
this.handle=this.element;
}
if(_26.scroll&&!_26.scroll.scrollTo&&!_26.scroll.outerHTML){
_26.scroll=$(_26.scroll);
}
Element.makePositioned(this.element);
this.delta=this.currentDelta();
this.options=_26;
this.dragging=false;
this.oHeight=parseInt(this.element.style.height);
this.oWidth=parseInt(this.element.style.width);
this.eventMouseDown=this.initDrag.bindAsEventListener(this);
Event.observe(this.handle,"mousedown",this.eventMouseDown);
Resizers.register(this);
},destroy:function(){
Event.stopObserving(this.handle,"mousedown",this.eventMouseDown);
Resizers.unregister(this);
},currentDelta:function(){
return ([parseInt(Element.getStyle(this.element,"width")||"0"),parseInt(Element.getStyle(this.element,"height")||"0")]);
},initDrag:function(_2c){
if(Event.isLeftClick(_2c)){
var src=Event.element(_2c);
if(src.tagName&&(src.tagName=="INPUT"||src.tagName=="SELECT"||src.tagName=="OPTION"||src.tagName=="BUTTON"||src.tagName=="TEXTAREA")){
return;
}
if(this.element._revert){
this.element._revert.cancel();
this.element._revert=null;
}
var _2e=[Event.pointerX(_2c),Event.pointerY(_2c)];
var pos=Position.cumulativeOffset(this.element);
this.offset[0]=_2e[0];
this.offset[1]=_2e[1];
Resizers.activate(this);
Event.stop(_2c);
}
},startDrag:function(_30){
this.dragging=true;
if(this.options.zindex){
this.originalZ=parseInt(Element.getStyle(this.element,"z-index")||0);
this.element.style.zIndex=this.options.zindex;
}
if(this.options.ghosting){
this._clone=this.element.cloneNode(true);
Position.absolutize(this.element);
this.element.parentNode.insertBefore(this._clone,this.element);
}
Resizers.notify("onStart",this,_30);
if(this.options.starteffect){
this.options.starteffect(this.element);
}
},updateDrag:function(_31,_32){
if(!this.dragging){
this.startDrag(_31);
}
Position.prepare();
Resizers.notify("onDrag",this,_31);
this.draw(_32);
if(this.options.change){
this.options.change(this);
}
if(this.options.scroll){
this.stopScrolling();
var p;
if(this.options.scroll==window){
with(this._getWindowScroll(this.options.scroll)){
p=[left,top,left+width,top+height];
}
}else{
p=Position.page(this.options.scroll);
p[0]+=this.options.scroll.scrollLeft;
p[1]+=this.options.scroll.scrollTop;
p.push(p[0]+this.options.scroll.offsetWidth);
p.push(p[1]+this.options.scroll.offsetHeight);
}
var _34=[0,0];
if(_32[0]<(p[0]+this.options.scrollSensitivity)){
_34[0]=_32[0]-(p[0]+this.options.scrollSensitivity);
}
if(_32[1]<(p[1]+this.options.scrollSensitivity)){
_34[1]=_32[1]-(p[1]+this.options.scrollSensitivity);
}
if(_32[0]>(p[2]-this.options.scrollSensitivity)){
_34[0]=_32[0]-(p[2]-this.options.scrollSensitivity);
}
if(_32[1]>(p[3]-this.options.scrollSensitivity)){
_34[1]=_32[1]-(p[3]-this.options.scrollSensitivity);
}
this.startScrolling(_34);
}
if(navigator.appVersion.indexOf("AppleWebKit")>0){
window.scrollBy(0,0);
}
Event.stop(_31);
},finishDrag:function(_35,_36){
this.dragging=false;
if(this.options.ghosting){
Position.relativize(this.element);
Element.remove(this._clone);
this._clone=null;
}
Resizers.notify("onEnd",this,_35);
var _37=this.options.revert;
if(_37&&typeof _37=="function"){
_37=_37(this.element);
}
var d=this.currentDelta();
if(_37&&this.options.reverteffect){
this.options.reverteffect(this.element,d[1]-this.delta[1],d[0]-this.delta[0]);
}else{
this.delta=d;
}
this.element.style.zIndex=this.originalZ;
if(this.options.endeffect){
this.options.endeffect(this.element);
}
Resizers.deactivate(this);
},keyPress:function(_39){
if(_39.keyCode!=Event.KEY_ESC){
return;
}
this.finishDrag(_39,false);
Event.stop(_39);
},endDrag:function(_3a){
if(!this.dragging){
return;
}
this.stopScrolling();
this.finishDrag(_3a,true);
Event.stop(_3a);
this.oWidth=parseInt(this.element.style.width);
this.oHeight=parseInt(this.element.style.height);
},draw:function(_3b){
var pos=Position.cumulativeOffset(this.element);
var d=this.currentDelta();
pos[0]-=d[0];
pos[1]-=d[1];
var p=new Array();
p[0]=this.oWidth+_3b[0]-this.offset[0];
p[1]=this.oHeight+_3b[1]-this.offset[1];
var _3f=this.element.style;
if((!this.options.constraint)||(this.options.constraint=="horizontal")){
_3f.width=p[0]+"px";
this.element.d4.style.width=p[0]+"px";
}
if((!this.options.constraint)||(this.options.constraint=="vertical")){
_3f.height=p[1]+"px";
this.element.d4.style.height=p[1]-30+"px";
}
if(_3f.visibility=="hidden"){
_3f.visibility="";
}
},stopScrolling:function(){
if(this.scrollInterval){
clearInterval(this.scrollInterval);
this.scrollInterval=null;
Resizers._lastScrollPointer=null;
}
},startScrolling:function(_40){
this.scrollSpeed=[_40[0]*this.options.scrollSpeed,_40[1]*this.options.scrollSpeed];
this.lastScrolled=new Date();
this.scrollInterval=setInterval(this.scroll.bind(this),10);
},scroll:function(){
var _41=new Date();
var _42=_41-this.lastScrolled;
this.lastScrolled=_41;
if(this.options.scroll==window){
with(this._getWindowScroll(this.options.scroll)){
if(this.scrollSpeed[0]||this.scrollSpeed[1]){
var d=_42/1000;
this.options.scroll.scrollTo(left+d*this.scrollSpeed[0],top+d*this.scrollSpeed[1]);
}
}
}else{
this.options.scroll.scrollLeft+=this.scrollSpeed[0]*_42/1000;
this.options.scroll.scrollTop+=this.scrollSpeed[1]*_42/1000;
}
Position.prepare();
Resizers.notify("onDrag",this);
Resizers._lastScrollPointer=Resizers._lastScrollPointer||$A(Resizers._lastPointer);
Resizers._lastScrollPointer[0]+=this.scrollSpeed[0]*_42/1000;
Resizers._lastScrollPointer[1]+=this.scrollSpeed[1]*_42/1000;
if(Resizers._lastScrollPointer[0]<0){
Resizers._lastScrollPointer[0]=0;
}
if(Resizers._lastScrollPointer[1]<0){
Resizers._lastScrollPointer[1]=0;
}
this.draw(Resizers._lastScrollPointer);
if(this.options.change){
this.options.change(this);
}
},_getWindowScroll:function(w){
var T,L,W,H;
with(w.document){
if(w.document.documentElement&&documentElement.scrollTop){
T=documentElement.scrollTop;
L=documentElement.scrollLeft;
}else{
if(w.document.body){
T=body.scrollTop;
L=body.scrollLeft;
}
}
if(w.innerWidth){
W=w.innerWidth;
H=w.innerHeight;
}else{
if(w.document.documentElement&&documentElement.clientWidth){
W=documentElement.clientWidth;
H=documentElement.clientHeight;
}else{
W=body.offsetWidth;
H=body.offsetHeight;
}
}
}
return {top:T,left:L,width:W,height:H};
}};

