/*
	Funciones en Javascript / AJAX para presentación de Ver más y Cerrar en
	la página de trámites
*/

var xmlHttp

function mostrarDestacado(str,pag)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	var url="get_destacado.php"
	url=url+"?cd="+str+"&pag="+pag
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}


function mostrarNoticia(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	var url="get_noticia.php"
	url=url+"?cd="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function mostrarInformacionTramite(str,longitud,descripcion,requisitos,procedimiento)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	xmlHttp1=GetXmlHttpObject()
	if (xmlHttp1==null) {
 		alert ("Browser does not support HTTP Request")
 		return
 	}	
	xmlHttp2=GetXmlHttpObject()
	if (xmlHttp2==null) {
 		alert ("Browser does not support HTTP Request")
 		return
 	}	
	if (descripcion == 'SI') {
		var url="get_tramite_descripcion.php"
		url=url+"?cd="+str+"&longitud="+longitud
		url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=stateChanged_descripcion 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
	if (requisitos == 'SI') {
		var url1="get_tramite_requisitos.php"
		url1=url1+"?cd="+str+"&longitud="+longitud
		url1=url1+"&sid="+Math.random()
		xmlHttp1.onreadystatechange=stateChanged_requisitos 
		xmlHttp1.open("GET",url1,true)
		xmlHttp1.send(null)
	}
	if (procedimiento == 'SI') {
		var url2="get_tramite_procedimiento.php"
		url2=url2+"?cd="+str+"&longitud="+longitud
		url2=url2+"&sid="+Math.random()
		xmlHttp2.onreadystatechange=stateChanged_procedimiento 
		xmlHttp2.open("GET",url2,true)
		xmlHttp2.send(null)	
	}
}

function mostrarInformacionTramite_descripcion(str,longitud)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	var url="get_tramite_descripcion.php"
	url=url+"?cd="+str+"&longitud="+longitud
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged_descripcion 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
	if(longitud == "corto"){
		document.getElementById("close_descripcion").style.display = "none";
		document.getElementById("open_descripcion").style.display = "inline";
	}
	if(longitud == "extenso"){
		document.getElementById("open_descripcion").style.display = "none";
		document.getElementById("close_descripcion").style.display = "inline";
	}
}

function mostrarInformacionTramite_requisitos(str,longitud)
{ 
	xmlHttp1=GetXmlHttpObject()
	if (xmlHttp1==null) {
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	
	var url1="get_tramite_requisitos.php"
	url1=url1+"?cd="+str+"&longitud="+longitud
	url1=url1+"&sid="+Math.random()
	xmlHttp1.onreadystatechange=stateChanged_requisitos 
	xmlHttp1.open("GET",url1,true)
	xmlHttp1.send(null)
	
	if(longitud == "corto"){
		document.getElementById("close_requisitos").style.display = "none";
		document.getElementById("open_requisitos").style.display = "inline";
	}
	if(longitud == "extenso"){
		document.getElementById("open_requisitos").style.display = "none";
		document.getElementById("close_requisitos").style.display = "inline";
	}		
}


function mostrarInformacionTramite_procedimiento(str,longitud)
{ 
	xmlHttp2=GetXmlHttpObject()
	if (xmlHttp2==null) {
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	
	var url2="get_tramite_procedimiento.php"
	url2=url2+"?cd="+str+"&longitud="+longitud
	url2=url2+"&sid="+Math.random()
	xmlHttp2.onreadystatechange=stateChanged_procedimiento 
	xmlHttp2.open("GET",url2,true)
	xmlHttp2.send(null)	


	if(longitud == "corto"){
		document.getElementById("close_procedimiento").style.display = "none";
		document.getElementById("open_procedimiento").style.display = "inline";
	}
	if(longitud == "extenso"){
		document.getElementById("open_procedimiento").style.display = "none";
		document.getElementById("close_procedimiento").style.display = "inline";
	}	
	
}


function stateChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		document.getElementById("texto_nota").innerHTML=xmlHttp.responseText 
 	} 
}

function stateChanged_descripcion() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		document.getElementById("texto_descripcion_tramite").innerHTML=xmlHttp.responseText 
 	} 
}

function stateChanged_requisitos() { 
	if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete") { 
		document.getElementById("texto_requisitos_tramite").innerHTML=xmlHttp1.responseText 
 	} 
}

function stateChanged_procedimiento() { 
	if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete") { 
		document.getElementById("texto_procedimiento_tramite").innerHTML=xmlHttp2.responseText 
 	} 
}


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;
}