function nuevoAjax()
{ 
	var xmlhttp=false; 
	try 
	{ 
		// Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e)
	{ 
		try
		{ 
			// Creacion del objet AJAX para IE 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) 
		{ 
			xmlhttp=false; 
		}
	}
	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); } 
	return xmlhttp; 
}

function cargaModelos(marca, id_select)
{
	ajax=nuevoAjax();
	ajax.open("GET","../php/carga_modelos.php?marca="+marca+"&id_select="+id_select, true);
	
	ajax.onreadystatechange = function() 
	{ 
		if (ajax.readyState==1)
		{ 
			document.getElementById('div_modelo').innerHTML = "<select id='"+id_select+"'><option value='0'>Cargando...</option></select>";
			document.getElementById(id_select).disabled = 'disabled';
		} 
		if (ajax.readyState==4)
		{ 
			if(ajax.status==200)
            {
				document.getElementById('div_modelo').innerHTML = ajax.responseText;
			}
		} 
	}
	ajax.send(null);
}

function cargaCiudades_(estado)
{
	ajax=nuevoAjax();
	ajax.open("GET","../php/car_ciudades_2.php?estado="+estado, true);
	
	ajax.onreadystatechange = function() 
	{ 
		if (ajax.readyState==1)
		{ 
			document.getElementById('div_ciudad').innerHTML = "<select id='ciudad_2'><option value='0'>Cargando...</option></select>";
			document.getElementById('ciudad_2').disabled = 'disabled';
		} 
		if (ajax.readyState==4)
		{ 
			if(ajax.status==200)
            {
				document.getElementById('div_ciudad').innerHTML = ajax.responseText;
			}
		} 
	}
	ajax.send(null);
}

function cargaCiudades(estado)
{
	ajax=nuevoAjax();
	ajax.open("GET","../php/carga_ciudades.php?estado="+estado, true);
	
	ajax.onreadystatechange = function() 
	{ 
		if (ajax.readyState==1)
		{ 
			document.getElementById('div_ciudad').innerHTML = "<select id='ciudad'><option value='0'>Cargando...</option></select>";
			document.getElementById('ciudad').disabled = 'disabled';
		} 
		if (ajax.readyState==4)
		{ 
			if(ajax.status==200)
            {
				document.getElementById('div_ciudad').innerHTML = ajax.responseText;
			}
		} 
	}
	ajax.send(null);
}


function contacto_cargaciudades(estado)
{
	ajax=nuevoAjax();
	ajax.open("GET","../anunciate/php/contacto_ciudades.php?estado="+estado, true);
	
	ajax.onreadystatechange = function() 
	{ 
		if (ajax.readyState==1)
		{ 
			document.getElementById('div_ciudad').innerHTML = "<select id='ciudad-2' name='ciudad'><option value='0'>Cargando...</option></select>";
			document.getElementById('ciudad-2').disabled = 'disabled';
		} 
		if (ajax.readyState==4)
		{ 
			if(ajax.status==200)
            {
				document.getElementById('div_ciudad').innerHTML = ajax.responseText;
			}
		} 
	}
	ajax.send(null);
}


function cargaImagen(imagen, nombre)
{
	var cargador;
	cargador = "../template/img/ajax-loader.gif";  
	ajax=nuevoAjax();
	
	//ENVIAR POST POR AJAX-------------------------------------------------------------------------
	//ajax.open("POST", "archivo.php",true);
	//ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    //ajax.send("imagen="+imagen);
    //---------------------------------------------------------------------------------------------
	
    ajax.open("GET", imagen,true);
	   
	ajax.onreadystatechange = function() 
	{ 
		if (ajax.readyState==1 )
		{ 
			document.getElementById('imagen').innerHTML = "<div align='center' class='cargador'>&nbsp;&nbsp;<img src='"+cargador+"' height='32' width='32' border='' align='' alt='Cargando' /><br/>&nbsp;&nbsp;Cargando...</div>";
		} 
		if (ajax.readyState==4)
		{ 
			if(ajax.status==200)
            {
				document.getElementById('imagen').innerHTML = "<img src='"+imagen+"' height='87' width='117' border='' align='' alt='"+nombre+"' />";
			}
		} 
	}
	ajax.send(null);
}