
	function getPageSize(tipo)
	{
		
		var xScroll, yScroll, pageWidth, pageHeight;
		if (window.innerHeight && window.scrollMaxY) 
		{
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else 
			if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
			
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else 
			if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} else 
				if (document.body) { // other Explorers
					windowWidth = document.body.clientWidth;
					windowHeight = document.body.clientHeight;
				}		
						
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else {
			pageHeight = yScroll;
		}	
		
		if(xScroll < windowHeight){
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}	
		
		if(tipo=='w')
			return pageWidth;
		else 
			if(tipo=='h')
				return pageHeight;
		
	}
	
	var abaSelecionado;	
	var divSelecionado;
	var abaMarcadores = new Array();	
	var bottaoAnt;
	
	function abreABA(bottao, local, color)
	{			
		//if(!color) color='ThreeDShadow';		
		campos=abaMarcadores
		
		if(abaSelecionado)
		{
			abaSelecionado.style.backgroundColor='';		
			abaSelecionado.disabled=false
		}
		
		for(i=0;i<campos.length;i++)
			escondeCampo(oId(campos[i]))
			
		mostraCampo(oId(campos[local]))
		
		divSelecionado = local;		
		abaSelecionado=bottao		
		//desabilitaCampo(bottao)		
		if(bottaoAnt)
			bottaoAnt.className='ABA'
		
		bottao.className='ABA_SELECT'
		bottaoAnt=bottao;
	}	

	//=============================================
	//HABILITA E DESABILITA CAMPO
	function habilitaCampo(obj,tipo)
	{
		var tipo       = tipo       || 1;
		if(tipo==1)		
			obj.disabled=''
			
		if(tipo==2)		
		{
			obj.readOnly=false 
			obj.style.backgroundColor=''
			obj.value=''
		}
	}
	
	function desabilitaCampo(obj,tipo)
	{
		var tipo       = tipo       || 1;
		if(tipo==1)
			obj.disabled='disabled'		
			
		if(tipo==2)		
		{
			obj.readOnly=true 
			obj.style.backgroundColor='silver'
			obj.value=''
		}
	}
	
	//=============================================
	
	//=============================================
	//MOSTRA E ESCONDE CAMPOS
	function mostraCampo(obj)
	{
		obj.style.display=''
	}
	
	function escondeCampo(obj)
	{
		obj.style.display='none'
	}
	
	//=============================================
	
	function oId(id)
	{	
		return document.getElementById(id)	
	}
		
	function oName(campo)	
	{
		return document.forms[0][campo]
	}
	//============================================
	
	function postIframe(src, id)
	{
		document.getElementById(id).src = src	
	}
	

	function postFormulario(action, idForm, target, method)
	{
		var target       = target       || "";
		var method       = method       || "POST";
		
		document.getElementById(idForm).action = action		
		document.getElementById(idForm).method = method
		
		if(target)
			document.getElementById(idForm).target=target
			
		document.getElementById(idForm).submit()
		
		
	}


	function Openme(newin) 
	{
		flyout=window.open(newin,"flyout","resizable=no,scrollbars=yes,width=" + window.screen.width + ",height=" + window.screen.height + ",top=0,left=0")
	}
	
	function isNum( caractere ) 
	{
		var strValidos = "0123456789"	 
		if ( strValidos.indexOf( caractere ) == -1 )
		{
			return false;	 
		}
		return true; 
	}

	function soNumero(campo, event) 
	{
		
		// 8  backspace			9  Tab				33 PageUp				34 PageDown	
		// 35 End				36 Home 			37 seta para esquerda	38 seta para cima 
		// 39 seta para direita 40 seta para baixo	46 Delete
	 		
		var key;	 
		var tecla;	 
		
		var teclasPermitidas = new Array(8,9,0); 
	 
		CheckTAB=true;
	 
		if(navigator.appName.indexOf("Netscape")!= -1)	 
			tecla= event.which;	 
		else	 
			tecla= event.keyCode;	 
			key = String.fromCharCode(tecla);	 
			//alert( 'key: ' + tecla + ' -> campo: ' + campo.value);	 
	 
		if ( tecla == 13 )		 
			return false;		 
		
		var i;		
		for(i=0;i<teclasPermitidas.length;i++)
		{				
			if (tecla == teclasPermitidas[i])
			{		 
				return true;
			}
		}
		 
		return ( isNum(key));		 
	}
	
	
	function formataCnpj(obj)
	{
		numero = _extraiNumero(obj.value)
		if (numero.length > 3) {			
			formataCampo(obj, "XX.XXX.XXX/XXXX-XX")
		} else {
			if (obj.value != numero)
			{
				obj.value = numero
			}
		}
	}	
	
	function formataPlaca(obj)
	{	
		
		//obj.value = obj.value.replace("-","");
		
		var objAux =obj.value.replace("-",""); 		
		var aux = "";
		
		
		for(i=0;i<objAux.length;i++)
		{			
			if(i<=2)
			{	
				
				if(is_string(objAux[i]))
				{					
					aux = aux + objAux[i];
				}
			}			
			
			if(i==3)
			{
				aux = aux + "-";
			}			
			
			if(i>=3)
			{	
				if(is_number(objAux[i]))
				{					
					aux = aux + objAux[i];
				}
			}
			
		}	
		
			
		obj.value = aux;
		
		
	}	
	
	function formataRa(obj)
	{
		numero = _extraiNumero(obj.value)
		if (numero.length > 6) {			
			formataCampo(obj, "XXXXXX-X")
		} else {
			if (obj.value != numero)
			{
				obj.value = numero
			}
		}
	}	
	
	function formataCpf(obj)
	{
		
		numero = _extraiNumero(obj.value)
		if (numero.length > 3) {			
			formataCampo(obj, "XXX.XXX.XXX-XX")
		} else {
			if (obj.value != numero)
			{
				obj.value = numero
			}
		}
	}	
	
	function formataCep(obj)
	{	
		numero = _extraiNumero(obj.value)
		if (numero.length > 3) {
			formataCampo(obj, "XXXXX-XXX")
		} else {
			if (obj.value != numero)
			{
				obj.value = numero
			}
		}
	}
	
	function formataData(obj)
	{	
		numero = _extraiNumero(obj.value)
		
		if (numero.length > 1 )	
			formataCampo(obj, "XX/XX/XXXX")
		else {
			if (obj.value != numero)
			{
				obj.value = numero
			}
		}
		
		if (obj.value.length == 10)
			verificaData(obj) 
	}

	function _retiraZeroEsquerda(obj)
	{		
		numero   = _extraiNumero(obj.value)
		
		for (var c=0; c<numero.length; c++)
			if (numero[c] != 0)
				break
				
		obj.value = numero = numero.substr(c, numero.length)
		
		return numero
	}
	
	function formataDecimal(obj)
	{	
		numero = _retiraZeroEsquerda(obj)
		
		if (numero.length == 7 )		
			formataCampo(obj, "XXXXX.XX")
		else if (numero.length == 6 )		
			formataCampo(obj, "XXXX.XX")
		else if (numero.length == 5 )	
			formataCampo(obj, "XXX.XX")
		else if (numero.length == 4 )
			formataCampo(obj, "XX.XX")
		else if (numero.length == 3) 
			formataCampo(obj, "X.XX")
		else {
			if (obj.value != numero)
				obj.value = numero
		}
		
		if (obj.value.length == 1)
			obj.value = '0.0' + obj.value
		else if (obj.value.length == 2)
			obj.value = '0.' + obj.value
	}	
	
	function formataValor(obj)
	{
		numero = _extraiNumero(obj.value)		
		if (numero.length >= 9 )						
			formataCampo(obj, "X.XXX.XXX,XX")					
		else if (numero.length == 8 )		
			formataCampo(obj, "XXX.XXX,XX")			
		else if (numero.length == 7 )		
			formataCampo(obj, "XX.XXX,XX")
		else if (numero.length == 6 )		
			formataCampo(obj, "X.XXX,XX")
		else if (numero.length == 5 )	
			formataCampo(obj, "XXX,XX")
		else if (numero.length == 4 )
			formataCampo(obj, "XX,XX")
		else if (numero.length == 3 )
			formataCampo(obj, "X,XX")			
		else{
			if (obj.value != numero)
			{
				obj.value = numero
			}
		}
	}
	
	function formataKilometro(obj)
	{
		numero = _extraiNumero(obj.value)		
		if (numero.length >= 9 )						
			formataCampo(obj, "XXX.XXX.XXX,X")					
		else if (numero.length == 8 )		
			formataCampo(obj, "X.XXX.XXX,X")			
		else if (numero.length == 7 )		
			formataCampo(obj, "XXX.XXX,X")
		else if (numero.length == 6 )		
			formataCampo(obj, "XX.XXX,X")
		else if (numero.length == 5 )	
			formataCampo(obj, "X.XXX,X")
		else if (numero.length == 4 )
			formataCampo(obj, "XXX,X")
		else if (numero.length == 3 )
			formataCampo(obj, "XX,X")			
		else{
			if (obj.value != numero)
			{
				obj.value = numero
			}
		}
	}
	
	function formataValorCombustivel(obj)
	{
		numero = _extraiNumero(obj.value)		
		if (numero.length >= 9 )						
			formataCampo(obj, "XXX.XXX,XXX")					
		else if (numero.length == 8 )		
			formataCampo(obj, "XX.XXX,XXX")			
		else if (numero.length == 7 )		
			formataCampo(obj, "X.XXX,XXX")
		else if (numero.length == 6 )		
			formataCampo(obj, "XXX,XXX")
		else if (numero.length == 5 )	
			formataCampo(obj, "XX,XXX")
		else if (numero.length == 4 )
			formataCampo(obj, "X,XXX")
		else if (numero.length == 3 )
			formataCampo(obj, "X,XX")			
		else{
			if (obj.value != numero)
			{
				obj.value = numero
			}
		}
	}
	
	function formataTelefone(obj)
	{
		numero = _extraiNumero(obj.value)
		if (numero.length >= 10) {
			formataCampo(obj, "(XX)XXXX-XXXX")
		} else if (numero.length == 9) {
			formataCampo(obj, "(XX)XXX-XXXX")
		} else if (numero.length == 8) {
			formataCampo(obj, "XXXX-XXXX")
		} else if (numero.length > 4) {
			formataCampo(obj, "XXX-XXXX")
		} else {
			if (obj.value != numero)
			{
				obj.value = numero
			}
		}
	}
	
	function formataCampo(obj, mascara)
	{
		var valor = ''
		var tamValor = 0
		var tamMascara = 0
		var resultado = ''
		var aux1 = ''
		var aux2 = ''
		var posMas = 1
		var posVal = 1
		var tecla = obj.value.substr( obj.value.length - 1, 1)
		var masclen = mascara.length
	
		if(obj.value.length > mascara.length)
		{
			valor = _extraiNumero(obj.value.substring(0, obj.value.length-(obj.value.length-mascara.length)))
		} else {
			valor = _extraiNumero(obj.value)
		}
	
		//muda formatação somente quando receber uma tecla válida 
		if( !_teclaValida(tecla) && (obj.value != ''))
		{
			tamValor = valor.length
			tamMascara = mascara.length
			while((posVal <= tamValor) && (posMas <= tamMascara))
			{
				// percorre caracter por caracter no valor dado (do fim p/ começo)
				aux1 = valor.substring(tamValor - posVal, (tamValor - posVal) + 1)
				// percorre caracter por caracter na máscara (do fim p/ começo)
				aux2 = mascara.substring(tamMascara - posMas, (tamMascara - posMas) + 1)
				if(aux2 == 'X')
				{
					resultado = aux1 + resultado
					posVal = posVal + 1
				}else if((aux2 == '-') || (aux2 == '/') || (aux2 == '.' ) || (aux2 == '(') || (aux2 == ')') || (aux2 == ',')) // símbolos presentes nas máscaras
				{
					resultado = aux2 + resultado
				}
				posMas = posMas + 1
			}
			//  colocando "posMas" e "posVal" em suas posições atuais
			posVal = posVal - 1
			posMas = posMas - 1
			// caso especial para número de telefone (máscara começa com símbolo)
			if((posMas == tamMascara - 1) && (mascara.substring(0, 1) == '('))
			{
				resultado = '(' + resultado
			}
			
			if (obj.value != resultado)
			{
				if ( (resultado.length>=obj.maxLength) && (masclen>=resultado.length) )
				{
					if (masclen == resultado.length)
					{
						obj.maxLength = masclen
					} else{
						obj.maxLength = resultado.length+1
					}
				}
				obj.value = resultado
			}
			
		}
	}
	
	
	function verificaData(param) 
	{
		dia = (param.value.substring(0,2));
		mes = (param.value.substring(3,5));
		ano = (param.value.substring(6,10));

		situacao = "";

		// verifica o dia valido para cada mes
		if ((dia < "01")||(dia < "01" || dia > "30") && ( mes == "04" || mes == "06" || mes=="09" || mes =="11" ) || dia > "31") {
			situacao = "falsa";
		}

		// verifica se o mes e valido
		if (mes < 01 || mes > 12 ) {
			situacao = "falsa";
		}

		// verifica se e ano bissexto
		if (mes == 2 && ( dia < 01 || dia > 29 || ( dia > 28 && (parseInt(ano / 4) != ano / 4)))) {
			situacao = "falsa";
		}

		// verifica se e ano esta correto
		if (situacao == "" && ano.length != 4) {
			alert("O ano deve possuir quatro dígitos!");
			param.value = dia + "/" + mes + "/";
			param.focus();
			return
		}

		if (situacao == "falsa") {
			if (param.value != "") 
			{
				alert("Data inválida!");
				param.value="";
				param.focus();
			}
		}
	}
		
	function _somenteNumero(numero)
	{
		// numeros aceitos 0,1,2,3,4,5,6,7,8,9,37,38,39,40,46
		ER=/(^[0-2]$|^3[789]{0,1}$|^4[06]{0,1}$|^[5-9]$)/
		return ER.test(numero)
	}
	
	//  teclas que podem ser pressionadas
	function _teclaValida(tecla)
	{
		// 8  backspace			9  Tab				33 PageUp				34 PageDown	
		// 35 End				36 Home 			37 seta para esquerda	38 seta para cima 
		// 39 seta para direita 40 seta para baixo	46 Delete
		ER=/(^[8-9]$|^3[3-9]{1}$|^4[06]{1}$)/
		return ER.test(numero)
	}
	
	// retorna somente números [0..9]
	function _extraiNumero(dado)
	{
		var aux = ''
		for(n=0; n < dado.length; n++){
			if(_somenteNumero(dado.substr(n,1))){
				aux += dado.substr(n,1)
			}
		}
		return aux
	}



	// url_encode version 1.0  
	function urlEncode(str) {  
	    var hex_chars = "0123456789ABCDEF";  
	    var noEncode = /^([a-zA-Z0-9\_\-\.])$/;  
	    var n, strCode, hex1, hex2, strEncode = "";  
	
	    for(n = 0; n < str.length; n++) {  
	        if (noEncode.test(str.charAt(n))) {  
	            strEncode += str.charAt(n);  
	        } else {  
	            strCode = str.charCodeAt(n);  
	            hex1 = hex_chars.charAt(Math.floor(strCode / 16));  
	            hex2 = hex_chars.charAt(strCode % 16);  
	            strEncode += "%" + (hex1 + hex2);  
	        }  
	    }  
	    return strEncode;  
	}  
	
	// url_decode version 1.0  
	function urlDecode(str) {  
	    var n, strCode, strDecode = "";  
	
	    for (n = 0; n < str.length; n++) {  
	        if (str.charAt(n) == "%") {  
	            strCode = str.charAt(n + 1) + str.charAt(n + 2);  
	            strDecode += String.fromCharCode(parseInt(strCode, 16));  
	            n += 2;  
	        } else {  
	            strDecode += str.charAt(n);  
	        }  
	    }  
	
	    return strDecode;  
	}  
	
	var camposForm = new Array();
	
	function pegaValoresForm(i)  { 
		var i          = i || 0;
		var parametros = "";
		var formulario = document.forms[i];
		
		camposForm[i] = new Array();
		
		for (var j=0; j < formulario.elements.length; j++) 
		{ 
			var campo = formulario.elements[j];		

			camposForm[i][campo.name] = campo.disabled;
	
			campo.disabled = true;
			
			var nome  = campo.name; 
			var tipo  = campo.type; 
			var valor = ""; 
			
			if (!nome || (nome.length == 0)) 
				continue; 		

			switch (tipo)
			{
				case "textarea":
				case "hidden":
				case "text":
				case "password":
				case "select-one":
						valor = campo.value.limpaString(); 			
					break;	
				case "checkbox":
				case "radio":
						if (campo.checked)
							valor = campo.value.limpaString(); 			
					break;	
			}
	
			if (valor.length == 0) 
				continue; 
			
			if (parametros.length > 0) 
				parametros += "&"; 
				
			parametros += nome + "=" + escape(valor); 
		} 
		
		return parametros; 
	} 
	
	function existeTipoCampo(i, tipo)  { 
		var i          = i || 0;
		var formulario = document.forms[i];
		var fields     = new Array();

		if (formulario)	
			for (var j=0; j < formulario.elements.length; j++) 
				if (formulario.elements[j].type == tipo)
					fields[fields.length] = formulario.elements[j];
			
		if (fields.length)
			return fields;
		
		return false;
	}
	
	function habilitaCampoForm(i, focus)  { 
		var formulario = document.forms[i];
		var focus      = focus || false;
		var naoAchou   = true;
		
		for (var j=0; j < formulario.elements.length; j++) 
		{ 
			var campo = formulario.elements[j];				
			var tipo  = campo.type; 
			
			if (camposForm[i])
				if (camposForm[i][campo.name] == false)
					campo.disabled = false;
			
			if (focus && naoAchou)
				switch (tipo)
				{
					case "textarea":
					case "text":
					case "password":
					case "select":
							if (!campo.readOnly && campo.value == "") {
								try{campo.focus()} catch (e) {};
								naoAchou = false;
							}
						break;	
				}
				
		} 	
	} 
	
	// remove brancos redundantes 
	String.prototype.limpaString = function () { 
		var src = this.toString().replace(/^\s+/,"").replace(/\s+$/,""); 
		var re  = /(\S+)(\x20{2,})(\S+)/; 
		
		while (src.match(re)) 
			src=src.replace(re,"$1 $3"); 
			
		re = /(\S+)(\s+)(\r)(\s+)(\S+)/; 
		
		while (src.match(re)) 
			src=src.replace(re,"$1$3$5"); 
			
		return src; 
	} 
	
	
	function validaEmail(obj, alerta)
	{
		var str = obj.value;
	
		// @ deve estar pelo menos na posição 1 de str,
		// deve estar pelo menos na posição 3 de str e não pde pode estar na última posição de str.
		if(str.length>0 && (str.indexOf('@') < 1 || str.indexOf('.') < 3 || (str.length < 5) || (str.substr(str.length-1, 1) == '.')))
		{
			// exibe mensagem ao usuário.
			if(alerta)
			{
				alert('E-mail inválido: ' + str);
				obj.value=''			
			}
			if(obj != null)
			{
				obj.focus();
			}
			return false;
		} else {
			return true;
		}
	}
	
	function is_number(a_string) 
	{
		tc = a_string.charAt(0);
		if (tc == "0" || tc == "1" || tc == "2" || tc == "3" ||	tc == "4" || tc == "5" || tc == "6" || tc == "7" || tc == "8" || tc == "9") {
			return true;
		} 
		else {
			return false;
	   }
	}
	
	function is_string(a_string) 
	{
		tc = a_string.charAt(0);
		if (
			tc == "a" || tc == "A" ||
			tc == "b" || tc == "B" ||			
			tc == "c" || tc == "C" ||			
			tc == "d" || tc == "D" ||			
			tc == "e" || tc == "E" ||			
			tc == "f" || tc == "F" ||			
			tc == "g" || tc == "G" ||			
			tc == "h" || tc == "H" ||			
			tc == "i" || tc == "I" ||			
			tc == "j" || tc == "J" ||			
			tc == "k" || tc == "K" ||			
			tc == "l" || tc == "L" ||			
			tc == "m" || tc == "M" ||			
			tc == "n" || tc == "N" ||			
			tc == "o" || tc == "O" ||			
			tc == "p" || tc == "P" ||			
			tc == "q" || tc == "Q" ||			
			tc == "r" || tc == "R" ||			
			tc == "s" || tc == "S" ||			
			tc == "t" || tc == "T" ||			
			tc == "u" || tc == "U" ||			
			tc == "v" || tc == "V" ||			
			tc == "w" || tc == "W" ||			
			tc == "y" || tc == "Y" ||			
			tc == "x" || tc == "X" ||			
			tc == "z" || tc == "Z" ||			
			tc == "ç" || tc == "Ç"
		){
			return true;
		} 
		else {
			return false;
	   }
	}
	
	
	// Valida CPF
	function validaCPF(obj, str, alerta)
	{
		var numero;
		var digito = new Array(10); // array para os dígitos do CPF.
		var aux    = 0;             // índice para a string num.
		var posicao
		var i
		var soma
		var dv
		var dvInformado;
	
		if(obj != null)
		{
			str = obj.value;
		}
	
		numero = _extraiNumero(str);
	
		// Retira os dígitos formatadores de CPF '.' e '-', caso existam.
		if (str.length > 0)
		{
			while ((str.indexOf('.') != -1) || (str.indexOf('-') != -1))
			{
			  if (str.indexOf('.') != -1)
				 {
				  aux = str.indexOf('.');
					str = str.substr(0, aux) + str.substr(aux+1, str.length-1);
				}
				 if (str.indexOf('-') != -1)
				  {
					 aux = str.indexOf('-');
					 str = str.substr(0, aux) + str.substr(aux+1, str.length-1);
			  }
			 } //while
		} //if
	
		//verifica CPFs manjados
		switch (str) {
			case '0':
			case '00':
			case '000':
			case '0000':
			case '00000':
			case '000000':
			case '0000000':
			case '00000000':
			case '000000000':
			case '0000000000':
			case '00000000000':
			case '11111111111':
			case '22222222222':
			case '33333333333':
			case '44444444444':
			case '55555555555':
			case '66666666666':
			case '77777777777':
			case '88888888888':
			case '99999999999':
				obj.value = '';
				alert('CPF inválido: ' + numero);
				return false;
		}
	
		// Início da validação do CPF.
		/* Retira do número informado os dois últimos dígitos */
		dvInformado = str.substr(9,2); 
		/* Desmembra o número do CPF no array digito */
		for (i=0; i<=8; i++)
		{
			digito[i] = str.substr(i,1);
		}
		/* Calcula o valor do 10o. digito de verificação */
		posicao = 10;
		soma = 0;
		for (i=0; i<=8; i++)
		{
			soma = soma + digito[i] * posicao;
			posicao--;
		}
		digito[9] = soma % 11;
		if (digito[9] < 2)
		{
			digito[9] = 0; 
		}
		else
		{
			digito[9] = 11 - digito[9];
		}
		/* Calcula o valor do 11o. digito de verificação */
		posicao = 11;
		soma = 0;
		for (i=0; i<=9; i++)
		{
			soma = soma + digito[i] * posicao;
			posicao--;
		}
		digito[10] = soma % 11;
		if (digito[10] < 2)
		{
			digito[10] = 0; 
		}
		else
		{
			digito[10] = 11 - digito[10];
		}
		dv = digito[9] * 10 + digito[10];
		/* Verifica se o DV calculado é igual ao informado */
		if(dv != dvInformado) 
		{
			// exibe mensagem ao usuário.
			if(alerta)
			{
				obj.value = '';
				alert('CPF inválido: ' + numero);
			}
			if(obj != null)
			{
				obj.focus();
			}
			return false;
		}
		else
		{
			return true;
		}
	}	
	
	
	
	
	
	
	
	
	
	
	
	/**
	 * UPLOAD 
	 * ---------------------------------------------------- **/
	
		var up = new Array();
			up["Q"] = 0;     		//upload qtd    -> true:já foi feito ao menos 1 upload / false:...
			up["F"] = false; 		//upload file   -> true:upload em processo / false:...
			up["S"] = "";   	 	//upload string -> string que guarda um comando que o upload interceptou
			up["E"] = new Array();	//upload extencion -> extensões validas
		
		function uploadFile(i, f) 
		{
			var form = document.forms[i];
	
				form.action="uploadFile.php?form=" + i 
				form.enctype="multipart/form-data" 
				form.method="POST" 
				form.target="upIframe"
			
				form.submit();
				
			up["F"] = true;
		}
		
		function uploadExecuteS()
		{
			up["Q"] = up["Q"] + 1;
			up["F"] = false;
			
			if (up["S"])
			{				
				eval(up["S"]);
				return;
			}							
		}	
		
		function uploadInit()
		{			
			up["Q"] = 0;
			up["F"] = false;
			up["S"] = "";
		}
		
		function uploadAddExtension(e)
		{	
			if (e[0].length == 3)
				for(var c=0; c<e.length; c++)
					up["E"][up["E"].length] = e[c];
			else
				up["E"][up["E"].length] = e;
		}
		
		
	try{
        xmlhttp = new XMLHttpRequest();
    }catch(e){
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(ee){
            try{
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }catch(eee){
                xmlhttp = false;
            }
        }
    }
    

    function carrega(url, id){
        //Exibe o texto carregando no div conteúdo
        var conteudo=document.getElementById(id)
        
        conteudo.innerHTML='carregando...'
        
        //Abre a url
        xmlhttp.open("GET", url, true);

        //Executada quando o navegador obtiver o código
        xmlhttp.onreadystatechange=function() {
            
            if (xmlhttp.readyState==4){
            
                //Lê o texto
                var texto=xmlhttp.responseText
                
                //Exibe o texto no div conteúdo
                var conteudo=document.getElementById(id)
                
                conteudo.innerHTML=texto
            }
        }
        
        xmlhttp.send(null)
    }    
    
    function preparaUrlForm(formulario, id)
    {
        var url = formulario.action + "?";
        
        for (var i=0; i<formulario.elements.length; i++)
        {
            var campo = formulario.elements[i];
            var nome = campo.name;
            var tipo = campo.type;
            var valor = "";
            
            switch (tipo) {
                case "textarea":
                case "hidden":
                case "text":
                case "password":
                case "select-one":
                    valor = campo.value;
                    break;
                case "checkbox":
                case "radio":
                    if (campo.checked)
                        valor = campo.value;
                break;
            }
            
            url += nome + "=" + valor + "&";
        }
        carrega(url, id)    
    }  
    
	
