/*
	ENDEREÇO 			   = ARQUIVO QUE VAI SER ABERTO
	NOME    			   = NOME DO POP-UP
	FULLSCREEN 			   = ABRE O POP-UP EM TELA CHEIA
	INDICE                 = CONTROLE DE FECHAMENDO DA TABELA
	TAMANHO_ALTURA         = ALTURA DO POP-UP
	TAMANHO_LARGURA        = LARGURA DO POP-UP
	ALINHAMENTO_HORIZONTAL = ALINHAMENTO HORIZONTAL DO POP-UP: C - CENTRALIZADO, R - DIREITA, L - ESQUERDA
	ALINHA_VERTICAL        = ALINHAMENTO VERTICAL DO POP-UP: C - CENTRALIZADO, U - ACIMA, D - ABAIXO
*/	
function redimensionar(objeto) {
var altura       = objeto.height + 110
var largura      = objeto.width  + 60
var altura_tela  = window.screen.availHeight - 50
var largura_tela = window.screen.availWidth  - 50
	if (altura  > altura_tela) 
		altura   = altura_tela
	if (largura > largura_tela) 
		largura  = largura_tela		
	window.resizeTo(largura, altura)
	window.moveTo(((largura_tela + 50) - largura) / 2, ((altura_tela + 50) - altura) / 2);
	window.focus()
}
var abertura_janela = new Array()
function janela(endereco, nome, fullscreen, indice, tipo_visualizacao, tamanho_altura, tamanho_largura, alinhamento_horizontal, alinhamento_vertical, tipo_janela, barra_rolagem, status, maximizar, botao, botao_menu, localizacao, diretorio) {
	if (fullscreen == 'S') {	
		if (tipo_visualizacao == 1) {
			if (abertura_janela[indice] && abertura_janela[indice].open && !abertura_janela[indice].closed) 
			abertura_janela[indice].close()
							
			abertura_janela[indice] = window.open(endereco, nome, 'fullscreen = yes')
 		    abertura_janela[indice].focus()		
		}else if (tipo_visualizacao == 2) {
			if (abertura_janela[indice] && abertura_janela[indice].open && !abertura_janela[indice].closed) {
				abertura_janela[indice].focus()
			}else {
				abertura_janela[indice] = window.open(endereco, nome, 'fullscreen = yes')
	 		    abertura_janela[indice].focus()
			}		
		}else {
			abertura_janela[0] = window.open(endereco, nome, 'fullscreen = yes')
 		    abertura_janela[0].focus()
		}	
	}else {				
	
		switch (alinhamento_horizontal) {
			case 'C':
				var largura 		= (screen.width / 2)
				var inicio_esquerda = (largura - (tamanho_largura / 2))
			break
			case 'L':
				var inicio_esquerda = 0
			break
			case 'R':				
				var inicio_esquerda = screen.width - tamanho_largura
			break
			default:
				var inicio_esquerda = alinhamento_horizontal
		}	
						
		switch(alinhamento_vertical) {
			case 'C':
				var altura		= (screen.height / 2)
				var inicio_topo = (altura - (tamanho_altura / 2))
			break
			case 'U':
				var inicio_topo = 0
			break
			case 'D':
				var inicio_topo = screen.height - tamanho_altura
			default:
				var inicio_topo = alinhamento_vertical
			break			
		}
			
		switch(barra_rolagem) {
			case 'S':
				barra_rolagem = 'yes'
			break
			case 'N':
				barra_rolagem = 'no'
			break
			case 'A':
				barra_rolagem = 'auto'
			break
			default:
				barra_rolagem = 'yes'			
		}
	
		switch(status) {
			case 'S':
				status = 'yes'
			break
			case 'N':
				status = 'no'
			break
			default:
				status  = 'yes'		
		}
		
		switch(maximizar) {
			case 'S':
				maximizar= 'yes'
			break
			case 'N':
				maximizar= 'no'
			break
			default:
				maximizar = 'no'
		}		
		
		switch(botao) {
			case 'S':
				botao = 'yes'
			break
			case 'N':
				botao = 'no'
			break
			default:
				botao = 'no'
		}
		
		switch(botao_menu) {
			case 'S':
				botao_menu = 'yes'
			break
			case 'N':
				botao_menu = 'no'
			break
			default:
				botao_menu = 'no'
		}	
		
		switch(localizacao) {
			case 'S':
				localizacao = 'yes'
			break
			case 'N':
				localizacao = 'no'
			break
			default:		
				localizacao = 'no'
		}		
		
		switch(diretorio) {
			case 'S':
				diretorio = 'yes'
				break
			case 'N':
				diretorio = 'no'
			break
			default:
				diretorio = 'no'
		}			
		if (tipo_janela == 1) {
			if (window.showModelessDialog) {
				if (alinhamento_horizontal == 'C'  && alinhamento_vertical == 'C')	
					window.showModalDialog(endereco, nome, 'dialogWidth:' + tamanho_largura + 'px; dialogHeight:' + tamanho_altura + 'px; center: yes; resizable: ' + maximizar + '; status: ' + status + '; scroll:' +  barra_rolagem + '; unadorned: yes; help: no')
				else
					window.showModalDialog(endereco, nome, 'dialogTop:' + inicio_topo + 'px; dialogLeft:' + inicio_esquerda + 'px; dialogWidth:' + tamanho_largura + 'px; dialogHeight:' + tamanho_altura + 'px; center: no; resizable: ' + maximizar + '; status: ' + status + '; scroll:' +  barra_rolagem + '; unadorned: yes; help: no')
			}else {				
				if (tipo_visualizacao == 1) {
					if (abertura_janela[indice] && abertura_janela[indice].open && !abertura_janela[indice].closed) 
					abertura_janela[indice].close()
								
					abertura_janela[indice] = window.open(endereco, nome, 'top = ' + inicio_topo + ', left = ' + inicio_esquerda + ', width = ' + tamanho_largura + ', height = ' + tamanho_altura + ', fullscreen = no, resizable = ' + maximizar + ', status = ' + status + ',  scrollbars = ' + barra_rolagem + ', toolbar = ' + botao + ', menubar = ' + botao_menu + ', location = ' + localizacao + ', directories = ' + diretorio)				
					abertura_janela[indice].focus()
				}else if (tipo_visualizacao == 2) {
					if (abertura_janela[indice] && abertura_janela[indice].open && !abertura_janela[indice].closed) {
						abertura_janela[indice].focus()
					}else {
						abertura_janela[indice] = window.open(endereco, nome, 'top = ' + inicio_topo + ', left = ' + inicio_esquerda + ', width = ' + tamanho_largura + ', height = ' + tamanho_altura + ', fullscreen = no, resizable = ' + maximizar + ', status = ' + status + ',  scrollbars = ' + barra_rolagem + ', toolbar = ' + botao + ', menubar = ' + botao_menu + ', location = ' + localizacao + ', directories = ' + diretorio)				
						abertura_janela[indice].focus()
					}		
				}else {
				   abertura_janela[0] = window.open(endereco, nome, 'top = ' + inicio_topo + ', left = ' + inicio_esquerda + ', width = ' + tamanho_largura + ', height = ' + tamanho_altura + ', fullscreen = no, resizable = ' + maximizar + ', status = ' + status + ',  scrollbars = ' + barra_rolagem + ', toolbar = ' + botao + ', menubar = ' + botao_menu + ', location = ' + localizacao + ', directories = ' + diretorio)				
 				   abertura_janela[0].focus()
				}
			}	
		}else {				
			if (tipo_visualizacao == 1) {
				if (abertura_janela[indice] && abertura_janela[indice].open && !abertura_janela[indice].closed) 
				abertura_janela[indice].close()
				abertura_janela[indice] = window.open(endereco, nome, 'top = ' + inicio_topo + ', left = ' + inicio_esquerda + ', width = ' + tamanho_largura + ', height = ' + tamanho_altura + ', fullscreen = no, resizable = ' + maximizar + ', status = ' + status + ',  scrollbars = ' + barra_rolagem + ', toolbar = ' + botao + ', menubar = ' + botao_menu + ', location = ' + localizacao + ', directories = ' + diretorio)				
				abertura_janela[indice].focus()
			}else if (tipo_visualizacao == 2) {
				if (abertura_janela[indice] && abertura_janela[indice].open && !abertura_janela[indice].closed) {
					abertura_janela[indice].focus()
				}else {
					abertura_janela[indice] = window.open(endereco, nome, 'top = ' + inicio_topo + ', left = ' + inicio_esquerda + ', width = ' + tamanho_largura + ', height = ' + tamanho_altura + ', fullscreen = no, resizable = ' + maximizar + ', status = ' + status + ',  scrollbars = ' + barra_rolagem + ', toolbar = ' + botao + ', menubar = ' + botao_menu + ', location = ' + localizacao + ', directories = ' + diretorio)				
					abertura_janela[indice].focus()
				}		
			}else {
			   abertura_janela[0] = window.open(endereco, nome, 'top = ' + inicio_topo + ', left = ' + inicio_esquerda + ', width = ' + tamanho_largura + ', height = ' + tamanho_altura + ', fullscreen = no, resizable = ' + maximizar + ', status = ' + status + ',  scrollbars = ' + barra_rolagem + ', toolbar = ' + botao + ', menubar = ' + botao_menu + ', location = ' + localizacao + ', directories = ' + diretorio)				
 			   abertura_janela[0].focus()
			}
		}	
	}
	return(abertura_janela[indice])
}
		
function fechar_janela(janela_aberta) {
var x 				 = null 
var janela_aberta    = janela_aberta.split(',')
	for (x = 0; x < janela_aberta.length; x ++) 
		if (abertura_janela[janela_aberta[x]] && abertura_janela[janela_aberta[x]].open && !abertura_janela[janela_aberta[x]].closed) 
			abertura_janela[janela_aberta[x]].close()
	return(null)
}

/*
document.oncontextmenu =
function () {
	return(false)
}
if (document.layers) {
	window.captureEvents(event.mousedown)
	window.onmousedown =	
function (evento) {
	if (evento.target == document)
		return(false)
	}
}else {
  	document.onmousedown =
	function () {
		return(false)
	}
}
*/
