// Menú cambio de color
function cambio(obj,num,acc) {
	if(num==1) {if(acc==1) {obj.className="mnucel2"};obj.style.cursor="hand";obj.style.cursor="pointer";} else {if(acc==1) {obj.className="mnucel"};}
}

function cambio4(obj) {obj.style.cursor="hand";obj.style.cursor="pointer";}

// Funciones del callejero
function plano(nu,x,y,cl) { 
	pagina = "plano.asp?nu="+nu+"&cl="+cl+"&x="+x+"&y="+y
	window.open(pagina,"_blank",'toolbar=no,directories=no,scrollbars=no,location=no,menubar=no,width=650, height=497, top=20,left=75,status=no,');
}

function plano2(nu,x,y,cl) { 
	pagina = "plano2.asp?nu="+nu+"&cl="+cl+"&x="+x+"&y="+y
	window.open(pagina,"_blank",'toolbar=no,directories=no,scrollbars=no,location=no,menubar=no,width=650, height=497, top=20,left=75,status=no,');
}

// Funciones para fotografías
function verfoto(nombre,w,h,txt) { 
	var x = (800-w)/2
	var y = (600-h)/2
	pagina = "verfoto.asp?nombre="+nombre+"&w="+w+"&h="+h+"&txt="+txt
	window.open(pagina,"_blank","toolbar=no,directories=no,scrollbars=no,location=no,menubar=no,width="+w+",height="+h+",top="+y+",left="+x+",status=no,");
}

function ampliar(id) { 
	pagina = "gal_ampliar.asp?id="+id
	window.open(pagina,"_blank","toolbar=no,directories=no,scrollbars=no,location=no,menubar=no,width=560,height=580,top=0,left=120,status=no,");
}

// COMPROBAR SI ES UN CORREO ELECTRONICO
var whitespace = " \t\n\r";
var defaultEmptyOK = false
var digits = "0123456789";
var lowercaseLetters = "abcdefghijklmnopqrstuvwxyzáéíóúñü"
var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚÑ"

function isEmail (s)
{
    if (isWhitespace(s)) return false;
    var i = 1;
    var sLength = s.length;
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

function isWhitespace (s)
{   var i;
	var compro = false
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        // si el caracter en que estoy no aparece en whitespace,
        // entonces retornar falso
        if (whitespace.indexOf(c) != -1) return true;
    }
    return false;
}

function isAlphanumeric (s)
{   var i;

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (!(isLetter(c) || isDigit(c) ) ) return false;
    }

    return true;
}

function esNumero (s)
{   var i;

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (!(isDigit(c))) return false;
    }

    return true;
}



function isLetter (c)
{
    return( ( uppercaseLetters.indexOf( c ) != -1 ) ||
            ( lowercaseLetters.indexOf( c ) != -1 ) )
}

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

function verono(form,objeto1,objeto2) {
	if(document.getElementById(objeto1).checked==true) {document.getElementById(objeto2).className='visible'}
	else {document.getElementById(objeto2).className='oculto'}
}

function largo(este,form,long) {if (este.value.length > long-1) {este.value = este.value.substr(0,long-1);}
	form.total.value = (long-1) - este.value.length
}

function largo2(este,form,long) {if (este.value.length > long-1) {este.value = este.value.substr(0,long-1);}
	form.total2.value = (long-1) - este.value.length
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function cambiarimgx(form,x) {
	cadena = document.getElementById('f'+x).value;ancho = document.getElementById('f'+x).value.length
	ext = cadena.substr(ancho-4,4).toLowerCase()
	if (ext!='.jpg'&&ext!='jpeg') {alert("Sólo se admiten imágenes en formato JPG,\nEl fichero seleccionado no será almacenado.");document.getElementById('gimg'+x).value='0'}
	else {MM_swapImage('fot'+x,'',cadena,1);document.getElementById('gimg'+x).value='1'}	
}

function cambiarimgx2(form,x) {
	if(x>0) {imag='media/imagen2.gif'} else {imag='media/imagen.gif'}
	MM_swapImage('fot'+x,'',imag,1)
	document.getElementById('gimg'+x).value='2'
}

function cambiarmenu(id) {
	for (i = 1; i < 7; i++) {
		if(i==id) {document.getElementById("menuc"+i).className='cabecera2'} 
		else {document.getElementById("menuc"+i).className='cabecera1'}
	}
	if(id==1) {document.getElementById("for1").className="visible";document.getElementById("for2").className="oculto";document.getElementById("botonc").value="Empresas";document.getElementById("buscarc").action="emp_buscar.asp"}
	if(id==2) {document.getElementById("for1").className="visible";document.getElementById("for2").className="oculto";document.getElementById("botonc").value="Callejero";document.getElementById("buscarc").action="cal_buscar.asp"}
	if(id==3) {document.getElementById("for1").className="visible";document.getElementById("for2").className="oculto";document.getElementById("botonc").value="Teléfonos";document.getElementById("buscarc").action="tel_buscar.asp"}
	if(id==4) {document.getElementById("for1").className="oculto";document.getElementById("for2").className="visible";document.getElementById("botonc").value="Vivienda";document.getElementById("buscarc").action="inm_buscar.asp"}
	if(id==5) {document.getElementById("for1").className="visible";document.getElementById("for2").className="oculto";document.getElementById("botonc").value="Noticias";document.getElementById("buscarc").action="not_noticias.asp"}
	if(id==6) {document.getElementById("for1").className="visible";document.getElementById("for2").className="oculto";document.getElementById("botonc").value="Web";document.getElementById("buscarc").action="web_buscar.asp"}
	if(id!=4) {document.getElementById("buscar").focus();}
}

function feliz() {
	window.open("navidad","_blank","fullscreen=1,status=no"); 
}

function SelectAll(id)
{
    document.getElementById(id).focus();
    document.getElementById(id).select();
}


