// JavaScript Document
function cargar_listado(cat,subcat,pagina){
	//alert(cat + " <<>> "+subcat);
	ajax=objetoAjax();
	ajax.open("POST", "listado_productos.php");
	divi=document.getElementById("contenpro");
	
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("idcate="+cat+"&idsub="+subcat+"&pagina="+pagina);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			dat=ajax.responseText;
			divi.innerHTML=dat;
			
			
		}else{
			divi.innerHTML="<marquee direction='left'>Cargando.... ESPERE UN MOMENTo</marque>";
			
		}
	}

	
}
function cargar_novedad(id){
	//alert(cat + " <<>> "+subcat);
	ajaxa2=objetoAjax();
	ajaxa2.open("POST", "cargar_novedad.php");
	divia2=document.getElementById("contenpro");
	
	ajaxa2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajaxa2.send("idnovedad="+id);
	ajaxa2.onreadystatechange=function() {
		if (ajaxa2.readyState==4) {
			data2=ajaxa2.responseText;
			divia2.innerHTML=data2;
			
			
		}else{
			divia2.innerHTML="<marquee direction='left'>Cargando.... ESPERE UN MOMENTo</marque>";
			
		}
	}

	
}


function limpiar_bus(){
 document.getElementById("btexto").value="";	
}
function buscador(text,pagina){
	ajax2=objetoAjax();
	ajax2.open("POST", "resultado_bus.php");
	divi2=document.getElementById("contenpro");
	var texto=document.getElementById("btexto").value;
	var texto2="";
	if (text==""){
		texto2=texto;	
	}else{
		texto2=text;	
	}
	ajax2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax2.send("texto="+texto2+"&pagina="+pagina);
	ajax2.onreadystatechange=function() {
		if (ajax2.readyState==4) {
			dat2=ajax2.responseText;
			divi2.innerHTML=dat2;
			
			
		}
	}
	
	
}
function limpiar_div(){
	
	document.getElementById("rightcolum").innerHTML="";
}

function cotizar(){
	ajax3=objetoAjax();
	var nombre=document.getElementById("CT_Nombre").value;
	var email=document.getElementById("CT_Email").value;
	var mensaje=document.getElementById("CT_Mensaje").value;
	var img=document.getElementById("CT_imagen").value;
	var nombre_pr=document.getElementById("CT_nombre_pr").value;
	var modelo=document.getElementById("CT_modelo").value;
	var codigo=document.getElementById("CT_codigo").value;
	var destinos="anussbaum@innovaweb.cl,jcohn33@gmail.com,contacto@eurofrenos.cl";
	if (nombre!="" && email!="" && mensaje!=""){
	ajax3.open("POST", "env_contacto.php");
	divi3=document.getElementById("rightcolum");
	//divi3.innerHTML="";
	ajax3.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax3.send("nombre="+nombre+"&email="+email+"&mensaje="+mensaje+"&img="+img+"&nombre_pr="+nombre_pr+"&modelo="+modelo+"&codigo="+codigo+"&destinos="+destinos);
	ajax3.onreadystatechange=function() {
		if (ajax3.readyState==4) {
			dat3=ajax3.responseText;
			divi3.innerHTML=dat3;
			
			
			
		}
	}
	}else{
		alert("Compruebe los campos: 'Recuerde Todos son obligatorios'");	
	}
	
	
}

function enviar(){
	nombre=document.getElementById("nombre").value;
	app=document.getElementById("App").value;
	fono=document.getElementById("fono").value;
	fax=document.getElementById("fax").value;
	email=document.getElementById("email").value;
	comentario=document.getElementById("comentario").value;
	rut=document.getElementById("Rut").value;
	codigo=document.getElementById("tmptxt").value;
	if (nombre!="" && fono!=""  && email!="" && comentario!="" && rut!="" && app!="" && codigo!=""){
		document.form1.submit();
	}else{
		alert("Complete los datos Obligatorios");
	}


}
function ver_mas_dest(codigo,cat,subcate,opcion){
	location.href='productos.php?cod='+codigo+"&categoria="+cat+"&subcate="+subcate+"&opcion="+opcion;	
	
	
}

function activar_desa(valor){
	//var opcion=confirm('\xBFEsta seguro de eliminar la foto?');
	//if(opcion==true){
	//alert(valor);
	ajax=objetoAjax();
	ajax.open("POST", "inactivar_foto.php");
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("id="+valor);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			dat=ajax.responseText;
			//alert(dat);
			location.href="banner.php";
		}
	}
//	}else{
//	     }
}

function nueva_foto(){
	var valorx=document.getElementsByName("archivos[]");
	var i;
	largo=valorx.length;
	//alert(largo);
	for(i = 0; i < largo; i++){
		valorx[i].value="";
	}
	document.getElementById("nueva_foto").style.display="block";
}

function carrar_ventana(){
	document.getElementById("nueva_foto").style.display="none";
}

function eliminar_f(valor){
	//alert(valor);
	var opcion=confirm('\xBFEsta seguro de eliminar la foto?');
	if(opcion==true){
	//alert(valor);
	ajax=objetoAjax();
	ajax.open("POST", "borrar_foto.php");
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("id="+valor);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			dat=ajax.responseText;
		//	alert(dat);
			location.href="banner.php";
		}
	}
	}else{
	     }
}
