/*****************************************************************************
* JS Class popUp by Lucas Ferreira - www.lucasferreira.com
* Classe para facilitação em criação de popUps no browser
*****************************************************************************/

function popUp(){
	this.win = null;
	this.loc = "";
	this.msgBlock = null;
	this.width = 0;
	this.height = 0;
	this.scroll = 0;
	this.extra = "";
}

popUp.prototype.setScale = function(w, h){
	this.width = w;
	this.height = h;
}

popUp.prototype.setMsgBlock = function(m){
	this.msgBlock = m;	
}

popUp.prototype.useScroll = function(s){
	this.scroll = s;
}

popUp.prototype.setExtra = function(e){
	this.extra = e;
}

popUp.prototype.open = function(l){
	this.close();
	this.loc = l;
	var cfg = "width=" + this.width + ", height=" + this.height + ", scrollbars=" + this.scroll;
	if(this.extra.length > 0){
		cfg += ", " + this.extra;
	}
	this.win = window.open(this.loc, "", cfg);
	if(this.win == null && this.msgBlock != null){
		alert(this.msgBlock);
		return true;
	} else {
		this.win.moveTo((screen.width-this.width)/2, (screen.height-this.height)/2);
		this.win.focus();
	}
}

popUp.prototype.close = function(){
	if(this.win != null){
			this.win.close();
	}
}