//Contacto---------------------------------
function jsLimpiaContacto()
{
	document.getElementById("txtNombre").value=""
	document.getElementById("txtCorreo").value=""
	document.getElementById("txtTelefono").value=""
	document.getElementById("txtMensaje").value=""
	document.getElementById("cboEnvia").value=""
}

function jsSendContacto()
{
	Nombre=trim(document.getElementById("txtNombre").value)
	Correo=trim(document.getElementById("txtCorreo").value)
	Telefono=trim(document.getElementById("txtTelefono").value)
	Mensaje=trim(document.getElementById("txtMensaje").value)
	Envia=document.getElementById("cboEnvia").value	
	if(Nombre!=""&&Correo!=""&&Mensaje!=""&&Envia!="")
	{
		url="Contacto/Envia.php?Nombre="+Nombre+"&Correo="+Correo+"&Telefono="+Telefono+"&Mensaje="+Mensaje+"&Envia="+Envia;
		res=jsJQueryIt(url)
		if(res==1)
		{
			alert("Mensaje Enviado")
			jsLimpiaContacto();
		}
		else
		{
			alert("Ocurrio un error "+res)	
		}
	}
	else
	{
		alert("Estos datos son obligatorios (Nombre,Correo,Mensaje y Enviar a)")	
		$("#txtNombre, #txtCorreo, #txtMensaje, #cboEnvia").each(function(i){if(this.value==""){jsBounceLeft("#"+this.id);}})	
		
	}
}
//APLIACIONES-----------------------------------------------------------------------------------------------------------
/************************************************************************************************************************/
//EQUIVALENCIAS---------------------------------------------------------------------------------
function jsRefreshFabricantessEquivalencia()
{
	obj=document.getElementById("producto");
	if(obj.value!="")
	{
		url="php/RefreshLocal.php?Op=RefreshFabricantesEquivalencias&idtipofiltro="+obj.value;
		$("#divFabricantes").load(url);
		url="php/RefreshLocal.php?Op=RefreshFabricantesCodigosEquivalencias&idtipofiltro="+obj.value;
		$("#divCodigos").load(url);
	}
}

function jsRefreshCodigosEquivalencia()
{
	obj=document.getElementById("fabricante");
	tipofiltro=document.getElementById("producto").value;
	if(obj.value!="")
	{
		url="php/RefreshLocal.php?Op=RefreshCodigosEquivalencias&IdFabricante="+obj.value+"&idtipofiltro="+tipofiltro;
		$("#divCodigos").load(url);
	}
}

function jsBuscaProductoEquivalencias()
{
	IdProducto=document.getElementById("codigo").value
	tipofiltro=document.getElementById("producto").value;
	fabricante=document.getElementById("fabricante").value;
	if(IdProducto!="")
	{
		pageload("Aplicaciones/equivalencia.php|IdP="+IdProducto+"&tipofiltro="+tipofiltro+"&fabricante="+fabricante)
		document.location.href="#Aplicaciones/equivalencia.php|IdP="+IdProducto+"&tipofiltro="+tipofiltro+"&fabricante="+fabricante;
		//$("#capitulo").html("<div style=' text-align:center;' alig='center'><img src='imagenes/cargando.gif' ></div>")
		//$("#capitulo").load(url);
	}
	else
	{	
		alert("debes seleccionar un Numero de producto Joe");
		jsBounceLeft("#codigo");
	}	
}
//NUMERO-------------------------------------------------------------------------------------------------------
function jsRefreshProductosNumero()
{
	obj=document.getElementById("producto");
	
	if(obj.value!="")
	{
		url="php/RefreshLocal.php?Op=RefreshProductoJoe&idtipofiltro="+obj.value;
		$("#divProductos").load(url);
	}
}


function jsBuscaProductoNumero()
{
	IdProducto=document.getElementById("cboProductos").value
	tipofiltro=document.getElementById("producto").value;

	if(IdProducto!="")
	{
		document.location.href="#Aplicaciones/numero.php|IdP="+IdProducto+"&tipofiltro="+tipofiltro;
		pageload("Aplicaciones/numero.php|IdP="+IdProducto+"&tipofiltro="+tipofiltro)
		//$("#capitulo").html("<div style=' text-align:center;' alig='center'><img src='imagenes/cargando.gif' ></div>")
		//$("#capitulo").load(url);
	}
	else
	{	
		alert("debes seleccionar un Numero de producto Joe");
		jsBounceLeft("#cboProductos");
	}
}

//apliaciones---------------------------------------------------------------------------
function jsRefreshApliacionestipo(tipo)
{
		pageload("Aplicaciones/aplicaciones.php|tipo="+tipo)
		document.location.href="#Aplicaciones/aplicaciones.php|tipo="+tipo;
}

function jsRefreshMarcaAplicaciones()
{
	IdMarca=$("#cbomarca").attr("value");
	tipo=$("#htipo").attr("value");
	pageload("Aplicaciones/aplicaciones.php|tipo="+tipo+"&IdMarca="+IdMarca)
	document.location.href="#Aplicaciones/aplicaciones.php|tipo="+tipo+"&IdMarca="+IdMarca;
	//alert(IdMarca)
}

function jsRefreshModeloAplicaciones()
{
	IdMarca=$("#cbomarca").attr("value");
	tipo=$("#htipo").attr("value");
	IdModelo=$("#cbomodelo").attr("value");
	pageload("Aplicaciones/aplicaciones.php|tipo="+tipo+"&IdMarca="+IdMarca+"&IdModelo="+IdModelo)
	document.location.href="#Aplicaciones/aplicaciones.php|tipo="+tipo+"&IdMarca="+IdMarca+"&IdModelo="+IdModelo;
	
}


function jsRefreshAnoAplicaciones()
{
	IdMarca=$("#cbomarca").attr("value");
	tipo=$("#htipo").attr("value");
	IdModelo=$("#cbomodelo").attr("value");
	Ano=$("#cboano").attr("value");
	pageload("Aplicaciones/aplicaciones.php|tipo="+tipo+"&IdMarca="+IdMarca+"&IdModelo="+IdModelo+"&ANO="+Ano)
	document.location.href="#Aplicaciones/aplicaciones.php|tipo="+tipo+"&IdMarca="+IdMarca+"&IdModelo="+IdModelo+"&ANO="+Ano;
	
}

function jsBuscaProductosAplicacion()
{
	IdMarca=$("#cbomarca").attr("value");
	tipo=$("#htipo").attr("value");
	IdMotor=trim($("#cbomotor").attr("value"));
	IdModelo=$("#cbomodelo").attr("value");
	Ano=$("#cboano").attr("value");
	pageload("Aplicaciones/aplicaciones.php|tipo="+tipo+"&IdMarca="+IdMarca+"&IdModelo="+IdModelo+"&IdMotor="+IdMotor+"&ANO="+Ano+"&consulta=1")
	document.location.href="#Aplicaciones/aplicaciones.php|tipo="+tipo+"&IdMarca="+IdMarca+"&IdModelo="+IdModelo+"&IdMotor="+IdMotor+"&ANO="+Ano+"&consulta=1";
	
}

function jsgetFotoAplicacion(Foto,objeto,evento)
{
	//verificar foto	
	//scrollIntoView(true)
	url="php/RefreshLocal.php?Op=VerificaFotoAplicacion&Foto="+Foto
	res=jsJQueryIt(url)
	if(res==0||Foto=="")
		Foto="NoDisponible.gif";
	
		//se crea el div
		
		//seevalua si es mocosoft
		posicionscroll=$(document).scrollTop()
		if(navigator.appName.indexOf("Microsoft")!=-1)
		{
		
			y=posicionscroll+posicionMouse(evento,'y')+"px"
		}
		else
				y=posicionMouse(evento,'y')+"px"
				
		x=posicionMouse(evento,'x')+"px"

		//creamos un div para mostrar la imagen
		div = document.createElement('DIV');
		div.style.top = y;
		div.style.left= x;
		div.id="imgEncima"
		div.style.zIndex="32000";
		div.style.position="absolute";
		div.style.backgroundColor="#fff"
		div.className="divtemporalimagen"
		//div.style.border="1px solid"
		div.innerHTML="<img width='350' src='Fotos/"+Foto+"'>"
		$("body").append(div);
	
}
//Referencia Cruzada-------------------------------------------------------
function jsBuscaProductoReferencia()
{
	Codigo=trim($("#txtparte1").attr("value"));
	if(Codigo!="")
	{
		Codigo=Codigo.replace(" ","@@@");
		//alert(Codigo)
		document.location.href="#Aplicaciones/referencia.php|codigo="+Codigo;
		pageload("Aplicaciones/referencia.php|codigo="+Codigo)
	}
}

//carrito------------------
function jsAddCar(ID)
{

	Cantidad=trim($("#txtCantidadCarrito").attr("value"));
	//alert(ID);
	if(Cantidad!=""&&Cantidad.indexOf("0")!=0)
	{
		//Observaciones=trim($("#txtObservaciones").attr("value"));
		url="php/CART.php?Op=AddProductoCart&ID="+ID+"&Cant="+Cantidad;
		res=jsJQueryIt(url);
		if(res==1)
		{
			alert("se agrego al carrito con exito");
			tb_remove();
			$("#txtCantidadCarrito").attr("value","")
		}
		else
		{
			alert("Ocurrio un error "+res);	
		}
	}
	else
	{
		jsBounceLeft("#txtCantidadCarrito");
		alert("Debes capturar una cantidad");
	}
}

function jsOpenListCart()
{
	url="Aplicaciones/ListCart.php?width=800&height=500";
	tb_show("Carrito de Compras",url)
}

function jsShowImg(Imagen)
{
	//Muestra una imagen del listado de el carrito
	//verificar si existe foto----------------------------
	url="php/CART.php?Op=VerificaFoto&Imagen="+Imagen;
	res=jsJQueryIt(url);
	
	if(res!=1)
		Imagen="Nodisponible.jpg";
		
	//x=getDimensions(objeto).x;	
	//y=getDimensions(objeto).y;

	//----------------------------------------------------
	
	x="280px";
	y="101px"
	//creamos un div para mostrar la imagen
	div = document.createElement('DIV');
 	div.style.top = y;
	div.style.left= x;
	div.id="imgEncima"
	div.style.zIndex="32000";
	div.style.position="absolute";
	div.style.backgroundColor="#fff"
	//div.style.border="1px solid"
	div.innerHTML="<img width='350' src='Fotos/"+Imagen+"'>"
  	$("body").append(div);
	//document.getElementById("document").appendChild(div); 
	
}

function jsRemoveImg()
{
  $("#imgEncima").remove();
}

function jsRemoveArticuloCart(codigo,num)
{
	if(confirm("Estas seguro de querer eliminar este articulo: "+codigo))	
	{
		url="php/CART.php?Op=RemoveArticulo&num="+num;
		res=jsJQueryIt(url);
		if(res==1)
		{
		 	alert("articulo Eliminado");
			//tb_remove();
			jsOpenListCart()
		}
		else
		{
			alert("Ocurrio un Error "+res);	
		}
	}
	else
	 return false;
	
}

function jsSendPedidoCart()
{
	//envia al correo el pedido
	
	NombrePedido=$("#txtCartNombre").attr("value");
	Ciudad=$("#txtCartCiudad").attr("value");
	Estado=$("#txtCartEstado").attr("value");
	Telefono=$("#txtCartTel").attr("value");
	Mail=$("#txtCartMail").attr("value");
	if(NombrePedido!=""&&Ciudad!=""&&Estado!=""&&Telefono!=""&&Mail!="")
	{
		if(!jsEvaluaEmail(Mail))
		{
			jsBounceLeft("#txtCartMail")
			return false;
		}
		
		Comentarios=$("#txtComentarios").attr("value");
		
		url="php/CART.php?Op=EnviaPedido&NombrePedido="+NombrePedido+"&Ciudad="+Ciudad+"&Estado="+Estado+"&Telefono="+Telefono
		url+="&Mail="+Mail+"&Comentarios="+Comentarios;
		res=jsJQueryIt(url)
		if(res==1)
		{
			alert("Pedido Enviado");
			r=jsJQueryIt("php/CART.php?Op=BorraPedidoEnviado")
			
			tb_remove();
		}
		else
		{
			alert("Ocurrio un Error "+res);	
		}
	}
	else
	{
		$("#tableSendCart input:text").each(function(){
														 if(this.value=="")
														 {
															cadena="#"+this.id
															jsBounceLeft(cadena); 
															return false
														 }
													 })
	}
}

//utilidades------------------------------------------------------
function jsOpenAutos(Codigo)
{
	Codigo=Codigo.replace(" ","@@");
	url="Aplicaciones/autos.php?codigo="+Codigo+"&height=500&width=500&modal=''";
	tb_show("",url,null)	
}


function jsShowHideCatalogo()
{

	if(document.getElementById("ulCatalogo").style.display=="none")
		$("#ulCatalogo").show();
	else
		$("#ulCatalogo").hide();
}

function jsPonecolorMenu(m)
{
	document.getElementById("mInicio").className="alink"
	document.getElementById("mEmpresa").className="alink"
	document.getElementById("mCatalogo").className="alink"
	document.getElementById("mContactanos").className="alink"
	document.getElementById("mFiltros").className="alink"
	document.getElementById("mQuimicos").className="alink"
	
	document.getElementById(m).className="active"
}

function jsPoneImagen(op)
{
	if(op==1)
	{
		document.getElementById("divImagenes").className="decorativo-1"
		document.getElementById("imgImagenes").src="imagenes/filtro-7.png"
		document.getElementById("imgImagenes").style.width="346px";
		document.getElementById("imgImagenes").style.height="180px";
		document.getElementById("imgImagenes").alt="comercializacion de filtros";
		return false
	}
	if(op==2)
	{
		document.getElementById("divImagenes").className="decorativo-2"
		document.getElementById("imgImagenes").src="imagenes/filtro-9.png";
		document.getElementById("imgImagenes").style.width="392px";
		document.getElementById("imgImagenes").style.height="180px";
		document.getElementById("imgImagenes").alt="variedad de filtros";
			return false
	}
	if(op==3)
	{
		document.getElementById("divImagenes").className="decorativo-1"
		document.getElementById("imgImagenes").src="imagenes/filtro-1.png";
		document.getElementById("imgImagenes").style.width="327px";
		document.getElementById("imgImagenes").style.height="180px";
		document.getElementById("imgImagenes").alt="todo tipo de filtro";
			return false
	}
	if(op==4)
	{
		document.getElementById("divImagenes").className="decorativo-2"
		document.getElementById("imgImagenes").src="imagenes/filtro-5.png";
		document.getElementById("imgImagenes").style.width="403px";
		document.getElementById("imgImagenes").style.height="180px";
		document.getElementById("imgImagenes").alt="filtros para aire";
			return false
	}
	if(op==5)
	{
		document.getElementById("divImagenes").className="decorativo-3"
		document.getElementById("imgImagenes").src="imagenes/filtro-7.png";
		document.getElementById("imgImagenes").style.width="371px";
		document.getElementById("imgImagenes").style.height="175px";
		document.getElementById("imgImagenes").alt="filtros automotrices y servicio pesado";
			return false
	}
	if(op==6)
	{
		document.getElementById("divImagenes").className="decorativo-2"
		document.getElementById("imgImagenes").src="imagenes/filtro-6.png";
		document.getElementById("imgImagenes").style.width="279px";
		document.getElementById("imgImagenes").style.height="180px";
		document.getElementById("imgImagenes").alt="filtro para aceite";
			return false
	}
	if(op==7)
	{
		document.getElementById("divImagenes").className="decorativo-1"
		document.getElementById("imgImagenes").src="imagenes/filtro-8.png";
		document.getElementById("imgImagenes").style.width="266px";
		document.getElementById("imgImagenes").style.height="180px";
		document.getElementById("imgImagenes").alt="filtro industrial";
			return false
	}
}


