function NuevoAjax(){
        var xmlhttp=false;
        try{
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(e){
                try{
                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }catch(E){
                        xmlhttp = false;
                }
        }

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

function Cargar(url){
	//alert('entro');
		var contenidos, preloader;
		//conchek = document.getElementById('concheck');
        //precheck = document.getElementById('concheck');		
        contenidos = document.getElementById('contenidos');
        preloader = document.getElementById('preloader');
        //creamos el objeto XMLHttpRequest
        ajax=NuevoAjax(); 
        //peticionamos los datos, le damos la url enviada desde el link
        ajax.open("POST", url,true); 
        ajax.onreadystatechange=function(){
                if(ajax.readyState==1){
                  // contenidos.innerHTML = "Cargando...";
				   contenidos.innerHTML = "<div align='center'><span class='estilo_contenido'> Cargando</span </div><br>";
                        //modificamos el estilo de la div, mostrando una imagen de fondo
//                     preloader.style.background = "url('../images/wait_ax.gif') no-repeat"; 
                   preloader.innerHTML = "<img src='ind.gif'>"; 
                }else if(ajax.readyState==4){
                        if(ajax.status==200){
                                //mostramos los datos dentro de la div
                                contenidos.innerHTML = ajax.responseText; 
                                preloader.innerHTML = " ";
                                //preloader.style.background = "url('loaded.gif') no-repeat";
                        }else if(ajax.status==404){
                                contenidos.innerHTML = "La página no existe";
                        }else{
                                //mostramos el posible error
                                contenidos.innerHTML = "Error:".ajax.status; 
                        }
                }
        }
        ajax.send(null);
}
function agr_cliente(urlc,valores)
{
		var con;
		if(document.myform.nombre.value == "")
		{
			alert("Introduce el nombre del cliente por favor");
			document.myform.nombre.focus();
			document.myform.nombre.select();
			return false;
		}
		if(document.myform.apellido.value == "")
		{
			alert("Introduce el apellido del cliente por favor");
			document.myform.apellido.focus();
			document.myform.apellido.select();
			return false;
		}
		if(document.myform.direccion.value == "")
		{
			alert("Introduce la dirección del cliente por favor");
			document.myform.direccion.focus();
			document.myform.direccion.select();
			return false;
		}
		if(document.myform.telefono.value == "")
		{
			alert("Introduce el teléfono del cliente por favor");
			document.myform.telefono.focus();
			document.myform.telefono.select();
			return false;
		}
/*		if(document.myform.pais.selectedIndex == "0")
		{
			alert("Introduce el pais de origen del cliente por favor");
			document.myform.pais.focus();
			document.myform.pais.select();
			return false;
		}*/
		if(document.myform.estado.value == "")
		{
			alert("Introduce el estado de origen del cliente por favor");
			document.myform.estado.focus();
			document.myform.estado.select();
			return false;
		}
		if(document.myform.ciudad.value == "")
		{
			alert("Introduce la ciudad de origen del cliente por favor");
			document.myform.ciudad.focus();
			document.myform.ciudad.select();
			return false;
		}
		if(document.myform.fnac.value == "")
		{
			alert("Introduce la fecha de nacimiento del cliente por favor");
			document.myform.fnac.focus();
			document.myform.fnac.select();
			return false;
		}
		if(document.myform.usuario.value == "")
		{
			alert("Introduce el nombre de usuario del cliente por favor");
			document.myform.usuario.focus();
			document.myform.usuario.select();
			return false;
		}
		if(document.myform.psw.value == "")
		{
			alert("Introduce la contraseña del cliente por favor");
			document.myform.psw.focus();
			document.myform.psw.select();
			return false;
		}
		if(document.myform.psw1.value == "")
		{
			alert("Introduce de nuevo la contraseña del cliente por favor");
			document.myform.psw.focus();
			document.myform.psw.select();
			return false;
		}
		var psw = document.myform.psw.value;		
		var psw1 = document.myform.psw1.value;
		//alert(psw);
		//alert(psw1);		
		if(psw != psw1)
		{
			alert("Las contraseñas no coinciden");
			document.myform.psw.focus();
			document.myform.psw.select();
			return false;
		}
		if(document.myform.email.value == "")
		{
			alert("Introduce el email del cliente por favor");
			document.myform.email.focus();
			document.myform.email.select();
			return false;
		}
		var em = document.myform.email.value;		
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(em)){
   			//alert("La dirección de email " + valor    + " es correcta.") 
  			// return (true)
  		} else {
  		 alert("La dirección de email es incorrecta.");
		 document.myform.email.focus();
			document.myform.email.select();
   			return (false);
  		}
		
	 var nombre = document.myform.nombre.value;
	// alert(nombre+" david");
//	 alert(valores);
	// urlc = urlc + "?" + valores;
	 //alert(urlc);				
	 var listaclientes, preloader,contenidos;
       // listaclientes = document.getElementById('listaclientes');
		contenidos = document.getElementById('contenidos');
        preloader = document.getElementById('preloader');
        //creamos el objeto XMLHttpRequest
        ajaxc=NuevoAjax(); 
        //peticionamos los datos, le damos la url enviada desde el link
        ajaxc.open('POST',urlc,true); 
        ajaxc.onreadystatechange=function(){
                if(ajaxc.readyState==1){
                  // contenidos.innerHTML = "Cargando...";
				   contenidos.innerHTML = "<div align='center'><span class='stylemensaje'> Cargando... </span </div>";
                        //modificamos el estilo de la div, mostrando una imagen de fondo
//                     preloader.style.background = "url('../images/wait_ax.gif') no-repeat"; 
                   preloader.innerHTML = "<img src='wait_ax.gif'>"; 
                }else if(ajaxc.readyState==4){
                        if(ajaxc.status==200){
                                //mostramos los datos dentro de la div
                                contenidos.innerHTML = ajaxc.responseText; 
                                preloader.innerHTML = " ";
								//contenidos.innerHTML = " ";
                                //preloader.style.background = "url('loaded.gif') no-repeat";
                        }else if(ajaxc.status==404){
                                contenidos.innerHTML = "La página no existe";
                        }else{
                                //mostramos el posible error
                                contenidos.innerHTML = "Error:".ajaxc.status; 
                        }
                }
        }
	    ajaxc.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        ajaxc.send(valores);
}
function Cmail(url,valor){ 

		if(document.form1.name.value.length == 0)
		{
			alert("No puede dejar el campo en blanco");
			document.form1.name.focus();
			document.form1.name.select();	
			return false();
		}
	    var em = document.form1.email.value;		
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(em)){
   			//alert("La dirección de email " + valor    + " es correcta.") 
  			// return (true)
  		} else {
  		 alert("La dirección de email es incorrecta.");
		    document.form1.email.focus();
			document.form1.email.select();
   			return false();
  		}
		if(document.form1.tel.value.length == 0)
		{
			alert("No puede dejar el campo en blanco");
			document.form1.tel.focus();
			document.form1.tel.select();	
			return false();
		}
		if(document.form1.invoicetotal.value.length == 0)
		{
			alert("No puede dejar el campo en blanco");
			document.form1.invoicetotal.focus();
			document.form1.invoicetotal.select();	
			return false();
		}
				
	 	var contenidosc;	   
		contenidosc = document.getElementById('contenidosc');
		
       // preloader = document.getElementById('preloader');
        //creamos el objeto XMLHttpRequest
        ajaxz=NuevoAjax(); 
        //peticionamos los datos, le damos la url enviada desde el link
        ajaxz.open("POST", url,true); 
        ajaxz.onreadystatechange=function(){
                if(ajaxz.readyState==1){
                  // contenidos.innerHTML = "Cargando...";
				contenidosc.innerHTML = "<div align='center'><span class='estilo_buscar'> Cargando... </span </div>";
				//modificamos el estilo de la div, mostrando una imagen de fondo
//                     preloader.style.background = "url('../images/wait_ax.gif') no-repeat"; 
                  // preloader.innerHTML = "<img src='../in.gif'>"; 
                }else if(ajaxz.readyState==4){
                        if(ajaxz.status==200){
                                //mostramos los datos dentro de la div
						
							contenidosc.innerHTML = ajaxz.responseText;
							
                              //  preloader.innerHTML = " ";
                                //preloader.style.background = "url('loaded.gif') no-repeat";
                        }else if(ajaxz.status==404){
						 contenidosc.innerHTML = "La pagina no existe"; 
                                
                        }else{
                                //mostramos el posible error
						 contenidosc.innerHTML = "Error:".ajaxz.status; 
													
                                 
                        }
                }
        }
        ajaxz.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        ajaxz.send(valor);

}

