

function carga_form_sugerir(){
	var url=document.getElementById("url").value;
	document.getElementById("url").readOnly=true;
	load("masdatos","ajax_sugerir.php?url="+url);
	document.getElementById("botoncontinuar").style.display="none";
	document.getElementById("sendurl").value=document.getElementById("url").value;
}

function reiniciar_sugerir(){
	document.getElementById("masdatos").innerHTML="";
	document.getElementById("url").value="http://";
	document.getElementById("url").readOnly=false;
	document.getElementById("botoncontinuar").style.display="inline";
}


function sel_subcategorias(nivel){
	var categoria=document.getElementById("categoria"+nivel).value;
	var categoria_actual=categoria;
	if(nivel>0&&categoria==0){
		categoria_actual=document.getElementById("categoria"+(nivel-1)).value;
	}
	document.getElementById("categoria").value=categoria_actual;
	load("subcategoria"+nivel,"ajax_sel_subcategorias.php?categoria="+categoria+"&nivel="+nivel+"")
	

}


function enlace(nombre) {
	var url="ajax_enlace.php?nombre="+nombre;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
	  alert ("Su navegador no soporta AJAX!");
	  return;
	 } 
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


var divid="";
var afterload="";

function load(div,url,postfunction) {
	afterload=postfunction;
	divid=div;
	//document.getElementById(divid).innerHTML="";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
	  alert ("Su navegador no soporta AJAX!");
	  return;
	 } 
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
	

function GetXmlHttpObject() {
  var xmlHttp=null;
  try{// Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
   }
  catch (e){ // Internet Explorer
    try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
    catch (e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
   }
  return xmlHttp;
}

function stateChanged() {
	/*
	if (xmlHttp.readyState==1){//request seteando
		document.getElementById(divid).innerHTML="<p>seteando</p>";
	}
	if (xmlHttp.readyState==2){//request enviado
		document.getElementById(divid).innerHTML="<p>enviado</p>";
	}
	if (xmlHttp.readyState==3){//request en proceso
		document.getElementById(divid).innerHTML="<p>en proceso</p>";
	}
	*/
	if (xmlHttp.readyState==4){//request completo
		document.getElementById(divid).innerHTML=xmlHttp.responseText;
		eval(afterload);
	}
}


