
$(document).ready(function(){
  $('#areaclientes').click(ac);

  $('#videoMarcadoCE').click(function(){
      MostrarModal( 325,340,"videoMarcadoCE.html" );
  });
  
  $('#videoindex').click(function(){
	  $('#flash').css("display",'none');						  
      MostrarModal( 325,340,"videoindex.html" );
  });
  
  $('#videoproductos').click(function(){
      MostrarModal( 325,340,"videoproductos.html" );
  });
  
  $('#videocalidad').click(function(){
      MostrarModal( 325,340,"videocalidad.html" );
  });
  
  $('#videoresp').click(function(){
      MostrarModal( 325,340,"videoresp.html" );
  });
  
  $('#prele').click(function(){
	  $('#flash1').css("display",'none');
      MostrarModal( 510,395,"imapreleva.html" );
  });
  
  $('#secci').click(function(){
	  $('#flash1').css("display",'none');
      MostrarModal( 510,395,"imaseccional.html" );
  });
  
  $('#abati').click(function(){
	  $('#flash1').css("display",'none');
      MostrarModal( 510,395,"imaabatible.html" );
  });
  
  $('#enrolla').click(function(){
	  $('#flash1').css("display",'none');
      MostrarModal( 510,395,"imaenrollable.html" );
  });
  
  $('#guillo').click(function(){
	  $('#flash1').css("display",'none');
      MostrarModal( 510,395,"imaguillotina.html" );
  });
  
  $('#bascu').click(function(){
	  $('#flash1').css("display",'none');
      MostrarModal( 510,395,"imabasculante.html" );
  });
  
  $('#correde').click(function(){
	  $('#flash1').css("display",'none');
      MostrarModal( 510,395,"imacorredera.html" );
  });
  
  $('#imabarrera').click(function(){
	  $('#flash2').css("display",'none');
      MostrarModal( 510,395,"imabarrera.html" );
  });
  
  $('#imapilona').click(function(){
      $('#flash2').css("display",'none');
      MostrarModal( 510,395,"imapilona.html" );
  });
  

  $('#buttonregistro').click(function(){
      CambiarModal( 316,334,"form.html" );
  });
  
  

  $(window).resize(function(){
      // dimensiones de la ventana del explorer 
     var wscr = $(window).width();
     var hscr = $(window).height();

     // estableciendo dimensiones de fondo
     $('#bgtransparent').css("width", wscr);
     $('#bgtransparent').css("height", hscr);
                
     // estableciendo tamaño de la ventana modal
//     $('#bgmodal').css("width", Fancho+'px');
//     $('#bgmodal').css("height", Falto+'px');
                
     // obtiendo tamaño de la ventana modal
     var wcnt = $('#bgmodal').width();
     var hcnt = $('#bgmodal').height();
                
     // obtener posicion central
     var mleft = ( wscr - wcnt ) / 2;
     var mtop = ( hscr - hcnt ) / 2;
                
     // estableciendo ventana modal en el centro
     $('#bgmodal').css("left", mleft+'px');
     $('#bgmodal').css("top", mtop+'px');
  });
  
  muestraFecha();
  
  
});



function closeModal(){
    // removemos divs creados
  $('#flash').css("display",'');
  $('#bgmodal').remove();
  $('#bgtransparent').remove();
}

function MostrarModal( ancho,alto,formulario ){
  // fondo transparente
  // creamos un div nuevo, con dos atributos
  var bgdiv = $('<div>').attr({
                className: 'bgtransparent',
                id: 'bgtransparent'
              });

  // agregamos nuevo div a la pagina
  $('body').append(bgdiv);

  // obtenemos ancho y alto de la ventana del explorer
  var wscr = $(window).width();
  var hscr = $(window).height();

  //establecemos las dimensiones del fondo
  $('#bgtransparent').css("width", wscr);
  $('#bgtransparent').css("height", hscr);

  // ventana modal
  // creamos otro div para la ventana modal y dos atributos
  var moddiv = $('<div>').attr({
                className: 'bgmodal',
                id: 'bgmodal'
               });

  // agregamos div a la pagina
  $('body').append(moddiv);

  // agregamos contenido HTML a la ventana modal
  jQuery.get( formulario, function(data) {
      $('#bgmodal').html( data );
  });

  // redimensionamos para que se ajuste al centro y mas
  $('#bgmodal').css("width", ancho+'px');
  $('#bgmodal').css("height", alto+'px');
  $(window).resize();
  $('#bgtransparent').fadeIn( "slow" );
  $('#bgmodal').fadeIn( "slow" );
};


function CambiarModal( ancho,alto,formulario ){

  // agregamos contenido HTML a la ventana modal
  $('#bgmodal').css("width", ancho+'px');
  $('#bgmodal').css("height", alto+'px');
  jQuery.get( formulario, function(data) {
      $('#bgmodal').html( data );
  });

  // redimensionamos para que se ajuste al centro y mas
  $(window).resize();
};

function muestraFecha()
{
var hoy=new Date();
var h=hoy.getHours();
var m=hoy.getMinutes();
var s=hoy.getSeconds();
var d=hoy.getDate();
var M=hoy.getMonth()+1;
var Y=hoy.getFullYear();
// agregamos un cero al principio para los números <10
m=checaNum(m);
s=checaNum(s);
d=checaNum(d);
M=checaNum(M);

document.getElementById('footertexto').innerHTML="Tfno : 956201020 - Puertas Bahía"+" - "+d+"/"+M+"/"+Y+" - "+h+":"+m+":"+s;
t=setTimeout('muestraFecha()',500);
}

function checaNum(i)
{
if (i<10)
  {
  i="0" + i;
  }
return i;
}



//Funciones que cambian de aspecto los botones del menu ppal y del menu izq

function cambiarClaseboton(id_div) {
    document.getElementById(id_div).className = (document.getElementById(id_div).className == 'barraboton2') ? 'barraboton1' : 'barraboton2';
}


function cambiarClasebotonmenu(id_div) {
    document.getElementById(id_div).className = (document.getElementById(id_div).className == 'menuboton2') ? 'menuboton1' : 'menuboton2';
}

//Avisos de campos erróneos en los formularios de la sección contactar

function cambiarClaseformulario(id_div) 
{
    document.getElementById(id_div).className = (document.getElementById(id_div).className == 'textorojo') ? 'textoblanco' : 'textorojo';
}

function cambiarClaseformulario2(id_div) 
{
    document.getElementById(id_div).className = (document.getElementById(id_div).className == 'textoblanco') ? 'textorojo' : 'textoblanco';
}


//Muestra la fecha y la hora en el footer

function muestraFecha()
{
var hoy=new Date();
var h=hoy.getHours();
var m=hoy.getMinutes();
var s=hoy.getSeconds();
var d=hoy.getDate();
var M=hoy.getMonth()+1;
var Y=hoy.getFullYear();
// agregamos un cero al principio para los números <10
m=checaNum(m);
s=checaNum(s);
d=checaNum(d);
M=checaNum(M);

document.getElementById('footertexto').innerHTML="Tfno : 956201020 - Puertas Bahía"+" - "+d+"/"+M+"/"+Y+" - "+h+":"+m+":"+s;
t=setTimeout('muestraFecha()',500);
}

function checaNum(i)
{
if (i<10)
  {
  i="0" + i;
  }
return i;
}
 
 //Funcion para elegir el motivo del contacto en la sección contactar
 
function irform()
{ 
   	var i;
	
	
	for(i=0;i<=5;i++)
	{
   		 if (document.form1.motivo[i].checked==true)  
		 	break;
	}
	return i;		 
}



//Carga de mapas de google en Donde Estamos

function cargar() {
if (GBrowserIsCompatible()) {
	carga_mapa( new GLatLng( 36.511201, -6.280902 ), 18, "mapaCadiz", new GLatLng( 36.511125, -6.280784 ) );
	carga_mapa( new GLatLng( 36.522909, -6.233395 ), 18, "mapaNave", new GLatLng( 36.523001, -6.233459 ) );
	carga_mapa( new GLatLng( 36.68038, -6.153889 ), 19, "mapaJerez", new GLatLng( 36.680208, -6.153956 ) );
	
  }
  else 
  {
    alert( "Lo siento, Google Maps no es compatible con este navegador" );

}
}

//Carga de mapas de google en Donde Estamos

function carga_mapa( Posicion, Zoom, Elemento, Marcador ) 
{
 
  map = new GMap2( document.getElementById( Elemento ) );
  map.addControl( new GLargeMapControl() );
  map.setCenter( Posicion, Zoom );
  map.setMapType(G_HYBRID_MAP);
 

  var Icon = new GIcon();
  Icon.image = "images/marcadorpb.png";
  Icon.iconSize = new GSize( 56, 52 );
  Icon.shadowSize = new GSize( 0, 0 );
  Icon.iconAnchor = new GPoint( 28, 26 );
  Icon.infoWindowAnchor = new GPoint( 28, 26 );
  Icon.infoShadowAnchor = new GPoint( 56,52 );
  var logo = new GMarker( Marcador, Icon );
  map.addOverlay( logo );
}

//mmuestra y oculta los div 


function mostrardiv(elemento){

div = document.getElementById(elemento);
div.style.display ='';
}

function cerrar(elemento){
	
div = document.getElementById(elemento);
div.style.display ='none';
}

//funcion que cierra los display antes de mostrar los siguientes


function cambiodiv(elemento){
	cerrar('caracseccional');
	cerrar('caracabatible');
	cerrar('caracpreleva');
	cerrar('caracguillotina');
	cerrar('caracbasculante');
	cerrar('caracenrollable');
	cerrar('caraccorredera');
	mostrardiv(elemento);
}

//funcion para barreras y pilonas

function cambiodiv1(elemento){
	cerrar('caracbarrera');
	cerrar('caracpilona');
	mostrardiv(elemento);
}


//Obtener el valor de los radio buttons

function get_radio_value(ctrl)
{

var rad=null;
for (var i=0; i < ctrl.length; i++)
   {
   if ( ctrl[i].checked)
      {
      rad = ctrl[i].value;
      }
   }
   return rad;
}




//funcion muestra fotos de puerta en formulario

function showimage(id) {
	
$("#secciones > div").slideUp( "slow" );
$("#"+tipopu.value).slideDown( "slow" );

}

//Validar formulario en Contactar Averías


function validar_formularioaveria()
{  
    var resultado = true;
	var focused = false;
	
	if (document.form1.nombre.value.length==0)
	{ 
		document.getElementById('errornombre').className="textorojo";
		document.form1.nombre.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errornombre').className="textoblanco";


	if (get_radio_value(document.form1.cargo)==null)
	{ 
	    document.getElementById('errorcargo').className="textorojo";
		if (!focused)
		{
		    document.form1.cargo[0].focus();
			focused = true;
		}
		resultado =  false;
    }else
		document.getElementById('errorcargo').className="textoblanco";

	
	if (document.form1.cd.value.length==0)
	{ 
		document.getElementById('errorcd').className="textorojo";
		document.form1.cd.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errorcd').className="textoblanco";
	
	
	if (document.form1.direccion.value.length==0)
	{ 
		document.getElementById('errordireccion').className="textorojo";
		document.form1.direccion.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errordireccion').className="textoblanco";
	
		
		
	if (document.form1.tfno.value.length==0)
	{ 
		document.getElementById('errortfno').className="textorojo";
		document.form1.tfno.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errortfno').className="textoblanco";
		 
	
	if (document.form1.email.value.length==0 || document.form1.email.value.indexOf('@') == -1)
	{ 
		document.getElementById('erroremail').className="textorojo";
		document.form1.email.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('erroremail').className="textoblanco";
	
	
	if (document.form1.fecha.value.length==0)
	{ 
		document.getElementById('errorfecha').className="textorojo";
		document.form1.fecha.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errorfecha').className="textoblanco";
	
    
	if (get_radio_value(document.form1.tipoave)==null)
	{ 
	    document.getElementById('errortipoave').className="textorojo";
		if (!focused)
		{
		    document.form1.tipoave[0].focus();
			focused = true;
		}
		resultado =  false;
    }else
		document.getElementById('errortipoave').className="textoblanco";
	
	
    if (resultado)
	    alert("Los datos fueron ingresados correctamente y seran enviados")
	else
	    alert("Debe rellenar correctamente el formulario"); 
	return resultado; 
} 


//Validar formulario en contactar felicitaciones

function validar_formulariofelicita()
{  
    var resultado = true;
	var focused = false;
	
	if (document.form1.nombre.value.length==0)
	{ 
		document.getElementById('errornombre').className="textorojo";
		document.form1.nombre.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errornombre').className="textoblanco";


	if (get_radio_value(document.form1.cargo)==null)
	{ 
	    document.getElementById('errorcargo').className="textorojo";
		if (!focused)
		{
		    document.form1.cargo[0].focus();
			focused = true;
		}
		resultado =  false;
    }else
		document.getElementById('errorcargo').className="textoblanco";

	
	if (document.form1.cd.value.length==0)
	{ 
		document.getElementById('errorcd').className="textorojo";
		document.form1.cd.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errorcd').className="textoblanco";
	
	
	if (document.form1.direccion.value.length==0)
	{ 
		document.getElementById('errordireccion').className="textorojo";
		document.form1.direccion.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errordireccion').className="textoblanco";
		
		
	if (document.form1.tfno.value.length==0)
	{ 
		document.getElementById('errortfno').className="textorojo";
		document.form1.tfno.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errortfno').className="textoblanco";
		 
	
	if (document.form1.email.value.length==0 || document.form1.email.value.indexOf('@') == -1)
	{ 
		document.getElementById('erroremail').className="textorojo";
		document.form1.email.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('erroremail').className="textoblanco";
	
	
	if (get_radio_value(document.form1.dpto)==null)
	{ 
	    document.getElementById('errordpto').className="textorojo";
		if (!focused)
		{
		    document.form1.dpto[0].focus();
			focused = true;
		}
		resultado =  false;
    }else
		document.getElementById('errordpto').className="textoblanco";
	
	
    if (resultado)
	    alert("Los datos fueron ingresados correctamente y seran enviados")
	else
	    alert("Debe rellenar correctamente el formulario"); 
	return resultado; 
} 


//Validar formulario Contactar otros

function validar_formulariootros()
{  
    var resultado = true;
	var focused = false;
	
	if (document.form1.nombre.value.length==0)
	{ 
		document.getElementById('errornombre').className="textorojo";
		document.form1.nombre.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errornombre').className="textoblanco";


	if (get_radio_value(document.form1.cargo)==null)
	{ 
	    document.getElementById('errorcargo').className="textorojo";
		if (!focused)
		{
		    document.form1.cargo[0].focus();
			focused = true;
		}
		resultado =  false;
    }else
		document.getElementById('errorcargo').className="textoblanco";

	
	if (document.form1.cd.value.length==0)
	{ 
		document.getElementById('errorcd').className="textorojo";
		document.form1.cd.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errorcd').className="textoblanco";
	
	
	if (document.form1.direccion.value.length==0)
	{ 
		document.getElementById('errordireccion').className="textorojo";
		document.form1.direccion.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errordireccion').className="textoblanco";
		
		
	if (document.form1.tfno.value.length==0)
	{ 
		document.getElementById('errortfno').className="textorojo";
		document.form1.tfno.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errortfno').className="textoblanco";
		 
	
	if (document.form1.email.value.length==0 || document.form1.email.value.indexOf('@') == -1)
	{ 
		document.getElementById('erroremail').className="textorojo";
		document.form1.email.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('erroremail').className="textoblanco";
	
	
	if (document.form1.comentario.value.length==0 || document.form1.comentario.value == 'Aquí su texto...')
	{ 
		document.getElementById('errorcomentario').className="textorojo";
		document.form1.comentario.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errorcomentario').className="textoblanco";
	
	
    if (resultado)
	    alert("Los datos fueron ingresados correctamente y seran enviados")
	else
	    alert("Debe rellenar correctamente el formulario"); 
	return resultado; 
} 

//Validar formulario en Contactar Reclamaciones

function validar_formulariorecla()
{  
    var resultado = true;
	var focused = false;
	if (document.form1.nombre.value.length==0)
	{ 
		document.getElementById('errornombre').className="textorojo";
		document.form1.nombre.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errornombre').className="textoblanco";


	if (get_radio_value(document.form1.cargo)==null)
	{ 
	    document.getElementById('errorcargo').className="textorojo";
		if (!focused)
		{
		    document.form1.cargo[0].focus();
			focused = true;
		}
		resultado =  false;
    }else
		document.getElementById('errorcargo').className="textoblanco";

	
	if (document.form1.cd.value.length==0)
	{ 
		document.getElementById('errorcd').className="textorojo";
		document.form1.cd.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errorcd').className="textoblanco";
	
	
	if (document.form1.direccion.value.length==0)
	{ 
		document.getElementById('errordireccion').className="textorojo";
		document.form1.direccion.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errordireccion').className="textoblanco";
		
		
	if (document.form1.tfno.value.length==0)
	{ 
		document.getElementById('errortfno').className="textorojo";
		document.form1.tfno.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errortfno').className="textoblanco";
		 
	
	if (document.form1.email.value.length==0 || document.form1.email.value.indexOf('@') == -1)
	{ 
		document.getElementById('erroremail').className="textorojo";
		document.form1.email.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('erroremail').className="textoblanco";
	
    
	if (get_radio_value(document.form1.comunicado)==null)
	{ 
	    document.getElementById('errorcomunicado').className="textorojo";
		if (!focused)
		{
		    document.form1.comunicado[0].focus();
			focused = true;
		}
		resultado =  false;
    }else
		document.getElementById('errorcomunicado').className="textoblanco";
		
	
	if (document.form1.comentario.value.length==0 || document.form1.comentario.value == 'Escriba aquí...')
	{ 
		document.getElementById('errorcomentario').className="textorojo";
		document.form1.comentario.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errorcomentario').className="textoblanco";
	
	
    if (resultado)
	    alert("Los datos fueron ingresados correctamente y seran enviados")
	else
	    alert("Debe rellenar correctamente el formulario"); 
	return resultado; 
} 

//Validar el fomulario subir anuncio


function validar_formularioanuncio()
{  
    var resultado = true;
	var focused = false;
	
	if (document.form1.nombre.value.length==0)
	{ 
		document.getElementById('errornombre').className="textorojo";
		document.form1.nombre.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errornombre').className="textoblanco";


	if (get_radio_value(document.form1.part)==null)
	{ 
	    document.getElementById('errorcargo').className="textorojo";
		if (!focused)
		{
		    document.form1.part[0].focus();
			focused = true;
		}
		resultado =  false;
    }else
		document.getElementById('errorcargo').className="textoblanco";


	if (get_radio_value(document.form1.vend)==null)
	{ 
	    document.getElementById('errorcargo2').className="textorojo";
		if (!focused)
		{
		    document.form1.vend[0].focus();
			focused = true;
		}
		resultado =  false;
    }else
		document.getElementById('errorcargo2').className="textoblanco";
	
			
		
	if (document.form1.tfno.value.length==0)
	{ 
		document.getElementById('errortfno').className="textorojo";
		document.form1.tfno.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errortfno').className="textoblanco";
		 
	
	if (document.form1.email.value.length==0 || document.form1.email.value.indexOf('@') == -1)
	{ 
		document.getElementById('erroremail').className="textorojo";
		document.form1.email.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('erroremail').className="textoblanco";
		 
		 
	
	
	
	if (document.form1.titulo.value.length==0)
	{ 
		document.getElementById('errortitulo').className="textorojo";
		document.form1.titulo.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errortitulo').className="textoblanco";
		 
		 
	if (document.form1.coment.value.length==0 || document.form1.coment.value == 'Aquí su texto...')
	{ 
		document.getElementById('errorcomentario').className="textorojo";
		document.form1.coment.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errorcomentario').className="textoblanco";
		 
		 
	if(document.form1.acepto.value==0)
	{ 
		document.getElementById('errorcondiciones').className="textorojo";
		document.form1.acepto.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errorcondiciones').className="textoblanco";
		 
	
	
    if (resultado)
	    alert("Los datos fueron ingresados correctamente y seran enviados")
	else
	    alert("Debe rellenar correctamente el formulario"); 
	return resultado; 
} 


//validar formulario satisfaccion del cliente


function validar_formulariosatis()
{  
    var resultado = true;
	var focused = false;
	
	if (document.form1.nombre.value.length==0)
	{ 
		document.getElementById('errornombre').className="textorojo";
		document.form1.nombre.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errornombre').className="textoblanco";


	if (get_radio_value(document.form1.cargo)==null)
	{ 
	    document.getElementById('errorcargo').className="textorojo";
		if (!focused)
		{
		    document.form1.cargo[0].focus();
			focused = true;
		}
		resultado =  false;
    }else
		document.getElementById('errorcargo').className="textoblanco";

	
	if (document.form1.cd.value.length==0)
	{ 
		document.getElementById('errorcd').className="textorojo";
		document.form1.cd.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errorcd').className="textoblanco";
	
	
	if (document.form1.direccion.value.length==0)
	{ 
		document.getElementById('errordireccion').className="textorojo";
		document.form1.direccion.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errordireccion').className="textoblanco";
	
		
		
	if (document.form1.tfno.value.length==0)
	{ 
		document.getElementById('errortfno').className="textorojo";
		document.form1.tfno.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errortfno').className="textoblanco";
		 
	
	if (document.form1.email.value.length==0 || document.form1.email.value.indexOf('@') == -1)
	{ 
		document.getElementById('erroremail').className="textorojo";
		document.form1.email.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('erroremail').className="textoblanco";
	
	
	
    if (resultado)
	    alert("Los datos fueron ingresados correctamente y seran enviados")
	else
	    alert("Debe rellenar correctamente el formulario"); 
	return resultado; 
} 

//validar presupuesto montaje puerta

function validar_formulariopre1()
{  
    var resultado = true;
	var focused = false;
	
	if (document.form1.nombre.value.length==0)
	{ 
		document.getElementById('errornombre').className="textorojo";
		document.form1.nombre.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errornombre').className="textoblanco";

		
		
	if (document.form1.tfno.value.length==0)
	{ 
		document.getElementById('errortfno').className="textorojo";
		document.form1.tfno.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errortfno').className="textoblanco";
		 
	
	if (document.form1.email.value.length==0 || document.form1.email.value.indexOf('@') == -1)
	{ 
		document.getElementById('erroremail').className="textorojo";
		document.form1.email.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('erroremail').className="textoblanco";
		 
	if(document.form1.tipopu.selectedIndex==0)
	{
		document.getElementById('errortipopu').className="textorojo";
		document.form1.tipopu.focus();
		focused = true;
		resultado = false;
	}else
		document.getElementById('errortipopu').className="textoblanco";
		
		
	if (get_radio_value(document.form1.tipoaca)==null)
	{ 
	    document.getElementById('erroracabado').className="textorojo";
		if (!focused)
		{
		    document.form1.tipoaca[0].focus();
			focused = true;
		}
		resultado =  false;
    }else
		document.getElementById('erroracabado').className="textoblanco";
		
		
	if(document.form1.color.selectedIndex==0)
	{
		document.getElementById('errorcolor').className="textorojo";
		document.form1.color.focus();
		focused = true;
		resultado = false;
	}else
		document.getElementById('errorcolor').className="textoblanco";
	
	
	if (get_radio_value(document.form1.apert)==null)
	{ 
	    document.getElementById('errorapert').className="textorojo";
		if (!focused)
		{
		    document.form1.apert[0].focus();
			focused = true;
		}
		resultado =  false;
    }else
		document.getElementById('errorapert').className="textoblanco";
		
		
	if (document.form1.ancho.value.length==0)
	{ 
		document.getElementById('errordimensiones').className="textorojo";
		document.form1.ancho.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errordimensiones').className="textoblanco";
		 
		 
	if (document.form1.alto.value.length==0)
	{ 
		document.getElementById('errordimensiones').className="textorojo";
		document.form1.alto.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errordimensiones').className="textoblanco";
	
	
	if (get_radio_value(document.form1.inst)==null)
	{ 
	    document.getElementById('errorinst').className="textorojo";
		if (!focused)
		{
		    document.form1.inst[0].focus();
			focused = true;
		}
		resultado =  false;
    }else
		document.getElementById('errorinst').className="textoblanco";
		
		
	if (get_radio_value(document.form1.peat)==null)
	{ 
	    document.getElementById('errorpeat').className="textorojo";
		if (!focused)
		{
		    document.form1.peat[0].focus();
			focused = true;
		}
		resultado =  false;
    }else
		document.getElementById('errorpeat').className="textoblanco";
		
		
	if(document.form1.usu.selectedIndex==0)
	{
		document.getElementById('errorusu').className="textorojo";
		document.form1.usu.focus();
		focused = true;
		resultado = false;
	}else
		document.getElementById('errorusu').className="textoblanco";
	
	
	if(document.form1.acepto.value==0)
	{ 
		document.getElementById('errorcondiciones').className="textorojo";
		document.form1.acepto.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errorcondiciones').className="textoblanco";
	
	
	
    if (resultado)
	    alert("Los datos fueron ingresados correctamente y seran enviados")
	else
	    alert("Debe rellenar correctamente el formulario"); 
	return resultado; 
} 

//validar formulario motorizacion


function validar_formulariopre2()
{  
    var resultado = true;
	var focused = false;
	
	if (document.form1.nombre.value.length==0)
	{ 
		document.getElementById('errornombre').className="textorojo";
		document.form1.nombre.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errornombre').className="textoblanco";

		
		
	if (document.form1.tfno.value.length==0)
	{ 
		document.getElementById('errortfno').className="textorojo";
		document.form1.tfno.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errortfno').className="textoblanco";
		 
	
	if (document.form1.email.value.length==0 || document.form1.email.value.indexOf('@') == -1)
	{ 
		document.getElementById('erroremail').className="textorojo";
		document.form1.email.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('erroremail').className="textoblanco";
		 
	if(document.form1.tipopu.selectedIndex==0)
	{
		document.getElementById('errortipopu').className="textorojo";
		document.form1.tipopu.focus();
		focused = true;
		resultado = false;
	}else
		document.getElementById('errortipopu').className="textoblanco";
		
		
	if (document.form1.ancho.value.length==0)
	{ 
		document.getElementById('errordimensiones').className="textorojo";
		document.form1.ancho.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errordimensiones').className="textoblanco";
		 
		 
	if (document.form1.alto.value.length==0)
	{ 
		document.getElementById('errordimensiones').className="textorojo";
		document.form1.alto.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errordimensiones').className="textoblanco";
		
	
		
	if(document.form1.usu.selectedIndex==0)
	{
		document.getElementById('errorusu').className="textorojo";
		document.form1.usu.focus();
		focused = true;
		resultado = false;
	}else
		document.getElementById('errorusu').className="textoblanco";
	
	
	if(document.form1.acepto.value==0)
	{ 
		document.getElementById('errorcondiciones').className="textorojo";
		document.form1.acepto.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errorcondiciones').className="textoblanco";
	
	
	
    if (resultado)
	    alert("Los datos fueron ingresados correctamente y seran enviados")
	else
	    alert("Debe rellenar correctamente el formulario"); 
	return resultado; 
} 

//validar formulario presupuesto accesorios


function validar_formulariopre3()
{  
    var resultado = true;
	var focused = false;
	
	if (document.form1.nombre.value.length==0)
	{ 
		document.getElementById('errornombre').className="textorojo";
		document.form1.nombre.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errornombre').className="textoblanco";

		
		
	if (document.form1.tfno.value.length==0)
	{ 
		document.getElementById('errortfno').className="textorojo";
		document.form1.tfno.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errortfno').className="textoblanco";
		 
	
	if (document.form1.email.value.length==0 || document.form1.email.value.indexOf('@') == -1)
	{ 
		document.getElementById('erroremail').className="textorojo";
		document.form1.email.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('erroremail').className="textoblanco";
		 
	
	
	if(document.form1.acepto.value==0)
	{ 
		document.getElementById('errorcondiciones').className="textorojo";
		document.form1.acepto.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errorcondiciones').className="textoblanco";
	
	
	
    if (resultado)
	    alert("Los datos fueron ingresados correctamente y seran enviados")
	else
	    alert("Debe rellenar correctamente el formulario"); 
	return resultado; 
} 

//formulario adpatacion normativa presupuesto

function validar_formulariopre4()
{  
    var resultado = true;
	var focused = false;
	
	if (document.form1.nombre.value.length==0)
	{ 
		document.getElementById('errornombre').className="textorojo";
		document.form1.nombre.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errornombre').className="textoblanco";

		
		
	if (document.form1.tfno.value.length==0)
	{ 
		document.getElementById('errortfno').className="textorojo";
		document.form1.tfno.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errortfno').className="textoblanco";
		 
	
	if (document.form1.email.value.length==0 || document.form1.email.value.indexOf('@') == -1)
	{ 
		document.getElementById('erroremail').className="textorojo";
		document.form1.email.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('erroremail').className="textoblanco";
		 
	
	if(document.form1.tipopu.selectedIndex==0)
	{
		document.getElementById('errortipopu').className="textorojo";
		document.form1.tipopu.focus();
		focused = true;
		resultado = false;
	}else
		document.getElementById('errortipopu').className="textoblanco";
		 
	
	if (get_radio_value(document.form1.ubi)==null)
	{ 
	    document.getElementById('errorubi').className="textorojo";
		if (!focused)
		{
		    document.form1.ubi[0].focus();
			focused = true;
		}
		resultado =  false;
    }else
		document.getElementById('errorubi').className="textoblanco";
	
	
	if(document.form1.acepto.value==0)
	{ 
		document.getElementById('errorcondiciones').className="textorojo";
		document.form1.acepto.focus();
		focused = true; 
		resultado =  false; 
    }else
		 document.getElementById('errorcondiciones').className="textoblanco";
	
	
	
    if (resultado)
	    alert("Los datos fueron ingresados correctamente y seran enviados")
	else
	    alert("Debe rellenar correctamente el formulario"); 
	return resultado; 
} 



