// Menú desplegable ok
var menu=function(){
	var t=15,z=1000,s=6,a;
	function dd(n){this.n=n; this.h=[]; this.c=[]}
	dd.prototype.init=function(p,c){
		a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
		for(i;i<l;i++){
			var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i];
			h.onmouseover=new Function(this.n+'.st('+i+',true)');
			h.onmouseout=new Function(this.n+'.st('+i+')');
		}
	}
	dd.prototype.st=function(x,f){
		var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
		clearInterval(c.t); c.style.overflow='hidden';
		if(f){
			p.className+=' '+a;
			if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
			if(c.mh==c.offsetHeight){c.style.overflow='visible'}
			else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
		}else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
	}
	function sl(c,f){
		var h=c.offsetHeight;
		if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
			if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'}
			clearInterval(c.t); return
		}
		var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
		c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')';
		c.style.height=h+(d*f)+'px'
	}
	return{dd:dd}
}();



// Fin Menú desplegable
$(document).ready(function() {
		// Muestra y oculta los men&uacute;s
		$('ul.general li:has(ul)').hover(
			function(e)
			{
				$(this).find('ul').slideDown();
			},
			function(e)
			{
				$(this).find('ul').slideUp();
			}
		);
	});
// Fin Menú desplegable

// Google Maps
function cargar() {
if (GBrowserIsCompatible()) {
var map2 = new GMap2(document.getElementById("map2"));
map2.setCenter(new GLatLng(42.138153,-0.409618), 15);
map2.addControl(new GSmallMapControl());
map2.addControl(new GMapTypeControl());
var point = new GLatLng (42.138153,-0.409618);
var marker = new GMarker(point);
map2.addOverlay(marker);

}
}

// Fin Google Maps

function abrir_ventana (pagina) {
var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=560, height=550, top=85, left=140";
window.open(pagina,"",opciones);
}
// Fin fop-up

// Faq desplegable
 $(document).ready(function()
        {
            $("div >  div.faqr:visible").hide();
            $("a.faqt").click(function()
            {
                $("div >  div.faqr:visible").slideUp();
                var div_medio = $(this).parent();
                var div_inferior_oculto = "div#" + div_medio.attr("id") + " > div:hidden";
                $(div_inferior_oculto).slideDown();
                return false;
            });
        });
		
		
		 $(document).ready(function()
        {
            $("div >  div.faqr:visible").hide();
            $("a.faqt2").click(function()
            {
                $("div >  div.faqr:visible").slideUp();
                var div_medio = $(this).parent();
                var div_inferior_oculto = "div#" + div_medio.attr("id") + " > div:hidden";
                $(div_inferior_oculto).slideDown();
                return false;
            });
        });
// Fin Faq desplegable

//*********************************************************************************  
// Function que valida que un campo contenga un string y no solamente un " "  
// Es tipico que al validar un string se diga  
//    if(campo == "") ? alert(Error)  
// Si el campo contiene " " entonces la validacion anterior no funciona  
//*********************************************************************************  
   
//busca caracteres que no sean espacio en blanco en una cadena  
 function vacio(q) {  
        for ( i = 0; i < q.length; i++ ) {  
                 if ( q.charAt(i) != " " ) {  
                         return true  
                 }  
         }  
         return false  
 }  
   
 //valida que el campo no este vacio y no tenga solo espacios en blanco  
 function valida(B) {  
           
	var er_dni = /^([0-9\s\+\-])+$/						//numeros, espacios, + o -
	var er_nsec = /^([0-9]{3,3})+$/						//numeros, espacios, + o -
	var er_ntarjeta = /^([0-9\s\+\-])+$/						//numeros, espacios, + o -
    var er_telefono = /^([0-9\s\+\-])+$/						//numeros, espacios, + o -
	var er_cp = /^([0-9\s\+\-])+$/						//numeros, espacios, + o -	
	var er_email = /^(.+\@.+\..+)$/ 	
           
    if( vacio(B.nombre.value) == false ) 
	{  
        alert("Debe introducir su nombre completo.")  
        return false  
    } 
	 if( vacio(B.direccion.value) == false ) 
	{  
        alert("Debe introducir su direcciÃ³n completa.")  
        return false  
    } 
	 if( vacio(B.localidad.value) == false ) 
	{  
        alert("Debe introducir su localidad.")  
        return false  
    } 
	if( !er_cp.test(B.cp.value) ) {
		alert('Introduzca un cÃ³digo postal vÃ¡lido.')
		return false
	}
	 if( vacio(B.provincia.value) == false ) 
	{  
        alert("Debe introducir su provincia.")  
        return false  
    } 	
	if(!er_email.test(B.mail.value)) { 
		alert('Introduzca un email vÃ¡lido.')
		return false
	}  
	if( !er_telefono.test(B.telefono.value) ) {
		alert('Introduzca un telÃ©fono vÃ¡lido.')
		return false
	}
	 if( vacio(B.asunto.value) == false ) 
	{  
        alert("Debe introducir un asunto.")  
        return false  
    }
	 if( vacio(B.contenido.value) == false ) 
	{  
        alert("Introduzaca su consulta, por favor.")  
        return false  
    } 



	
	else 
	{   
        return true  
    }  
      
}  
 //valida que el campo no este vacio y no tenga solo espacios en blanco  
 function valida2(B) {  

	var er_dni = /^([0-9\s\+\-])+$/						//numeros, espacios, + o -
	var er_nsec = /^([0-9]{3,3})+$/						//numeros, espacios, + o -
	var er_ntarjeta = /^([0-9\s\+\-])+$/						//numeros, espacios, + o -
    var er_telefono = /^([0-9\s\+\-])+$/						//numeros, espacios, + o -
	var er_cp = /^([0-9\s\+\-])+$/						//numeros, espacios, + o -	
	var er_email = /^(.+\@.+\..+)$/ 	
           
    if( vacio(B.nombre.value) == false ) 
	{  
        alert("Debe introducir su nombre completo.")  
        return false  
    } 
	 if( vacio(B.direccion.value) == false ) 
	{  
        alert("Debe introducir su direcciÃ³n completa.")  
        return false  
    } 
	 if( vacio(B.localidad.value) == false ) 
	{  
        alert("Debe introducir su localidad.")  
        return false  
    } 
	if( !er_cp.test(B.cp.value) ) {
		alert('Introduzca un cÃ³digo postal vÃ¡lido.')
		return false
	}
	 if( vacio(B.provincia.value) == false ) 
	{  
        alert("Debe introducir su provincia.")  
        return false  
    } 	
	if(!er_email.test(B.mail.value)) { 
		alert('Introduzca un email vÃ¡lido.')
		return false
	}  
	if( !er_telefono.test(B.telefono.value) ) {
		alert('Introduzca un telÃ©fono vÃ¡lido.')
		return false
	}
	 if( vacio(B.contenido.value) == false ) 
	{  
        alert("Introduzaca su consulta, por favor.")  
        return false  
    } 

	else 
	{   
        return true  
    }  
}  
