function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer") {
		ro = new ActiveXObject("Microsoft.XMLHTTP");	
	} else {
		ro = new XMLHttpRequest();	
	}
	return ro;
}

var http = createRequestObject();

// PINTO LISTADO EMPRESAS ////////////////////////////////////////////////////////////////////////////////////////////
function handlepintar_listado_empresas(){
	if(http.readyState == 4) {
		var txt = http.responseText;
		if (txt.substr(0,5) == 'ERROR'){
			alert('Se produjo un error:\n'+txt);
		} else {
			//alert(txt);
			$('contenedor_listado').innerHTML= txt;
			//document.getElementById('contenedor_listado').innerHTML= txt;
		}
	}
}

function pintar_listado_empresas(texto,lang){
	
	//$('cont_error').style.visibility='hidden';
	//$('cont_error').style.display='none';
	
	if(!lang){
    lang="es";
  }
	var ranNum= Math.floor(Math.random()*100000);
	url_envio= 'http://www.grupo-ink.com/listado_clientes.php?pagina='+texto+'&rnd='+ranNum+'&lang='+lang;
	//alert(url_envio);
	http.open('get',url_envio);
	http.onreadystatechange = handlepintar_listado_empresas;
	http.send(null);
}

// PINTO LISTADO DESTACADOS ////////////////////////////////////////////////////////////////////////////////////////////
function handlepintar_listado_destacados(){
	if(http.readyState == 4) {
		var txt = http.responseText;
		if (txt.substr(0,5) == 'ERROR'){
			alert('Se produjo un error:\n'+txt);
		} else {
			//alert(txt);
			$('contenedor_listado').innerHTML= txt;
			//document.getElementById('contenedor_listado').innerHTML= txt;
		}
	}
}

function pintar_listado_destacados(texto,seccion,lang){
	
	//$('cont_error').style.visibility='hidden';
	//$('cont_error').style.display='none';
	
	if(!lang){
    lang="es";
  }
	var ranNum= Math.floor(Math.random()*100000);
	url_envio= 'http://www.grupo-ink.com/listado_destacados.php?pagina='+texto+'&seccion='+seccion+'&rnd='+ranNum+'&lang='+lang;
	//alert(url_envio);
	http.open('get',url_envio);
	http.onreadystatechange = handlepintar_listado_destacados;
	http.send(null);
}

// PINTO LISTADO OTROS ////////////////////////////////////////////////////////////////////////////////////////////
function handlepintar_listado_otros(){
	if(http.readyState == 4) {
		var txt = http.responseText;
		if (txt.substr(0,5) == 'ERROR'){
			alert('Se produjo un error:\n'+txt);
		} else {
			//alert(txt);
			$('contenedor_listado').innerHTML= txt;
			//document.getElementById('contenedor_listado').innerHTML= txt;
		}
	}
}

function pintar_listado_otros(texto,lang){
	
	//$('cont_error').style.visibility='hidden';
	//$('cont_error').style.display='none';
	if(!lang){
    lang="es";
  }
	
	var ranNum= Math.floor(Math.random()*100000);
	url_envio= 'http://www.grupo-ink.com/listado_otros.php?pagina='+texto+'&rnd='+ranNum+'&lang='+lang;
	//alert(url_envio);
	http.open('get',url_envio);
	http.onreadystatechange = handlepintar_listado_otros;
	http.send(null);
}

//Cambio de idioma
function actualizar_permiso(sesion){
  //alert(sesion);
	var ranNum= Math.floor(Math.random()*100000);
	url_envio= 'http://www.grupo-ink.com/funciones_ajax.php?permiso='+sesion+'&rnd='+ranNum;
	//alert(url_envio);
	http.open('get',url_envio);
	http.onreadystatechange = handleactualizar_permiso;
	http.send(null);
}
function handleactualizar_permiso(){
	if(http.readyState == 4) {
		var txt = http.responseText;
		if (txt.substr(0,5) == 'ERROR'){
			alert('Se produjo un error:\n'+txt);
		} else {
			//alert(txt);
			  location.reload(true);
			//alert("se ha actualizado la sesion");
		}
	}
}

/*//RELLENO LOS DATOS DEL FORMULARIO DE LOS TIPOS/////////////////////////////////////////////////////////////////

function handlef_tipos(){
	//alert("f "+http.readyState);
	if(http.readyState == 4) {
		var txt = http.responseText;
		if (txt.substr(0,5) == 'ERROR'){
			alert('Se produjo un error:\n'+txt);
		} else {
			// alert(txt);
			scroll(0,0);
			$('formu_tipos').innerHTML= txt;
		}
	}
}


function f_tipos(cual){
	var ranNum= Math.floor(Math.random()*100000);
	url_envio= './formulario_admin_tipos.php?cual='+cual+'&rnd='+ranNum;
	//alert(url_envio);
	http.open('get',url_envio);
	http.onreadystatechange = handlef_tipos;
	http.send(null);
}

// PINTO EL LISTADO DE LOS TIPOS////////////////////////////////////////////////////////////////////////////////
function handlepintar_tipos(){
	//alert("l "+http.readyState);
	if(http.readyState == 4) {
		var txt = http.responseText;
		if (txt.substr(0,5) == 'ERROR'){
			alert('Se produjo un error:\n'+txt);
		} else {
			//alert(txt);
			$('listar_tipos').innerHTML= txt;
		}
	}
}

function pintar_tipos(){
	var ranNum= Math.floor(Math.random()*100000);
	url_envio= './listado_tipos.php?rnd='+ranNum;
	//alert(url_envio);
	http.open('get',url_envio);
	http.onreadystatechange = handlepintar_tipos;
	http.send(null);
}

//RELLENO LOS DATOS DEL FORMULARIO DE LAS CATEGORIAS/////////////////////////////////////////////////////////////////

function handlef_categorias(){
	//alert("f "+http.readyState);
	if(http.readyState == 4) {
		var txt = http.responseText;
		if (txt.substr(0,5) == 'ERROR'){
			alert('Se produjo un error:\n'+txt);
		} else {
			// alert(txt);
			scroll(0,0);
			$('formu_cate').innerHTML= txt;
		}
	}
}

function f_categorias(cual){
	var ranNum= Math.floor(Math.random()*100000);
	url_envio= './formulario_admin.php?cual='+cual+'&rnd='+ranNum;
	//alert(url_envio);
	http.open('get',url_envio);
	http.onreadystatechange = handlef_categorias;
	http.send(null);
}

// PINTO EL LISTADO DE LAS CATEGORIA ////////////////////////////////////////////////////////////////////////////////
function handlepintar_categorias(){
	//alert("l "+http.readyState);
	if(http.readyState == 4) {
		var txt = http.responseText;
		if (txt.substr(0,5) == 'ERROR'){
			alert('Se produjo un error:\n'+txt);
		} else {
			//alert(txt);
			$('listar_categorias').innerHTML= txt;
		}
	}
}

function pintar_categorias(){
	var ranNum= Math.floor(Math.random()*100000);
	url_envio= './listado_categorias.php?rnd='+ranNum;
	//alert(url_envio);
	http.open('get',url_envio);
	http.onreadystatechange = handlepintar_categorias;
	http.send(null);
}

// PINTO LISTADO EMPRESAS ////////////////////////////////////////////////////////////////////////////////////////////
function handlepintar_listado_empresas(){
	if(http.readyState == 4) {
		var txt = http.responseText;
		if (txt.substr(0,5) == 'ERROR'){
			alert('Se produjo un error:\n'+txt);
		} else {
			//alert(txt);
			$('contenedor_listado').innerHTML= txt;
		}
	}
}

function pintar_listado_empresas(texto){
	$('cont_error').style.visibility='hidden';
	$('cont_error').style.display='none';
	
	
	var ranNum= Math.floor(Math.random()*100000);
	url_envio= './lista_clientes.php?texto='+texto+'&rnd='+ranNum;
	//alert(url_envio);
	http.open('get',url_envio);
	http.onreadystatechange = handlepintar_listado_empresas;
	http.send(null);
}

// PINTO LISTADO PROYECTOS ////////////////////////////////////////////////////////////////////////////////////////////
function handlepintar_listado_proyectos(){
	if(http.readyState == 4) {
		var txt = http.responseText;
		if (txt.substr(0,5) == 'ERROR'){
			alert('Se produjo un error:\n'+txt);
		} else {
			//alert(txt);
			$('contenedor_listado').innerHTML= txt;
		}
	}
}

function pintar_listado_proyectos(texto){
	$('cont_error').style.visibility='hidden';
	$('cont_error').style.display='none';
	
	
	var ranNum= Math.floor(Math.random()*100000);
	url_envio= './lista_proyectos.php?texto='+texto+'&rnd='+ranNum;
	//alert(url_envio);
	http.open('get',url_envio);
	http.onreadystatechange = handlepintar_listado_proyectos;
	http.send(null);
}


// PINTO LISTADO OFERTAS ////////////////////////////////////////////////////////////////////////////////////////////
function handlepintar_listado_ofertas(){
	if(http.readyState == 4) {
		var txt = http.responseText;
		if (txt.substr(0,5) == 'ERROR'){
			alert('Se produjo un error:\n'+txt);
		} else {
			//alert(txt);
			$('contenedor_listado').innerHTML= txt;
		}
	}
}

function pintar_listado_ofertas(texto){
	$('cont_error').style.visibility='hidden';
	$('cont_error').style.display='none';
	
	
	var ranNum= Math.floor(Math.random()*100000);
	url_envio= './lista_ofertas.php?texto='+texto+'&rnd='+ranNum;
	//alert(url_envio);
	http.open('get',url_envio);
	http.onreadystatechange = handlepintar_listado_ofertas;
	http.send(null);
}
*/