// $Id: extra.js 876 2009-08-26 14:35:29Z sdalu $

/*
 * Stephane D'Alu (c) 2008-2009
 */

Ext.BLANK_IMAGE_URL = '/ext/resources/images/default/s.gif';




/*== Exting ExtJs ======================================================*/

/* 
 * Transfert effect
 */
Ext.Fx.transfert = function(to, o) {
    var from = this;
    var to   = Ext.get(to);
    var el   = Ext.get(this.dom);

    o = Ext.applyIf(o || {},
                    { duration: .2, easing: 'easeIn' });

    el.queueFx(o, function(){
        from.show();
	to.show();
	
	var f_b    = from.getBox();
	var t_b    = to.getBox();
	var proxy  = Ext.get(document.body ||
			     document.documentElement).createChild({
				     style : {
					 visbility: 'hidden',
					 position : 'absolute',
					 "z-index": 300, // yee haw
					 border   : '3px solid grey'
				     }
				 });
	var scale  = Ext.isBorderBox ? 0 : 1;
	var width  = proxy.getFrameWidth('lr') * scale;
	var height = proxy.getFrameWidth('tb') * scale;

	proxy.animate({
	    top    : { from : f_b.y,             to : t_b.y             },
	    left   : { from : f_b.x,             to : t_b.x             },
	    height : { from : f_b.height-height, to : t_b.height-height },
	    width  : { from : f_b.width-width,   to : t_b.width-width   } }, 
	    o.duration, 
	    function() { proxy.remove(); el.afterFx(o); },
	    o.easing);
    });
    
    return this;
};

Ext.Element.addMethods(Ext.Fx);



/*
 * Euro currency formating
 */
Ext.util.Format.eurMoney = function(v) { 
    v = (Math.round((v-0)*100))/100; 
    v = (v == Math.floor(v)) ? v + ".00" : ((v*10 == Math.floor(v*10)) 
					    ? v + "0" : v); 
    v = String(v); 
    var ps = v.split('.'); 
    var whole = ps[0]; 
    var sub = ps[1] ? '.'+ ps[1] : '.00'; 
    var r = /(\d+)(\d{3})/; 
    while (r.test(whole)) { 
	whole = whole.replace(r, '$1' + ',' + '$2'); } 
    v = whole + sub; 
    return v + ' €'; 
};



Ext.override(Ext.util.MixedCollection, {
    toArray : function()  {
	var list = [];
	this.each(function(elt) { list.push(elt.data); });
	return list; 
      }
  });


