

function PopCtrl(){
	this.windows = new Array();
	
	this.openPopup = function(url, name, settings){
		var win = window.open(url, name, settings);
		this.windows.push(win);
	}
	
	
	this.closeWindowByNumber = function(num){
		if(num > 0 && num < this.windows.length){
			this.windows[num].close();
			this.windows.splice(num,1);
			return true;
		}
		return false;
	}
	
	this.closeWindow = function(name){
		for(var i=0; i < this.windows.length; i++){
			if(url == this.windows.name){
				return this.closeWindowByNumber(i);
			}
		}
		
		return false;
	}
	
	this.closeAll = function (){
		for(var i=0; i < this.windows.length; i++){
			this.closeWindowByNumber(i);
		}
		return true;
	}
	
}

var PopupControl = new PopCtrl();
