function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

//desactiva enter
function pulsar(e) {

  /*
  tecla = (document.all) ? e.keyCode : e.which;
  return (tecla != 13);
  */
    tecla = (document.all) ? e.keyCode : e.which;
   if (tecla ==13){valida_envia();}
}


var marcas_1=new Array("TOYOTA")
var marcas_2=new Array("SELECCIONAR", "OTRA")  

var modelos_1=new Array("SELECCIONAR","4RUNNER","AVANZA","CAMRY","COROLLA","FJ CRUISER","HIACE","HIGHLANDER","HILUX","LAND CRUISER","MATRIX","MR2","RAV4","RUSH","SEQUOIA","SIENNA","SOLARA","TACOMA","TUNDRA","YARIS","YARIS SEDAN")

/*

function cambia_marca(){ 
    //tomo el valor del select del pais elegido 
    var pais 
    pais = document.f1.pais[document.f1.pais.selectedIndex].value 
    //miro a ver si el pais está definido 
    if (pais != 0) { 
       //si estaba definido, entonces coloco las opciones de la provincia correspondiente. 
       //selecciono el array de provincia adecuado 
       mis_provincias=eval("provincias_" + pais) 
       //calculo el numero de provincias 
       num_provincias = mis_provincias.length 
       //marco el número de provincias en el select 
       document.f1.provincia.length = num_provincias 
       //para cada provincia del array, la introduzco en el select 
       for(i=0;i<num_provincias;i++){ 
          document.f1.provincia.options[i].value=mis_provincias[i] 
          document.f1.provincia.options[i].text=mis_provincias[i] 
       } 
    }else{ 
       //si no había provincia seleccionada, elimino las provincias del select 
       document.f1.provincia.length = 1 
       //coloco un guión en la única opción que he dejado 
       document.f1.provincia.options[0].value = "-" 
       document.f1.provincia.options[0].text = "-" 
    } 
    //marco como seleccionada la opción primera de provincia 
    document.f1.provincia.options[0].selected = true 
} 
*/
var	crear=0;
var	crearm=0;
var mmm=0;
function cambiar()
{

if(document.fvalida.csnuevo[0].checked) {comon(); toyotaM();}// COMONUEVOS
//if(document.fvalida.csnuevo[1].checked) semin0(); // SEMINUEVOS
if(document.fvalida.csnuevo[1].checked) mm_otra(); // SEMINUEVOS
//if(document.fvalida.marca.options[0].value="TOYOTA") toyotaM(); // SEMINUEVOS

}

function marca_otra()
{
	var marca = document.getElementById("marca");
	var oOption=marca.options.selectedIndex;
	
	if(crear==1)
{
// Obtenemos el elemento
var el = document.getElementById("otra");
// Obtenemos el padre de dicho elemento
// con la propiedad “parentNode”
var padre = el.parentNode;
// Eliminamos el hijo (el) del elemento padre
padre.removeChild(el);
	crear=0;
}

if(marca.options[oOption].text=="OTRA")
{	


	crear=1;
	var capa = document.getElementById("mc1");
	//h1.innerHTML = "a";
	//capa.appendChild(h1);
	
	var valorA = document.createElement("INPUT"); 
	valorA.setAttribute("type","text");
	//valorA.setAttribute("size","1");
	//valorA.setAttribute("maxlength","3");
	valorA.setAttribute("name","otra");
	valorA.setAttribute("id","otra");
	//valorA.setAttribute("value","otra");
	//valorA.setAttribute("value","otra");
	valorA.setAttribute("onkeypress","tachita('otra','iderror1')");
	capa.appendChild(valorA);
	
//	valorA.setAttribute("onchange",mayus());
//	valorA.onchange=mayus(valorA);	
}

	

}
var mm_c=0;

function mm_otra()
{
	//var marca = document.getElementById("marca");
	//var oOption=marca.options.selectedIndex;
	
if(mmm==0)	
{
if(mm_c==1)
{
// Obtenemos el elemento
var mm1 = document.getElementById("mc_otra");
var mm2 = document.getElementById("md_otra");

// Obtenemos el padre de dicho elemento
// con la propiedad “parentNode”
var padre1 = mm1.parentNode;
var padre2 = mm2.parentNode;
// Eliminamos el hijo (el) del elemento padre
padre1.removeChild(mm1);
padre2.removeChild(mm2);
	mm_c=0;

}

if(mm_c==0 )
{	

	var mm1a = document.getElementById("marca");
	var mm2a = document.getElementById("modelo");
	

// Obtenemos el padre de dicho elemento
// con la propiedad “parentNode”
	var padre1a = mm1a.parentNode;
	var padre2a = mm2a.parentNode;
// Eliminamos el hijo (el) del elemento padre
	padre1a.removeChild(mm1a);
	padre2a.removeChild(mm2a);

	mm_c=1;
	var mc = document.getElementById("mc");
	var md = document.getElementById("md");
	//h1.innerHTML = "a";
	//capa.appendChild(h1);
	
	var valorMC = document.createElement("INPUT"); 
	valorMC.setAttribute("type","text");
	//valorA.setAttribute("size","1");
	//valorA.setAttribute("maxlength","3");
	valorMC.setAttribute("name","mc_otra");
	valorMC.setAttribute("id","mc_otra");
	valorMC.setAttribute("size","16");

	//valorA.setAttribute("value","otra");
	//valorA.setAttribute("value","otra");
	mc.appendChild(valorMC);
	
	var valorMD = document.createElement("INPUT"); 
	valorMD.setAttribute("type","text");
	//valorA.setAttribute("size","1");
	//valorA.setAttribute("maxlength","3");
	valorMD.setAttribute("name","md_otra");
	valorMD.setAttribute("id","md_otra");
	valorMD.setAttribute("size","16");
	//valorA.setAttribute("value","otra");
	//valorA.setAttribute("value","otra");
	md.appendChild(valorMD);
	mmm=1;
//	valorA.setAttribute("onchange",mayus());
//	valorA.onchange=mayus(valorA);	
}

	
}
}

function mayus(){
		//valorA.value=valorA.value.toUpperCase();	
		var motra = document.getElementById("otra");
		alert(motra.value)
		alert(motra.value.toUpperCase())
		
		motra.value=motra.value.toUpperCase();	
		
		}

function fnCreate(){
	mc.innerHTML="";
	var oOption=oSel.options[oSel.selectedIndex];
	if(oOption.text!="")
{
		var aElement=document.createElement(oOption.text);

		eval("aElement." + oOption.value + "='" + oText.value + "'");

		if(oOption.text=="A"){
			aElement.href="javascript:alert('A link.')";
		}
	//aElement.setAttribute("class","select1");
	mc.appendChild(aElement);
	}
}


function comon()
{

if(crear==1)
{
// Obtenemos el elemento
var el = document.getElementById("otra");
// Obtenemos el padre de dicho elemento
// con la propiedad “parentNode”
var padre = el.parentNode;
// Eliminamos el hijo (el) del elemento padre
padre.removeChild(el);
	crear=0;
/*
mc.innerHTML="";
	//var oOption=oSel.options[oSel.selectedIndex];
	var oOption="select";
//	if(oOption.text!="")
	if(oOption!="")
{
		//var aElement=document.createElement(oOption.text);
		var aElement=document.createElement(oOption);

		eval("aElement." + oOption.id + "='" + marca + "'");

//		if(oOption.text=="A"){
	//		aElement.href="javascript:alert('A link.')";
		//}
		mc.appendChild(aElement);
	}
*/
}

if(mm_c==1)
{
// Obtenemos el elemento
var mm1 = document.getElementById("mc_otra");
var mm2 = document.getElementById("md_otra");

// Obtenemos el padre de dicho elemento
// con la propiedad “parentNode”
var padre1 = mm1.parentNode;
var padre2 = mm2.parentNode;
// Eliminamos el hijo (el) del elemento padre
padre1.removeChild(mm1);
padre2.removeChild(mm2);
	mm_c=0;
	
var mca = document.getElementById("mc");
var mda = document.getElementById("md");
	//h1.innerHTML = "a";
	//capa.appendChild(h1);
	
	var valorMCa = document.createElement("SELECT"); 
	//valorMC.setAttribute("type","text");
	//valorA.setAttribute("size","1");
	//valorA.setAttribute("maxlength","3");
	valorMCa.setAttribute("name","marca");
	valorMCa.setAttribute("id","marca");
	//valorA.setAttribute("value","otra");
	//valorMCa.setAttribute("class","select1");
	valorMCa.setAttribute("className","select1")
	mca.appendChild(valorMCa);
	
	var valorMDa = document.createElement("SELECT"); 
//	valorMD.setAttribute("type","text");
	//valorA.setAttribute("size","1");
	//valorA.setAttribute("maxlength","3");
	valorMDa.setAttribute("name","modelo");
	valorMDa.setAttribute("id","modelo");
	//valorA.setAttribute("value","otra");
	//valorMDa.setAttribute("class","select1");
	valorMDa.setAttribute("className","select1")
	mda.appendChild(valorMDa);
}



       //selecciono el array de provincia adecuado 
       //mis_provincias=eval("provincias_" + pais)
	   //marcas_1;
       //calculo el numero de provincias 
       //num_provincias = mis_provincias.length 
       

	   
	   num_marcas=marcas_1.length 
	   
	   //marco el número de provincias en el select 
       //document.f1.provincia.length = num_provincias 
	   document.fvalida.marca.length = num_marcas 
       //para cada provincia del array, la introduzco en el select 
		//for(i=0;i<num_provincias;i++){ 
	   for(i=0;i<num_marcas;i++){ 
          //document.f1.provincia.options[i].value=mis_provincias[i] 
		  document.fvalida.marca.options[i].value=marcas_1[i] 
          //document.f1.provincia.options[i].text=mis_provincias[i] 
		  document.fvalida.marca.options[i].text=marcas_1[i] 
	   }   //marco como seleccionada la opción primera de provincia 
    //document.f1.provincia.options[0].selected = true 
	document.fvalida.marca.options[0].selected = true 
	document.fvalida.marca.disabled = document.fvalida.marca.options[0];
	

	
mmm=0;
}

function semin0()
{

	
       num_marcas=marcas_2.length 
	   
	   //marco el número de provincias en el select 
       //document.f1.provincia.length = num_provincias 
	   document.fvalida.marca.length = num_marcas 
	   document.fvalida.modelo.length = num_marcas 
       //para cada provincia del array, la introduzco en el select 
		//for(i=0;i<num_provincias;i++){ 
	   for(i=0;i<num_marcas;i++){ 
          //document.f1.provincia.options[i].value=mis_provincias[i] 
		  document.fvalida.marca.options[i].value=marcas_2[i] 
		  document.fvalida.modelo.options[i].value=marcas_2[i] 
          //document.f1.provincia.options[i].text=mis_provincias[i] 
		  document.fvalida.marca.options[i].text=marcas_2[i] 
  		  document.fvalida.modelo.options[i].text=marcas_2[i] 
	   }   //marco como seleccionada la opción primera de provincia 
    //document.f1.provincia.options[0].selected = true 
	document.fvalida.marca.options[0].selected = true 
	document.fvalida.modelo.options[0].selected = true 
}

function semin()
{
	
       //selecciono el array de provincia adecuado 
       //mis_provincias=eval("provincias_" + pais)
	   marcas_2;
       //calculo el numero de provincias 
       //num_provincias = mis_provincias.length 
       num_marcas=marcas_2.length 
	   //marco el número de provincias en el select 
       //document.f1.provincia.length = num_provincias 
	   document.fvalida.marca.length = num_marcas 
       //para cada provincia del array, la introduzco en el select 
		//for(i=0;i<num_provincias;i++){ 
	   for(i=0;i<num_marcas;i++){ 
          //document.f1.provincia.options[i].value=mis_provincias[i] 
		  document.fvalida.marca.options[i].value=marcas_2[i] 
          //document.f1.provincia.options[i].text=mis_provincias[i] 
		  document.fvalida.marca.options[i].text=marcas_2[i] 
	   }   //marco como seleccionada la opción primera de provincia 
    //document.f1.provincia.options[0].selected = true 
	document.fvalida.marca.options[0].selected = true 

}

function toyotaM()
{
		   
	   num_modelos=modelos_1.length 
	    //marco el número de provincias en el select 
       //document.f1.provincia.length = num_provincias 
	   document.fvalida.modelo.length = num_modelos
       //para cada provincia del array, la introduzco en el select 
		//for(i=0;i<num_provincias;i++){ 
	   for(i=0;i<num_modelos;i++){ 
          //document.f1.provincia.options[i].value=mis_provincias[i] 
		  document.fvalida.modelo.options[i].value=modelos_1[i] 
          //document.f1.provincia.options[i].text=mis_provincias[i] 
		  document.fvalida.modelo.options[i].text=modelos_1[i] 
	   }   //marco como seleccionada la opción primera de provincia 
    //document.f1.provincia.options[0].selected = true 
	document.fvalida.modelo.options[0].selected = true 

	}

function comprueba_extension(formulario, archivo) {
	
	extensiones_permitidas = new Array(".GIF", ".JPG", ".JPEG",".gif", ".jpg", ".jpeg");
	mierror = "";
	var permitida = new Boolean() ;
	if (!archivo) {
		//Si no tengo archivo, es que no se ha seleccionado un archivo en el formulario
		mierror = "No has seleccionado ningún archivo";
	}else{
		//recupero la extensión de este nombre de archivo
		extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase();
		//alert (extension);
		//compruebo si la extensión está entre las permitidas
		permitida = false;
		for (var i = 0; i < extensiones_permitidas.length; i++) {
			if (extensiones_permitidas[i] == extension) { 
				permitida = true;
				break;
			}
		}
		if (!permitida) {
			mierror = "Comprueba la extensión de los archivos a subir. \nSólo se pueden subir archivos con extensiones: " + extensiones_permitidas.join();
		
		}else{
			//submito!
			//alert ("Todo correcto.");
			//formulario.submit();
			return 1;
		}
	}
	//si estoy aqui es que no se ha podido submitir
	alert (mierror);
	return 0;
}


function valida_envia(){ 

div = document.getElementById("iderror1");
div.innerHTML = " ";

//valido el nombre 

if (document.fvalida)
{
		

if (
		(!document.fvalida.csnuevo[0].checked) 
		&& 
		(!document.fvalida.csnuevo[1].checked)		
		)
	{ 
       alert("Seleccionar Comonuevo o Seminuevo ") 
       document.fvalida.csnuevo[0].focus();
   	  
	   
	//document.getElementById("iderror0a").innerHTML="  FALTA";
	document.getElementById("iderror0a").innerHTML = "<img src='imagenes/png/botones/boton_negro_cerrar.png' border='0'></img>";
	//document.getElementById("iderror0a").setAttribute("class","usua_falta");
/*   
	div = document.getElementById("iderror0a");
	alert(div.firstChild.data)
	div = document.fvalida.getElementById("iderror0a");
	alert(div.firstChild.data)
	div.firstChild.data  = "FALTA";	   
	alert(div.firstChild.data)
*/

	return 0; 
    }
	else
	{
    	//div = document.getElementById('iderror0');
		//div.style.display='none';

	
		div = document.getElementById("iderror0a");
//		div.innerHTML = " ";
		
//		div = document.getElementById(tachita);
		div.innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";


		
	}
		
		

if (document.fvalida.modelo)
{	
	if (document.fvalida.modelo.options[document.fvalida.modelo.selectedIndex].value=="SELECCIONAR")
	{ 
       alert("Seleccionar Modelo ") 
       document.fvalida.modelo.focus();
   	  
  
/*
document.getElementById("iderror2").innerHTML="  FALTA";
	document.getElementById("iderror2").setAttribute("class","usua_falta");
*/
document.getElementById("iderror2").innerHTML = "<img src='imagenes/png/botones/boton_negro_cerrar.png' border='0'></img>";
/*   
	div = document.getElementById("iderror0a");
	alert(div.firstChild.data)
	div = document.fvalida.getElementById("iderror0a");
	alert(div.firstChild.data)
	div.firstChild.data  = "FALTA";	   
	alert(div.firstChild.data)
*/

	return 0; 
    }
	else
	{
    	//div = document.getElementById('iderror0');
		//div.style.display='none';
		div = document.getElementById("iderror2");
		div.innerHTML = " ";
		div.innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";

		
		}
}


if (document.fvalida.mc_otra)
{	
	if (document.fvalida.mc_otra.value.length==0)
	{ 
		alert("Escribir Marca") 
		document.fvalida.mc_otra.focus();
		document.getElementById("iderror1").innerHTML = "<img src='imagenes/png/botones/boton_negro_cerrar.png' border='0'></img>";
/*
document.getElementById("iderror1").innerHTML="  FALTA";
		document.getElementById("iderror1").setAttribute("class","usua_falta");
	
	*/
	return 0; 
    }
	else
	{
    	div = document.getElementById("iderror1");
		div.innerHTML = " ";
		div.innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";
	}
}


if (document.fvalida.md_otra)
{	
		if (document.fvalida.md_otra.value.length==0)
	{ 
	    alert("Escribir Modelo") 
    	document.fvalida.md_otra.focus();
		document.getElementById("iderror2").innerHTML = "<img src='imagenes/png/botones/boton_negro_cerrar.png' border='0'></img>";

/*document.getElementById("iderror2").innerHTML="  FALTA";
		document.getElementById("iderror2").setAttribute("class","usua_falta");
	
	*/return 0; 
    }
	else
	{
    	div = document.getElementById("iderror2");
		div.innerHTML = " ";
		div.innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";
}
}

	/*
	if (document.fvalida.anio.value.length==0){ 
       alert("falta año") 
       document.fvalida.anio.focus()
	   div = document.getElementById('iderror3');
	   div.style.display ='block';

       return 0; 
    }
	else
	{
    	div = document.getElementById('iderror3');
		div.style.display='none';
		
		}
	*/

	
	
	
	
	if (document.fvalida.version_a.value.length==0){ 
        alert("falta versión") 
     	document.fvalida.version_a.focus()
		//document.getElementById("iderror4").innerHTML="  FALTA";
	  document.getElementById("iderror14").innerHTML = "<img src='imagenes/png/botones/boton_negro_cerrar.png' border='0'></img>";
	    return 0; 
    }
	
	else
	{
   		div = document.getElementById("iderror14");
		div.innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";
	}
	
	
	if (document.fvalida.anio.options[document.fvalida.anio.selectedIndex].value=="0")
	{ 
       alert("Seleccionar Año ") 
       document.fvalida.anio.focus();
   	  
  	
	document.getElementById("iderror3").innerHTML = "<img src='imagenes/png/botones/boton_negro_cerrar.png' border='0'></img>";
/*
document.getElementById("iderror3").innerHTML="  FALTA";
	document.getElementById("iderror3").setAttribute("class","usua_falta");
	
	*/return 0; 
    }
	else
	{
    	//div = document.getElementById('iderror0');
		//div.style.display='none';
		div = document.getElementById("iderror3");
		div.innerHTML = " ";
		div.innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";
}
	
	if (document.fvalida.color_ext.value.length==0){ 
        alert("falta color exterior") 
     	document.fvalida.color_ext.focus()
		//document.getElementById("iderror4").innerHTML="  FALTA";
	  document.getElementById("iderror4").innerHTML = "<img src='imagenes/png/botones/boton_negro_cerrar.png' border='0'></img>";
	    return 0; 
    }
	else
	if (document.fvalida.color_ext.value.length<=2){ 
	
	 alert("Se necesitan mas de 3 caracteres") 
     	document.fvalida.color_ext.focus()
		 document.getElementById("iderror4").innerHTML = "<img src='imagenes/png/botones/boton_negro_cerrar.png' border='0'></img>";
	    return 0; 
		}
	else
	{
   		div = document.getElementById("iderror4");
		div.innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";
		
		}
		
	
	if (document.fvalida.color_int.value.length==0){ 
       alert("falta color interior") 
       document.fvalida.color_int.focus()
		document.getElementById("iderror5").innerHTML = "<img src='imagenes/png/botones/boton_negro_cerrar.png' border='0'></img>";/*
		document.getElementById("iderror5").innerHTML="  FALTA";
	    document.getElementById("iderror5").setAttribute("class","usua_falta");
		*/
	    return 0; 
    }
	else
	{
   		div = document.getElementById("iderror5");
		div.innerHTML = " ";
		div.innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";		
		}		
	/*
	if (document.fvalida.km.value.length==0){ 
       alert("falta kilometraje") 
       document.fvalida.km.focus()
		document.getElementById("iderror6").innerHTML="  FALTA";
	    document.getElementById("iderror6").setAttribute("class","usua_falta");
	    return 0; 
    }
	else
	{
   		div = document.getElementById("iderror6");
		div.innerHTML = " ";
		
		}		
		
		*/
	if (document.fvalida.eq.value.length==0){ 
       alert("falta equipamiento") 
       document.fvalida.eq.focus()
				document.getElementById("iderror7").innerHTML = "<img src='imagenes/png/botones/boton_negro_cerrar.png' border='0'></img>";/*
		document.getElementById("iderror7").innerHTML="  FALTA";
	    document.getElementById("iderror7").setAttribute("class","usua_falta");*/
	    return 0; 
    }
	else
	{
   		div = document.getElementById("iderror7");
		div.innerHTML = " ";
		div.innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";		
		}		
	if (document.fvalida.precio.value.length==0){ 
       alert("falta precio") 
       document.fvalida.precio.focus()
	   		document.getElementById("iderror8").innerHTML = "<img src='imagenes/png/botones/boton_negro_cerrar.png' border='0'></img>";/*
		document.getElementById("iderror8").innerHTML="  FALTA";
	    document.getElementById("iderror8").setAttribute("class","usua_falta");*/
	    return 0; 
    }
	else
	{
   		div = document.getElementById("iderror8");
		div.innerHTML = " ";
		div.innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>"; 
       
		}

if (document.fvalida.attachment1.value.length==0){ 
       alert("Tiene que seleccionar una foto1") 
       document.fvalida.attachment1.focus() 
     	 	 	
	 
	//div = document.getElementById('iderror9');
	//div.style.display ='block';
	
	
			document.getElementById("iderror9").innerHTML = "<img src='imagenes/png/botones/boton_negro_cerrar.png' border='0'></img>";/*
	document.getElementById("iderror9").innerHTML="  FALTA";
	document.getElementById("iderror9").setAttribute("class","usua_falta");*/
	return 0; 
    }
	else
	if
	(comprueba_extension(document.fvalida, document.fvalida.attachment1.value)==0) 
	{
				document.getElementById("iderror9").innerHTML = "<img src='imagenes/png/botones/boton_negro_cerrar.png' border='0'></img>";/*
		document.getElementById("iderror9").innerHTML="  FALTA";
	document.getElementById("iderror9").setAttribute("class","usua_falta");*/
	
		       return 0; 
	}
	else
		
		{
		div = document.getElementById("iderror9");
		div.innerHTML = " ";
		div.innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>"; 
       
			   
		}
    if (document.fvalida.attachment2.value.length==0){ 
       alert("Tiene que seleccionar un foto2") 
       document.fvalida.attachment2.focus() 
	   		document.getElementById("iderror10").innerHTML = "<img src='imagenes/png/botones/boton_negro_cerrar.png' border='0'></img>";/*
    	document.getElementById("iderror10").innerHTML="  FALTA";
	    document.getElementById("iderror10").setAttribute("class","usua_falta");*/
	
       return 0; 
    }
	else
	if
	(comprueba_extension(document.fvalida, document.fvalida.attachment2.value)==0) 
	{
		       return 0; 
	}
	else
	{
		
		div = document.getElementById("iderror10");
		div.innerHTML = " ";

		}
    if (document.fvalida.attachment3.value.length==0){ 
       alert("Tiene que seleccionar una foto3") 
       document.fvalida.attachment3.focus() 
	   		document.getElementById("iderror11").innerHTML = "<img src='imagenes/png/botones/boton_negro_cerrar.png' border='0'></img>";/*
    	document.getElementById("iderror11").innerHTML="  FALTA";
	    document.getElementById("iderror11").setAttribute("class","usua_falta");*/

       return 0; 
    }
	
	else
	if(comprueba_extension(document.fvalida, document.fvalida.attachment3.value)==0) 
	{
		       return 0; 
	}
	else

	{
		div = document.getElementById("iderror11");
		div.innerHTML = " ";
		div.innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";
}
    
	if (document.fvalida.attachment4.value.length==0){ 
       alert("Tiene que seleccionar una foto4") 
       document.fvalida.attachment4.focus() 
	   		document.getElementById("iderror12").innerHTML = "<img src='imagenes/png/botones/boton_negro_cerrar.png' border='0'></img>";/*
    	document.getElementById("iderror12").innerHTML="  FALTA";
	    document.getElementById("iderror12").setAttribute("class","usua_falta");*/

       return 0; 
    }
	
	else
	if(comprueba_extension(document.fvalida, document.fvalida.attachment4.value)==0) 
	{
		       return 0; 
	}
	else

	{
		div = document.getElementById("iderror12");
		div.innerHTML = " ";
		div.innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";		
	}
	
	if (document.fvalida.attachment5.value.length==0){ 
       alert("Tiene que seleccionar una foto5") 
       document.fvalida.attachment5.focus() 
	   		document.getElementById("iderror13").innerHTML = "<img src='imagenes/png/botones/boton_negro_cerrar.png' border='0'></img>";/*
    	document.getElementById("iderror13").innerHTML="  FALTA";
	    document.getElementById("iderror13").setAttribute("class","usua_falta");*/

       return 0; 
    }
	
	else
	if(comprueba_extension(document.fvalida, document.fvalida.attachment5.value)==0) 
	{
		       return 0; 
	}
	else

	{
		div = document.getElementById("iderror13");
		div.innerHTML = " ";
		div.innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";
	}
	showDiv();
    document.fvalida.submit(); 
}

if(document.login)
{
if (document.login.usuario.value.length==0){ 
       alert("falta Email") 
       document.login.usuario.focus()
	   	   		document.getElementById("iderror1").innerHTML = "<img src='imagenes/png/botones/boton_negro_cerrar.png' border='0'></img>";/*
       	document.getElementById("iderror1").innerHTML="  FALTA";
	    document.getElementById("iderror1").setAttribute("class","usua_falta");*/
       return 0; 
    }
	else
	{
    	//div = document.getElementById('usuario');
	    //div.style.backgroundColor ='#FFFFFF';
		div = document.getElementById("iderror1");
		div.innerHTML = " ";
		div.innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";
	}	

if (document.login.password.value.length==0){ 
       alert("falta Password") 
       document.login.password.focus()
	   	   		document.getElementById("iderror2").innerHTML = "<img src='imagenes/png/botones/boton_negro_cerrar.png' border='0'></img>";/*
		document.getElementById("iderror2").innerHTML=" FALTA";
	    document.getElementById("iderror2").setAttribute("class","usua_falta");*/
       return 0; 
    }
	else
	{
		div = document.getElementById("iderror2");
		div.innerHTML = " ";
		div.innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";		
		}	

    document.login.submit(); 
}

if(document.registrar)
{

if (document.registrar.nombre.value.length==0){ 
       alert("falta Email") 
       document.registrar.nombre.focus()
 		document.getElementById("iderror1").innerHTML=" FALTA";
	    document.getElementById("iderror1").setAttribute("class","usua_falta");


       return 0; 
    }
	else
	{
		div = document.getElementById("iderror1");
		div.innerHTML = " ";
		div.innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";		
		}	



    document.registrar.submit(); 
}

/*extension = (document.fvalida.attachment1.value.substring(document.fvalida.attachment1.value.lastIndexOf("."))).toLowerCase();
		if (extension=="jpg"){
alert("Tiene que seleccionar una foto JPG") 
       document.fvalida.attachment1.focus() 
		div = document.getElementById('iderror1');
		return 0;
	   }
	   else{
		div.style.display='none';
	   }

	*/	
	//valido la edad. tiene que ser entero mayor que 18 
    //edad = document.fvalida.edad.value 
    //edad = validarEntero(edad) 
    //document.fvalida.edad.value=edad 
    //if (edad==""){ 
    //   alert("Tiene que introducir un número entero en su edad.") 
    //   document.fvalida.edad.focus() 
    //   return 0; 
    //}else{ 
     //  if (edad<18){ 
     //     alert("Debe ser mayor de 18 años.") 
      //    document.fvalida.edad.focus() 
       //   return 0; 
       //} 
    //} 

    //valido el interés 
   // if (document.fvalida.interes.selectedIndex==0){ 
   //    alert("Debe seleccionar un motivo de su contacto.") 
    //   document.fvalida.interes.focus() 
     //  return 0; 
    //} 

    //el formulario se envia 
    //alert("enviando el formulario"); 

} 


function dar_formato(){  

var num=document.fvalida.precio.value;

var cadena = ""; var aux;  
  
var cont = 1,m,k;  
  
if(num<0) aux=1; else aux=0;  
  
num=num.toString();  
  
//0123456789 10 11  
//123456789.12
//m=12-1=11

for(m=num.length-1; m>=0; m--){  
  
 cadena = num.charAt(m) + cadena;  
  
 if(cont%3 == 0 && m >aux)  cadena = "," + cadena; else cadena = cadena;  
  
 if(cont== 3) cont = 1; else cont++;  
  
}  
  
cadena = cadena.replace(/.,/,",");  
cadena = cadena.replace(/,./,".");  
  
//return cadena;  
document.fvalida.precio.setAttribute("value",cadena);

  
} 


function oNumero(numero)
{
//numero=document.fvalida.precio.value;
//Propiedades 
this.valor = numero || 0
this.dec = -1;
//Métodos 
this.formato = numFormat;
this.ponValor = ponValor;
//Definición de los métodos 
function ponValor(cad)
{
if (cad =='-' || cad=='+') return
if (cad.length ==0) return
if (cad.indexOf('.') >=0)
    this.valor = parseFloat(cad);
else 
    this.valor = parseInt(cad);
} 
function numFormat(dec, miles)
{
var num = this.valor, signo=3, expr;
var cad = ""+this.valor;
var ceros = "", pos, pdec, i;
for (i=0; i < dec; i++)
ceros += '0';
pos = cad.indexOf('.')

if (pos < 0)
{

cad = cad+"."+ceros;

}
else
    {
    pdec = cad.length - pos -1;
    if (pdec <= dec)
        {
        for (i=0; i< (dec-pdec); i++)
            cad += '0';
        }
    else
        {
        num = num*Math.pow(10, dec);
        num = Math.round(num);
        num = num/Math.pow(10, dec);
        cad = new String(num);
        }
    }
pos = cad.indexOf('.')
if (pos < 0) pos = cad.lentgh
if (cad.substr(0,1)=='-' || cad.substr(0,1) == '+') 
       signo = 4;
if (miles && pos > signo)
    do{
        expr = /([+-]?\d)(\d{3}[\.\,]\d*)/
        cad.match(expr)
        cad=cad.replace(expr, RegExp.$1+','+RegExp.$2)
        }
while (cad.indexOf(',') > signo)
    if (dec<=0) cad = cad.replace(/\./,'')
        {
			return cad	;
			}
		
}

//document.fvalida.precio.setAttribute("value",numero.formato(2, true));

}//Fin del objeto oNumero:

function formateanumero(campo_id)
{
var nombre_id;	
var valor_id;
nombre_id = document.getElementById(campo_id);
valor_id=nombre_id.value;
var decimales;
var numero = new oNumero(valor_id);
//document.write("El número: " + numero.valor+'<br>')
//document.write("Formateado queda: ")
//numero.formato(2, true);
if(campo_id=="km")
decimales=0;
else
decimales=2;
nombre_id.setAttribute("value",numero.formato(decimales, true));

}

function mis_datos()
{
	
var key=window.event.keyCode;
if (key < 48 || key > 57){
window.event.keyCode=0;
}

if 
(key ==13){valida_envia();}
}


function equi()
{
	
var key=window.event.keyCode;
if (key < 48 || key > 57){
window.event.keyCode=0;
}

if 
(key ==13)
{
window.event.keyCode=0;
}


}

//var key=window.event.keyCode;
//if (key ==13)
//{
//alert("enter");
//}

//function imageChange(imageID,imageName,imageID2,imageName2) {
function imageChange(imageID,imageName) {

{
document.images[imageID].src = eval(imageName + ".src");
//document.images[imageID2].src = eval(imageName2 + ".src");
}

}


//popups
function hideDiv() { 
if (document.getElementById) { // DOM3 = IE5, NS6 
document.getElementById('hideshow').style.visibility = 'hidden'; 
} 
else { 
if (document.layers) { // Netscape 4 
document.hideshow.visibility = 'hidden'; 
} 
else { // IE 4 
document.all.hideshow.style.visibility = 'hidden'; 
} 
} 
}
 
function showDiv() { 
if (document.getElementById) { // DOM3 = IE5, NS6 
document.getElementById('hideshow').style.visibility = 'visible'; 
} 
else { 
if (document.layers) { // Netscape 4 
document.hideshow.visibility = 'visible'; 
} 
else { // IE 4 
document.all.hideshow.style.visibility = 'visible'; 
} 
} 
} 


function tacha(div,tachita)
{
//alert(div.id);
//alert(div.name);

div = document.getElementById(tachita);
div.innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";
//div.innerHTML = ' ';

}

function tachi()
{
	

var nombre_id;	
var valor_id;
var tam;
nombre_id = document.getElementById('color_ext');
valor_id=nombre_id.value;
tam=nombre_id.value.length;
//alert(div.id);
//alert(div.name);

if(tam>2)
{

div = document.getElementById('iderror4');
document.getElementById("iderror4").innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";

}
/*
div = document.getElementById('iderror4');
div.innerHTML = "<img src='imagenes/button_ok.png' border='0'></img>";
//div.innerHTML = ' ';
*/

}


function tachita(nid,nerror)
{
	

var nombre_id;	
var valor_id;
var tam;
nombre_id = document.getElementById(nid);
valor_id=nombre_id.value;
tam=nombre_id.value.length;
//alert(div.id);
//alert(div.name);

if(nid=='version_a')
{
if(tam>=1)
{
div = document.getElementById(nerror);
document.getElementById(nerror).innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";
}
	
}
else
{
if(tam>2)
{
div = document.getElementById(nerror);
document.getElementById(nerror).innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";
}
}
/*
div = document.getElementById('iderror4');
div.innerHTML = "<img src='imagenes/button_ok.png' border='0'></img>";
//div.innerHTML = ' ';
*/

}

function t_clave(nid,nerror)
{
	

var nombre_id;	
var valor_id;
var tam;
nombre_id = document.getElementById(nid);
valor_id=nombre_id.value;
tam=nombre_id.value.length;
//alert(div.id);
//alert(div.name);

if(tam>=6)
{
div = document.getElementById(nerror);
document.getElementById(nerror).innerHTML = "<img src='imagenes/png/botones/boton_negro_paloma.png' border='0'></img>";
}
/*
div = document.getElementById('iderror4');
div.innerHTML = "<img src='imagenes/button_ok.png' border='0'></img>";
//div.innerHTML = ' ';
*/

}

function borrar()
{
	document.getElementById("iderror0a").innerHTML="";
	document.getElementById("iderror1").innerHTML="";
	document.getElementById("iderror2").innerHTML="";
	document.getElementById("iderror3").innerHTML="";
	document.getElementById("iderror4").innerHTML="";
	document.getElementById("iderror5").innerHTML="";
	document.getElementById("iderror6").innerHTML="";
	document.getElementById("iderror7").innerHTML="";
	document.getElementById("iderror8").innerHTML="";
	document.getElementById("iderror9").innerHTML="";
	document.getElementById("iderror10").innerHTML="";
	document.getElementById("iderror11").innerHTML="";
	document.getElementById("iderror12").innerHTML="";
	document.getElementById("iderror13").innerHTML="";

}