// Code for generic box widgets. Copied from DynDuo's widget tutorial

// Draggable Box Widget Object
function Box(x,y,width,height,color) {
        this.name = "Box"+(Box.count++)
        this.x = x
        this.y = y
        this.w = width
        this.h = height
        this.color = color
        this.build = BoxBuild
        this.activate = BoxActivate
        this.makeDrag = BoxMakeDrag
        this.removeDrag = BoxRemoveDrag
}
function BoxBuild() {
        this.css = css(this.name+'Box',this.x,this.y,this.w,this.h)+
	css(this.name+'Top',0,0,this.w,1,this.color)+ 
	css(this.name+'Bottom',0,this.h-1,this.w,1,this.color)+
        css(this.name+'Left',0,0,1,this.h,this.color)+
        css(this.name+'Right',this.w-1,0,1,this.h,this.color)
        
        this.div = '<DIV ID="'+this.name+'Box">\n'+
        '<DIV ID="'+this.name+'Top"></DIV>\n'+
	'<DIV ID="'+this.name+'Bottom"></DIV>\n'+
        '<DIV ID="'+this.name+'Left"></DIV>\n'+
        '<DIV ID="'+this.name+'Right"></DIV>\n'+
        '</DIV>\n\n'
}
function BoxActivate() {
        this.lyr = new DynLayer(this.name+'Box')
//        this.makeDrag()
}
function BoxMakeDrag() {
        drag.add(this.lyr)
}
function BoxRemoveDrag() {
        drag.remove(this.lyr)
}
Box.count = 0
