var isie = (navigator.appVersion.indexOf("MSIE") != -1) ? (navigator.appVersion.indexOf("Mac") != -1) ? false : true  : false;

/* Desaparece com as div de Zoom e a Sombra que fica sobre o site. */
function fechaPop(nome) {
	
	var selectBox = document.getElementsByTagName("select");
	var selectTamanho = selectBox.length;
	
	if ((selectTamanho!=null) && (isie)) {
		for(var x=0;x<selectTamanho;x++)
			selectBox[x].style.visibility="visible"
	}
	
	try {
		document.body.removeChild(document.getElementById(nome));
	} catch(e) {
		alert(e);
	}

}

/* Função responsável por criar a Sombra sobre o site e a div Container que vai abrigar o conteudo da página a ser carrega */
function abrePop(url,nome,posicaoX,posicaoY) {
	var selectBox = document.getElementsByTagName("select");
	var selectTamanho = selectBox.length;
	
	if ((selectTamanho!=null) && (isie)) {
		for(var x=0;x<selectTamanho;x++)
			selectBox[x].style.visibility="hidden"
	}
	
	//Verifica se já existe algum div aparente com este mesmo nome, se tiver atualiza o conteudo
	try {
		
		if(document.getElementById(nome)){
			
			
			//document.body.removeChild(document.getElementById(nome));
			
			var divContainer = document.getElementById(nome)
			divContainer.style.top =  String(divContainer.offsetTop + posicaoY).concat('px');
			divContainer.style.left =  String(divContainer.offsetLeft + posicaoX).concat('px');
			
		}else{
			
			//Cria div que vai abrigar o conteudo da página
			var divContainer = document.createElement('div');
			divContainer.style.visibility = 'hidden';
			divContainer.id = nome;
			divContainer.style.top = String(posicaoY).concat('px');
			divContainer.style.left = String(posicaoX).concat('px');
			divContainer.style.position = 'absolute';
			divContainer.style.zindex = '9000';
			
			//Adiciona as divs criadas como filho da tag BODY
			document.body.appendChild(divContainer);
		}
		
	} catch(e) {
		alert(e);
	}
	


	//Cria objeto passando os valores necessários
	var pop = new popObj(url,divContainer);
}
	
function popObj(url,divContainer) {
	var self = this;
	
	//Cria um novo objeto XML passando os valores. Esse obj e funções estao no arq. xml.js
	this.xml = new xmlObj( {
		url: url,
		obj: self, 
		func: 'show', 
		args: { divContainer:divContainer }
	} );
	
}

popObj.prototype.show = function(args) {
	var htm = args.responseText;
	var divContainer = args.divContainer;
/*
	if (document.getElementById && !document.all){
		
		rng = document.createRange();
		el = divContainer;
		rng.setStartBefore(el);
		htmlFrag = rng.createContextualFragment(htm);
		while (el.hasChildNodes())
		el.removeChild(el.lastChild);
		el.appendChild(htmlFrag);
		
	}else{
*/
	divContainer.innerHTML = htm;
	
	
	divContainer.style.visibility = 'visible';
	
}
						
/* --------- */