
<!--
// devuelve un objeto XMLHttpRequest para varios navegadores
function AJAX() {
	var objetoAjax=false;
	try {
		/*Para navegadores distintos a internet explorer*/
		objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			/*Para explorer*/
			objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (E) {
			objetoAjax = false;
		}
	}

	if (!objetoAjax && typeof XMLHttpRequest!='undefined') {
		objetoAjax = new XMLHttpRequest();
	}
	return objetoAjax;
}

var registrousuario = function(RegUsuario){

	password = document.getElementById('password').value;
	dni = document.getElementById('dni').value;
	chkbH = document.getElementById('chkbH').checked;
	chkbM = document.getElementById('chkbM').checked;
	nombre = document.getElementById('nombre').value.toUpperCase();
	fechanacimiento = document.getElementById('fechanacimiento').value;
	email = document.getElementById('email').value;
	direccion  = document.getElementById('direccion').value.toUpperCase();
	localidad  = document.getElementById('localidad').value.toUpperCase();
	provincia = document.getElementById('provincia').value.toUpperCase();
	pais = document.getElementById('pais').value.toUpperCase();
	codigopostal = document.getElementById('cp').value;
	telefono1 = document.getElementById('telefono1').value;
	telefono2 = document.getElementById('telefono2').value;
	//newsletter = document.getElementById('newsletter').checked;
	apellido1 = document.getElementById('apellido1').value.toUpperCase();
	apellido2 = document.getElementById('apellido2').value.toUpperCase();
	unifamiliar = document.getElementById('unifamiliar').value;

	zona = document.getElementById('zona').value;


	//alert(usuario);
	//codigo = document.getElementById('codigodeseguridad').value;
	//divCodigo = document.getElementById('codigoseguridad');

	var ajax = new AJAX();
	var todoOK = 0;



	if(todoOK == 0){


		//ajax.open("GET","includes/acciones.php?accion=cod&codigo="+codigo,true);
		//ajax.onreadystatechange=function() {
		//if (ajax.readyState==4){
		//if (ajax.status==200){
		//divCodigo.innerHTML = ajax.responseText;
		//	longitud = divCodigo.innerHTML;
		//largo = longitud.length;
		//	if ((largo != 32) && (divCodigo.innerHTML != "Error, No coinciden los digitos!")){
		//						alert(RegUsuario);

		Registros(RegUsuario);
		//	}
		//	}
		//	}
		//}
		ajax.send(null);
	}
}

var Registros = function(RegUsuario){

	divResultado = document.getElementById('formbox');
	divResultado.innerHTML= '<div align="center"><img src="imagenes/animacionajax.gif" /></div>';
	var ajax1 = new AJAX();

	ajax1.open("GET","includes/acciones.php?accion=reg&hombre="+chkbH+"&mujer="+chkbM+"&nombre="+escape(nombre)+"&apellido1="+escape(apellido1)+"&apellido2="+escape(apellido2)+"&fechanacimiento="+escape(fechanacimiento)+"&email="+escape(email)+"&direccion="+escape(direccion)+"&localidad="+escape(localidad)+"&provincia="+escape(provincia)+"&pais="+escape(pais)+"&codigopostal="+escape(codigopostal)+"&telefono1="+escape(telefono1)+"&telefono2="+escape(telefono2)+"&password="+escape(password)+"&dni="+escape(dni)+"&unifamiliar="+escape(unifamiliar)+"&zona="+escape(zona)+"&nocache=" + Math.random(),true);
	ajax1.onreadystatechange=function() {
		if (ajax1.readyState==4) {divResultado.innerHTML = ajax1.responseText; window.scrollTo(0,0);}
	}
	ajax1.send(null);
}

/*Actualizacion de datos*/
var ActualizarRegistro = function(ActualizarUsuario){
	dni = document.getElementById('dni').value; 
	chkbH = document.getElementById('hombre').checked;
	chkbM = document.getElementById('mujer').checked;	
	nombre = document.getElementById('nombre').value.toUpperCase();
	fechanacimiento = document.getElementById('fechanacimiento').value;
	empresa = document.getElementById('empresa').value;	
	direccion = document.getElementById('direccion').value.toUpperCase();
	localidad  = document.getElementById('localidad').value.toUpperCase();	
	provincia = document.getElementById('provincia').value.toUpperCase();
	codigopostal = document.getElementById('codigopostal').value;	
	telefono1 = document.getElementById('telefono1').value;
	telefono2 = document.getElementById('telefono2').value;	newsletter = document.getElementById('newsletter').checked;
	apellido1 = document.getElementById('apellido1').value;	apellido2 = document.getElementById('apellido2').value;

	//alert(usuario);
	var ajax = new AJAX();
	var todoOK = 0;

	if (dni.length == 0){
		alert("Debe de introducir su DNI");
		var todoOK = 1;
	}
	else
	{
		numero = dni.substr(0,dni.length-1);
		let = dni.substr(dni.length-1,1);
		numero = numero % 23;
		letra='TRWAGMYFPDXBNJZSQVHLCKET';
		letra=letra.substring(numero,numero+1);
		if (letra!=let) {
			alert('Su DNI es erroneo');
			document.getElementById('dni').focus();
			var todoOK = 1;
		}
	}

	if (nombre.length == 0){
		alert("Su Nombre esta vacio");
		document.getElementById('nombre').focus();
		var todoOK = 1;
	}



	if (apellido1.length == 0){
		alert("Debe de ingresar su 1er Apellido");
		document.getElementById('apellido1').focus();
		var todoOK = 1;
	}

	if (apellido2.length == 0){
		alert("Debe de ingresar su 2º Apellido");
		document.getElementById('apellido2').focus();
		var todoOK = 1;
	}

	if (direccion.length == 0){
		alert("Dirección vacía");
		document.getElementById('direccion').focus();
		var todoOK = 1;
	}

	if (localidad.length == 0){
		alert("Localidad vacía");
		document.getElementById('localidad').focus();
		var todoOK = 1;
	}

	if (provincia.length == 0){
		alert("Provincia vacía");
		document.getElementById('provincia').focus();
		var todoOK = 1;
	}

	if(todoOK == 0){
		divResultado = document.getElementById('formbox');
		divResultado.innerHTML= '<div align="center"><img src="imagenes/animacionajax.gif" /></div>';
		var ajax = new AJAX();
		ajax.open("GET","includes/acciones.php?accion=upd&hombre="+chkbH+"&mujer="+chkbM+"&nombre="+nombre+"&apellido1="+apellido1+"&apellido2="+apellido2+"&fechanacimiento="+fechanacimiento+"&empresa="+empresa+"&direccion="+direccion+"&localidad="+localidad+"&provincia="+provincia+"&codigopostal="+codigopostal+"&telefono1="+telefono1+"&telefono2="+telefono2+"&newsletter="+newsletter+"&dni="+dni+"&nocache=" + Math.random(),true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {divResultado.innerHTML = ajax.responseText;}
		}
	}
	ajax.send(null)
}

var hacerlogin = function(LoginUsuario){
	var mail = document.getElementById('esmail').value;
	var pass = document.getElementById('passw').value;
	var retorno = true;
	if ((mail.length != 0) && (pass.length != 0)){
		divLogin = document.getElementById('capalogin');
		divLogin.innerHTML= '<div align="center"><br /><br /><br /><br /><img src="imagenes/animacionajax.gif" /></div>';
		var ajax = new AJAX();
		ajax.open("GET","includes/acciones.php?accion=login&mail="+mail+"&pass="+pass,false);
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		ajax.send(null)
		divLogin.innerHTML = ajax.responseText;
		if (ajax.responseText=="Usuario no actualizado"){
			retorno = false;
		}
		//		ajax.onreadystatechange=function() {
		//			if (ajax.readyState == 4){
		//				if (ajax.status==200){
		//					divLogin.innerHTML = ajax.responseText;
		//				}
		//			}
		//		}
		//		divCabeceraNombreUser = document.getElementById('headerbox');
		//		var ajax1 = new AJAX();
		//		//		alert("Mail: "+mail+"     -Pass: "+pass);
		//		ajax1.open("GET","includes/acciones.php?accion=nombre&mail="+mail+"&pass="+pass,true);
		//		ajax1.onreadystatechange=function() {
		//			if (ajax1.readyState == 4){
		//				//divCabeceraNombreUser.innerHTML=ajax1.responseText;
		//				//parent.location=location.href;
		//			}
		//		}
		//		ajax1.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		//		ajax1.send(null)
		//parent.location=location.href;
	}
	else
	{
		alert("compruebe los datos de acceso");
	}

	return retorno;
}

var NuevoPassword = function(){
	divLogin = document.getElementById('capalogin');
	var ajax = new AJAX();
	ajax.open("GET","includes/acciones.php?accion=lost",true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState == 4){divLogin.innerHTML = ajax.responseText;}
	}
	ajax.send(null)
}

var EnviarPass = function(){
	divCapa = document.getElementById('box_registro');
	divCapa.innerHTML="<div id='box_registro' ><form id='cambiocontra' name='cambiocontra'><label>E-mail:</label><br/><input name='mail' type='mail' id='mail' tabindex='1' /><br/>Introduzca el e-mail con el que se registró, y le enviaremos una nueva contraseña.<br /><input id='btnlogin' name='Enviar' type='button' value='Enviar' onclick='CambiarPassEnvio()' class='btinput'/></form><br><br></div>";
}
var CambiarPassEnvio = function(){
	mail = document.getElementById('mail').value;
	if (mail.length > 4){
		divEnvia = document.getElementById('box_registro');
		divEnvia.innerHTML= '<img src="imagenes/animacionajax.gif" />';
		var ajax = new AJAX();
		ajax.open("GET","includes/acciones.php?accion=envio&mail="+mail+"&nocache=" + Math.random(),true);
		ajax.onreadystatechange=function(){
			if (ajax.readyState==4){divEnvia.innerHTML = ajax.responseText;}
		}
		ajax.send(null)
	}
	else
	{
		alert("Introduzca un Email correcto");
	}
}

var Salir = function(){
	divSalir = document.getElementById('capalogin');
	divSalir.innerHTML= '<img src="imagenes/animacionajax.gif" />';
	var ajax = new AJAX();
	ajax.open("GET","logout.php?do=1",true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState == 4){divSalir.innerHTML = ajax.responseText;}
	}
	ajax.send(null)
	divCabeceraNombreUser = document.getElementById('headerbox');
	divSalir.innerHTML= '<div align="center"><br /><br /><br /><br /><img src="imagenes/animacionajax.gif" /></div>';
	var ajax1 = new AJAX();
	//	alert("Mail: "+mail+"     -Pass: "+pass);
	ajax1.open("GET","logout.php?do=2"+"&nocache=" + Math.random(),true);
	ajax1.onreadystatechange=function() {
		if (ajax1.readyState == 4){
			//divCabeceraNombreUser.innerHTML=ajax1.responseText;
		}
	}
	ajax1.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax1.send(null)
	//parent.location=location.href;
}

var CambiarPass = function(){
	var pass1 = document.getElementById('nuevopass1').value;
	var pass2 = document.getElementById('nuevopass2').value;
	//	alert("Pass1 "+pass1+"   Pass2 "+pass2);
	if(pass1==pass2 && pass1.length>=6 && pass2.length>=6){
		divPass = document.getElementById('capanewpass');
		divPass.innerHTML= '<img src="imagenes/animacionajax.gif" />';
		var ajax = new AJAX();
		ajax.open("GET","includes/acciones.php?accion=newpass&pass="+pass1+"&nocache=" + Math.random(),true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState == 4){divPass.innerHTML = ajax.responseText;}
		}
		ajax.send(null)
	}
	else{
		alert("No coinciden los passwords o tienen menos de 6 caracteres");
	}
}


/* Carrito */
var Comprar = function(idarticulo,cantidad,precio,nombre,un_desc,descuento,oferta,cambiaprecio,tienetalla){
	var cadena;
	var pasa=0;
	if(tienetalla=="0"){
		cadena="procesacompra.php?accion=additem&id="+idarticulo+"&cantidad="+cantidad+"&precio="+precio+"&nombre="+nombre+"&un_desc="+un_desc+"&descuento="+descuento+"&oferta="+oferta+"&cambiaprecio="+cambiaprecio+"&talla=&color=";
		pasa=1;
	}
	else if(tienetalla=="1"){
		var talla = document.getElementById(idarticulo).value;
		if(talla=="Seleccione una talla..." || talla.length=="0"){alert("¡ Tiene que seleccionar una talla !");}
		else{
			var color = document.getElementById(talla+"c").value;
			if (color==""){
				color= document.getElementById(talla).value;
			}
			if(color=="Seleccione color..." || color.length=="0"){
				alert("¡ Tiene que seleccionar un color !");
			}
			else{
				pasa=1;
				cadena="procesacompra.php?accion=additem&id="+idarticulo+"&cantidad="+cantidad+"&precio="+precio+"&nombre="+nombre+"&un_desc="+un_desc+"&descuento="+descuento+"&oferta="+oferta+"&cambiaprecio="+cambiaprecio+"&talla="+talla+"&color="+color;
			}
		}
	}
	else if(tienetalla=="2"){
		var color = document.getElementById(idarticulo).value;
		if(color=="Seleccione un color..." || color.length=="0"){alert("¡ Tiene que seleccionar un color !");}
		else{
			cadena="procesacompra.php?accion=additem&id="+idarticulo+"&cantidad="+cantidad+"&precio="+precio+"&nombre="+nombre+"&un_desc="+un_desc+"&descuento="+descuento+"&oferta="+oferta+"&cambiaprecio="+cambiaprecio+"&talla=&color="+color;
		}
	}

	if (pasa==1){
		//		  alert("Cadena: "+cadena+"    Talla: "+talla+"                       Color: "+color);
		//	alert("Articulo ID: "+idarticulo+"    Cantidad: "+cantidad+"   Precio: "+precio+"   nombre :"+nombre);
		//	var idarticulo = document.getElementById('idarticulo').value;
		//	var cantidad = document.getElementById('cantidad').value;
		//	var precio = document.getElementById('idprecio').value;
		//	var nombre = document.getElementById('nombre').value;
		divCompra = document.getElementById('cesta')
		divCompra.innerHTML= '<br /><br /><br />&nbsp;&nbsp;<img src="imagenes/animacionajax.gif" />';
		var ajax = new AJAX();

		ajax.open("GET",cadena,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){divCompra.innerHTML=ajax.responseText;}
			}
		}

		ajax.send(null)
	}
}


var ActualizaPrecios = function(unidades,Id,talla,color){
	//	var cantidad = document.getElementById('cantidad').value;
	var cantidad = unidades.value
	divRecarga = document.getElementById('box_inicio');
	divRecarga.innerHTML= '<img src="imagenes/animacionajax.gif" />';
	var ajax = new AJAX();
	ajax.open("GET","procesacompra.php?accion=actualizar&id="+Id+"&cantidad="+cantidad+"&talla="+talla+"&color="+color,true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState == 4){
			if (ajax.status==200){
				divRecarga.innerHTML = ajax.responseText;
			}
		}
	}
	//	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send(null)
}

var Eliminar = function(Id,talla,color){
	//	var cantidad = document.getElementById('cantidad').value;
	//	var cantidad = unidades.value
	//	alert("ID: "+Id+" Cantidad: "+cantidad);
	divElimina = document.getElementById('box_inicio');
	//	divElimina.innerHTML= '<img src="imagenes/cargando.gif"/>';
	var ajax = new AJAX();
	ajax.open("GET","procesacompra.php?accion=eliminar&id="+Id+"&talla="+talla+"&color="+color+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState == 4){
			if (ajax.status==200){
				divElimina.innerHTML = ajax.responseText;
			}
		}
	}
	//	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send(null)
}

var Vaciar = function(){
	divElimina = document.getElementById('box_inicio');
	divElimina.innerHTML= '<img src="imagenes/animacionajax.gif"/>';
	var ajax = new AJAX();
	ajax.open("GET","procesacompra.php?accion=vaciar"+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState == 4){
			if (ajax.status==200){
				divElimina.innerHTML = ajax.responseText;
			}
		}
	}
	ajax.send(null)
}

/* Zona Admin */
var ADMLogin = function(ALogin){
	var mail = document.getElementById('mail').value;
	var pass = document.getElementById('pass').value;
	divAdmin = document.getElementById('capaadminlogin');
	divAdmin.innerHTML= '<img src="../imagenes/animacionajax.gif" />';
	var ajax = new AJAX();
	ajax.open("GET","../includes/acciones.php?accion=admin&mail="+mail+"&pass="+pass+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState == 4){
			if (ajax.status==200){
				divAdmin.innerHTML = ajax.responseText;
				longitud = divAdmin.innerHTML;
				largo = longitud.length;
				if ((largo == 35) && (divAdmin.innerHTML == "Error, los datos no son correctos!")){
					divAdmin.innerHTML = ajax.responseText;
				}
			}
		}
	}
	ajax.send(null)
}

/* Zona Usuario */
var CargarMenuUsuario = function(cambio){
	divAdmin = document.getElementById('formbox');
	divAdmin.innerHTML= '<img src="../imagenes/animacionajax.gif" />';
	var ajax = new AJAX();
	if(cambio=="CambioPass"){
		ajax.open("GET","cpusuario.php&do=cc",true);
		alert("Cambiamos Password");
	}
	else if(cambio=="DatosPersonales"){
		ajax.open("GET","cpusuario.php&do=vu",true);
		alert("Datos personales");
	}
	else if(cambio=="VerPedido"){
		ajax.open("GET","cpusuario.php&do=vp",true);
		alert("VerPedido");
	}
	ajax.onreadystatechange=function() {
		if (ajax.readyState == 4){
			if (ajax.status==200){
				divAdmin.innerHTML = ajax.responseText;
			}
		}
	}
	ajax.send(null)
}

// Cargamos los Colores del combo
var CargarColores=function(id){
	var reftalla = document.getElementById(id).value;
	//	alert(id+"  "+reftalla);
	divColores = document.getElementById('combo_colores');
	if(reftalla!="Seleccione una talla..."){
		var ajax = new AJAX();
		ajax.open("GET","includes/acciones.php?accion=colores&art="+id+"&talla="+reftalla+"&nocache=" + Math.random(),true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState == 4){
				divColores.innerHTML = ajax.responseText;
			}
		}
		ajax.send(null)
	}
	else{
		divColores.innerHTML ="";
	}
}

var ComprobarCodigoDesc=function(codigo){
	divAdmin=document.getElementById('resulcodigodesc');
	var ajax = new AJAX();
	ajax.open("GET","includes/acciones.php?accion=compcoddesc&codigo="+codigo+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function(){
		if (ajax.readyState == 4){
			if (ajax.status==200){
				divAdmin.innerHTML = ajax.responseText;
			}
		}
	}
	ajax.send(null)
}

/* Cambiar Configuracion */
var mostrandoInput=false;
//	alert("Id: "+id+"  texto: "+texto+"  Opcion: "+opcion);
var CargaDatos = function(id,idi){
	var texto=document.getElementById(idi).value;
	var divError=document.getElementById("error");
	document.getElementById(id).innerHTML=texto;
	DivResultado=document.getElementById(id+"s");
	//$highlight(id+"s");
	DivResultado.innerHTML= 'Grabando... ';
	divError.style.display="none";
	mostrandoInput=false;
	var ajax= new AJAX();
	ajax.open("GET","includes/proceso_configuracion.php?dato="+texto+"&actualizar="+id+"&nocache=" + Math.random(), true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState == 4){
			if (ajax.status==200){
				DivResultado.innerHTML = ajax.responseText;
			}
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send(null)
}

var CambiarConfi = function(id,ids,texto){
	var divError=document.getElementById("error");
	/* Solo mostramos el input si ya no esta siendo mostrado y si ademas el div del error no esta en pantalla */
	if(!mostrandoInput && divError.style.display!="block")
	{
		//alert("Id: "+id+"  Texto: "+texto);
		var DivCambio=document.getElementById(id);
		DivCambio.innerHTML= "<input type='text' onBlur='CargaDatos(\""+id+"\",\""+id+"i\")' value='"+texto+"' id='"+id+"i' name='input' />";
		document.getElementById(id+"i").select();
		mostrandoInput=true;
	}
}





var EliminarCliente = function(cid){

	if(confirm("¿Desea eliminar este cliente?")) {
		$highlight(cid+"c");
		DivResultado=document.getElementById("listado");
		var ajax= new AJAX();
		ajax.open("GET","includes/acciones.php?cid="+cid+"&do=eliminar"+"&nocache=" + Math.random(), true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState == 4){
				if (ajax.status==200){
					DivResultado.innerHTML = ajax.responseText;
				}
			}
		}
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		ajax.send(null)
	}
}

var EliminarPedido = function(cid){

	if(confirm("¿Desea eliminar este pedido?")) {
		$highlight(cid);
		DivResultado=document.getElementById("listado");
		var ajax= new AJAX();
		ajax.open("GET","includes/acciones.php?cid="+cid+"&do=eliminarpedido"+"&nocache=" + Math.random(), true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState == 4){
				if (ajax.status==200){
					DivResultado.innerHTML = ajax.responseText;
				}
			}
		}
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		ajax.send(null)
	}
}


function DatoConfiguracion (Variable,Defecto){
	this.Variable = Variable;
	this.Defecto = Defecto;
	var mivalor = "";
	this.Valor = function(){

		var ajax= new AJAX();
		ajax.open("GET","includes/acciones_configuracion.php?do=variableconfiguracion&variable="+Variable+"&defecto="+Defecto+"&nocache=" + Math.random());
		ajax.onreadystatechange=function() {
			if (ajax.readyState == 4){
				if (ajax.status==200){
					mivalor = ajax.responseText;
					alert(mivalor);
				}
			}
		}
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		ajax.send(null);
		return mivalor;
	};
}



function onlyNumbers(evt)
{
	var e = event || evt; // for trans-browser compatibility
	var charCode = e.which || e.keyCode;

	if (charCode > 31 && (charCode < 48 || charCode > 57))
	return false;

	return true;

}

var ClientesAbrirDatosEnvio = function()
{
	document.getElementById('LiteralDatosEnvio').innerHTML = "Datos de Envio Adicionales (<a onclick='ClientesCerrarDatosEnvio();'>-</a>)";
	document.getElementById('FormularioEnvio').style.display = "block";
}


var ClientesCerrarDatosEnvio = function()
{
	document.getElementById('LiteralDatosEnvio').innerHTML = "Datos de Envio Adicionales (<a onclick='ClientesAbrirDatosEnvio();'>+</a>)";
	document.getElementById('FormularioEnvio').style.display = "none";
}

var ActivarManita = function()
{
	document.getElementById('LiteralDatosEnvio').style.cursor = "hand";
}


var DesactivarManita = function()
{
	document.getElementById('LiteralDatosEnvio').style.cursor = "default";
}

var ClientesHabilitarModoBusqueda = function()
{
	//document.getElementById('btnAceptar').disabled = true;
	document.getElementById('btnModoBusqueda').disabled = true;
	document.getElementById('FechaNacimiento').disabled = true;
	document.getElementById('Hombre').disabled = true;
	document.getElementById('Mujer').disabled = true;
	document.getElementById('TipoVia').disabled = true;
	document.getElementById('Numero').disabled = true;
	document.getElementById('Escalera').disabled = true;
	document.getElementById('Puerta').disabled = true;
	document.getElementById('Portal').disabled = true;
	document.getElementById('Piso').disabled = true;
	document.getElementById('Unifamiliar').disabled = true;
	document.getElementById('Tarifa').disabled = true;
	document.getElementById('Descuento').disabled = true;
	document.getElementById('LiteralDatosEnvio').innerHTML = "<font color='#666666'>Datos de Envio Adicionales</font>";
	document.getElementById('FormularioEnvio').style.display = "none";

}
var ClientesHabilitarModoEdicion = function()
{
	//document.getElementById('btnAceptar').disabled = false;
	document.getElementById('btnModoBusqueda').disabled = false;
	document.getElementById('FechaNacimiento').disabled = false;
	document.getElementById('Hombre').disabled = false;
	document.getElementById('Mujer').disabled = false;
	document.getElementById('TipoVia').disabled = false;
	document.getElementById('Numero').disabled = false;
	document.getElementById('Escalera').disabled = false;
	document.getElementById('Puerta').disabled = false;
	document.getElementById('Portal').disabled = false;
	document.getElementById('Piso').disabled = false;
	document.getElementById('Unifamiliar').disabled = false;
	document.getElementById('Tarifa').disabled = false;
	document.getElementById('Descuento').disabled = false;
	document.getElementById('LiteralDatosEnvio').innerHTML = "Datos de Envio Adicionales (<a onclick='ClientesAbrirDatosEnvio();'>+</a>)";
	document.getElementById('FormularioEnvio').style.display = "none";

}
var ActualizaEstado = function(Id,estado,mostrar,solicitud,confirmacion,enviado){
	var pasa=0;
	if(estado!=3){pasa=1;}
	else if(estado==3){	if(confirm("Si cambias el estado ha ENVIADO, el pedido pasará automáticamente a factura y no se podrá volver a tras. ¿Desea Continuar?")) {pasa=1;	}}
	if(pasa==1){
		if(mostrar==1){
			$highlight(Id);
		}
		DivResultado = document.getElementById('prueba')
		var ajax= new AJAX();
		ajax.open("GET","includes/acciones.php?do=actualizaestado&pid="+Id+"&estado="+estado+"&nocache=" + Math.random(),true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState == 4){
				if (ajax.status==200){
					DivResultado.innerHTML = ajax.responseText;
				}
			}
		}
		ajax.send(null)
	}
	else{

		var pos=0;
		if(solicitud==0 && confirmacion==0 && enviado==0){
			pos=0;
		}
		else if(solicitud==1 && confirmacion==0 && enviado==0){
			pos=1;
		}
		else if(solicitud==1 && confirmacion==1 && enviado==0){
			pos=2;
		}
		else if(solicitud==1 && confirmacion==0 && enviado==1){
			pos=3;
		}
		document.getElementById('estado'+Id).selectedIndex=pos;
		alert("No se ha actualizado el estado!");
	}
}

var AbrirSeccion = function(seccion,boton)
{
	document.getElementById(seccion).style.display = "block";
	miBoton = boton || "";
	if (miBoton != "") {
		BotonOFF(miBoton);
	}
}

function BotonOFF(elBoton){
	document.getElementById(elBoton).disabled=true;
	document.getElementById(elBoton).className="boton_off";

}
function BotonON(elBoton){
	document.getElementById(elBoton).disabled=false;
	document.getElementById(elBoton).className="boton";

}

var CerrarSeccion = function(seccion,boton,funcionlimpiar)
{
	document.getElementById(seccion).style.display = "none";
	miBoton = boton || "";
	if (miBoton != "") {
		BotonON(miBoton);
	}
	funcionlimpiar.call();
}

var EliminarGenerico = function(Tabla,cid,recargar){

	if (PermitirBorrar(Tabla,cid)){
		if(confirm("¿Desea eliminar este elemento?"+"  ("+cid+")")) {
			//		$highlight(cid+"c");
			//		DivResultado=document.getElementById("listado");
			recargar = recargar || "";

			var ajax= new AJAX();
			ajax.open("GET","includes/acciones.php?cid="+cid+"&do=eliminargenerico&tabla="+Tabla+""+"&nocache=" + Math.random(), true);
			ajax.onreadystatechange=function() {
				if (ajax.readyState == 4){
					if (ajax.status==200){
						//DivResultado.innerHTML = ajax.responseText;
						if (recargar != ""){
							location.href="?id="+recargar
						}
					}
				}
			}
			ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			ajax.send(null)
		}
	} else {
		MostrarDivError("Eliminar","No se puede eliminar el registro. Contiene datos asociados");

	}
}

function GuardarImpuestos(recargapagina){
	//donde se mostrará lo resultados

	var recarga = recargapagina || "no" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "new";
	var codigo = "";
	if (document.getElementById('impuestos_btnAceptar').value == "Modificar"){
		codigo = document.getElementById('impuestos_Codigo').value;
		accion = "mod";
	}
	nombre=document.getElementById('impuestos_Nombre').value;
	impuesto=document.getElementById('impuestos_Impuesto').value;

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "impuestos_acciones.php?id="+accion,true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

			if (recarga == "si"){
				location.href="?id=impuestos";
			}
			//llamar a funcion para limpiar los inputs
			LimpiarCamposImpuestos();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Codigo="+escape(codigo)+"&Nombre="+escape(nombre)+"&Impuesto="+escape(impuesto)+"&nocache=" + Math.random())
}
function LimpiarCamposImpuestos(){

	document.getElementById('impuestos_Codigo').value="";
	document.getElementById('impuestos_Nombre').value="";
	document.getElementById('impuestos_Impuesto').value="";
	//document.getElementById('impuestos_Impuesto').focus();
	//document.getElementById('impuestos_Nombre').focus();

}

function GuardarEnvios(recargapagina){
	//donde se mostrará lo resultados

	var recarga = recargapagina || "no" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "new";
	var codigo = "";
	if (document.getElementById('envios_btnAceptar').value == "Modificar"){
		codigo = document.getElementById('envios_Codigo').value;
		accion = "mod";
	}
	nombre=document.getElementById('envios_Nombre').value;
	basecalculo=document.getElementById('envios_BaseCalculo').value;
	precio=document.getElementById('envios_Precio').value;
	transportista=document.getElementById('envios_Transportista').value;

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "envios_acciones.php?id="+accion,true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

			if (recarga == "si"){
				location.href="?id=envios";
			}
			//llamar a funcion para limpiar los inputs
			LimpiarCamposEnvios();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Codigo="+escape(codigo)+"&Nombre="+escape(nombre)+"&BaseCalculo="+escape(basecalculo)+"&Precio="+escape(precio)+"&Transportista="+escape(transportista)+"&nocache=" + Math.random())
}
function LimpiarCamposEnvios(){

	document.getElementById('envios_Codigo').value="";
	document.getElementById('envios_Nombre').value="";
	document.getElementById('envios_BaseCalculo').value="";
	document.getElementById('envios_Precio').value="";
	document.getElementById('envios_Transportista').value="";
	//document.getElementById('impuestos_Impuesto').focus();
	//document.getElementById('impuestos_Nombre').focus();

}

function GuardarTarifas(recargapagina){
	//donde se mostrará lo resultados

	var recarga = recargapagina || "no" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "new";
	var codigo = "";
	if (document.getElementById('tarifas_btnAceptar').value == "Modificar"){
		codigo = document.getElementById('tarifas_Codigo').value;
		accion = "mod";
	}
	nombre=document.getElementById('tarifas_Nombre').value;

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "tarifas_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

			if (recarga == "si"){
				location.href="?id=tarifas";
			}
			//llamar a funcion para limpiar los inputs
			LimpiarCamposTarifas();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Codigo="+escape(codigo)+"&Nombre="+escape(nombre))
}
function LimpiarCamposTarifas(){

	document.getElementById('tarifas_Codigo').value="";
	document.getElementById('tarifas_Nombre').value="";
	//document.getElementById('impuestos_Impuesto').focus();
	//document.getElementById('impuestos_Nombre').focus();

}


function cargaContenidoSelect(idSelect,tabla,valor,texto,multiple,UnoONinguno,TextoValorCero,Contenedor)
{
	// Obtengo la opcion que el usuario selecciono
	var IdContenedor = Contenedor || idSelect ;
	var selectDestino=document.getElementById(IdContenedor);

	// Creo el nuevo objeto AJAX y envio al servidor el ID del select a cargar y la opcion seleccionada del select origen

	var mul = multiple || false ;
	var uno = UnoONinguno || false ;
	var textovalorcero = TextoValorCero || '' ;

	var ajax=AJAX();
	ajax.open("GET", "includes/acciones.php?do=cargarselect&t="+tabla+"&v="+valor+"&x="+texto+"&s="+idSelect+"&m="+mul+"&n="+selectDestino.name+"&u="+uno+"&tvc="+textovalorcero+"&nocache=" + Math.random(), true);
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==1)
		{
			// Mientras carga elimino la opcion "Selecciona Opcion..." y pongo una que dice "Cargando..."
			selectDestino.length=0;
			var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Cargando...";
			selectDestino.appendChild(nuevaOpcion); selectDestino.disabled=true;
		}
		if (ajax.readyState==4)
		{
			selectDestino.parentNode.innerHTML=ajax.responseText;
		}
	}
	ajax.send(null);
}
function cargaContenidoSelectQuery(idSelect,query,valor,texto,multiple,UnoONinguno,TextoValorCero,Contenedor,CampoComprobarSeleccionado,ValorCampoSeleccionado,FuncionOnChange)
{
	// Obtengo la opcion que el usuario selecciono
	var IdContenedor = Contenedor || idSelect ;
	var selectDestino=document.getElementById(IdContenedor);

	// Creo el nuevo objeto AJAX y envio al servidor el ID del select a cargar y la opcion seleccionada del select origen

	var mul = multiple || false ;
	var uno = UnoONinguno || false ;
	var textovalorcero = TextoValorCero || '' ;
	var CampoComprobarSeleccionado = CampoComprobarSeleccionado || '' ;
	var ValorCampoSeleccionado = ValorCampoSeleccionado || '' ;
	var FuncionOnChange = FuncionOnChange || '' ;

	var ajax=AJAX();
	ajax.open("POST", "includes/acciones.php?do=cargarselectquery"+"&nocache=" + Math.random(), true);
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==1)
		{
			// Mientras carga elimino la opcion "Selecciona Opcion..." y pongo una que dice "Cargando..."
			selectDestino.length=0;
			var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Cargando...";
			selectDestino.appendChild(nuevaOpcion); selectDestino.disabled=true;
		}
		if (ajax.readyState==4)
		{
			selectDestino.parentNode.innerHTML=ajax.responseText;
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	ajax.send("q="+escape(query)+"&v="+escape(valor)+"&x="+escape(texto)+"&s="+escape(idSelect)+"&m="+escape(mul)+"&n="+escape(selectDestino.name)+"&u="+escape(uno)+"&tvc="+escape(textovalorcero)+"&CampoComprobarSeleccionado="+escape(CampoComprobarSeleccionado)+"&ValorCampoSeleccionado="+escape(ValorCampoSeleccionado)+"&FuncionOnChange="+escape(FuncionOnChange));
}

function cargaContenidoSelectJoin(idSelect,query,vPrimerValor)
{
	// Obtengo la opcion que el usuario selecciono
	var selectDestino=document.getElementById(idSelect);

	// Creo el nuevo objeto AJAX y envio al servidor el ID del select a cargar y la opcion seleccionada del select origen

	var ajax=AJAX();
	ajax.open("POST", "includes/acciones.php?accion=cargarselectjoin"+"&nocache=" + Math.random(), true);
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==1)
		{
			// Mientras carga elimino la opcion "Selecciona Opcion..." y pongo una que dice "Cargando..."
			selectDestino.length=0;
			//var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Cargando...";
			//selectDestino.appendChild(nuevaOpcion); selectDestino.disabled=false;
		}
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML=ajax.responseText;
		}
	}

	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("q="+escape(query)+"&s="+escape(idSelect)+"&pv="+escape(vPrimerValor)+"&v="+escape('Id')+"&t="+escape('Valor'));
}

function GuardarGruposClientes(recargapagina){
	//donde se mostrará lo resultados

	var recarga = recargapagina || "no" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "new";
	var codigo = "";
	if (document.getElementById('gruposclientes_btnAceptar').value == "Modificar"){
		codigo = document.getElementById('gruposclientes_Codigo').value;
		accion = "mod";
	}
	nombre=document.getElementById('gruposclientes_Nombre').value;
	descuento=document.getElementById('gruposclientes_Descuento').value;
	gastosenvio=document.getElementById('gruposclientes_GastosEnvio').value;

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "gruposclientes_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

			if (recarga == "si"){
				location.href="?id=gruposclientes";
			}
			//llamar a funcion para limpiar los inputs
			LimpiarCamposGruposClientes();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Codigo="+escape(codigo)+"&Nombre="+escape(nombre)+"&Descuento="+escape(descuento)+"&GastosEnvio="+escape(gastosenvio))
}
function LimpiarCamposGruposClientes(){

	document.getElementById('gruposclientes_Codigo').value="";
	document.getElementById('gruposclientes_Nombre').value="";
	document.getElementById('gruposclientes_Descuento').value="";
	document.getElementById('gruposclientes_GastosEnvio').value="";
	//document.getElementById('impuestos_Impuesto').focus();
	//document.getElementById('impuestos_Nombre').focus();

}

function PermitirBorrar(Tabla,Codigo){

	var permite = true;

	switch (Tabla)
	{

		//Impuestos
		case variablePHP('$TablaImpuestos'):
		if (permite == true ){
			permite =(Existe(variablePHP('$TablaZonas'),Codigo,'Impuesto'))? false : true;
		}
		break;
		//Envios
		case variablePHP('$TablaEnvios'):
		if (permite == true ){
			permite =(Existe(variablePHP('$TablaZonas'),Codigo,'GastosEnvio'))? false : true;
		}
		break;
		//Familias
		case variablePHP('$TablaFamilias'):
		if (permite == true ){
			permite =(Existe(variablePHP('$TablaFamilias'),Codigo,'Padre'))? false : true;
		}
		if (permite == true ){
			permite =(Existe(variablePHP('$TablaArticulos'),Codigo,'Familia'))? false : true;
		}
		break;
		//Proveedores
		case variablePHP('$TablaProveedores'):
		if (permite == true ){
			permite =(Existe(variablePHP('$TablaArticulos'),Codigo,'Proveedor'))? false : true;
		}
		break;
		//Tarifas
		case variablePHP('$TablaTarifas'):
		if (permite == true ){
			permite =(Existe(variablePHP('$TablaArticulos'),Codigo,'Tarifa'))? false : true;
		}
		break;
		//Marcas
		case variablePHP('$TablaMarcas'):
		if (permite == true ){
			permite =(Existe(variablePHP('$TablaArticulos'),Codigo,'Marca'))? false : true;
		}
		break;
		//Atajos
		case variablePHP('$TablaAtajos'):
		if (permite == true ){
			permite =(Existe(variablePHP('$TablaArticulos'),Codigo,'Atajo'))? false : true;
		}
		break;


		default :
		permite = true;
	}

	return permite;

}

function Existe(Tabla,cid,Campo,cid1,Campo1){
	var retorno = false;
	var ajax = new AJAX();
	ajax.open("GET","includes/acciones.php?do=existe&t="+Tabla+"&v="+cid+"&c="+Campo+"&v1="+cid1+"&c1="+Campo1+"&nocache=" + Math.random(),false);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send(null)
	if (ajax.responseText=="Si"){
		retorno = true;
	}
	return retorno;
}

function ExisteQuery(Query){

	var retorno = false;
	var ajax = new AJAX();
	ajax.open("POST","includes/acciones.php?do=existequery"+"&nocache=" + Math.random(),false);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("Query="+escape(Query))
	if (ajax.responseText=="Si"){
		retorno = true;
	}
	return retorno;
}

function ExisteRaiz(Tabla,cid,Campo,cid1,Campo1){

	var retorno = false;
	var ajax = new AJAX();
	ajax.open("GET","cpadmin/includes/acciones.php?do=existe&t="+Tabla+"&v="+cid+"&c="+Campo+"&v1="+cid1+"&c1="+Campo1+"&nocache=" + Math.random(),false);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send(null)
	if (ajax.responseText=="Si"){
		retorno = true;
	}
	return retorno;
}
function clsEjecutarRaiz(query){

	var retorno = false;
	var ajax = new AJAX();
	ajax.open("POST","cpadmin/includes/acciones.php?do=ejecutar",false);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("Query="+escape(query))
}

function RetornaValorCampoTabla(tabla,campo,indice,valor){
	var retorno = "";
	var ajax = new AJAX();
	ajax.open("GET","includes/acciones.php?do=retornavalorcampotabla&t="+tabla+"&i="+indice+"&c="+campo+"&v="+valor+"&nocache=" + Math.random(),false);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send(null)
	return ajax.responseText;

}

function RetornaValorCampoTablaRaiz(tabla,campo,indice1,valor1,indice2,valor2,indice3,valor3,indice4,valor4){
	var retorno = "";
	var ajax = new AJAX();
	ajax.open("GET","cpadmin/includes/acciones.php?do=retornavalorcampotablaraiz&t="+tabla+"&c="+campo+"&i1="+indice1+"&v1="+valor1+"&i2="+indice2+"&v2="+valor2+"&i3="+indice3+"&v3="+valor3+"&i4="+indice4+"&v4="+valor4+"&nocache=" + Math.random(),false);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send(null)
	return ajax.responseText;

}

function variablePHP(variable){
	var retorno = "";
	var ajax = new AJAX();
	ajax.open("GET","includes/acciones.php?do=variablePHP&v="+variable,false);

	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send(null)
	return ajax.responseText;
}


function GuardarZonas(recargapagina){
	//donde se mostrará lo resultados



	var recarga = recargapagina || "no" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "new";
	var codigo = "";
	if (document.getElementById('zonas_btnAceptar').value == "Modificar"){
		codigo = document.getElementById('zonas_Codigo').value;
		accion = "mod";
	}


	nombre=document.getElementById('zonas_Nombre').value;

	obj=document.getElementById('zonas_Paises');
	paises = "";
	for(i=0; opt=obj.options[i]; i++){
		if(opt.selected) {
			if (paises!="") {
				paises+="|"
			}
			paises += opt.value
		}
	}


	obj1=document.getElementById('zonas_select_formaspago');
	formaspago = "";
	for(i=0; opt1=obj1.options[i]; i++){
		if(opt1.selected) {
			if (formaspago!="") {
				formaspago+="|"
			}
			formaspago += opt1.value
		}
	}




	obj2=document.getElementById('zonas_select_envios');
	gastosenvio = "";
	for(i=0; opt2=obj2.options[i]; i++){
		if(opt2.selected) {
			if (gastosenvio!="") {
				gastosenvio+="|"
			}
			gastosenvio += opt2.value
		}
	}




	impuesto=document.getElementById('zonas_select_impuesto').value;
	//gastosenvio=document.getElementById('zonas_select_envios').value;
	descuento=document.getElementById('zonas_Descuento').value;
	activa=document.getElementById('zonas_Activa').value;


	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "zonas_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

			if (recarga == "si"){
				ejecutarretrasado("location.href=\"?id=zonas\"",1000);
			}
			//llamar a funcion para limpiar los inputs
			LimpiarCamposZonas();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Codigo="+escape(codigo)+"&Nombre="+escape(nombre)+"&Paises="+escape(paises)+"&Impuesto="+escape(impuesto)+"&GastosEnvio="+escape(gastosenvio)+"&Descuento="+escape(descuento)+"&FormasPago="+escape(formaspago)+"&Activa="+escape(activa))

}
function LimpiarCamposZonas(){

	document.getElementById('zonas_Codigo').value="";
	document.getElementById('zonas_Nombre').value="";
	// document.getElementById('zonas_Paises').value="";
	//	document.getElementById('zonas_select_impuestos').value="";
	//document.getElementById('zonas_select_envios').value="";
	document.getElementById('zonas_Descuento').value="";
	document.getElementById('zonas_Activa').value="";
}


function GuardarFormasPago(recargapagina){
	//donde se mostrará lo resultados

	var recarga = recargapagina || "no" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "new";
	var codigo = "";
	if (document.getElementById('formaspago_btnAceptar').value == "Modificar"){
		codigo = document.getElementById('formaspago_Codigo').value;
		accion = "mod";
	}
	nombre=document.getElementById('formaspago_Nombre').value;
	contrareembolso=document.getElementById('formaspago_Contrareembolso').value;
	pasarela=document.getElementById('formaspago_Pasarela').value;
	texto=document.getElementById('formaspago_Texto').value;
	datospasarela=document.getElementById('formaspago_DatosPasarela').value;
	coste=document.getElementById('formaspago_Coste').value;
	tipocoste=document.getElementById('formaspago_TipoCoste').value;

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "formaspago_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

			if (recarga == "si"){
				ejecutarretrasado("location.href=\"?id=formaspago\"",1000);
			}
			//llamar a funcion para limpiar los inputs
			LimpiarCamposFormasPago();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Codigo="+escape(codigo)+
	"&Nombre="+escape(nombre)+
	"&Contrareembolso="+escape(contrareembolso)+
	"&Pasarela="+escape(pasarela)+
	"&Texto="+escape(texto)+
	"&DatosPasarela="+escape(datospasarela)+
	"&Coste="+escape(coste)+
	"&TipoCoste="+escape(tipocoste)
	)
}
function LimpiarCamposFormasPago(){

	document.getElementById('formaspago_Codigo').value="";
	document.getElementById('formaspago_Nombre').value="";
	document.getElementById('formaspago_Contrareembolso').value="";
	document.getElementById('formaspago_Pasarela').value="";
	document.getElementById('formaspago_Texto').value="";
	document.getElementById('formaspago_DatosPasarela').value="";
	document.getElementById('formaspago_Coste').value="";
	document.getElementById('formaspago_TipoCoste').value="";
	//document.getElementById('impuestos_Impuesto').focus();
	//document.getElementById('impuestos_Nombre').focus();

}


function GuardarFamilias(recargapagina){
	//donde se mostrará lo resultados

	var recarga = recargapagina || "no" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "new";
	var codigo = "";
	if (document.getElementById('familias_btnAceptar').value == "Modificar"){
		codigo = document.getElementById('familias_Codigo').value;
		accion = "mod";
	}
	nombre =  document.getElementById('familias_Nombre').value;
	descripcion =	document.getElementById('familias_Descripcion').value;
	activa = document.getElementById('familias_Activa').value;
	padre = document.getElementById('familias_Padre').value;
	orden = document.getElementById('familias_Orden').value;
	orden = (orden == '') ? '0' : orden ;
	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "familias_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

			if (recarga == "si"){
				ejecutarretrasado("location.href=\"?id=familias\"",1000);
			}
			//llamar a funcion para limpiar los inputs
			LimpiarCamposFamilias();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Codigo="+escape(codigo)+"&Nombre="+escape(nombre)+"&Descripcion="+escape(descripcion)+"&Padre="+escape(padre)+"&Activa="+escape(activa)+"&Orden="+escape(orden) )
}
function LimpiarCamposFamilias(){

	document.getElementById('familias_Codigo').value="";
	document.getElementById('familias_Nombre').value="";
	document.getElementById('familias_Descripcion').value="";
	document.getElementById('familias_Activa').value="";
	document.getElementById('familias_Padre').value="";
	document.getElementById('familias_Orden').value="";
	//document.getElementById('impuestos_Impuesto').focus();
	//document.getElementById('impuestos_Nombre').focus();

}



function ValidarSelectMultiple(obj){

	var hasSelections = false;
	for(var i = 0; i < obj.options.length; i++)
	{
		if(obj.options[i].selected)
		{
			hasSelections = true;
			break;
		}
	}

	if (hasSelections==false){
		//		alert ("Tiene que seleccionar al menos un valor de "+obj.name);
		MostrarDivError("Error en la selección","Tiene que seleccionar al menos un valor de "+obj.name);
	}

	return hasSelections ;

}

function MostrarDivError(Titulo,Mensaje){
	var d = document.getElementById("nodo_opaco");
	if( d != null) {
		document.body.removeChild(d);
	}
	var d = document.getElementById("nodo_error");
	if( d != null) {
		document.body.removeChild(d);
	}

	//Ponemos el div wrap en overlay
	var pagina = document.createElement("div");
	pagina.id = "nodo_opaco";
	pagina.style.display="block";
	pagina.style.position="absolute";
	pagina.style.top="0px";
	pagina.style.left="0px";
	pagina.style.width="100%";
	var altogris = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight;
	var altocapa = document.getElementById("wrap").offsetHeight;
	if (altogris < altocapa){
		altogris = altocapa;
	}
	pagina.style.height=altogris+"px";
	pagina.style.background="#000";
	pagina.style.zindex="1001";
	pagina.style.opacity=".75";
	pagina.style.mozopacity="0.75";
	pagina.style.filter="alpha(opacity=75)";
	pagina.onclick=function () {document.body.removeChild(document.getElementById('nodo_error'));document.body.removeChild(document.getElementById('nodo_opaco'));}
	document.body.appendChild(pagina);



	var nodo = document.createElement("div");

	var width        = window.innerWidth  ? window.innerWidth  : document.documentElement.clientWidth;
	var height       = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight;

	var ancho = 250;
	var alto = 200;

	nodo.id = "nodo_error";
	nodo.style.position="absolute";
	nodo.style.border="1px solid #000";
	nodo.style.padding="0px";
	nodo.style.backgroundColor="#F6EBB1";
	nodo.style.width=ancho+"px";
	nodo.style.height=alto+"px";
	//nodo.style.left="50%";
	//nodo.style.top="50%";
	//nodo.style.marginLeft="-110px";
	//nodo.style.narginTop="-50%";
	nodo.style.visibility="visible";
	nodo.style.overflow="hidden";
	nodo.style.zIndex="1002";

	nodo.style.left = (document.documentElement.scrollLeft+(width -ancho )/2)+'px';
	nodo.style.top  = (document.documentElement.scrollTop +(height-alto)/2)+'px';


	//var x = (window.innerWidth / 2) - (nodo.offsetWidth / 2) ;
	//var y = (window.offsetHeight / 2) - (nodo.offsetHeight / 2)  ;
	//nodo.style.top = y+"px";
	//nodo.style.left = x+"px";
	//nodo.style.marginLeft="-50%";
	//nodo.style.narginTop="-50%";

	nodo.innerHTML = "<div style='width:100%; font-size: 15px; display:block; background-color:#802907 ; color: #fff; ' align='center'>"+Titulo+"</div><div style='padding:5px; height:65%; '>"+Mensaje+"</div></br style=\"clear:left;\"> <span style=\"float:right; padding:5px;\" ><a href=\"javascript:document.getElementById('nodo_opaco').style.display='none';BorrarDivError('"+nodo.id+"');\">Cerrar</a></span>";
	document.body.appendChild(nodo);

}

function BorrarDivError(obj){
	var p = document.getElementById(obj);
	document.body.removeChild(p);
}




function GuardarPaises(recargapagina){
	//donde se mostrará lo resultados

	var recarga = recargapagina || "no" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "new";
	var codigo = "";
	if (document.getElementById('paises_btnAceptar').value == "Modificar"){
		codigo = document.getElementById('paises_Codigo').value;
		accion = "mod";
	}
	nombre =  document.getElementById('paises_Nombre').value;
	idioma =	document.getElementById('paises_Idioma').value;
	zona = document.getElementById('paises_Zona').value;
	idioma = (idioma == '') ? '1' : idioma ;
	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "paises_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

			if (recarga == "si"){
				ejecutarretrasado("location.href=\"?id=paises\"",1000);
			}
			//llamar a funcion para limpiar los inputs
			LimpiarCamposPaises();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Codigo="+escape(codigo)+"&Nombre="+escape(nombre)+"&Idioma="+escape(idioma)+"&Zona="+escape(zona) )
}
function LimpiarCamposPaises(){

	document.getElementById('paises_Codigo').value="";
	document.getElementById('paises_Nombre').value="";
	document.getElementById('paises_Idioma').value="";
	document.getElementById('paises_Zona').value="";
	//document.getElementById('impuestos_Impuesto').focus();
	//document.getElementById('impuestos_Nombre').focus();

}


function GuardarMarcas(recargapagina){
	//donde se mostrará lo resultados

	var recarga = recargapagina || "no" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "new";
	var codigo = "";
	if (document.getElementById('marcas_btnAceptar').value == "Modificar"){
		codigo = document.getElementById('marcas_Codigo').value;
		accion = "mod";
	}
	nombre=document.getElementById('marcas_Nombre').value;

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "marcas_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

			if (recarga == "si"){
				ejecutarretrasado("location.href=\"?id=marcas\"",1000);
			}
			//llamar a funcion para limpiar los inputs
			LimpiarCamposMarcas();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Codigo="+escape(codigo)+"&Nombre="+escape(nombre))
}
function LimpiarCamposMarcas(){

	document.getElementById('marcas_Codigo').value="";
	document.getElementById('marcas_Nombre').value="";
	//document.getElementById('impuestos_Impuesto').focus();
	//document.getElementById('impuestos_Nombre').focus();

}

function GuardarAtajos(recargapagina){
	//donde se mostrará lo resultados

	var recarga = recargapagina || "no" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "new";
	var codigo = "";
	if (document.getElementById('atajos_btnAceptar').value == "Modificar"){
		codigo = document.getElementById('atajos_Codigo').value;
		accion = "mod";
	}
	nombre=document.getElementById('atajos_Nombre').value;

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "atajos_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

			if (recarga == "si"){
				ejecutarretrasado("location.href=\"?id=atajos\"",1000);
			}
			//llamar a funcion para limpiar los inputs
			LimpiarCamposAtajos();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Codigo="+escape(codigo)+"&Nombre="+escape(nombre))
}
function LimpiarCamposAtajos(){

	document.getElementById('atajos_Codigo').value="";
	document.getElementById('atajos_Nombre').value="";
	//document.getElementById('impuestos_Impuesto').focus();
	//document.getElementById('impuestos_Nombre').focus();

}

function Guardaratributos(recargapagina){
	//donde se mostrará lo resultados
	var recarga = recargapagina || "no" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "new";
	var codigo = "";
	if (document.getElementById('atributos_btnAceptar').value == "Modificar"){
		codigo = document.getElementById('atributos_Codigo').value;
		accion = "mod";
	}
	nombre=document.getElementById('atributos_Nombre').value;

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "atributos_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

			if (recarga == "si"){
				ejecutarretrasado("location.href=\"?id=atributos\"",1000);
			}
			//llamar a funcion para limpiar los inputs
			LimpiarCamposAtributos();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Codigo="+escape(codigo)+"&Nombre="+escape(nombre))
}
function LimpiarCamposatributos(){

	document.getElementById('atributos_Codigo').value="";
	document.getElementById('atributos_Nombre').value="";
	//document.getElementById('impuestos_Impuesto').focus();
	//document.getElementById('impuestos_Nombre').focus();

}


function GuardarArticulos(recargapagina){
	//donde se mostrará lo resultados

	var recarga = recargapagina || "no" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "new";
	var codigo = "";
	if (document.getElementById('articulos_btnAceptar').value == "Modificar"){
		codigo = document.getElementById('articulos_Codigo').value;
		accion = "mod";
	}
	nombre	=  document.getElementById('articulos_Nombre').value;
	familia	=  document.getElementById('articulos_Familia').value;
	proveedor	=  document.getElementById('articulos_Proveedor').value;
	tarifa ="";
	//tarifa	=  document.getElementById('articulos_Tarifa').value;
	foto	=  document.getElementById('articulos_Foto').value;
	fotop	=  document.getElementById('articulos_FotoP').value;
	activo	=  document.getElementById('articulos_Activo').value;
	destacado	=  document.getElementById('articulos_Destacado').value;
	home	=  document.getElementById('articulos_Home').value;
	proximamente	=  document.getElementById('articulos_Proximamente').value;
	pack	=  document.getElementById('articulos_Pack').value;
	descripcion	=	document.getElementById('articulos_Descripcion').value;
	marca	=	document.getElementById('articulos_Marca').value;
	atajo	=	document.getElementById('articulos_Atajo').value;
	descuentogeneral	=	document.getElementById('articulos_DescuentoGeneral').value;


	//netscape.security.PrivilegeManager.enablePrivilege("UniversalFileRead");

	imagen = document.getElementById('articulos_FotoFile');


	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "articulos_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

			if (recarga == "si"){
				ejecutarretrasado("location.href=\"?id=articulos\"",1000);
			}
			//llamar a funcion para limpiar los inputs
			LimpiarCamposArticulos();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Codigo="+escape(codigo)+
	"&Nombre="+escape(nombre)+
	"&Familia="+escape(familia)+
	"&Proveedor="+escape(proveedor)+
	"&Tarifa="+escape(tarifa)+
	"&Foto="+escape(foto)+
	"&FotoP="+escape(fotop)+
	"&Activo="+escape(activo)+
	"&Destacado="+escape(destacado)+
	"&Home="+escape(home)+
	"&Proximamente="+escape(proximamente)+
	"&Pack="+escape(pack)+
	"&Descripcion="+escape(descripcion)+
	"&Marca="+escape(marca)+
	"&Atajo="+escape(atajo)+
	"&DescuentoGeneral="+escape(descuentogeneral)+
	"&Imagen="+imagen
	);
}
function LimpiarCamposArticulos(){

	document.getElementById('articulos_Codigo').value='';
	document.getElementById('articulos_Nombre').value='';
	document.getElementById('articulos_Familia').value='';
	document.getElementById('articulos_Proveedor').value='';
	//document.getElementById('articulos_Tarifa').value='';
	document.getElementById('articulos_Foto').value='';
	document.getElementById('articulos_FotoP').value='';
	document.getElementById('articulos_Activo').value='';
	document.getElementById('articulos_Destacado').value='';
	document.getElementById('articulos_Home').value='';
	document.getElementById('articulos_Proximamente').value='';
	document.getElementById('articulos_Pack').value='';
	document.getElementById('articulos_Descripcion').value='';
	document.getElementById('articulos_Marca').value='';
	document.getElementById('articulos_Atajo').value='';
	document.getElementById('articulos_DescuentoGeneral').value='';
	document.getElementById('articulos_Referencia').value='';
	document.getElementById('articulos_FotoFile').value='';
	document.getElementById('articulos_FotoFileP').value='';
	//document.getElementById('impuestos_Impuesto').focus();
	//document.getElementById('impuestos_Nombre').focus();

}


function GuardarPrecios(recargapagina){
	//donde se mostrará lo resultados

	var recarga = recargapagina || "no" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "new";
	var codigo = "";
	if (document.getElementById('precios_btnAceptar').value == "Modificar"){
		accion = "mod";
	}
	articulo=document.getElementById('precios_Articulo').value;
	tarifa=document.getElementById('precios_Tarifa').value;
	precio=document.getElementById('precios_Precio').value;

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "precios_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

			if (recarga == "si"){
				ejecutarretrasado("location.href=\"?id=precios\"",1000);
			}
			//llamar a funcion para limpiar los inputs
			LimpiarCamposPrecios();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Articulo="+escape(articulo)+"&Tarifa="+escape(tarifa)+"&Precio="+escape(precio));
}
function LimpiarCamposPrecios(){

	document.getElementById('precios_Precio').value="";
	document.getElementById('precios_Articulo').value="";
	document.getElementById('precios_Precio').value="";
	document.getElementById('precios_Articulo').selectedIndex=0;
	document.getElementById('precios_Tarifa').selectedIndex=0;
	//document.getElementById('impuestos_Impuesto').focus();
	//document.getElementById('impuestos_Nombre').focus();

}



//Cargar linea cesta
function CargarLineaCesta(articulo,nombre,unidades,precio,descuento,atributo1,atributo2,atributo3,referencia,tipo,articulomaestro,idunicopack){
	//donde se mostrará lo resultados<br>

	divResultado = document.getElementById('resultadoquery');
	divResultado = document.getElementById('boxcesta');
	//valores de los inputs

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "compra_acciones.php?accion=compra"+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			divResultado.innerHTML = ajax.responseText;
		}
	}

	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Articulo="+escape(articulo)+
	"&Nombre="+escape(nombre)+
	"&Unidades="+escape(unidades)+
	"&Precio="+escape(precio)+
	"&Descuento="+escape(descuento)+
	"&Atributo1="+escape(atributo1)+
	"&Atributo2="+escape(atributo2)+
	"&Atributo3="+escape(atributo3)+
	"&Referencia="+escape(referencia)+
	"&Tipo="+escape(tipo)+
	"&ArticuloMaestro="+escape(articulomaestro)+
	"&IdUnicoPack="+escape(idunicopack)
	);

}

// function Modificar Linea Cesta (Unidades)

function ModificarLineaCesta(Linea,Unidades){
	divResultado = document.getElementById('boxcesta');
	//valores de los inputs

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "compra_acciones.php?accion=modificar"+"&nocache=" + Math.random(),false);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			divResultado.innerHTML = ajax.responseText;
		}
	}

	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Linea="+escape(Linea)+
	"&UnidadesNuevas="+escape(Unidades)
	);

}
// function Modificar Linea Cesta (Unidades)

function EliminarLineaCesta(Linea){
	divResultado = document.getElementById('boxcesta');
	//valores de los inputs

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "compra_acciones.php?accion=eliminar"+"&nocache=" + Math.random(),false);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			divResultado.innerHTML = ajax.responseText;
		}
	}

	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Linea="+escape(Linea));

}

function displayMessage(url,ancho,alto)
{

	messageObj.setSource(url);
	messageObj.setCssClassMessageBox(false);
	messageObj.setSize(ancho,alto);
	messageObj.setShadowDivVisible(true);	// Enable shadow for these boxes
	messageObj.display();
}
function displayStaticMessage(messageContent,cssClass,ancho,alto)
{
	messageObj.setHtmlContent(messageContent);
	messageObj.setSize(ancho,alto);
	messageObj.setCssClassMessageBox(cssClass);
	messageObj.setSource(false);	// no html source since we want to use a static message here.
	messageObj.setShadowDivVisible(false);	// Disable shadow for these boxes
	messageObj.display();


}

function closeMessage()
{
	messageObj.close();
}

function CargarPaisesZonas(Id,Destino){
	divResultado = document.getElementById(Destino);
	//valores de los inputs

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "zonas_acciones.php?id=cargapaises"+"&nocache=" + Math.random(),true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.onreadystatechange=function() {
		if (ajax.readyState == 4){
			if (ajax.status==200){
				divResultado.innerHTML = ajax.responseText;
			}
		}
	}
	//enviando los valores
	ajax.send("Codigo="+escape(Id));

}


function CargarValoresAtributos(Id,Destino){
	divResultado = document.getElementById(Destino);
	//valores de los inputs
	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "atributos_acciones.php?id=cargavalores"+"&nocache=" + Math.random(),true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.onreadystatechange=function() {
		if (ajax.readyState == 4){
			if (ajax.status==200){
				divResultado.innerHTML = ajax.responseText;
			}
		}
	}
	//enviando los valores
	ajax.send("Codigo="+escape(Id));

}

function GuardarValoresAtributos(accion,id,atributo,valor,orden){
	//donde se mostrará lo resultados

	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var codigo = "";

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "atributos_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Codigo="+escape(id)+"&Atributo="+escape(atributo)+"&Valor="+escape(valor)+"&Orden="+escape(orden));
}

function CargarVariedadesArticulos(Id,Destino){
	divResultado = document.getElementById(Destino);
	//valores de los inputs

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "articulos_variedades_acciones.php?id=listavariedades"+"&nocache=" + Math.random(),true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.onreadystatechange=function() {
		if (ajax.readyState == 4){
			if (ajax.status==200){
				divResultado.innerHTML = ajax.responseText;
			}
		}
	}
	//enviando los valores
	ajax.send("Codigo="+escape(Id));

}
function CargarPackArticulos(Id,Destino){
	divResultado = document.getElementById(Destino);
	//valores de los inputs

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "articulos_pack_acciones.php?id=lista"+"&nocache=" + Math.random(),true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.onreadystatechange=function() {
		if (ajax.readyState == 4){
			if (ajax.status==200){
				divResultado.innerHTML = ajax.responseText;
			}
		}
	}
	//enviando los valores
	ajax.send("Codigo="+escape(Id));

}


function GuardarAtributosArticulos(Articulo){
	//donde se mostrará lo resultados

	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "altamodificacion";
	atributo1=document.getElementById('articulos_Atributo1').value;
	atributo2=document.getElementById('articulos_Atributo2').value;
	atributo3=document.getElementById('articulos_Atributo3').value;

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php
	ajax.open("POST", "articulos_atributos_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Codigo="+escape(Articulo)+"&Atributo1="+escape(atributo1)+"&Atributo2="+escape(atributo2)+"&Atributo3="+escape(atributo3))
}


function GuardarPackArticulos(){
	//donde se mostrará lo resultados

	//valores de los inputs
	var accion = "guardar";
	//valores de los inputs
	Articulo =	document.getElementById('articulos_pack_articulo').value ;
	Precio =	document.getElementById('articulos_pack_precio').value;
	Dto =		document.getElementById('articulos_pack_descuento').value;

	obj=document.getElementById('articulos_pack_componentes');
	componentes = "";
	for(i=0; opt=obj.options[i]; i++){
		if(opt.selected) {
			if (componentes!="") {
				componentes+="|"
			}
			componentes += opt.value
		}
	}

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "articulos_pack_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send(
	"Articulo="+escape(Articulo)+
	"&Precio="+escape(Precio)+
	"&Dto="+escape(Dto)+
	"&Componentes="+escape(componentes)
	)
}



function GuardarCabeceraPedido(recargapagina){
	//donde se mostrará lo resultados


	var recarga = recargapagina || "no" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "new";
	var codigo = "";
	if (document.getElementById('pedidos_btnAceptar').value == "Modificar"){
		codigo = document.getElementById('pedidos_Codigo').value;
		accion = "mod";
	}

	codigo=document.getElementById('pedidos_Codigo').value;
	cliente=document.getElementById('pedidos_Cliente').value;
	nombre=document.getElementById('pedidos_Nombre').value;
	fecha = document.getElementById('fechapedido').value;
	direccion = document.getElementById('direccion').value;
	localidad = document.getElementById('localidad').value;
	provincia = document.getElementById('provincia').value;
	cp = document.getElementById('cp').value;
	comentario = document.getElementById('pedidos_Comentario').value;
	estado = document.getElementById('cmbEstado').value;
	pagado = document.getElementById('cmbPagado').value;
	tipo = document.getElementById('cmbTipo').value;
	formapago = document.getElementById('zonas_select_formaspago').value;
	formaenvio = document.getElementById('zonas_select_formasenvio').value;


	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "pedidos_acciones.php?id="+accion+"&nocache=" + Math.random(),false);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

			if (recarga == "si"){
				ejecutarretrasado("location.href=\"?id=pedidos\"",1000);
			}
			//llamar a funcion para limpiar los inputs
			//LimpiarCamposZonas();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Codigo="+escape(codigo)+"&Cliente="+escape(cliente)+"&Nombre="+escape(nombre)+"&Direccion="+escape(direccion)+"&Localidad="+escape(localidad)+"&Provincia="+escape(provincia)+"&Cp="+escape(cp)+"&FormaPago="+escape(formapago)+"&Comentario="+escape(comentario)+"&Fecha="+escape(fecha)+"&Estado="+escape(estado)+"&Pagado="+escape(pagado)+"&Tipo="+escape(tipo)+"&Envio="+escape(formaenvio))

}

function LimpiarCampospedidos(){

document.getElementById('pedidos_Codigo').value="";
document.getElementById('pedidos_Cliente').value="";
document.getElementById('pedidos_Nombre').value="";
document.getElementById('fechapedido').value="";
document.getElementById('direccion').value="";
document.getElementById('localidad').value="";
document.getElementById('provincia').value="";
document.getElementById('cp').value="";
document.getElementById('pedidos_Comentario').value="";
document.getElementById('cmbEstado').value="";
document.getElementById('cmbPagado').value="";
document.getElementById('cmbTipo').value="";
document.getElementById('zonas_select_formaspago').value="";
document.getElementById('zonas_select_formasenvio').value="";

	//document.getElementById('impuestos_Impuesto').focus();
	//document.getElementById('impuestos_Nombre').focus();

}

function MarcarEnviadoPedido(id){
	//donde se mostrará lo resultados


	var recarga = "si" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	accion = "marcarenviado";
	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "pedidos_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

			//	if (recarga == "si"){
			ejecutarretrasado("location.href=\"?id=pedidos\"",1000);
			//	}
			//llamar a funcion para limpiar los inputs
			//LimpiarCamposZonas();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Codigo="+escape(id))

}

function MarcarEnProcesoPedido(id){
	//donde se mostrará lo resultados


	var recarga = "si" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	accion = "marcarenproceso";
	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "pedidos_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

			//	if (recarga == "si"){
			ejecutarretrasado("location.href=\"?id=pedidos\"",1000);
			//	}
			//llamar a funcion para limpiar los inputs
			//LimpiarCamposZonas();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Codigo="+escape(id))

}

function MarcarPagadoPedido(id){
	//donde se mostrará lo resultados


	var recarga = "si" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	accion = "pagado";
	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "pedidos_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

			//	if (recarga == "si"){
			ejecutarretrasado("location.href=\"?id=pedidos\"",1000);
			//	}
			//llamar a funcion para limpiar los inputs
			//LimpiarCamposZonas();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Codigo="+escape(id))

}
function EliminarPedidoVenta(id){
	//donde se mostrará lo resultados


	var recarga = "si" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	accion = "eliminarpedido";
	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "pedidos_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

			//	if (recarga == "si"){
			ejecutarretrasado("location.href=\"?id=pedidos\"",1000);
			//	}
			//llamar a funcion para limpiar los inputs
			//LimpiarCamposZonas();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Codigo="+escape(id))

}

function CargarTablaLineasPedido(Id,Destino){
	divResultado = document.getElementById(Destino);
	//valores de los inputs

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "pedidos_acciones.php?id=cargarlineas"+"&nocache=" + Math.random(),true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.onreadystatechange=function() {
		if (ajax.readyState == 4){
			if (ajax.status==200){
				divResultado.innerHTML = ajax.responseText;
			}
		}
	}
	//enviando los valores
	ajax.send("Codigo="+escape(Id));

}

function GuardarLineaPedido(destino){
	//donde se mostrará lo resultados

	var destino = destino || "" ;

	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "modificalinea";
	pedido = document.getElementById('pl_campo_idpedido').value;
	linea = document.getElementById('pl_campo_idlinea').value;
	tipo = document.getElementById('pl_campo_tipo').value;
	idunicopack = document.getElementById('pl_campo_idunicopack').value;
	variedad = document.getElementById('pl_campo_variedad').value;
	refasoc = document.getElementById('pl_campo_refasoc').value;
	unidades = document.getElementById('pl_campo_unidades').value;
	precio = document.getElementById('pl_campo_precio').value;
	descuento = document.getElementById('pl_campo_descuento').value;
	tipoaccion = 			document.getElementById('pl_accion').value ;


	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "pedidos_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("pedido="+escape(pedido)+"&linea="+escape(linea)+"&tipo="+escape(tipo)+"&idunicopack="+escape(idunicopack)+"&unidades="+escape(unidades)+"&precio="+escape(precio)+"&descuento="+escape(descuento)+"&variedad="+escape(variedad)+"&tipoaccion="+escape(tipoaccion)+"&refasoc="+escape(refasoc));
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText
			var ajax1=AJAX();
			var accion = "recalcularpedido";
			ajax1.open("POST", "pedidos_acciones.php?id="+accion,true);
			ajax1.onreadystatechange=function() {
				if (ajax1.readyState==4) {
					//mostrar resultados en esta capa
					//divResultado.innerHTML = ajax.responseText
					if (destino != ""){
						document.getElementById(destino).innerHTML= ajax1.responseText;
					}

					//llamar a funcion para limpiar los inputs
					//LimpiarCamposZonas();
				}
			}
			ajax1.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

			//enviando los valores
			ajax1.send("pedido="+escape(pedido));

			//llamar a funcion para limpiar los inputs
			//LimpiarCamposZonas();
		}
	}

	//enviando los valores



}
function RecalcularPedido(pedido,destino){
	//donde se mostrará lo resultados

	var destino = destino || "" ;

	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "recalcularpedido";


	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "pedidos_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText
			if (destino != ""){
				document.getElementById(destino).innerHTML= ajax.responseText;
			}
			//llamar a funcion para limpiar los inputs
			//LimpiarCamposZonas();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("pedido="+escape(pedido));

}

function ArrayQuery(query){
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php
	var ajax = new AJAX();
	ajax.open("POST","includes/acciones.php?do=arrayquery"+"&nocache=" + Math.random(),false);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("query="+escape(query))
	valor = ajax.responseText;
	obj=new Function('return '+valor)();
	//return valor.split("|");
	return obj;
}
function BorrarLineaPedidoAjax(linea,pedido,destino){
	var destino = destino || "" ;

	//valores de los inputs
	var accion = "borrarlinea";


	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "pedidos_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("pedido="+escape(pedido)+"&linea="+escape(linea));
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText
			var ajax1=AJAX();
			var accion = "recalcularpedido";
			ajax1.open("POST", "pedidos_acciones.php?id="+accion,true);
			ajax1.onreadystatechange=function() {
				if (ajax1.readyState==4) {
					//mostrar resultados en esta capa
					//divResultado.innerHTML = ajax.responseText
					if (destino != ""){
						document.getElementById(destino).innerHTML= ajax1.responseText;
					}

					//llamar a funcion para limpiar los inputs
					//LimpiarCamposZonas();
				}
			}
			ajax1.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

			//enviando los valores
			ajax1.send("pedido="+escape(pedido));

			//llamar a funcion para limpiar los inputs
			//LimpiarCamposZonas();
		}
	}

	//enviando los valores



}
function GuardarClientes(recargapagina){
	//donde se mostrará lo resultados

	var recarga = recargapagina || "no" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "new";
	var codigo = "";
	if (document.getElementById('clientes_btnAceptar').value == "Modificar"){
		codigo = document.getElementById('clientes_codigo').value;
		accion = "mod";
	}

	email=	document.getElementById('clientes_email').value;
	password=	document.getElementById('clientes_password').value;
	nombre=	document.getElementById('clientes_nombre').value.toUpperCase();
	apellido1=	document.getElementById('clientes_apellido1').value.toUpperCase();
	apellido2=	document.getElementById('clientes_apellido2').value.toUpperCase();
	documento=	document.getElementById('clientes_documento').value;
	fechanacimiento=	document.getElementById('clientes_fechanacimiento').value;
	sexo=	document.getElementById('clientes_sexo').value;
	telefono1=	document.getElementById('clientes_telefono1').value;
	telefono2=	document.getElementById('clientes_telefono2').value;
	direccion=	document.getElementById('clientes_direccion').value.toUpperCase();
	unifamiliar=0;
	if (document.getElementById('clientes_unifamiliar').checked){
		unifamiliar=1;
	}
	localidad=	document.getElementById('clientes_localidad').value.toUpperCase();
	provincia=	document.getElementById('clientes_provincia').value.toUpperCase();
	codigopostal=	document.getElementById('clientes_codigopostal').value;
	validado=	document.getElementById('clientes_validado').value;
	zona=	document.getElementById('clientes_zona').value;
	grupo=	document.getElementById('clientes_grupo').value;
	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "clientes_acciones.php?id="+accion+"&nocache=" + Math.random(),false);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText
			if (recarga == "si"){
				ejecutarretrasado("location.href=\"?id=clientes\"",1000);
			}
			//llamar a funcion para limpiar los inputs
			LimpiarCamposClientes();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	//enviando los valores
	ajax.send("Codigo="+escape(codigo)+
	"&email="+escape(email)+
	"&password="+escape(password)+
	"&nombre="+escape(nombre)+
	"&apellido1="+escape(apellido1)+
	"&apellido2="+escape(apellido2)+
	"&documento="+escape(documento)+
	"&fechanacimiento="+escape(fechanacimiento)+
	"&sexo="+escape(sexo)+
	"&telefono1="+escape(telefono1)+
	"&telefono2="+escape(telefono2)+
	"&direccion="+escape(direccion)+
	"&unifamiliar="+escape(unifamiliar)+
	"&localidad="+escape(localidad)+
	"&provincia="+escape(provincia)+
	"&codigopostal="+escape(codigopostal)+
	"&validado="+escape(validado)+
	"&zona="+escape(zona)+
	"&grupo="+escape(grupo)
	);
}
function LimpiarCamposClientes(){

	document.getElementById('clientes_codigo').value="";
	document.getElementById('clientes_email').value="";
	document.getElementById('clientes_password').value="";
	document.getElementById('clientes_password2').value="";
	document.getElementById('clientes_nombre').value="";
	document.getElementById('clientes_apellido1').value="";
	document.getElementById('clientes_apellido2').value="";
	document.getElementById('clientes_documento').value="";
	document.getElementById('clientes_fechanacimiento').value="";
	document.getElementById('clientes_sexo').value="";
	document.getElementById('clientes_telefono1').value="";
	document.getElementById('clientes_telefono2').value="";
	document.getElementById('clientes_direccion').value="";
	document.getElementById('clientes_unifamiliar').value="";
	document.getElementById('clientes_localidad').value="";
	document.getElementById('clientes_provincia').value="";
	document.getElementById('clientes_codigopostal').value="";
	document.getElementById('clientes_validado').value="";
	document.getElementById('clientes_zona').value="";
	document.getElementById('clientes_grupo').value="";

}

function isFile(str){
	var O= AJAX();
	if(!O) return false;
	try
	{
		O.open("HEAD", str, false);
		O.send(null);
		return (O.status==200) ? true : false;
	}
	catch(er)
	{
		return false;
	}
}

function GuardarRecomendados(recargapagina){
	//donde se mostrará lo resultados

	var recarga = recargapagina || "no" ;
	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "new";
	articulo = document.getElementById('recomendados_select_origen').value;
	obj=document.getElementById('recomendados_select_recomendado');
	recomendados = "";
	for(i=0; opt=obj.options[i]; i++){
		if(opt.selected) {
			if (recomendados!="") {
				recomendados+="|"
			}
			recomendados += opt.value
		}
	}

	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "recomendados_acciones.php?id="+accion+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText

			if (recarga == "si"){
				ejecutarretrasado("location.href=\"?id=recomendados\"",1000);
			}
			//llamar a funcion para limpiar los inputs
			LimpiarCamposrecomendados();
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	//enviando los valores
	ajax.send("Articulo="+escape(articulo)+"&Recomendados="+escape(recomendados))
}
function LimpiarCamposrecomendados(){

	document.getElementById('recomendados_Codigo').value="";
	document.getElementById('recomendados_Nombre').value="";
	document.getElementById('recomendados_select_origen').value="";
	document.getElementById('recomendados_select_recomendado').value="";
	//document.getElementById('impuestos_Impuesto').focus();
	//document.getElementById('impuestos_Nombre').focus();

}

function modificarstock(modificaciones){
	//donde se mostrará lo resultados

	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "new";
	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "stock_acciones.php?id=mod"+"&nocache=" + Math.random(),false);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			divResultado.innerHTML = ajax.responseText

			//llamar a funcion para limpiar los inputs
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("Modificaciones="+escape(modificaciones))

	//enviando los valores
}

function ModificarUsuario(){
	//donde se mostrará lo resultados


	divResultado = document.getElementById('resultado');
	//valores de los inputs
	var accion = "propio";
	
	codigo = document.getElementById('codigocliente').value;
	email=	document.getElementById('email').value;
		nombre=	document.getElementById('nombre').value.toUpperCase();
	apellido1=	document.getElementById('apellido1').value.toUpperCase();
	apellido2=	document.getElementById('apellido2').value.toUpperCase();
	documento=	document.getElementById('dni').value;
	fechanacimiento=	document.getElementById('fechanacimiento').value;
	sexo=	document.getElementById('sexo').value;
	telefono1=	document.getElementById('telefono1').value;
	telefono2=	document.getElementById('telefono2').value;
	direccion=	document.getElementById('direccion').value.toUpperCase();
	unifamiliar=0;
	if (document.getElementById('unifamiliar').checked){
		unifamiliar=1;
	}
	localidad=	document.getElementById('localidad').value.toUpperCase();
	provincia=	document.getElementById('provincia').value.toUpperCase();
	codigopostal=	document.getElementById('codigopostal').value;
	//instanciamos el objetoAjax
	var ajax=AJAX();
	//uso del medotod POST
	//archivo que realizará la operacion
	//registro.php

	ajax.open("POST", "./cpadmin/clientes_acciones.php?id="+accion+"&nocache=" + Math.random(),false);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//mostrar resultados en esta capa
			//divResultado.innerHTML = ajax.responseText
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	//enviando los valores
	ajax.send("Codigo="+escape(codigo)+
	"&email="+escape(email)+
	"&nombre="+escape(nombre)+
	"&apellido1="+escape(apellido1)+
	"&apellido2="+escape(apellido2)+
	"&documento="+escape(documento)+
	"&fechanacimiento="+escape(fechanacimiento)+
	"&sexo="+escape(sexo)+
	"&telefono1="+escape(telefono1)+
	"&telefono2="+escape(telefono2)+
	"&direccion="+escape(direccion)+
	"&unifamiliar="+escape(unifamiliar)+
	"&localidad="+escape(localidad)+
	"&provincia="+escape(provincia)+
	"&codigopostal="+escape(codigopostal)
	);
}

function CargarComentarios(id){
	var destino  = document.getElementById('comentarios');
	if(destino){
		var ajax = new AJAX();
		ajax.open("POST","includes/acciones.php?accion=comentarios&nocache=" + Math.random());
		ajax.onreadystatechange=function() {
			if (ajax.readyState == 4){
				destino.innerHTML = ajax.responseText;
			}
		}
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		ajax.send("id="+escape(id))
	}
}

function GuardarComentario(){
	//donde se mostrará lo resultados
	divResultado = document.getElementById('comentarios');
	document.getElementById('submit').disabled=true;
	//valores de los inputs
	articulo=	document.getElementById('articulo').value;
	cliente=	document.getElementById('cliente').value;
	fecha=		document.getElementById('fecha').value
	comentario=	document.getElementById('comentario').value
	if (comentario != '') {
		//instanciamos el objetoAjax
		var ajax=AJAX();
		//uso del medotod POST
		//archivo que realizará la operacion
		//registro.php

		ajax.open("POST","includes/acciones.php?accion=insertacomentarios&nocache=" + Math.random());
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				//mostrar resultados en esta capa
				//divResultado.innerHTML = ajax.responseText
				ejecutarretrasado("CargarComentarios("+articulo+")",1550);
			}
		}
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		//enviando los valores
		ajax.send("articulo="+escape(articulo)+
		"&cliente="+escape(cliente)+
		"&fecha="+escape(fecha)+
		"&comentario="+escape(comentario)
		);
	}
}


//-->>


