function editacampo(dive,oid){
var comada = document.getElementById(dive);
SendEventProfile("GET", "eventprofilecore.php?id="+oid+"&campo="+dive, comada);
}

function editadone(inp,oid,leier){
if(inp == "sexo" || inp == "flag"){
var elput = document.getElementById(inp);
var coma = document.getElementById(leier);
elput = elput.options[elput.selectedIndex].value;
SendEventProfile("GET", "eventprofilecore.php?action=done&id="+oid+"&valor="+escape(elput)+"&campo="+inp, coma);
}if(inp == "about"){
var elput = document.getElementById("message");
var coma = document.getElementById(leier);
elput = elput.value;
SendEventProfile("GET", "eventprofilecore.php?action=done&id="+oid+"&valor="+escape(elput)+"&campo="+inp, coma);
}
if(inp != "sexo" && inp != "about" && inp != "flag"){
var elput = document.getElementById(inp);
elput = elput.value;
var coma = document.getElementById(leier);
SendEventProfile("GET", "eventprofilecore.php?action=done&id="+oid+"&valor="+escape(elput)+"&campo="+inp, coma);
}
//var coma = document.getElementById(leier);
//elput = elput.value;
//SendEventProfile("GET", "eventprofilecore.php?action=done&id="+oid+"&valor="+elput+"&campo="+inp, coma);
}

function editacampoextra(dive,oid){
var comada = document.getElementById(dive);
SendEventProfile("GET", "eventprofilecoreextra.php?id="+oid+"&campo="+dive, comada);
}

function EditPhoto() {
window.open('profile_editphoto.php','mywindow','width=500,height=400,status=yes')
}

function AddFriend(sid){
var evento = "profile_addfriend.php?friendID="+sid+"";
SendEventProfileAlert('GET',evento);
}

function DelFriend(sid){
var evento = "profile_delfriend.php?friendID="+sid+"";
SendEventProfileAlert('GET',evento);
}

function AcceptFriend(sid,layerto){
var evento = "profile_faddcore.php?action=acept&friendID="+sid+"";
layerto = "buddyadd-"+layerto;
var tohidden = document.getElementById(layerto);
SendEventProfileAlert2('GET', evento, tohidden);
}

function RejectFriend(sid,layerto){
var evento = "profile_faddcore.php?action=reject&friendID="+sid+"";
layerto = "buddyadd-"+layerto;
var tohidden = document.getElementById(layerto);
SendEventProfileAlert2('GET', evento, tohidden);
}

function JoinTeam(sid,layerto){
var evento = "teamprofile_taddcore.php?action=acept&userID="+sid+"&teamID="+layerto+"";
layerto = "teamadd-"+layerto;
var tohidden = document.getElementById(layerto);
SendEventProfileAlert2('GET', evento, tohidden);
}

function RejectTeam(sid,layerto){
var evento = "teamprofile_taddcore.php?action=reject&userID="+sid+"&teamID="+layerto+"";
layerto = "teamadd-"+layerto;
var tohidden = document.getElementById(layerto);
SendEventProfileAlert2('GET', evento, tohidden);
}

function EditAvatar(sid) {
window.open('profile_editavatar.php','mywindow','width=500,height=400,status=yes')
}

function editadoneextra(inp,oid,leier){
var elput = document.getElementById(inp);
var coma = document.getElementById(leier);
elput = elput.value;
SendEventProfile("GET", "eventprofilecoreextra.php?action=done&id="+oid+"&valor="+elput+"&campo="+inp, coma);
}

function SendEventProfile(type,event,camada) {

if (window.XMLHttpRequest) {
                xmlhttp = new XMLHttpRequest();
        } else if (window.ActiveXObject) {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } else {
            alert("Seu navegador n&atilde;o suporta XMLHttpRequest.");
                return;
        }

  xmlhttp.open(type, event, true);
  xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
  xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
  xmlhttp.setRequestHeader("Pragma", "no-cache");
  xmlhttp.onreadystatechange = function(){
  if(xmlhttp.readyState == 1){ //Consula em Andamento
  camada.innerHTML = 'Carregando, aguarde...<br><img src=\"images/loading.gif\" border=\"0\">'
  }
     
  if(xmlhttp.readyState == 4){ //Tudo ok, carregou. 

  if(xmlhttp.status == 200) { //pagina encontrada, pega a response e exibe aqui tio.

  var result = xmlhttp.responseText.replace("\\","");
  camada.innerHTML = result;

  }else{

  alert("Problemas na fonte. Consulte o programador.");
 
  }	

  }
  }
  xmlhttp.send(null);
}

function SendEventProfileAlert(type,event) {

if (window.XMLHttpRequest) {
                xmlhttp = new XMLHttpRequest();
        } else if (window.ActiveXObject) {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } else {
            alert("Seu navegador n&atilde;o suporta XMLHttpRequest.");
                return;
        }

  xmlhttp.open(type, event, true);
  xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
  xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
  xmlhttp.setRequestHeader("Pragma", "no-cache");
  xmlhttp.onreadystatechange = function(){
  if(xmlhttp.readyState == 4){ //Tudo ok, carregou.

  if(xmlhttp.status == 200) { //pagina encontrada, pega a response e exibe aqui tio.

  alert(xmlhttp.responseText);

  }else{

  alert("Problemas na fonte. Consulte o programador.");

  }

  }
  }
  xmlhttp.send(null);
}

function SendEventProfileAlert2(type,event,layerto) {

if (window.XMLHttpRequest) {
                xmlhttp = new XMLHttpRequest();
        } else if (window.ActiveXObject) {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } else {
            alert("Seu navegador n&atilde;o suporta XMLHttpRequest.");
                return;
        }

  xmlhttp.open(type, event, true);
  xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
  xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
  xmlhttp.setRequestHeader("Pragma", "no-cache");
  xmlhttp.onreadystatechange = function(){
  if(xmlhttp.readyState == 4){ //Tudo ok, carregou.

  if(xmlhttp.status == 200) { //pagina encontrada, pega a response e exibe aqui tio.

  alert(xmlhttp.responseText);
  layerto.style.visibility = "hidden";

  }else{

  alert("Problemas na fonte. Consulte o programador.");

  }

  }
  }
  xmlhttp.send(null);
}
