/*
* Copyright mtr 2008
* @desc dWin element based on dEl objet
*/
var _JFC_WIN_DEF_CLASSNAME 		= 'jfcWin';
var _JFC_DWIN_ZINDEX                    = 1;
var _JSONWinDef	= {
                className:'jfcWin',
                ___jfcChilds :{
                                shadow:{
                                                   className:'jfcShadow',
                                                   style:{background:'url(___images/shadow.png)'}
                                },
                                header:{
                                   className:'jfcWinTitle',
                                    ___jfcChilds:{
                                          close:{
                                              ___tagName  :'img',
                                              className   :'jfcWinCloseButton',
                                              src         :'___images/cross.gif',
                                              onclick     :function(){close();}
                                          }
                                    }
                                },
                                frame:{
                                             className:'jfcFrame'
                                    }
                }
};
function dRPCWin( _json, _parent, _align )
 {
 //prepare attributes
 	_json			= (_json)?_json:_JSONWinDef;
 	_json.className 	= (_json.className)?_json.className:_JFC_WIN_DEF_CLASSNAME;
 	_json.id 		= (_json.id)?_json.id:Math.random();
 	this.___json		= _json;
 	this.___uid 		= _json.id;
 	_json.___jfcChilds.frame.id = 'frame'+this.___uid;
 	this.align          = _align;
//create elements
        this.dElement       = new dEl( _parent, 0, _json );
        opacityApear(DOMel(this.dElement));
        
//methods
	this.setUrl         = function( _url ){
                                               this.dElement.prototype.frame.prototype.innerHTML = '<img src="___images/loading.gif">';
                                               this.show();
                                               rpcGet('rpc_dRPCWinHandler', this, _url ,'');
                                               if(this.align == 'top')
                                               {
                                                  posOnWin( );
                                               }
                                               else if(this.___object && !this.align)
                                               {
                                                  posOnObj();
                                               }
					}

//                                                        this.prototype = {a:1};
                                                      /*
        jfcMSGMapper.registerMessage('ON_SET_URL','d',1,this.prototype);

        jfcMSGMapper.sendMessage('ON_SET_URL','da');*/

	this.setAlignObject      = function(_object){this.___object=_object;}
	this.close          = function() {
            opacityApear(DOMel(this.dElement));
                                           this.dElement.prototype.style.display='none';
	};
	this.show           = function() {
                                            this.dElement.prototype.style.display='block';
                                            opacityApear(DOMel(this.dElement));

        };
    this.center         = function(){centerOnWindow(this.___uid);};
    this.attach         = function(_obj){this.___object = _obj;};
    this.dettach        = function(){this.___object = 0};
    this.posOnObj       = function(_obj){
         if(_obj)
         {
            attach(_obj);
            pos = GetPosition(this.___object);
            this.dElement.prototype=___prototype(this.dElement.prototype,{style:{top:pos.y+pos.height,left:pos.x}});
         }
    };
    this.posOnWin       = function(document)
    {
           y = getScrollY();
           this.dElement.prototype=___prototype(this.dElement.prototype,{style:{top:parseInt(y + 10 )+ "px",left:10 + "px"}});
    }
//initializing
    initDrag( this.dElement.prototype );
    return this;
 }

function rpc_dRPCWinHandler ( _req, _dRPCWin )
{
	var dRPCFrame = _dRPCWin.dElement.prototype.frame.prototype;
	dRPCFrame = ___prototype( dRPCFrame, {innerHTML:_req.responseText} );
        opacityApear(DOMel(_dRPCWin.dElement));
}
