 
 

ljex = {
 main: "/ljex/main.php5",
 path: "/ljex",
 theme: 'lunacms',
 uniqueID: 1,
 lang: 'de'
};

 
function $_(section, variable){
 return ljex.locale[section][variable];
}

ljex.clone = function() {
 var newObj = (this instanceof Array) ? [] : {};
 for (i in this) {
 if (this[i] && typeof this[i] == "object") {
 newObj[i] = ljex.clone.call(this[i]); 
 } else newObj[i] = this[i]
 } return newObj;
};


function $(id) { return document.getElementById(id); }

function $create(ident) {
 var el = document.createElement("div");
 if(ident!=undefined) el.id=ident;
 return el;
}

function $assimilate(args){
 
 
 for(key in args){
 this[key]=args[key];
 } 
}

function $genid(){
 return new Date().getTime();
}

function $setdef(defaults){
 for(var key in defaults){
 if(this[key]==undefined) this[key]=defaults[key];
 }
}

function $shadow(text){
 var s = "<div class='lx-shadow'> <div class='lx-shadow-black'>"+text+" <div class='lx-shadow-white'>"+text+"</div> </div> </div>";
 return s;
}


_myInfoWinIsOpen=false;
function _closeInfo(){ 
 new ljex.FX({
 id: _myInfoWin.id,
 callback: function(){
 _myInfoWin.close();
 _myInfoWinIsOpen=false;
 }
 }).fadeOut(); 
}

function $info(msg,config){

 if(_myInfoWinIsOpen) return; 

 _myInfoWin = new ljex.Window({
 contentBgColor: 'transparent',
 parentId: 'page',
 focusOpacity: false
 });

 if(config){
 if(config.center){
 _myInfoWin.center=true;
 }else if(config.left || config.top){
 if(config.top) _myInfoWin.top=config.top;
 if(config.left) _myInfoWin.left=config.left;
 }
 if(config.duration) var duration=config.duration; else var duration=3000;
 }else{
 _myInfoWin.center=true;
 var duration=3000;
 }

 tblHtml="<table style='width:100%;height:100%;padding:0px' cellspacing=10><tr><td><img src='/images/icons/info.png'></td><td>"+$shadow(msg)+"</td></tr></table>";

 _myInfoWin.html='<div style="background-image:url(/ljex/images/tp2.png);background-repeat: repeat-x repeat-y;width:100%;height:100%">'+tblHtml+'</div>';
 _myInfoWin.open();

 _myInfoWinIsOpen=true;

 window.setTimeout("_closeInfo()",duration);

}

function $alert(msg,title){
 new ljex.MessageBox({
 msg: msg,
 title: title||"Info",
 type: ljex.MessageBox.INFO
 });
}

function $warn(msg,title){
 new ljex.MessageBox({
 msg: msg,
 title: title||"Warn",
 type: ljex.MessageBox.WARN
 });
}

function $error(msg,title){
 new ljex.MessageBox({
 msg: msg,
 title: title||"Error",
 type: ljex.MessageBox.ERROR
 });
}

function $addEvent(el, ev, func){
 if(el.addEventListener){
 el.addEventListener(ev, func, false);
 }else if(el.attachEvent){
 el.attachEvent("on"+ev, func);
 }
}


function $loadScript(filename, objectname, args){
 try{
 var isLoaded = eval(objectname);
 }catch(e){

 ljex.moduleArgs = args;
 var jScript=document.createElement("script");
 jScript.src="scripts/"+filename;
 document.getElementsByTagName('head')[0].appendChild(jScript);
 }

 return true;
}

function $onScriptLoaded(objectName){
 eval("new "+objectName+"(ljex.moduleArgs)");
}


 

 
ljex.isIE = function(){
 if(navigator.appName=="Microsoft Internet Explorer"){
 return true;
 }else{
 return false;
 }
}

ljex.isSafari = function(){
 if(navigator.appVersion.match(/.*Safari.*/g)){
 return true;
 }else{
 return false;
 }
}

ljex.init = function(lang){
 if(lang!=undefined) ljex.lang=lang;

 var bodyd = document.getElementsByTagName("body");
 if(ljex.isIE()){
 bodyd[0].attachEvent("onclick", function(){
 if(ljex.Form){
 if(typeof ljex.Form.openDropDown == "string"){
 ljex.Form.openDropDown = $(ljex.Form.openDropDown);
 }else if(ljex.Form.openDropDown!=null ){
 ljex.Form.openDropDown.style.display='none';
 ljex.Form.openDropDown=null;
 }
 }
 });
 }else{
 bodyd[0].addEventListener('click',function(){
 if(ljex.Form){
 if(typeof ljex.Form.openDropDown == "string"){
 ljex.Form.openDropDown = $(ljex.Form.openDropDown);
 }else if(ljex.Form.openDropDown!=null ){
 ljex.Form.openDropDown.style.display='none';
 ljex.Form.openDropDown=null;
 }
 }
 },false);
 }

 var divs = document.getElementsByTagName("div");
 var tiptext=[]; 
 for(i=0;i<divs.length;i++){
 var el=divs[i];
 if(el.getAttribute("ljex")){
 var params=el.getAttribute("ljex").split(";");
 for(j=0;j<params.length;j++){
 var param=params[j].split(":");
 switch(param[0]){
 case 'scrollbar':
 break;
 case 'tooltip':
 tiptext[el.id]=param[1];
 el.onmouseover = function(e){
 var evt = (document.all) ? window.event : e;
 ljex.showToolTip(evt,tiptext[this.id]);
 }
 break;
 }
 }
 }
 }
}

ljex.progressBox = function(msg,conf){
 if(conf!=undefined){
 $assimilate.call(this,conf);
 }

 $setdef.call(this,{
 width: 350,
 height: 100,
 parentId: 'page'
 });

 this.pBoxWin = new ljex.Window({
 id: 'loadWindow',
 width: this.width,
 height: this.height,
 contentBgColor: '#eee',
 parentId: this.parentId,
 center: true,
 focusOpacity: false
 });
 
 this.pBoxWin.html='<div style="padding: 20px 0px 0px 20px;"><center><img id="busyImage" style="float:left" src="/ljex/themes/lunacms/images/anim/ajax-loader_medium.gif"><div style="padding-top:15px;">'+msg+'...</div></center></div>';
 
 this.pBoxWin.open();

 
}

ljex.progressBox.prototype.close = function(){
 
 this.pBoxWin.close();
}


 
 
ljex.showToolTip = function(e, tipText){
 var obj = (document.all) ? e.srcElement : e.target;


 tipDiv=document.createElement("div");
 tipDiv.id="lx-tooltip";
 tipDiv.style.position="absolute";
 tipDiv.style.zIndex=5000;

 document.body.appendChild(tipDiv);
 tipDiv.innerHTML='<div id="lx-tooltip-text" style="max-width:200px;background-color:#ffe;color:#000;border-style:dotted;border-color:#aaa;border-width:1px;padding:5px" >'+tipText+'</div>';

 x = (document.all) ? window.event.clientX + document.body.scrollLeft : e.pageX;
 y = (document.all) ? window.event.clientY + document.body.scrollTop : e.pageY;

 posLeft = (x + 10) + "px";
 posTop = (y + 10) + "px";

 tipDiv.style.left = posLeft;
 tipDiv.style.top = posTop;


 new ljex.FX({
 id : "lx-tooltip-text",
 fps : 25
 }).fadeIn();

 obj.onmouseout=function(){
 if($('lx-tooltip')) document.body.removeChild($('lx-tooltip'));
 }
}

ljex.prompt = function(args){
 args.type=ljex.MessageBox.ASK;
 args.height=150;
 new ljex.MessageBox(args);
}
 


 
ljex.locale = {
 add: function(site, section, lang, callback, scope){
 var cb=callback;
 var sc=scope||this;
 var sect=[];

 if(typeof(section)=='string'){
 sect[0]=section;
 }else{
 sect=section;
 }

 new ljex.Ajax({
 url: '/lib/Locale.php5',
 method: 'POST',
 param: {
 site: site,
 section: JSON.stringify(sect),
 lang: lang
 },
 scope: this,
 callback: function(response){ 
 data = eval("("+response.responseText+")");

 for(sec in data['sections']){
 ljex.locale[sec]=data['sections'][sec];
 }

 if(cb) cb.call(sc);
 }
 }).request();
 }
};
 

ljex.ajaxRequests = [];

 
 
 
ljex.Ajax = function(conf){
 ljex.uniqueID++;

 ljex.ajaxRequests[ljex.uniqueID]=this;
 this.requestID=ljex.uniqueID;

 this.url = conf.url;
 this.callback = conf.callback || null;
 this.method = conf.method || 'GET';
 this.param = conf.param || null;
 this.scope = conf.scope || this; 
 this.async = (conf.async!=undefined)?conf.async:true;

 this.myRequest=0;
}

ljex.Ajax.prototype.request = function(){  
 var thisObj=this;
  
 try {
  
 this.myRequest = new ActiveXObject("Microsoft.XMLHTTP");
 } catch (error) {
  
 this.myRequest = new XMLHttpRequest();
 }
 
  
 if(this.method=='GET'){
 this.myRequest.open("GET",this.url, this.async);
 if(!this.async){
 this.myRequest.send(null);
 return this.myRequest;
 }else{
  
 this.myRequest.onreadystatechange = function(){
 if(thisObj.myRequest.readyState == 4){
 thisObj.callback.call(thisObj.scope, thisObj.myRequest) ;
 }
 }
  
 this.myRequest.send(null);
 }
 }else{
 this.myRequest.open("POST",this.url, this.async);
 this.myRequest.setRequestHeader('Content-type','application/x-www-form-urlencoded');

  
 var postString="";
 var first=true;
 for(key in this.param){
 if(!first){
 postString+="&"+key+"="+encodeURIComponent(this.param[key]);
 }else{
 postString=key+"="+encodeURIComponent(this.param[key]);
 first=false;
 }
 }

 if(!this.async){
 this.myRequest.send(postString);
 return this.myRequest;
 }else{
  
 this.myRequest.onreadystatechange = function(){
 if(thisObj.myRequest.readyState == 4){
 thisObj.callback.call(thisObj.scope, thisObj.myRequest) ;
 }
 }
 this.myRequest.send(postString);
 }

 }
}
 
 

 
 
 
ljex.FX = function(config){  


 if(typeof(config.id)=="string"){
 this.id = config.id;
 this.el = $(config.id);
 }else{
 this.id = config.id.id;
 this.el = config.id;
 }

 ljex.FX.Instances[this.id]=this;

 this.aktiv=null;
 this.duration=0;
 this.fps= config.fps || 25;
 this.callback = config.callback || null;
 
 this.stepWidth=0.1;
 this.scope=config.scope;
 this.INFADE=false;
 this.SHIFTOPEN=false;
 this.aktOpacity=0;  
 this.targetOpacity=config.targetOpacity || 0;

 this.targetHeight=0;
 this.aktHeight=0;
}
ljex.FX.Instances = new Array();
 

ljex.FX.prototype.fade = function(){  
 if(this.INFADE){
 var targetOpacity= (ljex.isIE())?this.targetOpacity*100:this.targetOpacity ;
 if(this.aktOpacity< targetOpacity ){
 this.aktOpacity+=this.stepWidth;
 if(ljex.isIE()){
 this.el.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity="+this.aktOpacity+")";
 }else{
 this.el.style.opacity=this.aktOpacity;
 }
 }else{
 window.clearInterval(this.aktiv);
 if(this.callback!=null) this.callback(this.scope);
 }
 }else{
 var targetOpacity= (ljex.isIE())?this.targetOpacity*100:this.targetOpacity ;
 if(this.aktOpacity >= targetOpacity){
 this.aktOpacity-=this.stepWidth;
 if(this.aktOpacity<0) this.aktOpacity=0;
 if(ljex.isIE()){
 this.el.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity="+this.aktOpacity+")";
 }else{
 this.el.style.MozOpacity=this.aktOpacity;  
 this.el.style.opacity=this.aktOpacity;
 }
 if(this.aktOpacity==0 && this.callback!=null){
 window.clearInterval(this.aktiv);
 if(this.callback!=null) this.callback(this.scope);
 }
 }else{
  
 window.clearInterval(this.aktiv);
 if(this.callback!=null) this.callback(this.scope);
 }

 }
}
 

ljex.FX.prototype.fadeIn = function(){  
 this.aktOpacity=0;
 this.targetOpacity=1.0;

 if(ljex.isIE()){
 this.el.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
 this.stepWidth=5;
 }else{
 this.el.style.MozOpacity=0;
 this.el.style.opacity=0;
 }

 this.INFADE=true;
 this.aktiv=window.setInterval('ljex.FX.Instances["'+this.id+'"].fade()',this.fps);
}
 

ljex.FX.prototype.fadeOut = function(){  
 this.targetOpacity=0;

 if(ljex.isIE()){
 this.aktOpacity=100;
 this.stepWidth=5;
 this.el.display="block";
 this.el.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
 }else{
 this.aktOpacity=1;
 this.el.style.MozOpacity=1;
 this.el.style.opacity=1;
 }

 this.INFADE=false;

 this.aktiv=window.setInterval('ljex.FX.Instances["'+this.id+'"].fade()',this.fps);
}  

ljex.FX.prototype.shift = function(){  
 if(this.SHIFTOPEN){
 if(this.aktHeight<this.targetHeight){
 this.aktHeight+=this.stepWidth;
 this.el.style.height=this.aktHeight;
 }else{
 this.el.style.overflow=this.styleOverflow;
 window.clearInterval(this.aktiv);
 if(this.callback!=null) this.callback(this.scope);
 }
 }else{
 if(this.aktHeight>0){
 this.aktHeight-=this.stepWidth;
 this.el.style.height=this.aktHeight;
 }else{
 this.el.style.overflow=this.styleOverflow;
 this.el.style.display='none';
 window.clearInterval(this.aktiv);
 if(this.callback!=null) this.callback(this.scope);
 }
 }
}  

ljex.FX.prototype.shiftOpen = function(targetHeight){  
 this.el.style.height=0;
 if(this.stepWidth<1) this.stepWidth=6;
 this.fps=12;
 this.targetHeight=targetHeight;

 this.styleOverflow=this.el.style.overflow;
 this.el.style.overflow='hidden';

 this.SHIFTOPEN=true;

 this.aktiv=window.setInterval('ljex.FX.Instances["'+this.id+'"].shift()',this.fps);

}  

ljex.FX.prototype.shiftClose = function(){  
 this.fps=12;
 if(this.stepWidth<1) this.stepWidth=6;

 this.styleOverflow=this.el.style.overflow;
 this.el.style.overflow='hidden';

 this.aktHeight=parseInt(this.el.style.height);

 this.SHIFTOPEN=false;

 this.aktiv=window.setInterval('ljex.FX.Instances["'+this.id+'"].shift()',this.fps);

}  
 

 
ljex.buttonMenu = function(args, evt){
 $assimilate.call(this,args);
 var thisObj = this;
 this.items = args.items;
 this.evt=evt;
 this.el = $create(args.id);
 this.el.className="lx-context-ct";

  
 ljex.buttonMenu.prototype.init = ljex.contextMenu.prototype.init;

 for(var i=0;i<this.items.length;i++){
 this.el.appendChild(this.init(this.items[i]));
 }

 
 x = (document.all) ? window.event.clientX + document.body.scrollLeft : this.evt.pageX;
 y = (document.all) ? window.event.clientY + document.body.scrollTop : this.evt.pageY;

 posLeft = (x + 5) + "px";
 posTop = (y + 5) + "px";

 this.el.style.left = posLeft;
 this.el.style.top = posTop;

 document.body.appendChild(this.el);
}
 

 
 
 
ljex.contextMenu = function(args, evt){
 $assimilate.call(this,args);
 var thisObj = this;
 if(ljex.contextMenu.open){
 return;
 }else{
 ljex.contextMenu.open=true;
 }
 
 this.evt=evt;
 this.el = $create(args.id);
 this.el.style.zIndex=ljex.Window.zindex+1;
 this.el.className="lx-context-ct";

 for(var i=0;i<this.items.length;i++){
 this.el.appendChild(this.init(this.items[i]));
 }

 
 x = (document.all) ? window.event.clientX + document.body.scrollLeft : this.evt.pageX;
 y = (document.all) ? window.event.clientY + document.body.scrollTop : this.evt.pageY;

 posLeft = (x + 5) + "px";
 posTop = (y + 5) + "px";

 this.el.style.left = posLeft;
 this.el.style.top = posTop;


 var f = document.body.onclick;

 document.body.onclick = function(e){
 if($(args.id)){
 document.body.removeChild($(args.id));

 this.onclick = f;  
 }
 ljex.contextMenu.open=false;
 }

 document.body.appendChild(this.el);
}

ljex.contextMenu.open=false;

ljex.contextMenu.prototype.init = function(item){
 var thisObj=this;
 var itemEl = $create(item.id+'-itemel');
 itemEl.className="lx-context-item";

 itemEl.innerHTML=item.text;

 itemEl.onclick = function(){
 item.onclick.call(thisObj, item);  
 if(thisObj.el){
 document.body.removeChild(thisObj.el);
 ljex.contextMenu.open=false;
 }
 }

 itemEl.onmouseover = function(){ this.className='lx-context-item-hover'; }
 itemEl.onmouseout = function(){ this.className='lx-context-item'; }
 
 return itemEl;

}
 

 
 
 
ljex.Window = function(config){
 $assimilate.call(this,config);

 $setdef.call(this,{
 title: "",
 id: 'lx-window-'+$genid(),
 left: 0,
 top: 0,
 width: 'auto',
 height: null,
 html: "",
 icon: null,
 parentId: null,
 items: null,
 contentBgColor: null,
 color: '#000',
 center: false,
 focusOpacity: false,
 focusAlpha: 0.85,
 onclose: null
 });

}

ljex.Window.zindex=0;

ljex.Window.prototype.show = function(){  
 this.winEl.style.display='block';
 if(this.width=='auto'){
 
 
 }
 if(this.center){
 var offsetHeight=(ljex.isIE())?parseInt(document.documentElement.offsetHeight):parseInt(window.innerHeight);
 var pHeight=(this.parentEl.offsetHeight==0)?offsetHeight:parseInt(this.parentEl.offsetHeight);
 

 this.winEl.style.left=(parseInt(this.parentEl.offsetWidth)/2)-(parseInt(this.winEl.offsetWidth)/2)+"px";
 if(!this.top){
 var relHeight=(pHeight>offsetHeight)?offsetHeight:pHeight;
 this.winEl.style.top=(parseInt(relHeight)/2)-(parseInt(this.winEl.offsetHeight)/2)+"px";

 }
 }

 
}  

ljex.Window.prototype.close = function(){  
 var thisObj=this;

 this.winEl.style.display='none';

 thisObj.initDrag=false;
 
 if(!$(thisObj.id)){
 $alert("Seltener, abgefangener Fehler: core.js / ljex.Window.prototype.close<br><br> Window Objekt nicht mehr im DOM. onclose() - Handler wird nicht mehr ausgeführt.");
 }else{
 thisObj.parentEl.removeChild($(thisObj.id));
 if(thisObj.focusOpacity){
 thisObj.parentEl.removeChild($(thisObj.id+'_special'));
 }
 
 if(thisObj.onclose!=null){
 thisObj.onclose();
 }
 }
}  

ljex.Window.prototype.open = function(hidden){  
 var thisObj = this;
 if(this.parentId!=null){
 this.parentEl=$(this.parentId);
 }else{
 this.parentEl=document.body;
 }

 this.winEl=document.createElement("table");
 with(this.winEl){
 id=this.id;
 border=0;
 className="lx-window-frame";
 cellSpacing=0;
 cellPadding=0; 
 }
 ljex.Window.zindex++;
 this.winEl.style.zIndex=ljex.Window.zindex;
 var tbody = document.createElement("tbody");

 with(this.winEl.style){
 if(this.left) left=this.left+'px';
 if(this.top) top=this.top+'px';
 if(this.bgColor) backgroundColor=this.bgColor;
 if(this.border===false) border=0;
 
 if(this.width!='auto'){
 width=this.width+'px';
 }
 if(this.height) height=this.height+'px';
 }
 

 if(this.title){
 var titleCt = document.createElement("table");  
 titleCt.id=this.id+"-titlect";
 with(titleCt){
 cellSpacing=0;
 cellPadding=0;
 border=0;
 }
 titleCt.className='lx-window-title';

 var titleBody = document.createElement("tbody");

 var titleRow = document.createElement("tr");

 var titleLeft = document.createElement("td");  
 titleLeft.id=this.id+'-title-left';
 titleLeft.width=25;
 
 titleLeft.height=26;
 titleLeft.valign="middle";
 titleLeft.align="center";
 titleLeft.className='lx-window-title-left';
 titleRow.appendChild(titleLeft);

 if(this.icon){
 var titleIcon = document.createElement("img");
 titleIcon.src=this.icon;
 titleLeft.appendChild(titleIcon);
 }

 var titleCenter = document.createElement("td");
 titleCenter.id=this.id+"-title";
 
 titleCenter.height=26;
 titleCenter.className='lx-window-title-center';
 
 

 titleCenter.innerHTML=$shadow(this.title);
 titleRow.appendChild(titleCenter);

 var titleRight = document.createElement("td");
 titleRight.id=this.id+'-title-right';
 titleRight.width=25;
 titleRight.valign="middle";
  
 titleRight.height=26;
 titleRight.className='lx-window-title-right';

 var titleClose = document.createElement("img");
 titleClose.id=this.id+"-close";
 titleClose.style.cursor='pointer';
 titleClose.src=ljex.path+"/themes/"+ljex.theme+"/images/windows/close.png";

 titleRight.appendChild(titleClose);
 titleRow.appendChild(titleRight);
 titleBody.appendChild(titleRow);

 titleCt.appendChild(titleBody);

 var ttr = document.createElement("tr");
 var ttd = document.createElement("td");
 ttd.appendChild(titleCt);
 ttr.appendChild(ttd);
 tbody.appendChild(ttr);
 }

 if(this.focusOpacity){
  
 var specialEl = document.createElement("div");

 with(specialEl){
 id=this.id+'_special';
 style.position='absolute';
 style.left='0px';
 style.top='0px';
 style.zIndex=ljex.Window.zindex-1;
 style.width=this.parentEl.offsetWidth+'px';
 style.height=this.parentEl.offsetHeight+'px';
 style.backgroundColor='#000';
 style.opacity=String(this.focusAlpha);
 style.mozOpacity=String(this.focusAlpha);
 var ieAlpha=this.focusAlpha*100;
 style.filter="progid:DXImageTransform.Microsoft.Alpha(Opacity="+ieAlpha+")";

 }

 this.parentEl.appendChild(specialEl);
 }

  
 var bodyRow = document.createElement("tr");



 var ctEl = document.createElement("td");
 ctEl.id=this.id+'-content';
 ctEl.className='lx-window-content';
 ctEl.innerHTML=this.html;

 this.transEl = document.createElement("td");
 this.transEl.style.display='none';


 if(this.items!=null){
 for(var i=0;i<this.items.length;i++){
 if(!(this.items[i] instanceof ljex.Panel) && !(this.items[i] instanceof ljex.ToolBar) ){
 switch(this.items[i].xtype){
 case 'panel':
 var p = new ljex.Panel(this.items[i]);
 break;
 case 'treepanel':
 var p = new ljex.TreePanel(this.items[i]);
 break;
 case 'tabpanel':
 var p = new ljex.TabPanel(this.items[i]);
 break;
 }
 var pEl = p.render();
 }else{
 var pEl = this.items[i].render();
 }
 ctEl.appendChild(pEl);
 }
 }

 with(ctEl.style){
 if(this.width!='auto' && this.width!=undefined){
 width=this.width+'px';  
 }
 if(this.height!=null){
 height=(this.height-((this.title)?28:0))+"px";
 }
 if(this.contentBgColor!=null){
 backgroundColor=this.contentBgColor;
 }
 }

 bodyRow.appendChild(ctEl);
 bodyRow.appendChild(this.transEl);
 tbody.appendChild(bodyRow);
 this.winEl.appendChild(tbody);

 this.parentEl.appendChild(this.winEl);

 this.connectEvents();
 if(!hidden){
 this.show();
 }else{
 this.winEl.style.display='none';
 }
}  

ljex.Window.prototype.connectEvents = function(){  
 var thisObj=this;

 if(this.title!=""){
 $(this.id+'-close').onclick= function(){
 thisObj.initDrag=false;
 thisObj.parentEl.onmousemove = function(){return}
 thisObj.parentEl.removeChild($(thisObj.id));
 if(thisObj.focusOpacity){
 thisObj.parentEl.removeChild($(thisObj.id+'_special'));
 }
 if(thisObj.onclose!=null){
 thisObj.onclose();
 }
 }

 $(this.id+'-title').onmousedown = function(e){
 if(!thisObj.initDrag){
 ljex.Window.zindex++;
 thisObj.startX = (document.all) ? window.event.clientX + thisObj.parentEl.scrollLeft : e.pageX;
 thisObj.startY = (document.all) ? window.event.clientY + thisObj.parentEl.scrollTop : e.pageY;
 thisObj.initDrag=true;
 thisObj.winEl.style.backgroundColor="#ddd";
 thisObj.winEl.style.opacity='0.5';
 thisObj.winEl.style.filter="progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
 thisObj.winEl.style.zIndex=ljex.Window.zindex;

 var el=$(thisObj.id+'-content');
 var w=el.clientWidth; var h=el.clientHeight;

 thisObj.transEl.style.width=w+"px"; 
 thisObj.transEl.style.height=h+"px";

 el.style.display='none';
 thisObj.transEl.style.display='block';

 }

 }
 
 $addEvent(this.parentEl, "mouseup",
 function(){
 if(thisObj.initDrag){
 thisObj.initDrag=false;
 thisObj.winEl.style.backgroundColor="transparent";
 thisObj.winEl.style.opacity='1.0';
 thisObj.winEl.style.filter="progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
 var el=$(thisObj.id+'-content');

 el.style.display='block';
 thisObj.transEl.style.display='none';
 thisObj.transEl.style.width="0px"; 
 thisObj.transEl.style.height="0px";
 }
 return true;
 });

 $addEvent(this.parentEl, "mousemove",
 function(e){
 var winTitle = $(thisObj.id+'-title');
 if(thisObj.initDrag){
 aktX = (document.all) ? window.event.clientX + winTitle.scrollLeft : e.pageX ;
 aktY = (document.all) ? window.event.clientY + winTitle.scrollTop : e.pageY;
 
 x = aktX-thisObj.startX;
 y = aktY-thisObj.startY;

 thisObj.startX=aktX; thisObj.startY=aktY;

  
 with(thisObj.winEl.style){
 left=parseInt(left)+x+'px';

 top=parseInt(top)+y+'px';
 if(parseInt(top)<0) top='0px';
 }
 } 
 return true;
 });
 }

 if(this.onrender) this.onrender.call(this);

}  
 

 
 
 
ljex.MessageBox = function(args){
 var thisObj = this;

 var defaults = {
 id: 'lx-win#'+$genid(),
 title: 'LJEX MessageBox',
 width: 350,
 height: 150,
 msg: 'LJEX - Leightweight Javascript EXtension',
 type: ljex.MessageBox.WARN,
 scope: this,
 focusOpacity: false,
 parentId: null
 };

 $setdef.call(this, defaults);
 $assimilate.call(this, args);


 footerItems=[];

 var btnOK = { 
 id: 'ljex-msg-ok', 
 text: (this.type==ljex.MessageBox.ASK)?'Ja':'OK', 
 icon: '/ljex/images/ok.png'
 };

 if(this.type==ljex.MessageBox.ASK){
 btnOK.onclick = function(){
 thisObj.close();
 thisObj.callback.call(thisObj.scope,"OK");
 }

 var btnCANCEL ={ 
 id: 'ljex-msg-cancel', 
 text: '<span style="color:#f00;font-weight:bold;">Nein!</span>', 
 icon: '/ljex/images/cancel.png',
 onclick: function() { thisObj.close(); thisObj.callback.call(thisObj.scope,"CANCEL"); } 
 };
 }else{
 btnOK.onclick = function(){
 if(thisObj.callback){
 thisObj.callback.call(thisObj.scope,"OK");
 }
 thisObj.close();
 }

 }

 var msgHeight = this.height-62;
 
 this.win = new ljex.Window({
 title: this.title,
 id: this.id,
 width: this.width,
  
 html: '<div align=center style="background-color:#ddd;width:100%;height:100%;"><div align=left style="height:'+msgHeight+'px" class="'+this.type+'"><div class="lx-mbox-msg"><div style="padding-left:60px;padding-right:10px;">'+this.msg+'</div></div></div><table align=center><tr><td><div class="lx-mbox-footer" id="'+this.id+'-footer-ct'+'"></div></td></tr></table></div>',
 parentId: this.parentId,
 center: true,
 focusOpacity: this.focusOpacity,
 onclose: function(){
  
 } 

 
 });
 
 this.win.open(true);
 this.win.winEl.style.zIndex=ljex.Window.zindex+1;
 this.win.show();

  
 if(this.type!=ljex.MessageBox.STATUS){
 footerItems[0]=btnOK;
 
 }
 
 if(this.type==ljex.MessageBox.ASK){
 footerItems[1]=btnCANCEL;
 
 }

 var footer = new ljex.ToolBar({
 id: this.id+'-footer',
 renderTo: this.id+'-footer-ct',
 items: footerItems
 });
 
 
 
  
 

 footer.render();

 ljex.MessageBox.instance=this;
 if(this.autoclose) window.setTimeout("ljex.MessageBox.instance.close()",this.autoclose*1000);

}

ljex.MessageBox.prototype.close =function(){
 if(this.win.winEl) this.win.close();
}

ljex.MessageBox.instance=null;
ljex.MessageBox.INFO = "lx-mbox-body lx-mbox-info";
 
ljex.MessageBox.STATUS = "lx-mbox-body lx-mbox-info status"; 
ljex.MessageBox.ERROR = "lx-mbox-body lx-mbox-error";
ljex.MessageBox.WARN = "lx-mbox-body lx-mbox-warn";
ljex.MessageBox.ASK = "lx-mbox-body lx-mbox-ask"; 
 

 
 
 
ljex.FormWindow = function(args){
 var thisObj = this;
 $assimilate.call(this, args);
 this.uid = $genid();

 var defaults = {
 id: 'lx-win#'+this.uid,
 title: 'LJEX FormWindow',
 width: 'auto',
 parentId: 'page',
 center: true,
 focusOpacity: false,
 contentBgColor: '#ddd',
 onclose: function(){}
 };

 $setdef.call(this, defaults);

 this.form.renderTo = "form-ct#"+this.uid;
 if(this.form.onrender){
 var onrenderFunc=this.form.onrender;
 }else{
 var onrenderFunc=function(){ return true; }
 }
 this.form.onrender = function(){
 thisObj.win.show();
 onrenderFunc();
 }
 this.formular = new ljex.Form(this.form);
}

ljex.FormWindow.prototype.close = function(){
 this.win.close();
}

ljex.FormWindow.prototype.open = function(){
 var thisObj=this;

 this.win = new ljex.Window({
 title: this.title,
 id: this.id,
 width: this.width,
 icon: this.icon,
 height: this.height,
 html: '<div id="form-ct#'+this.uid+'" ></div>',
 parentId: this.parentId,
 center: this.center,
 focusOpacity: this.focusOpacity,
 contentBgColor: this.contentBgColor,
 onclose: this.onclose
 });
 
 if(this.top) this.win.top=this.top;
 if(this.left) this.win.left=this.left;

 this.win.open(true);

 if(this.formular.formLoader){
 this.formular.loadForm();
 }else{
 this.formular.render();
 }

}
 


