//Inicio do Shadowbox

Shadowbox.init({
    language: 'pt-BR',
    players:  ['flv', 'html', 'iframe', 'qt', 'wmp', 'swf', 'img']});

//Fim do Shadowbox


                function fmtTel(campo, e)
                 {
                     myVal = campo.value;
                     if (myVal.length > 4 && !myVal.match(/\-/))
                    {
                        myVal = '';
                     }
                     else
                     {
                         if (window.event)
                         {
                            keycode = window.event.keyCode;
                         }
                         else if (e)
                         {
                             keycode = e.which;
                         }
                
                         if (keycode < 48 || keycode > 57)
                         {
                		 	if (keycode < 96 || keycode > 105)
                        	{
                            myVal = myVal.substr(0, (myVal.length - 1));
                       		}
                	   	 }
                
                        if (myVal.length == 4)
                        {
                           myVal += '-';
                        }
                    }
                     campo.value = myVal;
                }
                //AJAX PARA CARREGAR AS CIDADES
                function Dados(valor) {
                      //verifica se o browser tem suporte a ajax
                	  try {
                         ajax = new ActiveXObject("Microsoft.XMLHTTP");
                      } 
                      catch(e) {
                         try {
                            ajax = new ActiveXObject("Msxml2.XMLHTTP");
                         }
                	     catch(ex) {
                            try {
                               ajax = new XMLHttpRequest();
                            }
                	        catch(exc) {
                               alert("Esse browser nao tem recursos para uso do Ajax");
                               ajax = null;
                            }
                         }
                      }
                	  //se tiver suporte ajax
                	  if(ajax) {
                	     //deixa apenas o elemento 1 no option, os outros sao excluidos
                		 document.forms[0].listCidades.options.length = 1;
                	     
                		 idOpcao  = document.getElementById("opcoes");
                		 
                	     ajax.open("POST", "cidades.php", true);
                		 ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                		 
                		 ajax.onreadystatechange = function() {
                            //enquanto estiver processando...emite a msg de carregando
                			if(ajax.readyState == 1) {
                			   idOpcao.innerHTML = "Carregando...!"; 
                			 //  document.getElementById("cidade").style.visibility = "hidden";
                			 //  document.getElementById("loading").style.visibility = "visible";  
                	           
                			}
                			//apos ser processado - chama funcao processXML que vai varrer os dados
                            if(ajax.readyState == 4 ) {
                			   if(ajax.responseXML) {
                			      processXML(ajax.responseXML);
                			//	  document.getElementById("cidade").style.visibility = "visible";
                			//  	  document.getElementById("loading").style.visibility = "hidden";
                				  
                			   }
                			   else {
                			       //caso nao seja um arquivo XML emite a mensagem abaixo
                				   idOpcao.innerHTML = "Selecione o estado";
                				   
                				     }
                            }
                         }
                		 //passa o codigo do estado escolhido
                	     var params = "estado="+valor;
                         
                		 ajax.send(params);
                		 
                      }
                   }
                   
                   function processXML(obj){
                      //pega a tag cidade
                      var dataArray   = obj.getElementsByTagName("cidade");
                      
                	  //total de elementos contidos na tag cidade
                	  if(dataArray.length > 0) {
                	     //percorre o arquivo XML paara extrair os dados
                         for(var i = 0 ; i < dataArray.length ; i++) {
                            var item = dataArray[i];
                			//conteudo dos campos no arquivo XML
                			var codigo    =  item.getElementsByTagName("codigo")[0].firstChild.nodeValue;
                			var descricao =  item.getElementsByTagName("descricao")[0].firstChild.nodeValue;
                			
                	        idOpcao.innerHTML = "--Selecione uma das opcoes abaixo--";
                			
                			//cria um novo option dinamicamente  
                			var novo = document.createElement("option");
                			    //atribui um ID a esse elemento
                			    novo.setAttribute("id", "opcoes");
                				//atribui um valor
                			    novo.value = codigo;
                				if(codigo == 'MACEIO'){
                					novo.selected = true;
                				}
                				//alert(codigo);
                				//atribui um texto
                			    novo.text  = descricao;
                				//finalmente adiciona o novo elemento
                				document.forms[0].listCidades.options.add(novo);
                		 }
                	  }
                	    else {
                	    //caso o XML volte vazio, printa a mensagem abaixo
                		idOpcao.innerHTML = "--Primeiro selecione o estado--";
                	    }	  
                    }
                
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; }
        }
}

<!-- Inicio da Funcao FormataReais -->
function FormataReais(fld, milSep, decSep, e){
    var sep = 0;
    var key = '';
    var i = j = 0;
    var len = len2 = 0;
    var strCheck = '0123456789';
    var aux = aux2 = '';
    var whichCode = (window.Event) ? e.which : e.keyCode;
    if ((whichCode == 13) || (whichCode == 0) || (whichCode == 8)) 
        return true;
    if (whichCode == 13) 
        return true;
    key = String.fromCharCode(whichCode); // Valor para o codigo da Chave
    if (strCheck.indexOf(key) == -1) 
        return false; // Chave invalida
    len = fld.value.length;
    for (i = 0; i < len; i++) 
        if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) 
            break;
    aux = '';
    for (; i < len; i++) 
        if (strCheck.indexOf(fld.value.charAt(i)) != -1) 
            aux += fld.value.charAt(i);
    aux += key;
    len = aux.length;
    if (len == 0) 
        fld.value = '';
    if (len == 1) 
        fld.value = '0' + decSep + '0' + aux;
    if (len == 2) 
        fld.value = '0' + decSep + aux;
    if (len > 2) {
        aux2 = '';
        for (j = 0, i = len - 3; i >= 0; i--) {
            if (j == 3) {
                aux2 += milSep;
                j = 0;
            }
            aux2 += aux.charAt(i);
            j++;
        }
        fld.value = '';
        len2 = aux2.length;
        for (i = len2 - 1; i >= 0; i--) 
            fld.value += aux2.charAt(i);
        fld.value += decSep + aux.substr(len - 2, len);
    }
    return false;
}
//Fim da Funcao FormataReais -->
                

    function ValidaSemPreenchimento(form){
       var contador =0; 
	   for (i = 0; i < form.length; i++) {
            var obg = form[i].name;
            
			// alert(obg);
			
			if (form[i].type == "checkbox"){
				if (form[i].checked == true){
					contador++;
				};
			};
			
            if (form[i].value == "") {
                var nome = form[i].name
                alert("O campo " + nome + " \xE9 obrigat\xF3rio.")
                form[i].focus();
                return false
               
            }
			
        }
		
		if(contador < 1){
			alert("Por favor, selecione um ingresso.")
            return false
		};
		
        return true
    }
-->
