	//estaré dentro¿?
	function abreventana(theURL,winName,features) 
	{ //v2.0
		window.open(theURL,winName,features);
	}
	function Habla(form1, tipo)
	{
		if (tipo==1)
			{
				document.form1.prueba.value=document.form1.menu.options[document.form1.menu.selectedIndex].text;
			}
		else if (tipo==2)
			{
				document.form1.prueba.value=document.form1.menu.options[document.form1.menu.selectedIndex].text+" "+document.form1.submenu.options[document.form1.submenu.selectedIndex].text;
			}
		else
			{
				document.form1.prueba.value=document.form1.menu.options[document.form1.menu.selectedIndex].text+" "+document.form1.submenu.options[document.form1.submenu.selectedIndex].text+" "+document.form1.model_name.value;
			}
	}
	function RevisaAnunciante(busqueda_clientes)
	{
		if (document.busqueda_clientes.menu2.value!=-1)
			{
				busqueda_clientes.submit();
			}
		else
			{
				alert("¡Tiene que elegir una provincia y un cliente!");
			}
	}
	function fecha()
	{
		var mydate=new Date() 
		var year=mydate.getYear() 
		if (year < 1000) 
		year+=1900 
		var day=mydate.getDay() 
		var month=mydate.getMonth() 
		var daym=mydate.getDate() 
		var dayarray=new Array("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado")
		var montharray=new Array("enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre")
		document.write("<font class='infosistema'>"+dayarray[day]+", "+daym+" de "+montharray[month]+" de "+year+"</font>") 
	}
	function FechaPortada()
	{
		var mydate=new Date() 
		var year=mydate.getYear() 
		if (year < 1000) 
		year+=1900 
		var day=mydate.getDay() 
		var month=mydate.getMonth() 
		var daym=mydate.getDate() 
		if (day<10)
		day="0"+day
		if (month<10)
		month="0"+month
		document.write("<label class='label2'>"+daym+"/"+month+"/"+year+"</font>") 
	}
	function valida(form)
		{
		if (vacio(form.usuario.value)==false)
			{
				alert("Debe introducir un usuario");
				form.usuario.focus();
			}
		else
			{				
				form.submit();
			}
		}
	function vacio(q)
		{
		for ( i = 0; i < q.length; i++ )
			{
				if ( q.charAt(i)!= " ") 
				{
					return true
				}
			}
		return false
		}
	
	function Confirma(form, opcion)
		{
			if (opcion==3)
			{
				var mensaje="ATENCIÓN: Se eliminará un tipo\n¿Desea continuar?"
				
			}
			else if(opcion==2)
			{
				var mensaje="ATENCIÓN: Se modificará un tipo\n¿Desea continuar?"
			}
			var entrar = confirm(mensaje);
			if ( entrar )
				{
				form.submit();
				}
			
		}
	function FocoForm1(id)
		{
			if (id==52)
				{
					document.forms.form1.cliente.focus();
				}
		}
	function NuevoMenu(menu) {
    for (i=0; i<menu_principal.length; i++){
        if(menu_principal[i]['txt'] == menu){
            PopulateSubMenu(menu_principal[i]['submenu']);
        }
    }
    return;
}
function PopulateSubMenu(valores){
    document.forms[0].submenu.options.length=0
    for (j=0; j<valores.length; j++){
        document.forms[0].submenu.options[j]=valores[j];
    }
}

function NuevoMenu2(menu2) {
    for (i=0; i<menu_principal2.length; i++){
        if(menu_principal2[i]['txt'] == menu2){
            PopulateSubMenu2(menu_principal2[i]['submenu2']);
        }
    }
    return;
}
function PopulateSubMenu2(valores2){
    document.forms[1].id.options.length=0
    for (j=0; j<valores2.length; j++){
        document.forms[1].id.options[j]=valores2[j];
    }
}

function NuevoMenu3(menu) {
    for (i=0; i<menu_principal.length; i++){
        if(menu_principal[i]['txt'] == menu){
            PopulateSubMenu3(menu_principal[i]['submenu']);
        }
    }
    return;
}
function PopulateSubMenu3(valores){
    document.forms[2].submenu.options.length=0
    for (j=0; j<valores.length; j++){
        document.forms[2].submenu.options[j]=valores[j];
    }
}


function SituarFoco() {
if (document.forms.length > 0) {
var field = document.forms[0];
for (i = 0; i < field.length; i++) {
if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
document.forms[0].elements[i].focus();
break;
         }
      }
   }
}

function FormatoMoneda(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+'.'+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-')+ num + ',' + cents + ' €');
}

function FormatoNumero(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+'.'+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-')+ num);
}

function refreshImg()
		{
			document.form1.picture.src = 'file:///'+ document.form1.imagen1.value;
		}

function ComprobarVehiculo(form1, tipo)
{
	var EnviarFormulario=true;
	var Error='';
	var Entrada=0;
	if (isNaN(document.form1.price1.value)==false)
		{
			Entrada=1;
		}
	else
		{
			Error="Precio\n";
		}
	if (isNaN(document.form1.car_engine.value)==false)
		{
			Entrada=Entrada+1;
		}
	else
		{
			Error=Error + "Potencia\n";
		}
	if (isNaN(document.form1.mileage.value)==false)
		{
		Entrada=Entrada+1;
		}
	else
		{
			Error=Error + "Kilómetros";
		}
	if (Entrada==3)
	{
			if (document.form1.menu.value=='')
				{
					Error="Marca de vehículo\n";
					EnviarFormulario=false;
				}
			if (document.form1.submenu.value=='')
				{
					Error=Error + "Modelo de vehículo\n";
					EnviarFormulario=false;
				}
			if (document.form1.user_id.value=='')
				{
					Error=Error + "Nombre de cliente\n";
					EnviarFormulario=false;
				}
			if (document.form1.tipo_vehiculo.value=='')
				{
					Error=Error + "Tipo de vehículo\n";
					EnviarFormulario=false;
				}
			if (tipo==0)
				{			
				if (document.form1.imagen1.value=='')
					{
						Error=Error + "Imagen Principal";
						EnviarFormulario=false;
					}
				}
			if (EnviarFormulario==false)
				{
					alert("ATENCIÓN: Error en campo(s) requerido(s):\n"+Error);
				}
			else
				{
					form1.submit();
				}
	}
	else
	{
		alert("ATENCIÓN: Error en campo(s) NUMÉRICO(S):\n"+Error);
	}
}

function ExtrasTurismo(form, tipo)
	{
		var tipe;
		tipe=tipo;
		if (tipe==1)
			{
				if (document.form1.basico.checked==true)
					{
						document.form1.serie.disabled=true;
					}
				else
					{
						document.form1.serie.disabled=false;
					}
				document.form1.ext54.click();
				document.form1.ext3.click();
				document.form1.ext5.click();
				document.form1.ext55.click();
				document.form1.ext2.click();
				document.form1.ext24.click();
				document.form1.ext32.click();
				document.form1.ext1.click();
				document.form1.ext11.click();
				document.form1.ext4.click();
				document.form1.ext53.click();
				document.form1.ext12.click();
				document.form1.ext6.click();
				document.form1.ext57.click();
				//***************************
				document.form1.ext25.click();
				document.form1.ext50.click();
				document.form1.ext31.click();
				document.form1.ext10.click();
				document.form1.ext7.click();
			}
		else if (tipe==2)
			{
				if (document.form1.serie.checked==true)
					{
						document.form1.basico.disabled=true;
					}
				else
					{
						document.form1.basico.disabled=false;
					}
				document.form1.ext54.click();
				document.form1.ext3.click();
				document.form1.ext5.click();
				document.form1.ext55.click();
				document.form1.ext2.click();
				document.form1.ext24.click();
				document.form1.ext32.click();
				document.form1.ext1.click();
				document.form1.ext11.click();
				document.form1.ext4.click();
				document.form1.ext53.click();
				document.form1.ext12.click();
				document.form1.ext6.click();
				document.form1.ext57.click();
			}
	}

function CargarImagen()
	{
		var logo;
		logo=document.form1.posicion.value;
		document.form1.vistaposicion.src="../images/publicidad/posiciones/"+logo+".gif";
	}
function CargarImagen2(imagen, ruta)
	{
		var imagen2;
		imagen2=ruta+imagen;
		document['fotocentral'].src=imagen2;
	}
function jooImage(target,fname) 
{
    document[target].src=fname;
}
function ComprobarNumero(text)
{
	if((text>=48 && text<=57) || (text>=96 && text<=105) || (text==9) || (text==8))
	{}
	else
	{
		alert("¡CAMPO NUMÉRICO!")
	}

}

function ValidaContacto(form, tipo)
{
	var EnviarFormulario=0;
	var Error='';
	var Nombre;
	var Email;
	var Telf;
	if (tipo==1)
		{
			Nombre=document.form1.nombre.value;
			Email=document.form1.email.value;
			Telf=document.form1.telf.value;
			Acepto=document.form1.acepto_nota_legal.checked;
		}
	else
		{
			Nombre=document.form2.nombre.value;
			Email=document.form2.email.value;
			Telf=document.form2.telf.value;
			Acepto=document.form2.acepto_nota_legal.checked;
		}
	if (Nombre=='')
		{
			Error="- Nombre de contacto\n";
			EnviarFormulario=1;
		}
	if (Email=='')
		{
			Error=Error +"- Email\n";
			EnviarFormulario=EnviarFormulario+1;
		}
	else
		{
			if (tipo==1)
				{
				emailCheck(document.form1.email.value);
				}
			else
				{
				emailCheck(document.form2.email.value);
				}
			//EnviarFormulario=EnviarFormulario+1;
		}
	if (Telf=='')
		{
			Error=Error +"- Telefono\n";
			EnviarFormulario=EnviarFormulario+1;
		}
	if (Acepto==false)
		{
			Error=Error +"- Aceptar las términos y condiciones de la Nota Legal\n";
			EnviarFormulario=EnviarFormulario+1;
		}
	if (EnviarFormulario<1)
		{
			form.submit();
		}
	else
		{
			alert("ATENCIÓN: Error en campo(s) requerido(s):\n"+Error+"Tenga en cuenta que necesitamos su email o teléfono para contactar con usted");
		}
}

function emailCheck (emailStr) {

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

alert("La dirección de correo parece incorrecta (verifique @ y .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("El nombre de usuario contiene caracteres no válidos");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Este nombre de dominio contiene caracteres no válidos");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

alert("El nombre de usuario no parece válido");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("La dirección IP de destino no es válida");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("El nombre de dominio no parece válido");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("La dirección de correo no parece válida");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
alert("Error no especificado en la dirección de correo");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}

//  End -->
