LITBox = Class.create(); LITBox.prototype = { initialize: function(mes){ this.mes = mes; 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;}
this.display();}, getWindow: function(){ this.over = null; this.d2 = document.createElement('div'); document.body.appendChild(this.d2); this.d2.className = 'LB_window'; this.d2.id = 'LB_id'; 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.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='<img src="icones/agt_stop.png" style="vertical-align:middle" />'; 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';}, display: function(){ if (is_ie7) { Element.setOpacity(this.d2, 0); this.position(); new Effect.Opacity(this.d2, {from:0,to:this.options.opacity,duration:.5});}
else
{ this.position(); this.d2.style.opacity=this.options.opacity; this.d2.style.display="block";}
}, 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 pagesize = this.getPageSize(); var arrayPageScroll = 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 = (arrayPageScroll[1] + ((pagesize[1]-this.d2.offsetHeight)/2))+"px";}else{ this.d2.style.top=parseInt(this.options.top)+'px';}
}
if(this.d){this.d.style.height = yScroll +"px";}
}, remove: function(){ if (is_ie7) { if(this.temp) this.temp(); new Effect.Opacity(this.d2, {from:1,to:0,duration:.5}); if(this.d){new Effect.Opacity(this.d, {from:.6,to:0,duration:.5}); Element.remove(this.d);}
Element.remove(this.d2); return false;}
else
{ if(this.temp) this.temp(); if(this.d){ Element.remove(this.d);}
Element.remove(this.d2); return false;}
}, parseQuery: function(query){ var Params = new Object (); if ( ! query ) return Params; var Pairs = query.split(/[;&]/); for ( var i = 0; i < Pairs.length; i++ ) { var KeyVal = Pairs[i].split('='); if ( ! KeyVal || KeyVal.length != 2 ) continue; var key = unescape( KeyVal[0] ); var val = unescape( KeyVal[1] ); val = val.replace(/\+/g, ' '); Params[key] = val;}
return Params;}, getPageScrollTop: function(){ var yScrolltop; if (self.pageYOffset) { yScrolltop = self.pageYOffset;} else if (document.documentElement && document.documentElement.scrollTop){ yScrolltop = document.documentElement.scrollTop;} else if (document.body) { yScrolltop = document.body.scrollTop;}
arrayPageScroll = new Array('',yScrolltop)
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 xmlhttp=false; if (!xmlhttp && typeof XMLHttpRequest!='undefined') xmlhttp = new XMLHttpRequest(); if(xmlhttp.overrideMimeType) xmlhttp.overrideMimeType('text/xml'); if(url != ""){ xmlhttp.open("GET", url, false); xmlhttp.send(null); return xmlhttp.responseText;}
}
}
