// JavaScript Document
var segundos	= 10;
var intervalo;
var tipo_div;

function div(txt, tipo){
	var campo 	= document.getElementById('div2').style;
	var x		= (document.body.clientWidth - campo.width) / 2;
	var y		= (document.body.clientHeight - campo.height) / 2;
	campo.left	= eval(x);
	campo.top	= eval(y);
	var fechar	= '<br><a href="javascript:;" onClick="div(\'\', \'\')"><img src="images/estrutura/fechar.gif" align="left" border="0" style="margin:0px 0px 5px 0px"></a>';
	
	var campo2 	= document.getElementById('div1').style;
	/*if(document.body.clientHeight < 855)
		campo2.height = '855';
	else*/
		campo2.height = '100%';
		
	var disp	= campo.display;
	if(disp == "block"){
		clearInterval(intervalo);
		campo.display = 'none';
		campo2.display = 'none';
	}
	else{
		tipo_div	= tipo;
		intervalo = window.setInterval('centraliza();', segundos);
		var elem = document.getElementById("div2");
		if(tipo == "imagem"){
			elem.innerHTML = '<img src="'+txt+'" style="border:#FFF solid 10px; filter:alpha(opacity=0);" id="imagem">'+fechar;
		}
		else
			if(tipo == "mapa"){
				elem.width	= 750;
				elem.height	= 400;
				var mapa	= "";
				switch(txt){
					case "technopark" : 
						mapa = '<iframe style="border:#FFF solid 10px; width:750px; height:400px" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com.br/maps?f=q&amp;source=s_q&amp;hl=pt-BR&amp;geocode=&amp;q=techno+park+campinas&amp;sll=-14.179186,-50.449219&amp;sspn=110.711032,158.203125&amp;ie=UTF8&amp;cid=8358941688430103818&amp;ll=-22.848732,-47.151303&amp;spn=0.015819,0.032187&amp;z=15&amp;iwloc=A&amp;output=embed"></iframe>'+fechar;
					break;
					
					case "tic" : 
						mapa = '<iframe style="border:#FFF solid 10px; width:750px; height:400px" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com.br/maps?f=q&amp;source=s_q&amp;hl=pt-BR&amp;geocode=&amp;q=Terminal+Intermodal+de+Cargas&amp;sll=-22.85324,-47.152977&amp;sspn=0.061376,0.109863&amp;ie=UTF8&amp;ll=-22.842087,-47.154994&amp;spn=0.01582,0.032187&amp;z=15&amp;iwloc=A&amp;output=embed"></iframe>'+fechar;
					break;
					
					case "alphaville" : 
						mapa = '<iframe style="border:#FFF solid 10px; width:750px; height:400px" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com.br/maps?f=q&amp;source=s_q&amp;hl=pt-BR&amp;geocode=&amp;q=-23.499633,-46.852700&amp;sll=-23.499725,-46.852795&amp;sspn=0.007635,0.009656&amp;ie=UTF8&amp;ll=-23.499361,-46.852098&amp;spn=0.007871,0.016093&amp;z=16&amp;output=embed"></iframe>'+fechar;
					break;
				}
				elem.innerHTML = mapa;
			}
			
		w	= '';
		h	= '';
		x	= '';
		y	= '';
		campo.display = 'block';
		campo2.display = 'block';
	}
}

var	w;
var	h;
var x;
var y;

function centraliza(){
	var campo 	= document.getElementById('div2').style;
	if(x < (document.body.clientWidth / 2)){
		//clearInterval(intervalo);
		if(tipo_div == "imagem")
			document.getElementById('imagem').style.filter = "alpha(opacity=100)";
	}
	if(tipo_div == "imagem"){
		w		= document.getElementById('imagem').width;
		h		= document.getElementById('imagem').height;
	}
	else
		if(tipo_div == "mapa"){
			w		= document.getElementById('div2').width;
			h		= document.getElementById('div2').height;
		}
	x		= (document.body.clientWidth - w) / 2;
	y		= (document.body.clientHeight - h) / 2;
	
	if(x < 0){
		x	= 30;
		campo.right = 30;
	}
	
	if(y < 0){
		y	= 30;
		campo.bottom	= 30;
	}
	
	campo.left	= eval(x);
	campo.top	= eval(y);
}