//==============================================
// DomAPI Product Window Component
// M. Salo 5/11/2004
// (c) Laborint 2004
//==============================================
domapi.loadUnit("label");
domapi.registerComponent("prodwin");
//------------------------------------------------------------------------------
domapi.Prodwin = function(arg){return domapi.comps.prodwin.constructor(arg)};
//------------------------------------------------------------------------------
domapi.comps.prodwin.constructor = function(arg){
    arg["w"] = domapi.rInt(arg["w"], 270+165);
    arg["h"] = domapi.rInt(arg["h"], 270+10);
    arg["bgcolor"] = domapi.rVal(arg["bgcolor"], "#000000");
    var e = domapi.Component(arg, "prodwin");
    e.hide();
    e.winPad = 15;
    e.winHeadH = 60;
    e.winHeadBottomPad = 5;
    e.closeSize = 15;
    
    picw = arg["w"]-2*e.winPad;
    picy = e.winHeadH + e.winPad + e.winHeadBottomPad;
    pich = arg["h"]-picy-e.winPad;
    picx = e.winPad;
    closex = arg["w"]-e.winPad-e.closeSize;
    
    e.elPict = domapi.Elm({parent:e,bgcolor:"#FFFFFF",w:picw,h:pich,x:picx,y:picy});
    
    e.elComm = domapi.Elm({parent:e,x:e.winPad,h:e.winHeadH});
    e.elComm.setText("<h1>black chair</h1>materjal: puit<br>m&otilde;&otilde;dud:1x2x3");

    e.elClose = domapi.Elm({parent:e,x:closex,y:e.winPad,w:e.closeSize,h:e.closeSize});
    e.elClose.setText('<a href="#" onclick="return false;"><img src="/images/close.gif" width="15" height="15" alt="Close" /></a>');

    e.turnOnDrag();
    e.elPict.turnOnDrag(e);
    e.elComm.turnOnDrag(e);
    
    
    var p = domapi._private.prodwin;
    domapi.addEvent(e.elClose, "click", p.doclose);

    domapi.disallowSelect(e);
    domapi._finalizeComp( e);
    return e;
};
//------------------------------------------------------------------------------
domapi.comps.prodwin._draw = function(){
  this.prodwDraw();
};
//------------------------------------------------------------------------------
domapi.comps.prodwin.prodwDraw = function(){

};
//------------------------------------------------------------------------------
domapi.comps.prodwin.setProd = function(prod){
       this.elPict.setText('<img src="'+prod.img+'" border="0" alt="" width="'+prod.imgw+'" height="'+prod.imgh+'"/>');
       this.elComm.setText("<h1>"+prod.page_title + "</h1>" + prod.page_description + "<br />");
       
       winw = prod.imgw+2*this.winPad;
       winh = prod.imgh+this.winHeadH + 2*this.winPad + this.winHeadBottomPad;

       //this.setSize(winw,winh);
       this.show();
       this.sizeTo({endw:winw,endh:winh,type:2,steps:10,speed:40});
};
//------------------------------------------------------------------------------
domapi.comps.prodwin._layout = function(w,h){
    picw = w-2*this.winPad;
    picy = this.winHeadH + this.winPad + this.winHeadBottomPad;
    pich = h-picy-this.winPad;
    picx = this.winPad;
    
    closex = w-this.winPad-this.closeSize;
    this.elClose.setX(closex);
    this.elClose.setY(this.winPad);
    
    this.elPict.setW(picw);
    this.elPict.setH(pich);
    
    this.elComm.setX(this.winPad);
    this.elComm.setY(this.winPad);
    //this.elComm.setH(head);
    this.elComm.setW(w-2*this.winPad);
    
    this.setH(h);
    this.setW(w);
};
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// private members
domapi._private.prodwin.doclose = function(E){
  var e = domapi.findTarget(E,"PRODWIN");
  e.hide();
};
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------