var obj;

function ProcessXML(url,szDivID)
{
//INICIA codigo para insertar los datos en la BD 
  if (window.XMLHttpRequest) {
    // obtain new object
    obj = new XMLHttpRequest();
    // set the callback function
    obj.onreadystatechange = processChange;
    // we will do a GET with the url; "true" for asynch
    obj.open("GET", url, true);
    // null for GET with native object
    obj.send(null);
  // IE/Windows ActiveX object
  } else if (window.ActiveXObject) {
    obj = new ActiveXObject("Microsoft.XMLHTTP");
    if (obj) {
      obj.onreadystatechange = processChange;
      obj.open("GET", url, true);
      // don't send null for ActiveX
      obj.send();
    }
  } else {
    alert("Your browser does not support AJAX");
  }
//FINALIZA codigo para insertar los datos en la BD
 
// INICIA codigo para cambiar la imagen del div
    if(document.layers)    //NN4+
    {
	document.layers[szDivID].innerHTML= "<img src='/images/fav_added.gif' border='0' title='Sex Gallery Added' height='10' width='10' />";
    }
    else if(document.getElementById)      //gecko(NN6) + IE 5+
    {
        var objj = document.getElementById(szDivID);
	objj.innerHTML = "<img src='/images/fav_added.gif' border='0' title='Sex Gallery Added' height='10' width='10' />";
    }
    else if(document.all)       // IE 4
    {
	document.all[szDivID].innerHTML = "<img src='/images/fav_added.gif' border='0' title='Sex Gallery Added' height='10' width='10' />";
    }
 // FINALIZA codigo para cambiar la imagen del div

}

function processChange() {
    // 4 means the response has been returned and ready to be processed
    if (obj.readyState == 4) {
        // 200 means "OK"
        if (obj.status == 200) {
                  //   alert("Listo Insertado"); 
            // process whatever has been sent back here:
        // anything else means a problem
        } else {
            alert("There was a problem in the returned data:\n");
        }
    }
}

//INICIA codigo para reportar la galleria

function reportBad(id)
{
	var win = '/report/out.php?id=' + id; 
	var idr = 'r' + id; 

	if(document.layers)    //NN4+
    {
	document.layers[idr].innerHTML= "R";
    }
    else if(document.getElementById)      //gecko(NN6) + IE 5+
    {
        var objj = document.getElementById(idr);
	objj.innerHTML = "R";
    }
    else if(document.all)       // IE 4
    {
	document.all[idr].innerHTML = "R";
    }
	var al = 400;// alto del popup a lanzar 
	var an = 250;// ancho del popup a lanzar 

	var ancho = ((screen.width/2)-(an/2));
	var alto = ((screen.height/2)-(al/2));
	
 win1= window.open(win,"under","width=400,height=250,toolbar=no,location=no,directories=no,status=no,menubar=no,screenX=150,screenY=125,left="+ancho+",top="+alto+",scrollbars=auto,resizeable=no"); 

}

/*INICIA FUNCION para aņadir los comentarios al wall */

function addWall(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('ajaxDiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	var postUserComment = document.getElementById('postUserComment').value;
	var username = document.getElementById('username').value;
	var usernamepost = document.getElementById('usernamepost').value;
	var queryString = "?postUserComment=" + postUserComment + "&username=" + username + "&usernamepost=" + usernamepost;
	ajaxRequest.open("GET", "/users/wall_insert.php" + queryString, true);
	ajaxRequest.send(null); 
}
/*FINALIZA FUNCION para aņdir los comentarios al wall */



/*INICIA remover galleria */
function removeGal(url,szDivID)
{
//INICIA codigo para insertar los datos en la BD 
  if (window.XMLHttpRequest) {
    // obtain new object
    obj = new XMLHttpRequest();
    // set the callback function
    obj.onreadystatechange = processChange;
    // we will do a GET with the url; "true" for asynch
    obj.open("GET", url, true);
    // null for GET with native object
    obj.send(null);
  // IE/Windows ActiveX object
  } else if (window.ActiveXObject) {
    obj = new ActiveXObject("Microsoft.XMLHTTP");
    if (obj) {
      obj.onreadystatechange = processChange;
      obj.open("GET", url, true);
      // don't send null for ActiveX
      obj.send();
    }
  } else {
    alert("Your browser does not support AJAX");
  }
//FINALIZA codigo para insertar los datos en la BD
 
// INICIA codigo para cambiar la imagen del div
    if(document.layers)    //NN4+
    {
	document.layers[szDivID].innerHTML= "<img src='/images/t.gif' border='0' title='Sex Gallery Removed' height='10' width='10' />";
    }
    else if(document.getElementById)      //gecko(NN6) + IE 5+
    {
        var objj = document.getElementById(szDivID);
	objj.innerHTML = "<img src='/images/t.gif' border='0' title='Sex Gallery Removed' height='10' width='10' />";
    }
    else if(document.all)       // IE 4
    {
	document.all[szDivID].innerHTML = "<img src='/images/t.gif' border='0' title='Sex Gallery Removed' height='10' width='10' />";
    }
 // FINALIZA codigo para cambiar la imagen del div

}
/*Aqui llama a una funciona "processChange" que esta al inicio
/*FINALIZA remover galleria */


/*INICIA el codigo para cambiar el Add Friend */
function addFriend(url,szDivID)
{
//INICIA codigo para insertar los datos en la BD 
  if (window.XMLHttpRequest) {
    // obtain new object
    obj = new XMLHttpRequest();
    // set the callback function
    obj.onreadystatechange = processChange;
    // we will do a GET with the url; "true" for asynch
    obj.open("GET", url, true);
    // null for GET with native object
    obj.send(null);
  // IE/Windows ActiveX object
  } else if (window.ActiveXObject) {
    obj = new ActiveXObject("Microsoft.XMLHTTP");
    if (obj) {
      obj.onreadystatechange = processChange;
      obj.open("GET", url, true);
      // don't send null for ActiveX
      obj.send();
    }
  } else {
    alert("Your browser does not support AJAX");
  }
//FINALIZA codigo para insertar los datos en la BD
 
// INICIA codigo para cambiar la imagen del div
    if(document.layers)    //NN4+
    {
	document.layers[szDivID].innerHTML= "Added as Friend";
    }
    else if(document.getElementById)      //gecko(NN6) + IE 5+
    {
        var objj = document.getElementById(szDivID);
	objj.innerHTML = "Added as Friend";
    }
    else if(document.all)       // IE 4
    {
	document.all[szDivID].innerHTML = "Added as Friend";
    }
 // FINALIZA codigo para cambiar la imagen del div

} 
/*Aqui llama a una funciona "processChange" que esta al inicio
/*FINALIZA codigo para add friend */

/* INICIA code pare remover friend */
function removeFriend(url,szDivID)
{
//INICIA codigo para insertar los datos en la BD 
  if (window.XMLHttpRequest) {
    // obtain new object
    obj = new XMLHttpRequest();
    // set the callback function
    obj.onreadystatechange = processChange;
    // we will do a GET with the url; "true" for asynch
    obj.open("GET", url, true);
    // null for GET with native object
    obj.send(null);
  // IE/Windows ActiveX object
  } else if (window.ActiveXObject) {
    obj = new ActiveXObject("Microsoft.XMLHTTP");
    if (obj) {
      obj.onreadystatechange = processChange;
      obj.open("GET", url, true);
      // don't send null for ActiveX
      obj.send();
    }
  } else {
    alert("Your browser does not support AJAX");
  }
//FINALIZA codigo para insertar los datos en la BD
 

    if(document.layers)    //NN4+
    {
	document.layers[szDivID].innerHTML= "Friend Removed";
    }
    else if(document.getElementById)      //gecko(NN6) + IE 5+
    {
        var objj = document.getElementById(szDivID);
	objj.innerHTML = "Friend Removed";
    }
    else if(document.all)       // IE 4
    {
	document.all[szDivID].innerHTML = "Friend Removed";
    }


}
/*Aqui llama a una funciona "processChange" que esta al inicio
/*FINALIZA code para remover friend */


/*INICIA remover COMENTARIO DE GALLERIAS */
function removeComment(url,szDivID)
{
	var idcg = 'cg' + szDivID;
//INICIA codigo para insertar los datos en la BD 
  if (window.XMLHttpRequest) {
    // obtain new object
    obj = new XMLHttpRequest();
    // set the callback function
    obj.onreadystatechange = processChange;
    // we will do a GET with the url; "true" for asynch
    obj.open("GET", url, true);
    // null for GET with native object
    obj.send(null);
  // IE/Windows ActiveX object
  } else if (window.ActiveXObject) {
    obj = new ActiveXObject("Microsoft.XMLHTTP");
    if (obj) {
      obj.onreadystatechange = processChange;
      obj.open("GET", url, true);
      // don't send null for ActiveX
      obj.send();
    }
  } else {
    alert("Your browser does not support AJAX");
  }
//FINALIZA codigo para insertar los datos en la BD
 
// INICIA codigo para cambiar la imagen del div
    if(document.layers)    //NN4+
    {
	document.layers[idcg].innerHTML= "<img src='/images/t.gif' border='0' title='Comment Removed' height='10' width='10' />";
    }
    else if(document.getElementById)      //gecko(NN6) + IE 5+
    {
        var objj = document.getElementById(idcg);
	objj.innerHTML = "<img src='/images/t.gif' border='0' title='Comment Removed' height='10' width='10' />";
    }
    else if(document.all)       // IE 4
    {
	document.all[idcg].innerHTML = "<img src='/images/t.gif' border='0' title='Comment Removed' height='10' width='10' />";
    }
 // FINALIZA codigo para cambiar la imagen del div

}
/*Aqui llama a una funciona "processChange" que esta al inicio
/*FINALIZA remover COMENTARIO DE GALLERIAS */


/*INICIA remover POST en WALL */
function removeWall(url,szDivID)
{
	var idw = 'w' + szDivID;
//INICIA codigo para insertar los datos en la BD 
  if (window.XMLHttpRequest) {
    // obtain new object
    obj = new XMLHttpRequest();
    // set the callback function
    obj.onreadystatechange = processChange;
    // we will do a GET with the url; "true" for asynch
    obj.open("GET", url, true);
    // null for GET with native object
    obj.send(null);
  // IE/Windows ActiveX object
  } else if (window.ActiveXObject) {
    obj = new ActiveXObject("Microsoft.XMLHTTP");
    if (obj) {
      obj.onreadystatechange = processChange;
      obj.open("GET", url, true);
      // don't send null for ActiveX
      obj.send();
    }
  } else {
    alert("Your browser does not support AJAX");
  }
//FINALIZA codigo para insertar los datos en la BD
 
// INICIA codigo para cambiar la imagen del div
    if(document.layers)    //NN4+
    {
	document.layers[idw].innerHTML= "<img src='/images/t.gif' border='0' title='Comment Removed' height='10' width='10' />";
    }
    else if(document.getElementById)      //gecko(NN6) + IE 5+
    {
        var objj = document.getElementById(idw);
	objj.innerHTML = "<img src='/images/t.gif' border='0' title='Comment Removed' height='10' width='10' />";
    }
    else if(document.all)       // IE 4
    {
	document.all[idw].innerHTML = "<img src='/images/t.gif' border='0' title='Comment Removed' height='10' width='10' />";
    }
 // FINALIZA codigo para cambiar la imagen del div

}
/*Aqui llama a una funciona "processChange" que esta al inicio
/*FINALIZA remover POST en WALL */

// Function to validate that something is tipped in the serach box
function validateForm()
 {
 var x=document.forms["searchForm"]["q"].value
 if (x==null || x=="")
   {
   alert("Please write a key word to search");
   return false;
   }
 }
