/**
  * Application Layout
  * by Jozef Sakalos, aka Saki
  * http://extjs.com/learn/Tutorial:Application_Layout_for_Beginners
  */

// reference local blank image
 
// create namespace
Ext.namespace('Karma');
 
// create application
Karma = function() 
{
    return {
        // public methods
        init: function() 
		{
			this.resizeNewsPictures();
			this.initIframe();
        } 
		,resizeNewsPictures: function()
		{			
            var T = 600;
            var DH = Ext.DomHelper;            
            var Img = Ext.select('.k-news-body img[alt="Bild"]', true);
            Img.each(function(I)
            {
                var W = I.getWidth();
                var H = I.getHeight();
                var R = 0;
                if(W > H)
                {
                    R = T / W;
                }
                else
                {
                    R = T / H;
                }
                var NW = W * R;
                var NH = H * R;
                if(W > T || H > T) {
                    I.resize(NW, NH);
                }
                var Div = DH.insertAfter(I, {tag: 'div', style: 'text-align: center;'});
                var Div = I.appendTo(Div);                
            });
		}
		,initIframe: function() {
			var ifrm = Ext.get('ifrm');
		    if (ifrm) {
				ifrm.on('load',   this.resizeIframe, this);
				ifrm.on('resize', this.resizeIframe, this);
		    }
		}
		,resizeIframe: function() 
		{			
			var mif = new Ext.ux.ManagedIFrame('ifrm');
			if (mif.dom) { // If iframe exists
				// set frame height
				var height = mif.getDoc().child('body').getHeight();
				mif.setHeight(height);				
			}
		}
    }
}(); // end of app
 
Ext.onReady(Karma.init, Karma);
// end of file
