
		var Ajax = false;
		function AjaxRequest() {
		Ajax = false;
		if (window.XMLHttpRequest) {
		Ajax = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
		try {
		Ajax = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		try {
		Ajax = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
		}
		}	}
		function Aleatorio(){ aleat = Math.random() * 5000; aleat = Math.round(aleat); return aleat;}
		function BuscaElementosForm(idForm) {
		var elementosFormulario = document.getElementById(idForm).elements;
		var qtdElementos = elementosFormulario.length;
		var queryString = "";
		var elemento;
		this.ConcatenaElemento = function(nome,valor) {
		if (queryString.length>0) {
		queryString += "&";
		}
		queryString += encodeURIComponent(nome) + "=" + encodeURIComponent(valor);
		};
		for (var i=0; i<qtdElementos; i++) {
		elemento = elementosFormulario[i];
		if (!elemento.disabled) {
		switch(elemento.type) {
		case "text": case "password": case "hidden": case "textarea":
		this.ConcatenaElemento(elemento.name,elemento.value);
		break;
		case "select-one":
		if (elemento.selectedIndex>=0) {
		this.ConcatenaElemento(elemento.name,elemento.options[elemento.selectedIndex].value);
		}
		break;
		case "select-multiple":
		for (var j=0; j<elemento.options.length; j++) {
		if (elemento.options[j].selected) {
		this.ConcatenaElemento(elemento.name,elemento.options[j].value);
		}
		}
		break;
		case "checkbox": case "radio":
		if (elemento.checked) {
		this.ConcatenaElemento(elemento.name,elemento.value);
		}
		break;
		}
		}
		}
		return queryString;
		}function retorna(idForm,target,valida,target_valida) {
		var url = document.getElementById(idForm).action;
		var lista = BuscaElementosForm(idForm);
		if(valida!=""){
		var str = valida.split(",");
		for(var i = 0; i < str.length; i++) {
		if(document.getElementById(str[i]).value <= 0){
		if(target_valida!=""){
		document.getElementById(target_valida).innerHTML = "Campo "+str[i].toUpperCase()+" Obrigatorio";
		}else{
		alert("Campo "+str[i].toUpperCase()+" Obrigatorio");	}
		return;	}
		}
		}
		AjaxRequest();
		if(!Ajax) {
		document.getElementById(target).innerHTML ="[Erro]";
		}
		Ajax.onreadystatechange = function () {
		if (Ajax.readyState != 4) {
		document.getElementById(target).innerHTML =	"Carregando...!";	}
		if (Ajax.readyState == 4) {
		if (Ajax.status == 200) {
		document.getElementById(target).innerHTML = Ajax.responseText;
		} else {
		document.getElementById(target).innerHTML =	Ajax.responseText;
		}
		}
		}
		Ajax.open("POST",url,true);	Ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		Ajax.setRequestHeader("Content-length", lista.length);
		Ajax.setRequestHeader("Connection", "close");
		Ajax.send(lista);
		}function GeraCombo(valor,pagina,campo,id) {
		AjaxRequest();
		if(Ajax) {
		document.getElementById(campo).options.length = 1;
		idOpcao  = document.getElementById(id);
		Ajax.open("POST",pagina,true);
		Ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		Ajax.onreadystatechange = function() {
		if(Ajax.readyState == 1) {
		idOpcao.innerHTML = "Carregando...!";
		}
		if(Ajax.readyState == 4 ) {
		if(Ajax.responseXML) {
		idOpcao.innerHTML = "Selecione!";
		processXML(Ajax.responseXML,campo,id);
		}
		else {
		document.getElementById("valida").innerHTML = Ajax.responseText;
		alert( Ajax.responseXML);
		}
		}
		}
		var params = "intId="+valor;
		Ajax.send(params);
		}
		}
		function processXML(obj,campo,id){
		var dataArray   = obj.getElementsByTagName("dados");
		if(dataArray.length > 0) {
		for(var i = 0 ; i < dataArray.length ; i++) {
		var item = dataArray[i];
		var codigo    =  item.getElementsByTagName("codigo")[0].firstChild.nodeValue;
		var descricao =  item.getElementsByTagName("descricao")[0].firstChild.nodeValue;
		var novo = document.createElement("option");
		novo.setAttribute("id", id);
		novo.value = codigo;
		novo.text  = descricao;
		document.getElementById(campo).options.add(novo);
		}
		}
		else {
		idOpcao.innerHTML = "--Primeiro selecione o campo acima--";
		}	
		}function extraiScript(texto){
		var ini = 0;
		while (ini!=-1){
		ini = texto.indexOf("<script", ini);
		if (ini >=0){
		ini = texto.indexOf(">", ini) + 1;
		var fim = texto.indexOf("</script>", ini);
		codigo = texto.substring(ini,fim);
		eval(codigo);
		}
		}
		}function retorna_excluir(url,target,elem) {
		if(confirm("Deseja excluir: "+elem+"")){
		AjaxRequest();
		if(!Ajax) {
		document.getElementById(target).innerHTML ="[Erro]";
		return;
		}
		Ajax.onreadystatechange = function () {
		if (Ajax.readyState == 4) {
		if (Ajax.status == 200) {
		texto=unescape(Ajax.responseText.replace(/\+/g," "));
		document.getElementById(target).innerHTML=texto;
		extraiScript(texto);
		} else {
		document.getElementById(target).innerHTML =	Ajax.responseText;
		}
		}
		}
		;
		if(url.indexOf("?")== -1)
		var operador = "?";
		else
		var operador = "&";
		Ajax.open("GET",url+operador+"rand="+Aleatorio(),true);
		Ajax.send(null);
		}else{
		return;
		}
		}function retorna_menu_topo(url,target,exibe) {
		AjaxRequest();
		if(!Ajax) {
		document.getElementById(target).innerHTML ="[Erro]";
		return;
		}
		document.getElementById(exibe).innerHTML= "<dl><dt class=\"mostrar\"><a href=\"#\" onClick=\"retorna_menu('listar_"+url+".php','home')\">"+url+"</a></dt><dd class=\"mostrar\"><ul><li><a href=\"#\" onClick=\"retorna_menu('form_"+url+".php?opcao=inserir','home')\">Cadastrar</a></li><li class=\"ultimo\"><a href=\"#\" onClick=\"retorna_menu('listar_"+url+".php','home')\">Consultar</a></li></ul></dd></dl>";
		
		var exibe_url = "listar_"+url+".php";
		Ajax.onreadystatechange = function () {
		if (Ajax.readyState != 4) {
		document.getElementById(target).innerHTML =	"Carregando...!";	}
		if (Ajax.readyState == 4) {
		if (Ajax.status == 200) {
		document.getElementById(target).innerHTML=Ajax.responseText;
		extraiScript(Ajax.responseText);
		} else {
		document.getElementById(target).innerHTML =	Ajax.responseText;
		}
		}
		}
		;
		if(url.indexOf("?")== -1)
		var operador = "?";
		else
		var operador = "&";
		Ajax.open("GET",exibe_url+operador+"rand="+Aleatorio(),true);
		Ajax.send(null);
		}
		function retorna_menu(url,target) {
		AjaxRequest();
		if(!Ajax) {
		document.getElementById(target).innerHTML ="[Erro]";
		return;
		}
		Ajax.onreadystatechange = function () {
		if (Ajax.readyState != 4) {
		document.getElementById(target).innerHTML =	"Carregando...!";	}
		if (Ajax.readyState == 4) {
		if (Ajax.status == 200) {
		document.getElementById(target).innerHTML=Ajax.responseText;
		extraiScript(Ajax.responseText);
		} else {
		document.getElementById(target).innerHTML =	Ajax.responseText;
		}
		}
		}
		;
		if(url.indexOf("?")== -1)
		var operador = "?";
		else
		var operador = "&";
		Ajax.open("GET",url+operador+"rand="+Aleatorio(),true);
		Ajax.send(null);
		}function moeda(z){
		v = z.value;
		v=v.replace(/\D/g,"")
		v=v.replace(/[0-9]{12}/,"inválido")
		v=v.replace(/(\d{1})(\d{8})$/,"$1.$2")
		v=v.replace(/(\d{1})(\d{5})$/,"$1.$2")
		v=v.replace(/(\d{1})(\d{1,2})$/,"$1,$2")
		z.value = v;
		}	function txtBoxFormat(objeto, sMask, evtKeyPress) {
		var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
		if(document.all) {
		nTecla = evtKeyPress.keyCode;
		} else if(document.layers) {
		nTecla = evtKeyPress.which;
		} else {
		nTecla = evtKeyPress.which;
		if (nTecla == 8) {
		return true;
		}
		}
		sValue = objeto.value;
		sValue = sValue.toString().replace( "-", "" );
		sValue = sValue.toString().replace( "-", "" );
		sValue = sValue.toString().replace( ".", "" );
		sValue = sValue.toString().replace( ".", "" );
		sValue = sValue.toString().replace( "/", "" );
		sValue = sValue.toString().replace( "/", "" );
		sValue = sValue.toString().replace( ":", "" );
		sValue = sValue.toString().replace( ":", "" );
		sValue = sValue.toString().replace( "(", "" );
		sValue = sValue.toString().replace( "(", "" );
		sValue = sValue.toString().replace( ")", "" );
		sValue = sValue.toString().replace( ")", "" );
		sValue = sValue.toString().replace( " ", "" );
		sValue = sValue.toString().replace( " ", "" );
		fldLen = sValue.length;
		mskLen = sMask.length;
		i = 0;
		nCount = 0;
		sCod = "";
		mskLen = fldLen;
		while (i <= mskLen) {
		bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))
		bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))
		if (bolMask) {
		sCod += sMask.charAt(i);
		mskLen++; }
		else {
		sCod += sValue.charAt(nCount);
		nCount++;
		}
		i++;
		}
		objeto.value = sCod;
		if (nTecla != 8) {
		if (sMask.charAt(i-1) == "9") {
		return ((nTecla > 47) && (nTecla < 58)); }
		else {
		return true;
		}
		}
		else {
		return true;
		}
		}function excluir_item(url,target,obj,op) {
		switch(op) {
		case "arquivo":
		var cont_tipo = "cont_arquivo";
		var nr_tipo = "na";
		var submit_tipo = "submit_arquivo";
		break;
		case "imagem":
		var cont_tipo = "cont";
		var nr_tipo = "nr";
		var submit_tipo = "submit_image";
		break;
		case "destaque":
		var cont_tipo = "cont_destaque";
		var nr_tipo = "nd";
		var submit_tipo = "submit_destaque";
		break;
		case "video":
		var cont_tipo = "cont_video";
		var nr_tipo = "nv";
		var submit_tipo = "submit_video";
		break;
		
		}
		
		AjaxRequest();
		if(!Ajax) {
		document.getElementById(target).innerHTML ="[Erro]";
		return;
		}
		Ajax.onreadystatechange = function () {
		if (Ajax.readyState != 4) {
		document.getElementById(target).innerHTML =	"Carregando...!";	}
		if (Ajax.readyState == 4) {
		if (Ajax.status == 200) {
		document.getElementById(target).innerHTML="";
		document.getElementById(obj).value = "";
		var nr = parseInt(document.getElementById(nr_tipo).innerHTML) - 1;
		document.getElementById(nr_tipo).innerHTML = nr;
		var cont = document.getElementById(cont_tipo).innerHTML;
		if (document.getElementById(nr_tipo).innerHTML < document.getElementById(cont_tipo).innerHTML){
		document.getElementById("image").disabled = false;
		document.getElementById(submit_tipo).disabled = false;
		}
		} else {
		document.getElementById(target).innerHTML =	Ajax.responseText;
		}
		}
		}
		;
		if(url.indexOf("?")== -1)
		var operador = "?";
		else
		var operador = "&";
		Ajax.open("GET",url+operador+"rand="+Aleatorio(),true);
		Ajax.send(null);
		}function conta_imagem(){
		if (document.getElementById("nr").innerHTML == document.getElementById("cont").innerHTML){
		document.getElementById("submit_image").disabled = true;
		}
		}function conta_destaque(){
		if (document.getElementById("nd").innerHTML == document.getElementById("cont_destaque").innerHTML){
		document.getElementById("submit_destaque").disabled = true;
		}
		}
		function conta_arquivo(){
		if (document.getElementById("na").innerHTML == document.getElementById("cont_arquivo").innerHTML){
		document.getElementById("submit_arquivo").disabled = true;
		}
		}function conta_video(){
		if (document.getElementById("nv").innerHTML == document.getElementById("cont_video").innerHTML){
		document.getElementById("submit_video").disabled = true;
		}
		}function upload(form,timeout,loading,callback){
			var $gE, addEvent, removeEvent, periodic, loadAnim, loaded, abortFrame; //small functions
			var error_prog = []; //errors by programer	
			var new_form, loading_msg, loadpos=0; //the new form that will replace old form AND loading msg
			var z, old_action, concat, timeload, timecounter=0, iframe, name;
			var loads = ["&nbsp;&nbsp;&nbsp;",".&nbsp;&nbsp;","..&nbsp;","..."]; //loading animation
			
			/*** small functions */
			$gE = function(quem){ return document.getElementById(quem) }
			addEvent = function(obj, evType, fn){
				if (obj.addEventListener){ obj.addEventListener(evType, fn, true) ; }
				if (obj.attachEvent) { obj.attachEvent("on"+evType, fn);}
			}
			removeEvent = function( obj, type, fn ) {
				if ( obj.detachEvent ) { obj.detachEvent( "on"+type, fn ); }
				if ( obj.removeEventListener ) { obj.removeEventListener( type, fn, false ); }
			} 
			loadAnim = function(){ //get animation of array loads
				if(loading.indexOf("<img")<0){ // 3 dots just if no image
					if(loadpos>loads.length - 1){ loadpos = 0; }
					return loads[loadpos++] + " ";
				}else{ return "";}	
			}
			periodic = function(){
				timecounter++ ;
				if(timecounter/2 > timeout && timeout > 0){ //timeout expired (timeout = 0 is infinite)
					clearInterval(timeload); //fim do contador
					abortFrame(name);
					loaded("timeout");
				}
				loading_msg.innerHTML = loading + " " + loadAnim();
			}
			abortFrame = function(o_frame){ //stop iframe
				var o_frame = typeof(o_frame)=="string" ? $gE(o_frame):o_frame;
				if(!o_frame){ return false; }
				try{ o_frame.contentWindow.stop(); //FF e OP
				}catch(e){ 
					try{ o_frame.contentWindow.document.execCommand("stop");//IE
					} catch(e){ 	o_frame.src = ""; /* tenta parar mermo */ }
				}
			}
			cloneEvents = function(source2,target,recursive){
				for(var p in source2){ //all params
					try{if(source2[p].constructor==Function){
							target[p] = source2[p]
					}}catch(e){}
				}
				if(recursive){
					for(var el=0; el<source2.childNodes.length; el++){
						var elem = source2.childNodes[el]
						var elem_target = target.childNodes[el]
						if(elem.nodeType==1){
							cloneEvents(elem,elem_target);
						}
					}
				}
			}
		
		
			//testing callback
			if(typeof(callback)!="function"){ error_prog.push("The  parameter must be a function") }
			
			//testing if "form" is a html object or a id string
			form = typeof(form)=="string" ? $gE(form):form;
			if(form.nodeName.toUpperCase()!="FORM"){
				error_prog.push("The first parameter must be a form element ID or a form element reference") }
				
			//testing if form have some input file
			var input_file = false;
			var infile = form.getElementsByTagName("input")
			for(z in infile){
				if(infile[z].type=="file"){
					if(infile[z].value==""){ 
						alert("Primeiro selecione o arquivo.")
						return true;
					}else{
						input_file = infile[z];
					}
				}
			}
			if(input_file==false){ error_prog.push("The form must be a input type file") }
			
			//exit if programmer errors
			if(error_prog.length>0) {
				alert("Error in parameters of micoxUpload:\n\n" + error_prog.join("\n"));
				/* uncoment this if you want use try-catch-throw
				throw(error_prog.join("\n"))		*/		
				return true;		
			}
				
			//random id for multiple calls
			rand = (m=Math).round( 20 * m.random() );
			
			//adding callback function to global scope
			//window["micoxCallbackTemp" + rand] = callback
			
			//creating the iframe
			name = "micox-temp" + rand;
			iframe = document.createElement("iframe");
			iframe.setAttribute("id",name);
			iframe.setAttribute("name",name);
			iframe.setAttribute("width","0");
			iframe.setAttribute("height","0");
			iframe.setAttribute("border","0");
			iframe.setAttribute("style","width: 0; height: 0; border: none;");
			//add to document
			form.parentNode.appendChild(iframe);
			window.frames[name].name = name; //ie sucks
				
			//event after load
			loaded = function(){
				//var iframe2 = $gE(name);
				clearInterval(timeload); //fim do contador
				//first, removing the event of iframe
				removeEvent(iframe,"load",loaded)
				//removind loading msg
				loading_msg.parentNode.removeChild(loading_msg);
				//removing old form
				//form.parentNode.removeChild(form);	
				
				//calling callback with the return
				if(arguments[0]!="timeout"){
					callback(iframe.contentWindow.document.body.innerHTML);
				}else{
					callback("Tempo esgotado . " + timeout + " secs.");
				}
				
				//removing old iframe
				abortFrame(iframe);
				iframe.src=""; //to stop "loadind" in FF. bug.
				iframe.parentNode.removeChild(iframe);
				delete iframe;
			}
			//adding the event
			addEvent(iframe,"load",loaded)
			
			//properties of form to a normal upload
			form.setAttribute("target",name);
			form.setAttribute("method","post");
			form.setAttribute("enctype","multipart/form-data");
			form.setAttribute("encoding","multipart/form-data");
			//aditional information if micoxUpload
			old_action = form.action;
			if(form.action.indexOf("?")>1){ concat = "&" } else { concat = "?" }
			form.setAttribute("action",form.action + concat + "micoxUpload=1");
			
			//submit
			form.submit();
			
			//make loading
			loading_msg = document.createElement("div");
			loading_msg.innerHTML = loading;
			form.parentNode.insertBefore(loading_msg,form);
			//making new form and hidden old form
			input_file.value="";
			form.reset();
			new_form = form.cloneNode(true);
			cloneEvents(form,new_form,true);
			new_form.reset();
			new_form.action = old_action;
			form.style.display = "none";
			form.parentNode.insertBefore(new_form,form);
			//if you want new input file before the "loading div", use this above (invert the comment)
			//form.parentNode.insertBefore(new_form,loading_msg);
			
			timeload = setInterval(periodic,500);
			
			//no submit default
			return false;
			
		}function upload_imagem(response){
			var nr = parseInt(document.getElementById("nr").innerHTML);
			var cont = document.getElementById("cont").innerHTML;
			for(var i=1;i<=cont;i++){
				if (document.getElementById("imagem"+i).value == '' ) {
				var quebra=response.split("/");
					document.getElementById("imagem"+i).value = quebra[1];
					document.getElementById("nr").innerHTML =nr+1;
				var bt_excluir = "<a href=javascript:excluir_item('x_excluir_imagem.php?pasta="+quebra[0]+"&imagem="+quebra[1]+"','exibe_imagem"+i+"','imagem"+i+"','imagem')> Excluir</a>";
				document.getElementById("exibe_imagem"+i).innerHTML="<img src='../arquivos/"+response+"' width='100'/>"+bt_excluir;
					if (document.getElementById('nr').innerHTML == document.getElementById('cont').innerHTML){
						document.getElementById('submit_image').disabled = true;
					}
					return;
				}
			}
		}function upload_destaque(response){
			var nr = parseInt(document.getElementById("nd").innerHTML);
			var cont = document.getElementById("cont_destaque").innerHTML;
			for(var i=1;i<=cont;i++){
				if (document.getElementById("foto_destaque"+i).value == '' ) {
				var quebra=response.split("/");
					document.getElementById("foto_destaque"+i).value = quebra[1];
					document.getElementById("nd").innerHTML =nr+1;
				var bt_excluir = "<a href=javascript:excluir_item('x_excluir_imagem.php?pasta="+quebra[0]+"&imagem="+quebra[1]+"','exibe_destaque"+i+"','foto_destaque"+i+"','destaque')> Excluir</a>";
				document.getElementById("exibe_destaque"+i).innerHTML="<img src='../arquivos/"+response+"' width='100'/>"+bt_excluir;
					if (document.getElementById('nd').innerHTML == document.getElementById('cont_destaque').innerHTML){
						document.getElementById('submit_destaque').disabled = true;
					}
					return;
				}
			}
		}function upload_arquivo(response){	
			var nr = parseInt(document.getElementById("na").innerHTML);
			var cont = document.getElementById("cont_arquivo").innerHTML;
			for(var i=1;i<=cont;i++){
				if (document.getElementById("arquivo"+i).value == '' ) {
				var quebra=response.split("/");
					document.getElementById("arquivo"+i).value = quebra[1];
					document.getElementById("na").innerHTML =nr+1;
				var bt_excluir = "<a href=javascript:excluir_item('x_excluir_imagem.php?pasta="+quebra[0]+"&imagem="+quebra[1]+"','exibe_arquivo"+i+"','arquivo"+i+"','arquivo')> Excluir</a>";
				document.getElementById("exibe_arquivo"+i).innerHTML= response+"(<? $size = filesize('../arquivos/"+response+"');echo round($size/1024);?>kb)"+bt_excluir;
					if (document.getElementById('na').innerHTML == document.getElementById('cont_arquivo').innerHTML){
						document.getElementById('submit_arquivo').disabled = true;
					}
					return;
				}
			}
		}function upload_video(response){	
			var nr = parseInt(document.getElementById("nv").innerHTML);
			var cont = document.getElementById("cont_video").innerHTML;
			for(var i=1;i<=cont;i++){
				if (document.getElementById("video"+i).value == '' ) {
				var quebra=response.split("/");
					document.getElementById("video"+i).value = quebra[1];
					document.getElementById("nv").innerHTML =nr+1;
				var bt_excluir = "<a href=javascript:excluir_item('x_excluir_imagem.php?pasta="+quebra[0]+"&imagem="+quebra[1]+"','exibe_video"+i+"','video"+i+"','video')> Excluir</a>";
				document.getElementById("exibe_video"+i).innerHTML= "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" width=\"100\" height=\"100\"><param name=\"movie\" value=\""+response+"\" /><param name=\"quality\" value=\"high\" /><embed src=\""+response+"\" quality=\"high\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"100\" height=\"100\" ></embed></object>"+bt_excluir;
					if (document.getElementById('nv').innerHTML == document.getElementById('cont_video').innerHTML){
						document.getElementById('submit_video').disabled = true;
					}
					return;
				}
			}
		}function VerificaSoCPF(pForm, pCampo)
		{
		var wVr, wTam, wSoma, wSoma2, i, j, wDig1, wDig2,
		wVETOR_CC = new Array(9),
		wVETOR_PESO = new Array(9);
		for (i=0; i < pForm.elements.lenght; i++)
		{
		if (pForm.elements[i].name == pCampo)
		{
		pCampo = i;
		i = pForm.elements.lenght;
		}
		}
		wVr = pForm[pCampo].value;
		wVr = wVr.replace( ".", "" );
		wVr = wVr.replace( ".", "" );
		wVr = wVr.replace( "-", "" );
		wTam = wVr.length + 1;
		if (wVr == "")
		{
		return false;
		}
		if (wTam < 11)
		{
		alert("Atenção: Nº de dígitos do CPF menor que o normal.");
		pForm[pCampo].value = "";
		pForm[pCampo].focus();
		return false;
		}
		for (i = 0; i < wVr.length; i++)
		{
		if (isNaN(parseInt(wVr.charAt(i))) )
		{
		alert("Atenção: O CPF contém dígitos inválidos.");
		pForm[pCampo].value = "";
		pForm[pCampo].focus();
		return false;
		}
		}
		if (wVr == "00000000000" || wVr == "11111111111" || wVr == "22222222222" || wVr == "33333333333" || wVr == "44444444444" || wVr == "55555555555" ||
		wVr == "66666666666" || wVr == "77777777777" || wVr == "88888888888" || wVr == "99999999999")
		{
		alert("Atenção: Este Tipo de CPF é inválido");
		pForm[pCampo].value = "";
		pForm[pCampo].focus();
		return false;
		}
		wSoma = 0;
		wSoma2 = 0;
		j = 2;
		for (i = 0; i < 11; i++)
		{
		wVETOR_CC[i] = wVr.charAt(i);
		wVETOR_PESO[i] = j;
		j++;
		}
		i = 0;
		while (i < 9)
		{
		i++;
		if (i < 10)
		{
		wSoma += wVETOR_CC[9 - i] * wVETOR_PESO[i - 1];
		}
		wSoma2 += wVETOR_CC[10 - i] * wVETOR_PESO[i - 1];
		}
		wDig1 = (wSoma * 10) % 11;
		wDig2 = (wSoma2 * 10) % 11;
		if (wDig1 == 10)
		{
		wDig1 = 0;
		}
		if (wDig2 == 10)
		{
		wDig2 = 0;
		}
		if (parseInt(wVr.charAt(9)) != wDig1 || parseInt(wVr.charAt(10)) != wDig2)
		{
		alert("Atenção: CPF com Dígito verificador é inválido.");
		pForm[pCampo].value = "";
		pForm[pCampo].focus();
		return false;
		}
		return true;
		}function VerificaEmail(pform, pcampo)
		{
		for (i=0; i < pform.elements.lenght; i++)
		{
		if (pform.elements[i].name == pcampo)
		{
		pcampo = i;
		i = pform.elements.lenght;
		}
		}
		parametro = pform[pcampo].value;
		teste_parametro = "false";
		tamanho_parametro = parametro.length;
		aposicao = 0;
		pposicao = 0;
		narrobas = 0;
		for (i = 0; i < tamanho_parametro; i++)
		{
		if (parametro.charAt(i) == "@")
		{
		narrobas = narrobas + 1
		aposicao = i;
		}
		if (parametro.charAt(i) == ".")
		{
		pposicao = i;
		}
		}
		if (aposicao > 0 && aposicao+1 < pposicao && narrobas<2)
		{
		teste_parametro = "true";
		}
		for (i = 0; i < tamanho_parametro; i++)
		{
		if (parametro.charAt(i) == "")
		{
		teste_parametro = "false";
		}
		}
		if (tamanho_parametro < 5)
		{
		teste_parametro = "false";
		}
		if (parametro.charAt(0) == "" || parametro.charAt(1) == "")
		{
		teste_parametro = "false";
		}
		if (teste_parametro == "false" && tamanho_parametro != 0 )
		{
		alert("Atenção: E-mail inválido!");
		pform[pcampo].focus();
		return false;
		}
		else
		{
		return true;
		}
		}function FormataDadoCPF(pForm,pCampo,pTamMax,pPos1,pPos2,pPosTraco,pTeclaPres)
		{
		var wTecla, wVr, wTam;
		wTecla = pTeclaPres.keyCode;
		for (i=0; i < pForm.elements.lenght; i++)
		{
		if (pForm.elements[i].name == pCampo)
		{
		pCampo = i;
		i = pForm.elements.lenght;
		}
		}
		wVr = pForm[pCampo].value;
		wVr = wVr.replace( "-", "" );
		wVr = wVr.replace( ".", "" );
		wVr = wVr.replace( ".", "" );
		wVr = wVr.replace( "/", "" );
		wTam = wVr.length ;
		if (wTam < pTamMax && wTecla != 8)
		{
		wTam = wVr.length + 1 ;
		}
		if (wTecla == 8 )
		{
		wTam = wTam - 1 ;
		}
		if ( wTecla == 8 || wTecla == 88 || wTecla >= 48 && wTecla <= 57 || wTecla >= 96 && wTecla <= 105 )
		{
		if ( wTam <= 2 )
		{
		pForm[pCampo].value = wVr ;
		}
		if (wTam > pPosTraco && wTam <= pTamMax)
		{
		wVr = wVr.substr(0, wTam - pPosTraco) +"-" + wVr.substr(wTam - pPosTraco, wTam);
		}
		if ( wTam == pTamMax)
		{
		wVr = wVr.substr( 0, wTam - pPos1 ) +"."+ wVr.substr(wTam - pPos1, 3) +"."+ wVr.substr(wTam - pPos2, wTam);
		}
		pForm[pCampo].value = wVr;
		}
		}function somente_numero(campo){
		var digits="0123456789"
		var campo_temp
		for (var i=0;i<campo.value.length;i++){
		campo_temp=campo.value.substring(i,i+1)
		if (digits.indexOf(campo_temp)==-1){
		campo.value = campo.value.substring(0,i);
		}
		}
		}function limita_numerico(e,virgula_ponto)
		{
		if (document.all)
		var tecla = event.keyCode;
		else if(document.layers)
		var tecla = e.which;
		if (tecla > 47 && tecla < 58)
		return true;
		else
		{
		if (virgula_ponto)
		{
		if  ((tecla == 44) || (tecla == 46))
		return true;
		}
		if (tecla != 8)
		{
		return false;
		}
		else
		return true;
		}
		}function MM_formtCep(e,src,mask) {
		if(window.event) { _TXT = e.keyCode; }
		else if(e.which) { _TXT = e.which; }
		if(_TXT > 47 && _TXT < 58) {
		var i = src.value.length; var saida = mask.substring(0,1); var texto = mask.substring(i)
		if (texto.substring(0,1) != saida) { src.value += texto.substring(0,1); }
		return true; } else { if (_TXT != 8) { return false; }
		else { return true; }
		}
		}function FormataDadoCGC(pForm,pCampo,pTeclaPres)
		{
		var wTecla, wVr, wTam;
		wTecla = pTeclaPres.keyCode;
		if (pTeclaPres.keyCode < 45 || pTeclaPres.keyCode > 57) return true;
		for (i=0; i < pForm.elements.lenght; i++)
		{
		if (pForm.elements[i].name == pCampo)
		{
		pCampo = i;
		i = pForm.elements.lenght;
		}
		}
		wVr = pForm[pCampo].value;
		wVr = wVr.replace( "-", "" );
		wVr = wVr.replace( ".", "" );
		wVr = wVr.replace( ".", "" );
		wVr = wVr.replace( "/", "" );
		wTam = wVr.length ;
		if (wTam < 14 && wTecla != 8)
		{
		wTam = wVr.length + 1 ;
		}
		if (wTecla == 8 )
		{
		wTam = wTam - 1 ;
		}
		if ( wTecla == 8 || wTecla == 88 || wTecla >= 48 && wTecla <= 57 || wTecla >= 96 && wTecla <= 105 )
		{
		if ( wTam <= 2 )
		{
		pForm[pCampo].value = wVr ;
		}
		if (wTam > 2 && wTam <= 14)
		{
		wVr = wVr.substr(0, wTam - 2) + "-" + wVr.substr(wTam - 2, wTam);
		}
		if ( wTam == 14)
		{
		wVr = wVr.substr( 0, wTam - 12 ) + "." + wVr.substr(wTam - 12, 3) + "." + wVr.substr(wTam - 9, 3) + "/" + wVr.substr(wTam - 6, wTam);
		}
		pForm[pCampo].value = wVr;
		}
		}function horizontal() {
		var navItems = document.getElementById("menu_dropdown").getElementsByTagName("li");
		for (var i=0; i< navItems.length; i++) {
		if(navItems[i].className == "submenu")
		{
		if(navItems[i].getElementsByTagName("ul")[0] != null)
		{
		navItems[i].onmouseover=function() {this.getElementsByTagName("ul")[0].style.display="block";this.style.backgroundColor = "#f9f9f9";}
		navItems[i].onmouseout=function() {this.getElementsByTagName("ul")[0].style.display="none";this.style.backgroundColor = "#FFFFFF";}
		}
		}
		}
		}
		var Password = function() {
		this.pass = "";
		this.generate = function(chars) {
		for (var i= 0; i<chars; i++) {
		this.pass += this.getRandomChar();
		}
		return this.pass;
		}
		this.getRandomChar = function() {
		var ascii = [[48, 57],[64,90],[97,122]];
		var i = Math.floor(Math.random()*ascii.length);
		return String.fromCharCode(Math.floor(Math.random()*(ascii[i][1]-ascii[i][0]))+ascii[i][0]);
		}
		}
		function showPass(alvo, pass) {
		document.getElementById(alvo).value = pass;
		}
		function newPass() {
		var pwd = new Password();
		showPass("senha", pwd.generate(6));
		}function exibe_imagem(target,imagem,url,altera) {
		document.getElementById(target).style.visibility = altera;
		document.getElementById(target).innerHTML ="<a href=\""+url+"\" target=\"_blank\"><img onclick=\"javascript:exibe_imagem('exibe_imagem','','','hidden')\" class='exibe_imagem' src='"+imagem+"'/></a><br><a href=\"javascript:exibe_imagem('exibe_imagem','','','hidden')\"> Fechar</a>";
		if(altera == "visible"){
		document.body.style.visibility = "hidden";
		}else{
		document.body.style.visibility = "visible";
		}
		}function retorna_url(target,url,altera) {
			
		document.getElementById(target).style.visibility = altera;
		if(altera == "hidden"){
			return false;
		}

		AjaxRequest();
		if(!Ajax) {
		document.getElementById(target).innerHTML ="[Erro]";
		return;
		}
		Ajax.onreadystatechange = function () {
		if (Ajax.readyState != 4) {
		document.getElementById(target).innerHTML =	"Carregando...!";	}
		if (Ajax.readyState == 4) {
		if (Ajax.status == 200) {
		texto=unescape(Ajax.responseText.replace(/\+/g," "));
		document.getElementById(target).innerHTML=texto;
		extraiScript(texto);
		} else {
		document.getElementById(target).innerHTML =	Ajax.responseText+"<br><a href=\"javascript:retorna_url('target','url','hidden')\"> Fechar</a>";
		}
		}
		}
		;
		if(url.indexOf("?")== -1)
		var operador = "?";
		else
		var operador = "&";
		Ajax.open("GET",url+operador+"rand="+Aleatorio(),true);
		Ajax.send(null);
		}function conta() {
		if(contador == 0) {
		retorna_menu('xt_verifica_novo.php','verifica');
		setTimeout("conta()", 3000);
		}
		if (contador != 0){
		contador = contador-1;
		setTimeout("conta()", 3000);
		}
		}function show_campo(campo1,tipo1,campo2,tipo2){  

             document.getElementById(campo1).style.display = tipo1;  
			  document.getElementById(campo2).style.display = tipo2;  
       
		}
		function retorna_menu_placar(url,target,exibe) {
		AjaxRequest();
		if(!Ajax) {
		document.getElementById(target).innerHTML ="[Erro]";
		return;
		}
		document.getElementById(exibe).innerHTML= "<dl><dt class=\"mostrar\"><a href=\"#\" onClick=\"retorna_menu('listar_"+url+".php','home')\">"+url+"</a></dt><dd class=\"mostrar\"><ul><li><a href=\"#\" onClick=\"retorna_menu('form_"+url+".php?opcao=atualiza&id=1','home')\">Ultimo Jogo</a></li><li class=\"ultimo\"><a href=\"#\" onClick=\"retorna_menu('form_"+url+".php?opcao=atualiza&id=2','home')\">Proximo Jogo</a></li></ul></dd></dl>";
		
		var exibe_url = "listar_"+url+".php";
		Ajax.onreadystatechange = function () {
		if (Ajax.readyState != 4) {
		document.getElementById(target).innerHTML =	"Carregando...!";	}
		if (Ajax.readyState == 4) {
		if (Ajax.status == 200) {
		document.getElementById(target).innerHTML=Ajax.responseText;
		extraiScript(Ajax.responseText);
		} else {
		document.getElementById(target).innerHTML =	Ajax.responseText;
		}
		}
		}
		;
		if(url.indexOf("?")== -1)
		var operador = "?";
		else
		var operador = "&";
		Ajax.open("GET",exibe_url+operador+"rand="+Aleatorio(),true);
		Ajax.send(null);
		}
  var max=250; 
  var ancho=300; 
   function progreso_tecla(obj) { 
   var progreso = document.getElementById("progreso");  
   if (obj.value.length < max) { 
   progreso.style.backgroundColor = "#FFFFFF";  
   progreso.style.backgroundImage = "url(images/textarea.png)";  
   progreso.style.color = "#000000"; 
   var pos = ancho-parseInt((ancho*parseInt(obj.value.length))/250); 
  progreso.style.backgroundPosition = "-"+pos+"px 0px"; 
     } else { 
  progreso.style.backgroundColor = "#CC0000";  
  progreso.style.backgroundImage = "url()";  
   progreso.style.color = "#FFFFFF"; 
     }  
     progreso.innerHTML = "("+obj.value.length+" / "+max+")"; 
   } 