function criaTitlePopup(value){
	document.getElementById('titlePopup').innerHTML = value;
	document.getElementById('divJanelinhaSubTop').style.borderBottom = '1px solid #E1E1E1';
}

function fechaPopup(){
	document.getElementById('titlePopup').innerHTML = '';
	document.getElementById('divJanelinhaSubTop').innerHTML = '';
	document.getElementById('divConteudoPopup').innerHTML = '';
	document.getElementById('divPopup').style.display = 'none';
}

//Centralizo a POPUP
function getWidth(){
	return window.innerWidth ? window.innerWidth : 
	    document.documentElement ? document.documentElement.clientWidth : 
	    document.body ? document.body.clientWidth : 
	    window.screen.width;
}
function getHeight(){
	return window.innerHeight ? window.innerHeight : /* Para non-IE */
	     document.documentElement ? document.documentElement.clientHeight : /* IE 6+ */
	     document.body ? document.body.clientHeight : /* IE 4 Compativel */
	     window.screen.height; /* Outros (Nao eh browser window size, mas screen size) */
}
function getScrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function getScrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
function getHeight2(){
      return document.getElementById('divSite').offsetHeight;
}

function centralizaPopup(){
	var posScroll = getScrollTop();
	var height = getHeight();
 	var height2 = getHeight2();
 	if(height > height2) height2 = height;
	var width = getWidth();
	var margemTop = posScroll + 28;
	if(margemTop < 0) margemTop = 0;
	var margemLeft = Math.ceil((width - 810)/2);
	if(margemTop > 0)document.getElementById('divJanela').style.marginTop = margemTop+"px";
	if(margemLeft > 0)document.getElementById('divJanela').style.marginLeft = margemLeft+"px";
	if(height2 >= height)document.getElementById('bckTransp').style.height = height2+"px";
	else document.getElementById('bckTransp').style.height = Math.ceil(height)+"px";
	document.getElementById('divPopup').style.display = 'block';
}


//Devo editar o que aparece na JanelinhaSubTop, pois depende de cada projeto seu conteudo
function janela(title, pag){
	criaTitlePopup(title);
	centralizaPopup();
	//var cont = '';
	//document.getElementById('divJanelinhaSubTop').style.display = 'block';
	//document.getElementById('divJanelinhaSubTop').innerHTML = cont;
	
	ajax(pag, 'divConteudoPopup', 'divCarregando2');
}
