function CFamilia(Dia){
	F = document.getElementById("f").value
	
	if (Dia!=0){
		Filtro = "&date="+Dia;
	}
	location.href="novedades.php?id="+F+Filtro
}

function CambiarSF(id){
	SF = document.getElementById("subf").value
	location.href="categoria.php?id="+id+"&sub="+SF
}


function CambiarF(){
	Fabricante = document.getElementById("Fabricantelist").value
	location.href="fabricante.php?fab="+Fabricante
}

//Cambiar de subfamilia en pagina de fabricante.php
function CambiarSub(Fabricante){
	Sub = document.getElementById("sub").value
	document.cookie='FiltroNuevo = a1B8j6op235; expires = 2 Dec 2020 23:59:59 GMT';
	location.href="fabricante.php?fab="+Fabricante+"&sub="+Sub
}

//Cambiar de fabricante en pagina de cateria.php
function CambiarFabri(Familia, SubFamilia){
	Fabricante = document.getElementById("Fabri").value
	Sub = document.getElementById("SubFamilia").value
	
	location.href="categoria.php?id="+Familia+"&sub="+SubFamilia+"&fab="+Fabricante
}

//Cambiar de fabricante en pagina de articulos.php
function CambiarFab(Familia, SubFamilia){
	Fabricante = document.getElementById("Fabri").value
	Sub = document.getElementById("SubFamilia").value
	
	location.href="articulos.php?id="+Familia+"&sub="+SubFamilia+"&fab="+Fabricante
}



function CambiarDia(){
	Dia = document.getElementById("date").value
	
	location.href="novedades.php?date="+Dia
}

function CSubFamilia(Dia){
	Sub = document.getElementById("sub").value
	Fam = document.getElementById("Familia").value
	
	if (Dia!=0){
		Filtro = "&date="+Dia;
	}
	location.href="novedades.php?id="+Fam+"&sub="+Sub+Filtro
}

function CFabricante(Dia){
	Sub = document.getElementById("subfam").value
	Fam = document.getElementById("Familia").value
	Fab = document.getElementById("fab").value
	
	
	if (Dia!=0){
		Filtro = "&date="+Dia;
	}
	location.href="novedades.php?id="+Fam+"&sub="+Sub+"&fab="+Fab+Filtro
}


function Ordenar(Fabricante, Familia, SubFamilia, Ord, Tip, Pag){
	
	Filtro = "&Ord="+Ord+"&Tip="+Tip;
	
	if (SubFamilia != 0){
		Sub = document.getElementById("SubFamilia").value
		location.href=Pag+".php?id="+Familia+"&sub="+SubFamilia+"&fab="+Fabricante+Filtro
	}else{
		location.href=Pag+".php?fab="+Fabricante+Filtro
	}
	
}

function Imprimir(Ref){
	var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=680, height=600, top=150, left=150";
	
	window.open("print.php?ref="+Ref,"",opciones);
}

function PrintList(Fam, Sub, Dia, Fab, Ord, Tip, Pag){
	var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=680, height=600, top=150, left=150";
	
	window.open("printlist.php?id="+Fam+"&sub="+Sub+"&fab="+Fab+"&date="+Dia+"&Ord="+Ord+"&Tip="+Tip+"&Pag="+Pag,"",opciones);
}



//Funcion para agregar nuevos productos al carrito...
// **************************************************

function Addcar(Ref, Valor, Cant){
	
	if (Cant <= 0 ){
		return;
	}else{
		Modalbox.show('classes/addart.php?valor='+Valor+'0&ref='+Ref, {title: 'Art&iacute;culo: '+Ref, width: 600}); 
	}
}

//Funcion para ver los productos al carrito...
// **************************************************

function Vercar(Ref, Valor){
			
	ajax=nuevoAjax();
    ajax.open("GET", "classes/carrito.php?Tipo=nuevo&ref="+Ref+"&valor="+Valor+"&nocahe="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
			Carrito();
        } 
    }
    ajax.send(null);
}


//Funcion para ver ver u ocultar precios...
// **************************************************

function VerP(){
			
	ajax=nuevoAjax();
    ajax.open("GET", "classes/precios.php?Tipo=Mostrar"+"&nocahe="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
			window.location.reload();
        } 
    }
    ajax.send(null);
}

function OcultarP(){
			
	ajax=nuevoAjax();
    ajax.open("GET", "classes/precios.php?Tipo=Ocultar"+"&nocahe="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
			window.location.reload();
        } 
    }
    ajax.send(null);
}

//Funcion para ver ver u ocultar IVA...
// **************************************************

function VerIva(){ //IVA INLCUIDO
			
	ajax=nuevoAjax();
    ajax.open("GET", "classes/iva.php?Tipo=Incluido"+"&nocahe="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
			document.cookie='Novedad = a1B8j6op235; expires = 2 Dec 2020 23:59:59 GMT';
			window.location.reload();
        } 
    }
    ajax.send(null);
}

function OcultarIva(){ //MAS IVA
			
	ajax=nuevoAjax();
    ajax.open("GET", "classes/iva.php?Tipo=NoIncluido"+"&nocahe="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
			window.location.reload();
        } 
    }
    ajax.send(null);
}


//Funcion para ver el carrito...
// **************************************************

function Carrito(){
			
	ajax=nuevoAjax();
    ajax.open("GET", "classes/carrito.php?Tipo=carrito"+"&nocahe="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
			var elm = document.getElementById('carrito')
				elm.innerHTML = ajax.responseText;
        } 
    }
    ajax.send(null);
}


//Funcion para redimencionar la cantidad de articulos...
// **************************************************

function ChangeCar(Item, Cant){
			
	ajax=nuevoAjax();
    ajax.open("GET", "classes/carrito.php?Tipo=borrarart&item="+Item+"&cant="+Cant+"&nocahe="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
			window.location.reload();
        } 
    }
    ajax.send(null);
}


//Funcion para guardar las observaciones del pedido...
// **************************************************

function Save(){
	
	OBS = document.getElementById("Observacion").value
	
	ajax=nuevoAjax();
    ajax.open("GET", "classes/carrito.php?Tipo=OBS&Obs="+OBS+"&nocahe="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
			window.location.reload();
        } 
    }
    ajax.send(null);
}




function  Printcar(){
	//var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, width=800, height=600, top=85, left=140";
	 
	//window.open("carprint.php","Pago",opciones);
	Modalbox.show('classes/shopcart.php', {title: 'Realizar pedido: ', width: 600}); 
}


//Funcion para eliminar un articulo...
// **************************************************

function  Delart(Ref, Art){
	//Modalbox.show('classes/delart.php?ref='+Ref+'&item='+Art, {title: 'Eliminar art&iacute;culo: '+Ref, width: 600}); 
}


function  Delcar(){	
	Modalbox.show('classes/delcart.php', {title: 'Realizar pedido: ', width: 600}); 
}


function  Savecar(){	
	Modalbox.show('classes/savecart.php', {title: 'Salvar carrito: ', width: 600}); 
}


//Funcion para Recibir el formulario de contactenos...
// **************************************************

function Contact(){
	Msj = document.Contacto.Comentario.value;
	
	if (document.Contacto.Usuario.value != 0){
		Modalbox.show('classes/contact.php?Ident=true&Mensaje='+Msj, {title: 'Cont&aacute;ctenos', width: 600});
	}else{
		Nombre = document.Contacto.Nombre.value;
		Correo = document.Contacto.Correo.value;
		Modalbox.show('classes/contact.php?Ident=false&Nombre='+Nombre+'&Correo='+Correo+'&Mensaje='+Msj, {title: 'Cont&aacute;ctenos', width: 600});
	}
	 
}


function GenPdf(Id, Admin){
	if (Admin == "True"){
		AbrirpopUp("../classes/pdf.php?Id="+Id)
	}else{
		AbrirpopUp("classes/pdf.php?Id="+Id)
	}
}













function AbrirpopUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=600,top=150,left=150');");
}


function Index (){
	location.href="index.php"
}

/*
  >>>>>>>> -- Creando objeto AJAX -- <<<<<<<<<<
*/
function nuevoAjax()
{ 
    var xmlhttp=false;
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		try {
	 		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	 	} catch (E) {
	 		xmlhttp = false;
	 	}
	}
	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	 	xmlhttp = new XMLHttpRequest();
	}
		return xmlhttp;
}
	
function cargarContenido(pagina1, nombre){
	 var contenedor;
	 contenedor = document.getElementById(nombre);
	 ajax=nuevoAjax();
	
	 ajax.open("GET", pagina1,true);
	
	ajax.onreadystatechange=function() {
	if (ajax.readyState==4) {
	 contenedor.innerHTML = ajax.responseText
	}
	}
	ajax.send(null)

}

