/*funcao para subir e descer pontos na criaçao, caracteristicas*/
function sobeDesce(valor, tipo){
    var coisa = new ajax();
    var pontos = document.getElementById("pontos").innerHTML;
    var i = 0;
    var str1 = new String("<img src=\"../not.gif\">");
    var str2 = new String("<img src=\"../yes.gif\">");
    var cont = 0;
    var cont2 = 0;
    var valorup = parseInt(valor)+1;

    if (valorup == 6)  valorup = 5;
    
    for(i=1; i<valor; i++){
       if(document.getElementById("image"+i+tipo).innerHTML == str2){
          cont++;
       }
    }
    
    aux = parseInt(pontos) - parseInt(valor) + parseInt(cont);
    
    cont = 0;

       if(document.getElementById("image"+valor+tipo).innerHTML == str1){
          if(aux < 0){
             alert("Voce nao tem pontos suficientes!!!");
             return true;
          }else{
             for(i=1; i<valor; i++){
                if(document.getElementById("image"+i+tipo).innerHTML == str2){
                   cont++;
                }
             }
          
             for(i = 1; i <= valor; i++){
                document.getElementById("image"+i+tipo).innerHTML = "<img src=\"../yes.gif\">";
             }

             if(cont == 0)
                document.getElementById("pontos").innerHTML = pontos - valor;
             else
                document.getElementById("pontos").innerHTML = parseInt(pontos) - parseInt(valor) + parseInt(cont);
          }
       }else{
          if(document.getElementById("image"+valorup+tipo).innerHTML == str2){
            for(i=1; i<=5; i++){
               document.getElementById("image"+i+tipo).innerHTML;
               if(document.getElementById("image"+i+tipo).innerHTML == str2){
                 cont++;
               }
             }
             
             if(valor == 5){
                 for(i = 1; i <= valor; i++){
                   document.getElementById("image"+i+tipo).innerHTML = "<img src=\"../not.gif\">";
                 }
                 document.getElementById("pontos").innerHTML = parseInt(pontos) + parseInt(valor);
                 valor = 0;
             }else{
             
                for(i=valorup; i<=cont; i++){
                   document.getElementById("image"+i+tipo).innerHTML = "<img src=\"../not.gif\">";
                   cont2++;
                }

                document.getElementById("pontos").innerHTML = parseInt(pontos) + parseInt(cont2);
              }
          }else{
            for(i = 1; i <= valor; i++){
             document.getElementById("image"+i+tipo).innerHTML = "<img src=\"../not.gif\">";
            }
            document.getElementById("pontos").innerHTML = parseInt(pontos) + parseInt(valor);
            valor = 0;
           }
       }

       document.getElementById(tipo).innerHTML = valor;

}

/*funcao para subir pontos na criaçao, genericamente*/
function up(valor, id){
     if(document.getElementById("desvantagem" + id).checked == true)
        document.getElementById("pontos").innerHTML = parseInt(document.getElementById("pontos").innerHTML) + parseInt(valor);
     else{
        if(document.getElementById("pontos").innerHTML - valor < 0){
           alert("Voce nao tem pontos suficientes!!!");
           document.getElementById("desvantagem" + id).checked = true;
           return true;
        }
        document.getElementById("pontos").innerHTML -= valor;
     }
}

/*funcao para descer pontos na criaçao, genericamente*/
function down(valor, id){
     if(document.getElementById("pontos").innerHTML - valor < 0){
        alert("Voce nao tem pontos suficientes!!!");
        document.getElementById("vantagem" + id).checked = false;
        return true;
     }
     if(document.getElementById("vantagem" + id).checked == true)
          document.getElementById("pontos").innerHTML -= valor;
     else
          document.getElementById("pontos").innerHTML = parseInt(document.getElementById("pontos").innerHTML) + parseInt(valor);
}
