var Window = Base.extend({

    width: null,
    primatives: [ "head", "body", "foot" ],
    dom: null,
    frame: null,
    errors: null,
    props: null,
    container: null,

	constructor: function( props, container ) {
	    this.dom = new DOM();
	    this.container = container || document.body;
	    this.props = props;
	    this.errors = [];
	},
	
	build: function(){
        
        var attrs = {   "class": this.type,
                        "style": {"width": this.setWidth() }};
        
        this.frame = this.dom.add( "div", attrs );
        this.dom.append( this.frame, this.container );
        
        for( var i = 0, divs = this.primatives; i<divs.length; i++ ){
            var elem = this.dom.add( "div" );
            var span = this.dom.add( "span" );
            
            this.dom.setAttr( elem, "class", divs[i] );
            this.dom.append( span, elem );
            this.dom.append( elem, this.frame );
        };
	},
	
	move: function( x, y ){
		this.frame.style.position = "absolute";
    	this.frame.style.left = x + "px";
    	this.frame.style.top = y + "px";
	},
		
	setType: function( def ){
	   var sub = this.props.className;
	   return this.type = 
	      ( def == sub ? def : def + " " + sub );
	},
	
	setWidth: function(){
	    return this.width = this.props.width || "auto";
	},
	
	getContent: function( type, elem ){
	   
	   type = type.replace( /(\w)/, function( m, c, n, s ){
				                        return c.toUpperCase(); });
				                        
	   var method = this.props["get"+[type]];
	   
	   if( ! method ){
	       throw new Error("Method get" + type + " not found" );
	   }else if( method.constructor !== Function ){
	       throw new Error("Method get" + type + " is not a function" );
	   }else{		                        
	       return method( elem );
	   }
	},
	
	removeChildren: function( target ){
        if( target.hasChildNodes ){
		    for( var i = 0, cn = target.childNodes; i<cn.length; i++ ){
		        this.dom.remove( cn[i] );
		    }
		}
		return target;
    }
});