function layer_aguarde () {
	if (document.getElementById) {
		var win_largura = (document.body.offsetWidth - 350) / 2;
   		var theElement = document.getElementById("loaderContainer").style;
	//	theElement.left = win_largura + 'px';
		theElement.display = "";
	//	showPOPUP("loaderContainer", {'size':'550px:150px','pos':'370px:200px','fundo':'1'});
	}
}
//-------------------------------------------------------------------------------------------------------------------------------------
function abrir(pagina,largura,altura,formx) {

//pega a resolução do visitante
w = screen.width;
h = screen.height;

//divide a resolução por 2, obtendo o centro do monitor
meio_w = w/2;
meio_h = h/2;

//diminui o valor da metade da resolução pelo tamanho da janela, fazendo com q ela fique centralizada
altura2 = altura/2;
largura2 = largura/2;
meio1 = meio_h-altura2;
meio2 = meio_w-largura2;

//abre a nova janela, já com a sua devida posição
window.open('','vpos','toolbar=no,resizable=no,status=no,scrollbars=auto,height=' + altura + ', width=' + largura + ', top='+meio1+', left='+meio2+'');
var ir = eval("document."+formx+".submit()");
}
//-------------------------------------------------------------------------------------------------------------------------------------
function carrega_dados_servidores(usuario) {
		if ($("carrega_dados_servidores") == null) {
			// Cria o elemento box
			var div_servidores = document.createElement("DIV");
			div_servidores.setAttribute("id", "carrega_dados_servidores");
			// Aplica o css
			(navigator.appName.indexOf("Internet Explorer") > 0) ? div_servidores.setAttribute("className", "box_carrega_dados_servidores") : div_servidores.setAttribute("class", "box_carrega_dados_servidores");
			// Inseri o elementp box apos o body
			document.body.appendChild(div_servidores);
			// Cria o box flutuante
			showPOPUP("carrega_dados_servidores", {'size':'350px:auto','pos':'760px:410px'});
			
			Drag.init(document.getElementById("carrega_dados_servidores"));
		}				
		// DEFINICOES AJAX
		var url = 'pre.asp';
		var pars = 'usuario='+usuario;
		var myAjax = new Ajax.Updater( {}, url, { 
												 method: 'post', 
												 parameters: pars, 
												 onFailure: function() {reportError_carrega_dados_servidores();}, 
												 onLoading: function() {IniciaLoading_carrega_dados_servidores();},
												 onComplete: function(request) {LoadingCompleto_carrega_dados_servidores(request);}
												}
									 );
	}
	
	function reportError_carrega_dados_servidores() {
		alert('Erro ao processar as informações, tente mais tarde.');
		if($("carrega_dados_servidores"))
			document.body.removeChild($("carrega_dados_servidores"));
	}
	
	function IniciaLoading_carrega_dados_servidores() {
		$("carrega_dados_servidores").innerHTML = "<center><br><b>Aguarde, carregando...</b>&nbsp;&nbsp;<img src=\"/images/indicator2.gif\" width=\"16\" height=\"16\" vspace=\"2\" /><br><br></center>";		
	}
	
	function LoadingCompleto_carrega_dados_servidores(request) {
		$("carrega_dados_servidores").innerHTML = request.responseText;
		EvalJavascript(request.responseText);
	}
//-------------------------------------------------------------------------------------------------------------------------------------

//Funcão showPOPUP resposável por mostrar um div na tela em posição definida pelo programador.
	// nameDiv: nome da Tag que será visualizada
	// wValue: valor da largura da TAG
	// hValue: valor da altura da Tag
	// text: texto que será impresso na tela
	// position: caso o programador queira difinir a posição exata na tela (x:y), caso ela não seja passada a TAG 
	//           ficará  no centro da tela
	function showPOPUP(nameTag,parms){
		var variavel = eval (parms)
		
		if ("fundo" in variavel) {
				if (variavel.fundo == 1) {
					var __div = document.createElement("div")
					__div.setAttribute("id","__fundoDiv")
					__div.setAttribute("name","__fundoDiv")
					
					document.body.appendChild(__div);
					var __divFundo = document.getElementById("__fundoDiv")
		
					__divFundo.style.filter = "alpha(Opacity=50)"
					__divFundo.style.opacity = ".50"
					__divFundo.style.position = 'absolute'
					__divFundo.style.margin = "0px"
					__divFundo.style.padding = "0px"
					__divFundo.style.width 	= (0+document.body.scrollWidth)+'px'
					__divFundo.style.height = (0+document.body.scrollHeight)+'px'
					__divFundo.style.top = "0px"
					__divFundo.style.left = "0px"
					__divFundo.style.zIndex = 98
					__divFundo.style.display = "block"
					if("corFundo" in variavel){
						__divFundo.style.background = variavel.corFundo
					} else {
						__divFundo.style.background = "#000000"
					}
					var __iframe = document.createElement("iframe")
					__iframe.setAttribute("id","__fundoiframe")
					__iframe.setAttribute("src","javascript:false;")
					__iframe.setAttribute("name","__fundoiframe")
					__iframe.setAttribute("scrolling","no")
					
					document.body.appendChild(__iframe);
					var __iframefundo = document.getElementById("__fundoiframe")
					__iframefundo.style.width 	= __divFundo.offsetWidth
					__iframefundo.style.height = __divFundo.offsetHeight
					__iframefundo.style.top = __divFundo.style.top
					__iframefundo.style.left = __divFundo.style.left
					__iframefundo.style.zIndex = __divFundo.style.zIndex - 1;
					//__iframefundo.style.display = "block"
					__iframefundo.style.position = 'absolute'					
					__iframefundo.style.filter = "alpha(Opacity=10)"
					__iframefundo.style.opacity = ".50"
					
	
				}
		}
		
		var idNameTag = document.getElementById(nameTag)
		idNameTag.style.position = 'absolute'
		idNameTag.style.zIndex = 99
		if ("size" in variavel){
			var arraySize = variavel.size.split(':')
			idNameTag.style.width = arraySize[0]
			idNameTag.style.height = arraySize[1]
		}
		if ("pos" in variavel){
			var arrayPos = variavel.pos.split(':')
			idNameTag.style.left = arrayPos[0]
			idNameTag.style.top = arrayPos[1]
		} else {
			idNameTag.style.top = ((screen.height/2 - idNameTag.style.height/2)-100)+"px"
			idNameTag.style.left = (screen.width/2 - idNameTag.style.width/2)+"px"
		}
		idNameTag.style.display = '';
	}

function verifica(valor){
//    if(valor == "nao"){
	var va = get_radio_value();

        var campo = document.createElement('input');
        campo.setAttribute('id','tipoX');
        campo.setAttribute('name','tipoX');
		campo.setAttribute('value',getValue());
        campo.style.display = 'block';
    document.getElementById('motivoOpcao').appendChild(campo);
        document.getElementById('motivoOpcao').style.display = 'block';
//    }else{
//        document.getElementById('motivoOpcao').style.display = 'yes';
//    }
}

function output() {

			for(counter = 0; counter < document.form1.tipo.length; counter++){ 
			//  for (counter = 0; counter < document.getElementById('tipo').length ; counter++ ) {
				if (document.form1.tipo[counter].checked) { 
			//    if (document.getElementById('tipo')[counter].checked = true){
					//alert(document.form1.tipo[counter].value); 
					//document.form1.tipoX.value = document.form1.tipo[counter].value;
					var variavel = document.getElementsByName('tipo')[counter].value;
					//alert(document.getElementsByName('tipo')[counter].value);
					document.getElementById('tipoX').value = variavel;
					//alert(document.getElementById('tipoX').value);
					//alert(document.form1.tipoX.value);
				}
	
			}
}


function rmvMoreFiles(divNum,nome){
    var d = document.getElementById(nome);
    var olddiv = document.getElementById(divNum);
    d.removeChild(olddiv);
    num--;
}

function MoreFiles(){
		try{
				var campo = document.createElement('input');
				campo.setAttribute('id','tipoX');
				campo.setAttribute('name','tipoX');
				campo.setAttribute('type','hidden');
				campo.setAttribute('value','');
				campo.style.display = 'block';
				document.getElementById('motivoOpcao').appendChild(campo);
				document.getElementById('motivoOpcao').style.display = 'block';
			} catch (e) {
				return false;
		}
}


function lon(target)
{
	try {
		if (parent.visibilityToolbar)
			parent.visibilityToolbar.set_display("standbyDisplayNoControls");
	} catch (e) {}

	try {
		if (!target)
			target = this;
		lsetup(target);

		if (!target._lon_disabled_arr)
			target._lon_disabled_arr = new Array();
		else if (target._lon_disabled_arr.length > 0)
			return true;

		target.document.getElementById("loaderContainer").style.display = "";
		_lon(target);

		var select_arr = target.document.getElementsByTagName("select");

		for (var i = 0; i < select_arr.length; i++) {
			if (select_arr[i].disabled)
				continue;

			select_arr[i].disabled = true;
			_lon_disabled_arr.pop(select_arr[i]);
			var clone = target.document.createElement("input");
			clone.type = "hidden";
			clone.name = select_arr[i].name;
			var values = new Array();
			for (var n = 0; n < select_arr[i].length; n++) {
				if (select_arr[i][n].selected) {
					values[values.length] = select_arr[i][n].value;
				}
			}
			clone.value = values.join(",");
			select_arr[i].parentNode.insertBefore(clone, select_arr[i]);
		}
	} catch (e) {
		return false;
	}
	return true;
}

function loff(target)
{
	try {
		if (parent.visibilityToolbar) {
			parent.visibilityToolbar.set_display(visibilityCount
												 ? "standbyDisplay"
												 : "standbyDisplayNoControls");
		}
	} catch (e) {}

	try {
		if (!target)
			target = this;

		_loff(target);
		target.document.getElementById("loaderContainer").style.display = "none";

		if (target._lon_disabled_arr) {
			while(_lon_disabled_arr.legth > 0) {
				var select = _lon_disabled_arr.push();
				select.disabled = false;

				var clones_arr = target.document.getElementsByName(select.name);
				for (var n = 0; n < clones_arr.length; n++) {
					if ("hidden" == clones_arr[n].type)
						clones_arr[n].parent.removeChild(clones_arr[n]);
				}
			}
		}
	} catch (e) {
		return false;
	}
	return true;
}

/*
function _loff(target) {
	try {
		if (!target)
			target = this;
	
		target.document.getElementById("loaderSubLayer").style.display = "none";
	} catch (e) {
		return false;
	}
	return true;
}
*/
function _lon(target) {
	try {
		if (!target)
			target = this;

		oLoader = target.document.getElementById("loader");
		oBody = target.document.getElementsByTagName("body")[0];
		if (oLoader || oBody) {
			zIndex = oLoader.style.zIndex;
			if ( zIndex == "" ) zIndex = oLoader.currentStyle.zIndex;
			zIndex = parseInt(zIndex);
			/*
			if (!isNaN(zIndex) && zIndex > 1) {
				sHiderID = oLoader.id + "SubLayer";
				oBody.insertAdjacentHTML("afterBegin", '<iframe src="javascript:false;" id="' + sHiderID + '" scroll="no" frameborder="0" style="position:absolute;visibility:hidden;border:0;top:0;left;0;width:0;height:0;background-color:#ccc;z-index:' + (zIndex - 1) + ';"></iframe>');
				oIframe = target.document.getElementById(sHiderID);
				oIframe.style.width = oLoader.offsetWidth + "px";
				oIframe.style.height = oLoader.offsetHeight + "px";
				oIframe.style.left = oLoader.offsetLeft + "px";
				oIframe.style.top = oLoader.offsetTop + "px";
				oIframe.style.visibility = "visible";
			}
			*/
		}
	} catch (e) {
		return false;
	}
	return true;
}



function _loff(target) {
	try {
		if (!target)
			target = this;
	
		target.document.getElementById("loaderContainer").style.display = "none";
	} catch (e) {
		return false;
	}
	return true;
}
