Ext.onReady(function(){
  
  var contentdivdescriptionpanel = new Ext.Panel({
	  frame: true,
	  width:'100%',
	  id:'contentdivdescriptionpanel',
	  title:'Description',
	  frame: true,             
	  collapsible: false,          
	  contentEl: 'contentdivdescription'
  });
  var tooltips=Array();
  if (document.getElementById('contentdivfeatures')){
    var theimgs=document.getElementById('contentdivfeatures').getElementsByTagName("img");
    for(var i=0; i<theimgs.length; i++){
      var imgparent=theimgs[i].parentNode;
      if (imgparent.tagName.toUpperCase()!="DIV") imgparent=imgparent.parentNode;
      theh2=imgparent.getElementsByTagName("h2")[0];
      thetext=imgparent.getElementsByTagName("span")[0];
      tooltips[i]= new Ext.ToolTip({
        target: theimgs[i],
        title: theh2.innerHTML,
        html: thetext.innerHTML,
        plain: true,
        showDelay: 0,
        hideDelay: 0,
        trackMouse: true
      });
      imgparent.removeChild(thetext);
    }
    var contentdivfeaturespanel = new Ext.Panel({
  	  frame: true,
  	  width:'100%',
  	  id:'contentdivfeaturespanel',
  	  title:'Features',
  	  frame: true,             
  	  collapsible: false,          
  	  contentEl: 'contentdivfeatures'
    });
  }
  
  

  if (document.getElementById('contentdivnews')){
    var thenewsdivs=Array();
    var thenewschdivs=document.getElementById('contentdivnews').childNodes;
    var newsz=0;
    for (var i=0; i<thenewschdivs.length; i++){
      
      if (thenewschdivs[i].tagName && thenewschdivs[i].tagName.toUpperCase()=="DIV"){
        newsz++;
        var iscollapsed=false;
        if (newsz>3) iscollapsed=true;
        thenewsdivs[thenewsdivs.length]= new Ext.Panel({
      	  frame: true,
      	  width:'100%',
      	  id:'newsdiv_'+thenewsdivs.length,
      	  title:thenewschdivs[i].getAttribute("title"),
      	  frame: true,             
      	  collapsible: true,
          collapsed: iscollapsed,  
      	  contentEl: thenewschdivs[i].id
        });
      }
    }
    var contentdivnewspanel = new Ext.Panel({
  	  frame: true,
  	  width:'100%',
  	  id:'contentdivnewspanel',
  	  title:'News',
  	  frame: true,             
  	  collapsible: false,          
  	  contentEl: 'contentdivnews',
  	  items: thenewsdivs
    });
  }
  var contentdivlinkspanel = new Ext.Panel({
	  frame: true,
	  width:'100%',
	  id:'contentdivlinkspanel',
	  title:'Navigation',
	  frame: true,             
	  collapsible: true,          
	  margins:'5',
	  cmargins:'5',
	  contentEl: 'contentdivlinks'
  });
  var contentdivadpanel = new Ext.Panel({
	  frame: true,
	  width:'100%',
	  id:'contentdivadpanel',
	  title:'Advertisings',
	  frame: true,             
	  collapsible: true,          
	  margins:'5',
	  cmargins:'5',
	  contentEl: 'contentdivad'
  });
  
  var statusbarcontent = new Ext.Toolbar.TextItem('&copy; 2007-2010 Julian Stricker');
  
  if (typeof contentdivfeaturespanel != 'undefined' ){
    var contentitems=[contentdivdescriptionpanel,contentdivfeaturespanel];
  }else if (typeof contentdivnewspanel != 'undefined' ){
    var contentitems=[contentdivdescriptionpanel,contentdivnewspanel];
  }else{
    var contentitems=[contentdivdescriptionpanel];
  }
  
  panel = new Ext.Viewport({
	 layout:'border',
	
  	items:[{
  	  region:'center',
  	  id:'images-view',
  	  title:'AIE - (Ajax Image Editor)',
  	  margins:'5 5 5 5',
  	  cmargins:'5 5 5 5',
  	  layout:'column',
  	  frame: true,
  	  autoScroll:true,
  	  bbar: new Ext.StatusBar({
          id: 'thestatusbar',
          items: [statusbarcontent]
      }),
  	  items: contentitems
  	},{
  	  region:'east',
  	  id:'east-panel',
  	  title:'Info',
  	  frame: true,
  	  split:true,
  	  width: 270,
  	  minSize: 175,
  	  maxSize: 400,
  	  collapsible: true,  
  	  margins:'5 5 5 5',
  	  cmargins:'5 5 5 5',
  	  layout:'column',
  	  autoScroll:true,
  	  items: [contentdivlinkspanel,contentdivadpanel]
  	}]
	

  });    
  
  Ext.QuickTips.init();

});

function showimageold(imageurl) {
  alert('hi');
  if (typeof win != 'undefined'){
    win.close();
    delete win;
  }
  alert('hi');
  theimg=Ext.get('bigimgdiv').createChild({tag: 'img', id: 'imagebig', src: imageurl});
  theimg.on('load',function(wthis){
    win = new Ext.Window({
      title: 'Image',
      shadow:true,
      layout:'fit',      
      items: [theimg]
    });
    getId('bigimgdiv').innerHTML="";
    win.show(this);
  });
}

function showimage(imageurl) {

  if (typeof win != 'undefined'){
    win.close();
    delete win;
  }
  theimg=Ext.get('bigimgdiv').createChild({tag: 'img', id: 'imagebig', src: imageurl});
  theimg.on('load',function(wthis){  
    win = new Ext.Window({
      title: 'Image',
      shadow:true,
      layout:'fit',
      y:10,
      width:document.getElementById('imagebig').width+14,   
      height:document.getElementById('imagebig').height+28,  
      contentEl: theimg
    });
    //getId('bigimgdiv').innerHTML="";
    win.show(this);
  });
}



function showimageolld(imageurl) {
  
  /*if (typeof win != 'undefined'){
    win.close();
    delete win;
  }*/
  win = new Ext.Window({
    title: 'Image',
    layout:'fit',
    shadow:false,
    x: 100,
    y: 50,
    autoHeight: true,
    autoWidth: true,
    html: '<img src="'+imageurl+'" />'
  });
  win.show();
}
