function cargarPaginaProducto(url) 
{

  if(url=='')
  {
    return;
  }
  	
  conexion2=crearXMLHttpRequest();
  conexion2.onreadystatechange = procesarEventosProducto;
  conexion2.open("GET", url, true);
  conexion2.send(null);
}
function cargarPaginaAlbaran(url) 
{

  if(url=='')
  {
    return;
  }
  	
  conexion2=crearXMLHttpRequest();
  conexion2.onreadystatechange = procesarEventosAlbaran;
  conexion2.open("GET", url, true);
  conexion2.send(null);
}

function presionEnlaceAlbaran(e)
{
  if (window.event)
  {
    window.event.returnValue=false;
	
    var url=window.event.srcElement.getAttribute('href');
   }
  else
    if (e)
    {
      e.preventDefault();
      var url=e.target.getAttribute('href');
    } 
	
		   cargarPaginaAlbaran(url);  
}

function presionEnlaceProducto(e)
{
  if (window.event)
  {
    window.event.returnValue=false;
	
    var url=window.event.srcElement.getAttribute('href');
   }
  else
    if (e)
    {
      e.preventDefault();
      var url=e.target.getAttribute('href');
    } 
	
		   cargarPaginaProducto(url);  
}


function enviardatos(e)
{
   if (window.event)
   {
    window.event.returnValue=false;
   }
  else
    if (e)
	{
	   e.preventDefault(); 
	}
  enviarFormulario();
}

function enviardatos1(e)
{
   if (window.event)
   {
    window.event.returnValue=false;
   }
  else
    if (e)
	{
    e.preventDefault();
	}
 enviarFormulario1();

}






function formularioforo(e)
{
 	var enlace;
  if (window.event)
  {
	enlace=window.event.srcElement;
	window.event.returnValue=false;
	
 }
	else
    if (e)
     {
	 enlace=e.target;
	  e.preventDefault();
	 }
	 
 
 var autor=document.getElementById('autorpreguntaid').value;
 var temapreguntap=document.getElementById('temapreguntaid').value;
 var texto=document.getElementById('textopreguntaid').value;
 var temasp=document.getElementById('temasid').value;
 

 if (autor=='' || temapreguntap=='' || texto=='')
 {
	 alert ("tienes que rellenar todos los campos");
 }
 else
 {
	conexionEnviarPregunta(autor,temapreguntap,texto,temasp);
 }

}

function conexionEnviarPregunta(autor,temapreguntap,texto,temasp)
{
		
	conexion1=crearXMLHttpRequest();
	  conexion1.onreadystatechange = procesarEventos;
	  url='nuevapreguntaformulario.php';
	  conexion1.open('POST',url, true);
		conexion1.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		conexion1.send(retornarEnviarforo(autor,temapreguntap,texto,temasp)); 	
}


function retornarEnviarforo(autor,temapreguntap,texto,temasp)
{

  var cad='';
 autor=verificarcaracteres(autor);
 temapreguntap=verificarcaracteres(temapreguntap);
 texto=verificarcaracteres(texto);
 temasp=verificarcaracteres(temasp);
 

  cad='autorpregunta='+encodeURIComponent(autor)+'&temapregunta='+encodeURIComponent(temapreguntap)+'&textopregunta='+encodeURIComponent(texto)+'&temas='+encodeURIComponent(temasp);

  return cad;
}


function formularioforoRespuesta(e)
{
 	var enlace;
  if (window.event)
  {
	enlace=window.event.srcElement;
	window.event.returnValue=false;
	
 }
	else
    if (e)
     {
	 enlace=e.target;
	  e.preventDefault();
	 }
	 
 
 var autor=document.getElementById('autorpreguntaid').value;
 var temapreguntap=document.getElementById('temapreguntaid').value;
 var texto=document.getElementById('textopreguntaid').value;
 var temasp=document.getElementById('temasid').value;
 

 if (autor=='' || temapreguntap=='' || texto=='')
 {
	 alert ("tienes que rellenar todos los campos");
 }
 else
 {
	conexionEnviarRespuesta(autor,temapreguntap,texto,temasp);
 }

}

function conexionEnviarRespuesta(autor,temapreguntap,texto,temasp)
{
		
	conexion1=crearXMLHttpRequest();
	  conexion1.onreadystatechange = procesarEventos;
	  url='nuevarespuestaformulario.php';
	  conexion1.open('POST',url, true);
		conexion1.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		conexion1.send(retornarEnviarforo(autor,temapreguntap,texto,temasp)); 	
}









function formularioEnviarPedido(e)
{
	var enlace;
  if (window.event)
  {
	 
  
	enlace=window.event.srcElement; 
	window.event.returnValue=false;
 }
	else
    if (e)
     {
	 enlace=e.target;
	  e.preventDefault();
	 }
	 
 
 var nome=document.getElementById('nidenviar').value;
 var tipo=document.getElementById('tipoviaenviar').value;
 var dire=document.getElementById('direccionidenviar').value;
 
 var nev=document.getElementById('numeroidenviar').value;
   var pev=document.getElementById('pisoidenviar').value;
   var puev=document.getElementById('puertaidenviar').value;
   var eev=document.getElementById('escaleraidenviar').value;
   
	var cpe=document.getElementById('codigopostalidenviar').value;
   var pbe=document.getElementById('poblacionidenviar').value;
   var pve=document.getElementById('provinciaidenviar').value;
    var tfe=document.getElementById('telefonoidenviar').value;
      var emaile=document.getElementById('emailidenviar').value;
	   var obs=document.getElementById('observacionesenviar').value;

 if (nome=='' || dire=='' || cpe=='' || pbe=='' || pve=='' || tfe=='' || emaile=='')
 {
	 alert ("tienes que rellenar todos los campos");
 }
 else
 {
	 if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emaile))
 		{
			 
				
				conexionEnviarPedido(nome,tipo,dire,nev,pev,puev,eev,cpe,pbe,pve,tfe,emaile,obs);
		
		}

 	
		else
		{
		 alert ('no es un email valido');
		 var mail= document.getElementById('emailid');
		 if (mail!=null)
		 {
			mail.value='';
		 	mail.focus();
		 }
		}	 

   }

}

function conexionEnviarPedido(nome,tipo,dire,nev,pev,puev,eev,cpe,pbe,pve,tfe,emaile,obs)
{
		
	conexion1=crearXMLHttpRequest();
	  conexion1.onreadystatechange = procesarEventos;
	  url='verloquellevocomprado.php';
	  conexion1.open('POST',url, true);
		conexion1.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		conexion1.send(retornarEnviarpedido(nome,tipo,dire,nev,pev,puev,eev,cpe,pbe,pve,tfe,emaile,obs)); 	
}
function verificarcaracteres(nombre)
{
	var contador;
	nombre=nombre.replace(/ñ/g,"/ny/");
	nombre=nombre.replace(/á/g,"a");
	nombre=nombre.replace(/é/g,"e");
	nombre=nombre.replace(/í/g,"i");
	nombre=nombre.replace(/ó/g,"o");
	nombre=nombre.replace(/ú/g,"u");
	nombre=nombre.replace(/à/g,"a");
	nombre=nombre.replace(/é/g,"e");
	nombre=nombre.replace(/í/g,"i");
	nombre=nombre.replace(/ó/g,"o");
	nombre=nombre.replace(/ú/g,"u");
	nombre=nombre.replace(/Ñ/g,"/NY/");
	nombre=nombre.replace(/Á/g,"A");
	nombre=nombre.replace(/È/g,"E");
	nombre=nombre.replace(/Í/g,"I");
	nombre=nombre.replace(/Ó/g,"O");
	nombre=nombre.replace(/Ú/g,"U");
	nombre=nombre.replace(/À/g,"A");
	nombre=nombre.replace(/È/g,"E");
	nombre=nombre.replace(/Ì/g,"I");
	nombre=nombre.replace(/Ò/g,"O");
	nombre=nombre.replace(/Ù/g,"U");
	
		return (nombre);
}

function retornarEnviarpedido(nome,tipo,dire,nev,pev,puev,eev,cpe,pbe,pve,tfe,emaile,obs)
{
 var cad='';
 
 nome=verificarcaracteres(nome);
 dire=verificarcaracteres(dire);
 cpe=verificarcaracteres(cpe);
 pbe=verificarcaracteres(pbe);
 pve=verificarcaracteres(pve);
 tfe=verificarcaracteres(tfe);
 emaile=verificarcaracteres(emaile);
  obs=verificarcaracteres(obs);

  cad='nombre='+encodeURIComponent(nome)+'&tipovia='+encodeURIComponent(tipo)+'&direccion='+encodeURIComponent(dire)+'&numero='+encodeURIComponent(nev)+'&piso='+encodeURIComponent(pev)+'&puerta='+encodeURIComponent(puev)+'&escalera='+encodeURIComponent(eev)+'&codigopostal='+encodeURIComponent(cpe)+'&poblacion='+encodeURIComponent(pbe)+'&provincia='+encodeURIComponent(pve)+'&telefono='+encodeURIComponent(tfe)+'&email='+encodeURIComponent(emaile)+'&observaciones='+encodeURIComponent(obs);

  return cad;
}



function formularioAgregarCliente(e)
{
	var enlace;
  if (window.event)
  {
	 
    window.event.returnValue=false;
	enlace=window.event.srcElement;
 }
	else
    if (e)
     {
	 enlace=e.target;
	  e.preventDefault();
	 }
	 
 
 var nom=document.getElementById('nid').value;
 var ape=document.getElementById('apellidosid').value;
   var nf=document.getElementById('nifid').value;
   var tv=document.getElementById('tipodeviaid').value;
var dir=document.getElementById('direccionid').value;
var pis=document.getElementById('pisoid').value;
var pue=document.getElementById('puertaid').value;
var esc=document.getElementById('escaleraid').value;
	var cp=document.getElementById('codigopostalid').value;
   var pb=document.getElementById('poblacionid').value;
   var pv=document.getElementById('provinciaid').value;
    var tf=document.getElementById('telefonoid').value;
      var fx=document.getElementById('faxid').value;
 var email=document.getElementById('emailid').value;
  var pagweb=document.getElementById('paginawebid').value;
   var usu=document.getElementById('usuarioid').value;
var con=document.getElementById('pass').value;
var apto=document.getElementById('aceptoid').value;
var seg=document.getElementById('seguridadid').value;
  
var nopasar=0;
var posicion;
posicion=con.indexOf('ñ');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('ñ');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('Ñ');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('Ñ');
if (posicion!=-1)
  nopasar=2;
  
 posicion=con.indexOf('á');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('á');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('Á');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('Á');
if (posicion!=-1)
  nopasar=2; 
  
 posicion=con.indexOf('é');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('é');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('É');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('É');
if (posicion!=-1)
  nopasar=2; 
  
 
 posicion=con.indexOf('í');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('í');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('Í');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('Í');
if (posicion!=-1)
  nopasar=2; 
  
 posicion=con.indexOf('ó');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('ó');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('Ó');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('Ó');
if (posicion!=-1)
  nopasar=2; 
   
 posicion=con.indexOf('ú');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('ú');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('Ú');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('Ú');
if (posicion!=-1)
  nopasar=2;  
   
 posicion=con.indexOf('ü');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('ü');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('Ü');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('Ü');
if (posicion!=-1)
  nopasar=2; 
  
 
 posicion=con.indexOf('ï');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('ï');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('Ï');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('Ï');
if (posicion!=-1)
  nopasar=2; 
  
 posicion=con.indexOf('à');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('à');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('À');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('À');
if (posicion!=-1)
  nopasar=2; 
  
 posicion=con.indexOf('ò');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('ò');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('Ò');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('Ò');
if (posicion!=-1)
  nopasar=2; 
   
 posicion=con.indexOf('è');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('è');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('È');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('È');
if (posicion!=-1)
  nopasar=2;  



 if (nom=='' || ape=='' || nf=='' || dir=='' || cp=='' || pb==''  || tf=='' || email=='' ||  usu=='' || con=='' || seg=='' )
 {
	 alert ("Es obligatorio rellenar los campos que no contengan *");
 }
 else
 {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
 	{
			if (con.length>=6 && con.length<=16) 
				{ 
				  if (nopasar==0)
				 conexionAgregarCliente();
				  else
				  if (nopasar==1)
				  {
				  alert ('no se pueden poner en la contraseña ñ, ni acentos');
				   var con1= document.getElementById('pass');
					 if (con1!=null)
					 {
						con1.value='';
						con1.focus();
					 }
				  }
				   if (nopasar==2)
				   {
					alert ('no se pueden poner en la cuenta de usuario ñ, ni acentos');
				   var con1= document.getElementById('usuarioid');
					 if (con1!=null)
					 {
						con1.value='';
						con1.focus();
					 }   
				   }
				}
			else
			{
				
				alert ('la contraseña tiene que tener entre 6 y 16 digitos');
				 var con1= document.getElementById('pass');
				 if (con1!=null)
				 {
					con1.value='';
					con1.focus();
				 }
				
			}

 	}
	else
	{
		 alert ('no es un email valido');
		 var mail= document.getElementById('emailid');
		 if (mail!=null)
		 {
			mail.value='';
		 	mail.focus();
		 }
	}	 

   
}
}
function formularioAgregarClientela(e)
{
	var enlace;
  if (window.event)
  {
	 
    window.event.returnValue=false;
	enlace=window.event.srcElement;
 }
	else
    if (e)
     {
	 enlace=e.target;
	  e.preventDefault();
	 }
	
 
 var nom=document.getElementById('nid').value;
 var ape=document.getElementById('apellidosid').value;
   var nf=document.getElementById('nifid').value;
   var tv=document.getElementById('tipodeviaid').value;
var dir=document.getElementById('direccionid').value;
var pis=document.getElementById('pisoid').value;
var pue=document.getElementById('puertaid').value;
var esc=document.getElementById('escaleraid').value;
	var cp=document.getElementById('codigopostalid').value;
   var pb=document.getElementById('poblacionid').value;
   var pv=document.getElementById('provinciaid').value;
    var tf=document.getElementById('telefonoid').value;
      var fx=document.getElementById('faxid').value;
 var email=document.getElementById('emailid').value;
  var pagweb=document.getElementById('paginawebid').value;
   var usu=document.getElementById('usuarioid').value;
var con=document.getElementById('pass').value;
var apto=document.getElementById('aceptoid').value;
var seg=document.getElementById('seguridadid').value;
  
var nopasar=0;
var posicion;
posicion=con.indexOf('ñ');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('ñ');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('Ñ');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('Ñ');
if (posicion!=-1)
  nopasar=2;
  
 posicion=con.indexOf('á');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('á');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('Á');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('Á');
if (posicion!=-1)
  nopasar=2; 
  
 posicion=con.indexOf('é');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('é');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('É');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('É');
if (posicion!=-1)
  nopasar=2; 
  
 
 posicion=con.indexOf('í');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('í');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('Í');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('Í');
if (posicion!=-1)
  nopasar=2; 
  
 posicion=con.indexOf('ó');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('ó');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('Ó');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('Ó');
if (posicion!=-1)
  nopasar=2; 
   
 posicion=con.indexOf('ú');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('ú');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('Ú');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('Ú');
if (posicion!=-1)
  nopasar=2;  
   
 posicion=con.indexOf('ü');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('ü');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('Ü');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('Ü');
if (posicion!=-1)
  nopasar=2; 
  
 
 posicion=con.indexOf('ï');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('ï');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('Ï');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('Ï');
if (posicion!=-1)
  nopasar=2; 
  
 posicion=con.indexOf('à');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('à');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('À');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('À');
if (posicion!=-1)
  nopasar=2; 
  
 posicion=con.indexOf('ò');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('ò');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('Ò');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('Ò');
if (posicion!=-1)
  nopasar=2; 
   
 posicion=con.indexOf('è');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('è');
if (posicion!=-1)
  nopasar=2;
  
posicion=con.indexOf('È');
if (posicion!=-1)
  nopasar=1;
  
posicion=usu.indexOf('È');
if (posicion!=-1)
  nopasar=2;  



 if (nom=='' || ape=='' || nf=='' || dir=='' || cp=='' || pb==''  || tf=='' || email=='' ||  usu=='' || con=='' || seg=='' )
 {
	 alert ("Es obligatorio rellenar los campos que no contengan *");
 }
 else
 {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
 	{
			if (con.length>=6 && con.length<=16) 
				{ 
				  if (nopasar==0)
				 conexionAgregarClientela();
				  else
				  if (nopasar==1)
				  {
				  alert ('no se pueden poner en la contraseña ñ, ni acentos');
				   var con1= document.getElementById('pass');
					 if (con1!=null)
					 {
						con1.value='';
						con1.focus();
					 }
				  }
				   if (nopasar==2)
				   {
					alert ('no se pueden poner en la cuenta de usuario ñ, ni acentos');
				   var con1= document.getElementById('usuarioid');
					 if (con1!=null)
					 {
						con1.value='';
						con1.focus();
					 }   
				   }
				}
			else
			{
				
				alert ('la contraseña tiene que tener entre 6 y 16 digitos');
				 var con1= document.getElementById('pass');
				 if (con1!=null)
				 {
					con1.value='';
					con1.focus();
				 }
				
			}

 	}
	else
	{
		 alert ('no es un email valido');
		 var mail= document.getElementById('emailid');
		 if (mail!=null)
		 {
			mail.value='';
		 	mail.focus();
		 }
	}	 

   
}
}
function conexionAgregarCliente()
{
	 var nom=document.getElementById('nid').value;
 var ape=document.getElementById('apellidosid').value;
   var nf=document.getElementById('nifid').value;
   
   var tv=document.getElementById('tipodeviaid').value;
   
var dir=document.getElementById('direccionid').value;
var num=document.getElementById('numeroid').value;
var pis=document.getElementById('pisoid').value;
var pue=document.getElementById('puertaid').value;
var esc=document.getElementById('escaleraid').value;

	var cp=document.getElementById('codigopostalid').value;
   var pb=document.getElementById('poblacionid').value;
   var pv=document.getElementById('provinciaid').value;
    var tf=document.getElementById('telefonoid').value;
      var fx=document.getElementById('faxid').value;
 var email=document.getElementById('emailid').value;
  var pagweb=document.getElementById('paginawebid').value;
   var usu=document.getElementById('usuarioid').value;
var con=document.getElementById('pass').value;
var apto=document.getElementById('aceptoid').value;
var seg=document.getElementById('seguridadid').value;

	conexion1=crearXMLHttpRequest();
	  conexion1.onreadystatechange = procesarAgregarCliente;
	  url='registro.php';
	  conexion1.open('POST',url, true);
		conexion1.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		conexion1.send(retornarDatosAgregarCliente(nom,ape,nf,tv,dir,num,pis,pue,esc,cp,pb,pv,tf,fx,email,pagweb,usu,con,apto,seg)); 	
}

function conexionAgregarClientela()
{
	 var nom=document.getElementById('nid').value;
 var ape=document.getElementById('apellidosid').value;
   var nf=document.getElementById('nifid').value;
   
   var tv=document.getElementById('tipodeviaid').value;
   
var dir=document.getElementById('direccionid').value;
var num=document.getElementById('numeroid').value;
var pis=document.getElementById('pisoid').value;
var pue=document.getElementById('puertaid').value;
var esc=document.getElementById('escaleraid').value;

	var cp=document.getElementById('codigopostalid').value;
   var pb=document.getElementById('poblacionid').value;
   var pv=document.getElementById('provinciaid').value;
    var tf=document.getElementById('telefonoid').value;
      var fx=document.getElementById('faxid').value;
 var email=document.getElementById('emailid').value;
  var pagweb=document.getElementById('paginawebid').value;
   var usu=document.getElementById('usuarioid').value;
var con=document.getElementById('pass').value;
var apto=document.getElementById('aceptoid').value;
var seg=document.getElementById('seguridadid').value;

	conexion1=crearXMLHttpRequest();
	  conexion1.onreadystatechange = procesarAgregarCliente;
	  url='registromodificar.php';
	  conexion1.open('POST',url, true);
		conexion1.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		conexion1.send(retornarDatosAgregarCliente(nom,ape,nf,tv,dir,num,pis,pue,esc,cp,pb,pv,tf,fx,email,pagweb,usu,con,apto,seg)); 	
}



function retornarDatosAgregarCliente(nom,ape,nf,tv,dir,num,pis,pue,esc,cp,pb,pv,tf,fx,email,pagweb,usu,con,apto,seg)
{
 var cad='';
 nom=verificarcaracteres(nom);
 
 ape=verificarcaracteres(ape);
 nf=verificarcaracteres(nf);
 dir=verificarcaracteres(dir);
 cp=verificarcaracteres(cp);
 pb=verificarcaracteres(pb);
 pv=verificarcaracteres(pv);
 tf=verificarcaracteres(tf);
 fx=verificarcaracteres(fx);
 email=verificarcaracteres(email);
 usu=verificarcaracteres(usu);
  seg=verificarcaracteres(seg);

  cad='nombre='+encodeURIComponent(nom)+'&apellidos='+encodeURIComponent(ape)+'&nif='+encodeURIComponent(nf)+'&tipodevia='+encodeURIComponent(tv)+'&direccion='+encodeURIComponent(dir)+'&numero='+encodeURIComponent(num)+'&piso='+encodeURIComponent(pis)+'&puerta='+encodeURIComponent(pue)+'&escalera='+encodeURIComponent(esc)+'&codigopostal='+encodeURIComponent(cp)+'&poblacion='+encodeURIComponent(pb)+'&provincia='+encodeURIComponent(pv)+'&telefono='+encodeURIComponent(tf)+'&fax='+encodeURIComponent(fx)+'&email='+encodeURIComponent(email)+'&pagweb='+encodeURIComponent(pagweb)+'&usuario='+encodeURIComponent(usu)+'&pass='+encodeURIComponent(con)+'&acepto='+encodeURIComponent(apto)+'&seguridad='+encodeURIComponent(seg);
  
  return cad;
}




function procesarAgregarCliente()
{
  var detalles = document.getElementById("detalles");

	
  if(conexion1.readyState == 4)
  {
	

    detalles.innerHTML = conexion1.responseText;
	var punt=document.getElementById('incluirclientemodificar');
	if (punt!=null)
	{
	var puntformblanco=punt.getElementsByTagName('input');
	for (f=0;f<puntformblanco.length;f++)
				   { 
					   addEvent(puntformblanco[f],'keypress',presionTecla,false);
				   }
	}
	 if (punt!=null)
		 addEvent(punt,'submit',formularioAgregarCliente,false);
	
	var pregistromodificar=document.getElementById('conclusion');
	if (pregistromodificar!=null)
	{
		var pregistromodificara=pregistromodificar.getElementsByTagName('a');
		for (f=0;f<pregistromodificara.length;f++)
				   { 
					   addEvent(pregistromodificara[f],'click',presionEnlace,false);
				   }
	}
	
  
  } 
  else 
  {
	  if (conexion1.readyState!=4)
	  {
		 detalles.innerHTML = '<img src="../images/cargando.gif">';
	  }
  }
}	
function ponerblanco(e)
{
  	var enlace;
  if (window.event)
  {
	 enlace=window.event.srcElement;
  window.event.returnValue=false;
	
 }
	else
    if (e)
     {
	 enlace=e.target;
	 
	 }
	 enlace.style.backgroundColor="#FFFFFF";
}
function poneramarillo(e)
{
  	var enlace;
  if (window.event)
  {
	 enlace=window.event.srcElement;
   window.event.returnValue=false;

 }
	else
    if (e)
     {
	 enlace=e.target;
	  
	 }
	 enlace.style.backgroundColor="#FFFFCC";
   
}
function presionTecla(e)
{
	var caracter;
  if (window.event)
  {
    
	
	caracter = window.event.srcElement;
	var car=caracter.value;
	car=verificarcaracteres(car);
	caracter.value=car;
	var tecla=window.event.keyCode; 
	if (tecla==42)
	  {
	  window.event.returnValue=false;
      alert('No se puede poner *');
  		}
		 if (tecla==63)
	  {
	  window.event.returnValue=false;
      alert('No se puede poner ?');
  		}
		if (tecla==170)
	  {
	  window.event.returnValue=false;
      alert('No se puede poner ª');
  		}
		if (tecla==186)
	  {
	  window.event.returnValue=false;
      alert('No se puede poner º');
  		}
		
  }
  else
    if (e)
    {
	
     
     caracter=e.target;
	 car = caracter.value;
	 car=verificarcaracteres(car);
	 caracter.value=car;
	  var tecla=e.which; 
	  if(tecla==42)
      {
        e.preventDefault();
        alert('No se pueden poner *');

      }
	  if(tecla==63)
      {
        e.preventDefault();
        alert('No se pueden poner ?');

      }
	  if(tecla==170)
      {
        e.preventDefault();
        alert('No se pueden poner ª');

      }
	  if(tecla==186)
      {
        e.preventDefault();
        alert('No se pueden poner ª');

      }
    }
    
}
 
function borrarform(e)
{
		
				  if (window.event)
				  {
					 window.event.returnValue=false;
				 }
					else
					if (e)
					 {
					   e.preventDefault();
					 }
					var punt=document.getElementById('fenviardatos');
					if (punt!=null)
						{
						var puntenviar=punt.getElementsByTagName('input');
						for (f=0;f<puntenviar.length;f++)
									   { 
										   puntenviar[f].value='';
									   }
						}
						document.getElementById('botoncillo').value='Continuar Pedido';
	
}
function quitarMensaje(e)
{
	var enlace;
				  if (window.event)
				  {
					enlace=window.event.srcElement;
					
				 }
					else
					if (e)
					 {
					 enlace=e.target;
					 
					 }
				 
	
	enlace.value=''; 
	enlace.style.backgroundColor="#FFFFCC";
}




function procesarEventosProducto()
{
  var detalles = document.getElementById("productosmismamarca");

	
  if(conexion2.readyState == 4)
  {
	
 
    detalles.innerHTML = conexion2.responseText;

	var punteroproducto=document.getElementById('mismalinea');
	if (punteroproducto!=null)
	 {
	var compraproducto=punteroproducto.getElementsByTagName('a');
					for (f=0;f<compraproducto.length;f++)
				   { 
					   addEvent(compraproducto[f],'click',presionEnlace,false);
				   }
	 }
	 var puntant=document.getElementById('antproducto');
	 if (puntant!=null)
	 {
		 addEvent(puntant,'click',presionEnlaceProducto,false);
	 }
	 var puntsig=document.getElementById('sigproducto');
	 if (puntsig!=null)
	 {
		 addEvent(puntsig,'click',presionEnlaceProducto,false);
	 }
	
  }
  else 
  {
	  if (conexion2.readyState!=4)
	  {
		
	 detalles.innerHTML = '<img src="../images/cargando.gif">';
	  }
  }
}

function procesarEventosAlbaran()
{
  var detalles = document.getElementById("detalleAlbaran");

	
  if(conexion2.readyState == 4)
  {
    detalles.innerHTML = conexion2.responseText;
		var aalbaran=document.getElementById('antalbaran');
			if (aalbaran!=null)
			   addEvent(aalbaran,'click',presionEnlaceAlbaran,false);
			   
			var salbaran=document.getElementById('sigalbaran');
			if (salbaran!=null)
			   addEvent(salbaran,'click',presionEnlaceAlbaran,false);
			var anterioresprod=document.getElementById('anterioresprod');
			 if (anterioresprod!=null)
			{
			addEvent(anterioresprod,'click',presionEnlaceAlbaran,false);
			}
			var siguientesprod=document.getElementById('siguientesprod');
				 if (siguientesprod!=null)
				{
			addEvent(siguientesprod,'click',presionEnlaceAlbaran,false);
			}
			var contcompra=document.getElementById('continuarcompra');
							if (contcompra!=null)
							  addEvent(contcompra,'click',presionEnlace,false);
			 var puntmasmenos=document.getElementById('detallestabla');
								 if (puntmasmenos!=null)
								 {
									 var masmenos=puntmasmenos.getElementsByTagName('a');
												for (f=0;f<masmenos.length;f++)
											   { 
									 addEvent(masmenos[f],'click',presionEnlace,false);
											   }
								 }	
			var antesdos=document.getElementById('antesdos1');
			 if (antesdos!=null)
			 {
				 addEvent(antesdos,'click',presionEnlaceAlbaran,false);
			 }
			 
			  var despuesdos=document.getElementById('despuesdos1');
			 if (despuesdos!=null)
			 {
				 addEvent(despuesdos,'click',presionEnlaceAlbaran,false);
			 }					 
  }
  else 
  {
	  if (conexion2.readyState!=4)
	  {
		 
	 detalles.innerHTML = '<img src="../images/cargando.gif">';
	  }
  }
}

