//vapi.require("jquery.ifixpng.js");
//vapi.require("jquery.blockUI.js");
//vapi.require("util");
//vapi.comp.define(function(){
(function($){
    if ($.localhost) alert("jQuery.localhost is already defined!");

    $.localhost = {

	    ready: function(){
	    
	        var self = this;
	        this.init();
	        
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function(){self.update();});
	        
	    },
	    
	    init: function(){	 
	       
	        this.master.init();
	        
	        this.page.init();
	        
	        $(this.controls).each(function(){
	            this.init();
	        });
	        
	        this.update();
	    },
	    
	    update: function(){
	        $(this.controls).each(function(){
	            this.update();
	        });
	    }
	    
    };
    
    $.localhost.master = {
    
        init: function(){},
        
        define: function(o){
            $.extend(this, o);
        }
        
    };
    
    $.localhost.page = {
    
        init: function(){},
        
        define: function(o){
            $.extend(this, o);
        }
        
    };
    
    $.localhost.control = {
    
        proto: function(){
        
            this.instances = [];
            
            this.add = function(id) {
                var c = $.extend(this, {id: id});
                this.instances.push(c);
                $.localhost.controls.push(c);
            };
            
            this.$ = function() {
                return $("#" + this.id);
            };
            
            this.init = function(){};
            this.update = function(){};
        },
    
        define: function(id, o) {
            var c = $.extend(true, new this.proto(), o, {type: id});
            $.localhost[id] = c;    // Add as $.localhost.ControlName
        }
        
    };

    $.localhost.controls = [];
    
    $(document).ready(function(){$.localhost.ready();});
    
})(jQuery);
