function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() 
{ //v6.0
var i,p,v,obj,args=MM_showHideLayers.arguments;    
for (i=0; i<(args.length-2); i+=3) 
if ((obj=MM_findObj(args[i]))!=null) 
{ v=args[i+2];      
if (obj.style) 
{ obj=obj.style; 
v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
}      obj.visibility=v; 
}  
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// abre janela
function abre(url,janela,larg,alt,pos1,pos2)
{
window.open(url,janela,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,top="+pos1+",left="+pos2+",screenY="+pos1+",screenX="+pos2+",width="+larg+",height="+alt);
}
// abre janela
function abre2(url,janela,larg,alt,pos1,pos2)
{
window.open(url,janela,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,top="+pos1+",left="+pos2+",screenY="+pos1+",screenX="+pos2+",width="+larg+",height="+alt);
}
// abre janela
function abre3(url,janela,larg,alt,pos1,pos2)
{
window.open(url,janela,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,top="+pos1+",left="+pos2+",screenY="+pos1+",screenX="+pos2+",width="+larg+",height="+alt);
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function Mensalidade()
{ 
janela=window.open("http://www.custos.satc.edu.br/fac/tec/default.asp", "newwin", "height=600,width=800,toolbar=no,scrollbars=yes,menubar=no");
}
function ReservaMatricula()
{ 
janela=window.open("http://www.custos.satc.edu.br/fac/al1/default.asp", "newwin", "height=600,width=800,toolbar=no,scrollbars=yes,menubar=no");
}
function validacampos(){
if(document.ins.inome.value.length==""
|| document.ins.iendereco.value.length==""
|| document.ins.ibairro.value.length==""
|| document.ins.ipagamento.value.length==""
|| document.ins.icep.value.length==""
|| document.ins.icid.value.length==""
|| document.ins.iuf.value.length==""
|| document.ins.icpf.value.length==""
|| document.ins.irg.value.length==""
|| document.ins.iddd1.value.length==""
|| document.ins.itel1.value.length==""
|| document.ins.iemail.value.length==""
|| document.ins.iprofissao.value.length==""
|| document.ins.iempresa.value.length=="")
{
alert("ATENÇÃO: todos os campos são obrigatórios. As exceções estão assinaladas abaixo do campos.");
return false;}
else{
return true;}
}

function esconde (id) {
	e=document.getElementById(id);
	e.style.display = 'none';
	}
function changeDisplayState (id) {
	e=document.getElementById(id);
	if (e.style.display == 'none' || e.style.display == "") {
	e.style.display = 'block';
	} else {
	e.style.display = 'none';
	}
}

function posicao(fonte, modo, elemento_imagem) {
	elemento_testa = document.getElementById('div_foto')
		if (!elemento_testa) {
			elemento_cria = document.createElement('div');
			elemento_cria.id = "div_foto"
			elemento_cria.innerHTML = "&nbsp;"
			document.getElementById('miolo').appendChild(elemento_cria);
		}
	elemento_testa = document.getElementById('img_foto')
		if (!elemento_testa) {
			elemento_cria = document.createElement('img');
			elemento_cria.id = "img_foto"
			document.getElementById('miolo').appendChild(elemento_cria);
		}
	elemento_testa = document.getElementById('img_foto_carregando')
		if (!elemento_testa) {
			elemento_cria = document.createElement('img');
			elemento_cria.src = "http://www.satc.edu.br/satc/imagens/galerias/1/Abadeus1.jpg"
			elemento_cria.id = "img_foto_carregando"
			document.getElementById('miolo').appendChild(elemento_cria);
		}
	elemento_testa = document.getElementById('div_fechar')
		if (!elemento_testa) {
			elemento_cria = document.createElement('div');
			elemento_cria.innerHTML = "<a href=\"javascript:void(0)\" onclick=\"javascript:fechar()\"><img src=\"imagens/galerias/botao_fechar.jpg\"/></a>"
			elemento_cria.id = "div_fechar"
			document.getElementById('miolo').appendChild(elemento_cria);
		}
	elemento_testa = document.getElementById('div_vai_volta')
		if (!elemento_testa) {
			elemento_cria = document.createElement('div');
			elemento_cria.innerHTML = "<a href=\"javascript:void(0)\" onclick=\"javascript:fechar()\"><img src=\"imagens/galerias/botao_traz.jpg\"/></a><a href=\"javascript:void(0)\" onclick=\"javascript:fechar()\"><img src=\"imagens/galerias/botao_frente.jpg\"/></a>"
			elemento_cria.id = "div_vai_volta"
			document.getElementById('miolo').appendChild(elemento_cria);
		}
	window.onscroll = function() { posicao('', 'posiciona') }
	if (modo == 'posiciona' && document.getElementById('div_foto').style.display != 'block') {
		return
	}
	if( typeof( window.innerWidth ) == 'number' ) {
		altura_pagina = window.innerHeight;
		largura_pagina = window.innerWidth;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		altura_pagina = document.documentElement.clientHeight;
		largura_pagina = document.documentElement.clientWidth;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		altura_pagina = document.body.clientHeight;
		largura_pagina = document.body.clientWidth;
	}
	scroll_pagina = document.documentElement.scrollTop;

	elemento = document.getElementById('div_foto')
	elemento.style.width = largura_pagina+"px"
	//elemento.style.height = altura_pagina+"px"
	//elemento.style.top = scroll_pagina+"px"
	elemento.style.height = document.body.clientHeight+"px"

	document.getElementById('img_foto_carregando').style.display = "block"
	document.getElementById('div_foto').style.display = "block"

	imagem_carregando = document.getElementById('img_foto_carregando')
	imagem_carregando.onload = function() {
		altura_pagina = eval(altura_pagina)
		largura_pagina = eval(largura_pagina)
		scroll_pagina = eval(scroll_pagina)
		altura_imagem = this.height
		largura_imagem = this.width
		this.style.left = (largura_pagina/2) - (largura_imagem/2).toFixed(0) + 'px'
		this.style.top = ((altura_pagina/2) - (altura_imagem/2).toFixed(0) + scroll_pagina) + 'px'
	}
	imagem_carregando.src = "http://www.satc.edu.br/portais/imagens/ajax-loader.gif"

	imagem = document.getElementById('img_foto')
	imagem.onclick = function() {
		fechar()
	}
	imagem.onload = function() {
		document.getElementById('img_foto').style.display = "block"
		altura_pagina = eval(altura_pagina)
		largura_pagina = eval(largura_pagina)
		scroll_pagina = eval(scroll_pagina)
		altura_imagem = this.height
		largura_imagem = this.width
		if (altura_imagem + 50 > altura_pagina) {
			altura_imagem = altura_pagina-50
			this.style.height = altura_imagem
			largura_imagem = this.width
			this.onclick = function() { window.open(this.src) }
		}
		this.style.left = (largura_pagina/2) - (largura_imagem/2).toFixed(0) + 'px'
		this.style.top = ((altura_pagina/2) - (altura_imagem/2).toFixed(0) +scroll_pagina) + 'px'

		div_fecha = document.getElementById('div_fechar')
		div_fecha.style.display = "block"
		div_fecha.style.left = ( (largura_pagina/2) - (largura_imagem/2).toFixed(0) +largura_imagem - 100) + 'px'
		div_fecha.style.top = (((altura_pagina/2) - (altura_imagem/2).toFixed(0) +scroll_pagina) + altura_imagem) + 'px'

		div_vaivolta = document.getElementById('div_vai_volta')
		div_vaivolta.style.display = "block"
		div_vaivolta.style.left = ( (largura_pagina/2) - (largura_imagem/2).toFixed(0) ) + 'px'
		div_vaivolta.style.top = (((altura_pagina/2) - (altura_imagem/2).toFixed(0) +scroll_pagina) + altura_imagem) + 'px'

		document.getElementById('img_foto_carregando').style.display = "none"
	}
	imagem.style.cursor = "pointer"

	if (modo == 'posiciona') 
		imagem.src = imagem.src
	else 
		imagem.src = fonte

	if (elemento_imagem) {
		anterior_link = document.getElementById('div_vai_volta').childNodes[0]
		proxima_link = document.getElementById('div_vai_volta').childNodes[1]
		anterior = elemento_imagem.previousSibling
		proxima = elemento_imagem.nextSibling

		anterior_link.onclick = function() { null }
		proxima_link.onclick = function() { null }
		
		if (anterior) {
			if (anterior.tagName == 'IMG') {
				anterior_link.onclick = function() { posicao(anterior.src, null, anterior) }
			}
		} 
		if (proxima) {
			if (proxima.tagName == 'IMG') {
				proxima_link.onclick = function() { posicao(proxima.src, null, proxima) }
			}
		} 
	}
}
function fechar() {
	document.getElementById('div_fechar').style.display = "none"
	document.getElementById('div_vai_volta').style.display = "none"
	document.getElementById('img_foto_carregando').style.display = "none"
	document.getElementById('img_foto').style.display = "none"
	document.getElementById('div_foto').style.display = "none"
	window.onscroll = function() { void(0) }
}


