//Tenta criar o objeto xmlHTTP
try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}

//Fila de conexões
fila=[];
ifila=0;

//Carrega via XMLHTTP a url recebida e coloca seu valor
//no objeto com o id recebido
function ajaxHTML(id,url){
    //Carregando...
//    document.getElementById(id).innerHTML="<span class='carregando'>"+
//                                          "Carregando...</span>"
    //Adiciona à fila
    fila[fila.length]=[id,url];
    //Se não há conexões pendentes, executa
    if ((ifila+1) == fila.length) {
		//ajaxRun();
	}
}

//Executa a próxima conexão da fila
function ajaxRun(){
    //Abre a conexão
    xmlhttp.open("GET",fila[ifila][1],true);
    //Função para tratamento do retorno
    xmlhttp.onreadystatechange=function() {
	
        if (xmlhttp.readyState==4){
            //Mostra o HTML recebido
            retorno=unescape(xmlhttp.responseText.replace(/\+/g," "))
			//verifica retorno para saber se usuário está logado
	        if (retorno==-1){
				alert("não logado");
				wopen('../pop_login.php', 300, 300);
	            //Roda o próximo
	            ifila++
	            if(ifila<fila.length)setTimeout("ajaxRun()",20)
	        }else{
				//verifica retorno para saber se usuário está logado
			    if (retorno==-2){
					alert("Você já deu nota para esse item.");
				    //Roda o próximo
				    ifila++
				    if(ifila<fila.length)setTimeout("ajaxRun()",20)
				} else{
					document.getElementById(fila[ifila][0]).innerHTML=retorno
		            //Roda o próximo
		            ifila++
		            if(ifila<fila.length)setTimeout("ajaxRun()",20)
				}
			}
        }
    }
    //Executa
    xmlhttp.send(null)
}

function point_it(event,obj){
    pos_x = event.offsetX?(event.offsetX):event.pageX-obj.offsetLeft;
    pos_y = event.offsetY?(event.offsetY):event.pageY-obj.offsetTop;
	stringRetorno = "pos_x=" + pos_x + "&pos_y=" + pos_y;
	alert(pos_y);
	return stringRetorno;
}

function listaRelato() {
	var DA = document.frmSigno;
	var id_signo1 = DA.it_signo1.value;
	var id_signo2 = DA.it_signo2.value;
	
	if (id_signo1 != 0 && id_signo2 != 0) {
		codigo.location.href = 'signo.php?signo1=' + id_signo1 + '&signo2=' + id_signo2;
		//alert('executar ajax');
		//ajaxHTML('1','relato.php');
	}				
}

function verificarRelato() {
	var DA = document.frmRelato;
	var vc_erro	= '';
	
	if (DA.vc_relato.value.length == 0) {
		vc_erro = vc_erro + '- Digite o seu RELATO.\n';
	}
	
	if (DA.it_nota.value.length == 0) {
		vc_erro = vc_erro + '- Digite uma NOTA.\n';
	} else {
		if (DA.it_nota.value < 0 || DA.it_nota.value > 10) {
			vc_erro = vc_erro + '- Digite uma NOTA entre 0 e 10.\n';
			DA.it_nota.value = '';
			DA.it_nota.focus();
		} else {
			DA.it_nota.value = DA.it_nota.value.replace(",", "\.");
		}
	}
	
	if (vc_erro.length == 0) {
		DA.submit();
	} else {
		alert('ATENÇÃO!\n\n' + vc_erro);
		return false;
	}
}


