dojo.provide("com.qi.ClickObject");
dojo.declare("com.qi.ClickObject", null, {
        _static: {
					 _connectsList: new Array()
		},
		constructor: function(newWindowLink, linkTarget){
				var Connector = dojo.connect(newWindowLink, 'click', function(clickEvent){
						//Open a new window
						window.open(linkTarget);
						dojo.stopEvent(clickEvent);
					});
				
				//Put the new handler-id in the _connectsList array
				this._static._connectsList.push(Connector);
				
				if(!this._static._connectsList.lenght)
				{
					// Disconnect all connects when the page is unloaded
					// Note: dojo.hitch saves the scope, so that this still refers/points to this this and not that this, is that clear?
					dojo.addOnWindowUnload(dojo.hitch(this, function(){
						dojo.forEach(this._static._connectsList, function(handler){
							dojo.disconnect(handler);
						});
					}));
				}
        }
});