// BUSCARDOR 



 //declaro mi objeto httpdRequest
var http = getXmlHttpObject();

/*
Este es nuestro manejador de eventos, lo que hace despues de resivir la info en el metodo sendQueryString

Estado del Objeto:
0 = uninitialized
1 = loading
2 = loaded
3 = interactive
4 = complete
*/
function handleHttpResponse() 
{
	if (http.readyState == 0 )
	{
		 results = "Error al Cargar los datos";
		//innerHTML es para llenar el div resultado con info, recuerden javascript es casesensitive (una variable a != A)
		document.getElementById('centro').innerHTML = results;
	}

	if (http.readyState == 1 )
	{
		 results = "Cargando....";
		//innerHTML es para llenar el div resultado con info, recuerden javascript es casesensitive (una variable a != A)
		document.getElementById('centro').innerHTML = results;
	}


	if (http.readyState == 4)
	{
		 results = http.responseText;
		//innerHTML es para llenar el div resultado con info, recuerden javascript es casesensitive (una variable a != A)
		document.getElementById('centro').innerHTML = results;
	}
}

function send()
{

	
	//cojo el elemento search del textbox
		searchV = document.getElementById("buscar").value;

				
	//abre la pagina
    
	http.open("GET", "mostrar_productos.php?buscar=" + searchV, true);

						
																	
	// mando la informacion obtenido a la funcion handelHttpResponse
	http.onreadystatechange = handleHttpResponse;

	//send nada
	http.send(null);

}

function sendQuerystring()
{

	
	//cojo el elemento search del textbox
		searchV = document.getElementById("buscar").value;

				
	//abre la pagina
    
	http.open("GET", "producto_admin.php?buscar=" + searchV, true);

						
																	
	// mando la informacion obtenido a la funcion handelHttpResponse
	http.onreadystatechange = handleHttpResponse;

	//send nada
	http.send(null);

}



function pagvehiculos(pagina)
{

	http.open("GET", "mostrar_productos.php?pagina=" + pagina, true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null);

}

function pagvehiculosadmin(pagina)
{

	http.open("GET", "producto_admin.php?pagina=" + pagina, true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null);

}





// ASEGURADOS
function sendmodvehiculo(valor)
{
 //del=encodeURI(document.getElementById("eliminar").value); 	
 
 http.open("GET","mod_vehiculos.php?cod=" + valor , true);
 http.onreadystatechange = handleHttpResponse;
 http.send(null);  
       
 

}

function sendnewvehiculo()
{
 //del=encodeURI(document.getElementById("eliminar").value); 	
 
 window.open('new_productos.php','window','width=370,height=290 screenX=150,screenY=150');


       
 

}

function ventana(ruta) {
 //window.open('ventana.php?cod='+ruta,'window','width=360,height=340,screenX=150,screenY=150,status=no');
document.getElementById("image").src="productos/"+ruta; 

} 




function savemodvehiculo()
{

 marca=	document.getElementById("marca").value; //del=encodeURI(document.getElementById("eliminar").value); 	
 precio=	document.getElementById("precio").value;
 modelo=	document.getElementById("modelo").value;
 placa= document.getElementById("placa").value;
 color=	document.getElementById("color").value;
 transmision=	document.getElementById("transmision").value;
 vidrios=	document.getElementById("vidrios").value;
 asientos= document.getElementById("asientos").value;
 year= document.getElementById("year").value;
 recorrido= document.getElementById("recorrido").value;
 motor= document.getElementById("motor").value;
 direccion= document.getElementById("direccion").value;
 aire= document.getElementById("aire").value;
 sonido= document.getElementById("sonido").value;
 extra = document.getElementById("extra").value;
  rifh = document.getElementById("rifh").value;
 http.open("POST", "mod_vehiculos.php", true);
 http.onreadystatechange = handleHttpResponse;
 http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
 http.send("rifh="+rifh+"&marca="+marca+"&precio="+precio+"&modelo="+modelo+"&placa="+placa+"&color="+color+"&transmision="+transmision+"&vidrios="+vidrios+"&asientos="+asientos+"&year="+year+"&recorrido="+recorrido+"&motor="+motor+"&direccion="+direccion+"&aire="+aire+"&sonido="+sonido+"&extra="+extra);   
// http.send('nombre='+nombre+'&correo='+correo+'&login='+login+'&clave='+clave+'&nivel='+nivel+'&idusuario='+idusuario);         
 

}

function detallevehiculo(cod) 
{

  window.open("detalle_productos.php?cod=" + cod, true,'window,scrollbars=yes,width=440,height=386,screenX=100,screenY=100');
  //window.open("detalle_carros.php?cod=" + cod, true,'scrollbars=yes','width=650,height=600,screenX=100,screenY=100');
  //http.open("GET","detalle_carros.php?cod=" + cod, true);
 http.onreadystatechange = handleHttpResponse;
 http.send(null);    

}

function volver () {

http.open("GET", "mostrar_productos.php", true); 
 http.onreadystatechange = handleHttpResponse;
 http.send(null);  

}
 
function delvehiculo(eliminar) 
			{
http.open("GET", "producto_admin.php?eliminar="+eliminar, true);
http.onreadystatechange = handleHttpResponse;

http.send(null);   
			
			
			}



/*

*/
function getXmlHttpObject()
{
	var xmlhttp;

	/*@cc_on
	@if (@_jscript_version >= 5)
	try
	{
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
	try
	{
	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch (e)
	{
	xmlhttp = false;
	}
	}
	@else
	xmlhttp = false;
	@end @*/

	if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
	{
		try
		{
			xmlhttp = new XMLHttpRequest();
		}
		catch (e)
		{
			xmlhttp = false;
		}
	}

	return xmlhttp;
}
