// JavaScript Document -
// Funcoes PopUp
// Requer dojo.js

	xhrPopUpIsLoaded = false;
	try
	{
	  if ( typeof(dojo) == "undefined" ) xhrPopUpIsLoaded = false;
	 	else xhrPopUpIsLoaded = true;
	 	
	} catch (e)
	{
		xhrPopUpIsLoaded = false;
	}
	
	closePopUp = function(){
    try {
  	  var popUp = dojo.byId("modalPanel");
  	  
  	  if (popUp != null && typeof(popUp) != "undefined"){
  		  dojo.style(popUp, "display", "none");
  	  }

  	  popUp = dojo.byId("divPopUp");
  	  if (popUp != null && typeof(popUp) != "undefined"){
  		  dojo.style(popUp, "display", "none");
  	  }
	  }
	  catch (e)
    {
      
    }
	}

	centralizar = function(elm){
	  var el_w = dojo.style(elm, "width");
	  var el_h = dojo.style(elm, "height");
	  
	  //Configurando o elemento centralizado
	  dojo.style(elm,
	  {
	    "position": "absolute",
	    "margin-left": "50%",
	    "margin-top": "50%",
	    "left": document.body.clientWidth/2 - el_w/2,
	    "top": document.body.clientHeight/2 - el_h/2 + document.body.scrollTop
	  });
	}

	makeModal = function(elm){
	  var panel = dojo.byId("modalPanel");

	  if (panel == null){
		  panel = document.createElement("div");
		  panel.setAttribute("id", "modalPanel");
			dojo.body().appendChild(panel);
			//panel.appendChild(elm);
			panel = dojo.byId("modalPanel");

			//Configurando o Panel
			dojo.style(panel,
			{
			  "position": "absolute",
			  "opacity": 0.5,
			  "width": document.body.clientWidth,
			  "height": document.body.clientHeight,
			  "margin": 0,
			  "left": "0px",
			  "top": document.body.scrollTop + "px",
			  "background": "#000000",
			  "zIndex": 0
			});
			
			dojo.connect(dojo.body(), "onscroll", function(){
				dojo.style(panel, "top", document.body.scrollTop)
			});
		}
	}

	showPopUp = function(path, width, height, modal){
 		var el = null;

		el = document.createElement("div");
		el.setAttribute("id", "divPopUp");
		el.setAttribute("align", "center");
		dojo.body().appendChild(el);
		el = dojo.byId("divPopUp");

		dojo.style(el,
		{
		  "width": width,
		  "height": height,
		  "zIndex": 1,
		  "opacity": 1
		});
		
		if (modal){
		  makeModal(el);
		  centralizar(el);
		}
		
		makeTextRequest(path,
			function(data){
			  el.innerHTML = data;
			},
			function(error){
				el.innerHEML = error;
			});
	}

	showPopUpInPosition = function(path, posX, posY){
		var el = null;

		el = document.createElement("div");
		el.setAttribute("id", "divPopUp");
		el.setAttribute("align", "center");
		dojo.body().appendChild(el);
		el = dojo.byId("divPopUp");

		dojo.style(el,
		{
		  "position": "absolute",
		  "left": posX,
		  "top": posY
		});

		//makeModal(el);
		//centralizar(el);
		makeTextRequest(path, function(data){
		  el.innerHTML += data;
		});
	}
