	function ajax(url,divId, flag){
		var myDiv;
		if (document.getElementById(divId)!=null) {
				myDiv = document.getElementById(divId);
		}
		//if (flag=='true'){
        	//	$('placab').slideDown();
		//}else{
	       	myDiv.innerHTML = "Buscando placa....";
		//}
		execAjax(myDiv,url);
	}
	
	function execAjax(myDiv,url){			
		
		new Ajax.Request(url,
				{
				encoding:     'UTF-8',
	    		onSuccess: function(transport){
					var data=transport.responseText;
					myDiv.innerHTML = data;
					
				},
	    		onFailure: function(){ 	
				 alert('Erro Ajax: '+e);
				 fnLoadComplete();
				}
			});
		
		
	}
	
	function imposeMaxLength(Object, MaxLen)
{
  return (Object.value.length <= MaxLen);
}

function submeteTitulo(){			
		var autor = $('autor').value;
		var titulo = $('titulo').value;	
		$('status').innerHTML = "<b>enviando...</b>";
		new Ajax.Request('sendtitulo.php',
				{
	    		method:'post',
	    		asynchronous: true,   
    			contentType:  'application/x-www-form-urlencoded', 
	    		encoding:     'ISO-8859-1',
				parameters: {
						autor: autor,
						titulo: titulo
						
				},
	    		onSuccess: function(transport){
	  			    if(transport.responseText.indexOf("#OK#")!=-1){
						$('autor').value = "";
		                $('titulo').value = "";	
						alert("Titulo enviado com sucesso.");
						window.location.reload();
					}else if(transport.responseText.indexOf("#CAMPOS#")!=-1){
						alert("Voce nao preencheu todos os campos.");
					}else if(transport.responseText.indexOf("#LIMITE#")!=-1){
						alert("O numero de titulos enviados chegou ao limite. Apos a escolha do titulo final, a imagem sera mostrada com o titulo em placas enigmaticas.");
					}
					else{
						alert("Ocorreu um erro.");
					}
					$('status').innerHTML = "";
					
				},
	    		onFailure: function(){ //alert('Ocorreu um erro ao tentar acessao o servidor...')
					//$('button_mostrar_indicator_cet_' + chamador ).style.display = 'none';
					//$('cet_img_' + chamador).style.display = 'block';
	
				 alert(e);
				 fnLoadComplete();
				}
			});
		
	}
	
	function submeteVoto(id){			
		var id = id;
		$('status').innerHTML = "<b>enviando...</b>";
		new Ajax.Request('sendvoto.php',
				{
	    		method:'post',
	    		asynchronous: true,   
    			contentType:  'application/x-www-form-urlencoded', 
	    		encoding:     'ISO-8859-1',
				parameters: {
						id: id
				},
	    		onSuccess: function(transport){
	  			    if(transport.responseText.indexOf("#OK#")!=-1){
						alert("Seu voto foi enviado com sucesso.");
					}else{
						alert("Ocorreu um erro.");
					}
					$('status').innerHTML = "";
					
				},
	    		onFailure: function(){ //alert('Ocorreu um erro ao tentar acessao o servidor...')
					//$('button_mostrar_indicator_cet_' + chamador ).style.display = 'none';
					//$('cet_img_' + chamador).style.display = 'block';
	
				 alert(e);
				 fnLoadComplete();
				}
			});
		
	}
	
	function makeId(id){
	var kkk = id.toString().substring(1);
		if (kkk<10){
			return kkk.toString().substring(1);
		}else{
			return kkk;
		}
	}
	
	function submeteRespAjax(id, valor){	
		var idImagem = id;
	    var cssId = null;
		if (id > 800){
			cssId = 'filme'+id;
		}else{
			cssId = 'icone'+id;
		}
		var status = 'status'+id;
		var setaId = 'seta'+id;
		if (id > 800){
			id = 'filmes ('+makeId(id)+')';
		}else{
			id = 'icones ('+id+')';
		}
		var valor = valor;
		$(status).innerHTML = "<b>verificando...</b>";
		new Ajax.Request('sendresp.php',
				{
	    		method:'post',
	    		asynchronous: true,   
    			contentType:  'application/x-www-form-urlencoded', 
	    		encoding:     'ISO-8859-1',
				parameters: {
						id: id,
						valor: valor
				},
	    		onSuccess: function(transport){
	  			    if(transport.responseText.indexOf("#ACERTOU#")!=-1){
						alert(";-)  Acertou! PARABENS!!");
						$(cssId).style.backgroundColor='#3FFF7F';
						$(cssId).disabled="true";
						$(setaId).src='icones/imgs/ok1.gif';
						$(setaId).onclick= function() {
							alert('Já enviado');
						}
					}else if (transport.responseText.indexOf("#ERROU#")!=-1){
						alert(":-(  Errou, tente novamente.");
					}else if (transport.responseText.indexOf("#JAACERTARAM#")!=-1){
						alert(";-)  Alguém ja acertou antes de voce, a pagina sera atualizada.");
						window.location.href = "http://localhost/pracasdobraziu/icones.php";
					}
					else{
						alert("Ocorreu um erro");
					}
					$(status).innerHTML = "";
					
				},
	    		onFailure: function(){ //alert('Ocorreu um erro ao tentar acessao o servidor...')
					//$('button_mostrar_indicator_cet_' + chamador ).style.display = 'none';
					//$('cet_img_' + chamador).style.display = 'block';
	
				 alert(e);
				 fnLoadComplete();
				}
			});
		
	}
	
	
	