// JavaScript Document

function obtiene_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()
if (daym<10)
daym="0"+daym
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(daym+" de "+montharray[month]+" de "+year+ ", " +dayarray[day])


}
 
function mostrardiv(id) {

id.style.display ='';

}

function cerrar(id) {

id.style.display='none';

} 
 

function delayer(id){
	
	//Si es descargas a lo que has dado, lo que hacemos es mostrar
	//una alerta para decirle al usuario que es necesario pass y user
	
    window.alert('Zona descarga: se necesita usuario y password proporcionado por Medical Sorevan')
	window.open("ftp://ftp.sorevan.com",'ftpsorevan')
	/*acojonante, no me funcionaba en ie porque el nombre de la ventano no puede tener espacios y yo había puesto ftp sorevan, al ponerlo junto funciona sin 
	problemas.Es el segundo parámetro de la función window.open*/
}

 
 
function comprobar(){ 
 
//Abrir popup una vez por visitante
var dire = "Productos_Advertencia.html" //página a cargar en la popup
var dias = 1 //días a los que caduca la cookie
var ancho = 300 //anchura de la ventana
var alto = 200 //altura de la ventana
if(document.cookie.indexOf('popupillo=false')<0){
	cad=new Date()
	cad.setTime(cad.getTime() + (dias*24*60*60*1000))
	expira="; expires=" + cad.toGMTString()
	document.cookie = "popupillo=false" + expira
	$('#coldrch').load('Productos_Advertencia.html')
//	ventanita = window.open (dire,'ventanita','width=' + ancho +',height=' + alto) En caso de que quiera un popup
 }  
else {
    $('#coldrch').load('Productos.html')	
 }
}

// funcion para cambiar el contenido de un div...a ver si es verdad que funciona

function cargarcontenido (id,pag){

//Tal y como esta ahora nunca caera en este if en Productos_Advertencia porque 
//se ha quitado la llamada desde el index, pero vamos a dejar el código por si
//te tiene que recuperar algún día. Recordemos que gracias a esta función comprobar
//y a este if, sabemos si el usuario ya ha visitado la página en las anteriores 24 horas
//y no le presentamos la advertencia de nuevo.

 if (pag == 'Productos_Advertencia.html'){
 	comprobar()
//	$(id).load('Productos.html')
   }
//	$(id).load('Productos_Advertencia.html')
 else if (pag =='Descargas.html'){
	delayer(id)
 }
 else{	 
   $(id).load(pag)
 }
  
/*Todo este código que está abajo nos servía para cargar el donde estás en la 
parte izquierda del div separación. Lo sustituimos por las etiquetas que hemos
puesto finalmente en el margen derecho*/
  
/* if ( pag == 'Presentacion_SP.html'){
 /* document.getElementById('separacion').innerHTML = 'presentacion'
  cerrar('#tagCloud1')
 }
 else if ( pag == 'ServicioTecnico.html' ){
  document.getElementById('separacion').innerHTML = 'servicio tecnico'
 }
 else if ( pag == 'Contacto.html'){
     document.getElementById('separacion').innerHTML = 'contacto'
 }
 else if ( pag == 'lactancia_alquiler.html'){
     document.getElementById('separacion').innerHTML = 'lactancia materna | alquiler'	 
 }
 else if ( pag == 'LactanciaMaterna.html'){
     document.getElementById('separacion').innerHTML = 'lactancia materna'
 }
 else if ( pag == 'Presentacion_EN.html'){
     document.getElementById('separacion').innerHTML = 'about us'
 }
 else if ( pag == 'Productos_Avertencia.html'){	 
     document.getElementById('separacion').innerHTML = 'productos'
 }
 else if ( pag == 'Productos.html'){
	 document.getElementById('separacion').innerHTML = 'productos'
 } 
	 
 else if ( pag == 'TiendaOnline.html'){
     document.getElementById('separacion').innerHTML = 'tienda online'
 }
 else if ( pag == 'productos/accesorios.html'){
     document.getElementById('separacion').innerHTML = 'productos | accesorios'
 }
 else if ( pag == 'productos/calentamiento.html'){
     document.getElementById('separacion').innerHTML = 'productos | calentamiento'
 }
 else if ( pag == 'productos/compresion.html'){
     document.getElementById('separacion').innerHTML = 'productos | compresion'
 }
 else if ( pag == 'productos/ginecologia.html'){
     document.getElementById('separacion').innerHTML = 'productos | ginecologia'
 }
 else if ( pag == 'productos/neonatos.html'){
     document.getElementById('separacion').innerHTML = 'productos | neonatos'
 } 
 else if ( pag =='Descargas.html'){
	 document.getElementById('separacion').innerHTML = 'descargas'
 } 
 else if (pag=='Nube_Sorevan.html'){
/*    document.getElementById('separacion').innerHTML ="Medical Sorevan, S.L."

 }*/
}

function mainmenu(){
// Oculto los submenus
$(" #nav ul ").css({display: "none"});
// Defino que submenus deben estar visibles cuando se pasa el mouse por encima
$(" #nav li").hover(function(){
    $(this).find('ul:first:hidden').css({visibility: "visible",display: "none"}).slideDown(400);
    },function(){
        $(this).find('ul:first').slideUp(400);
    });
}

$(document).ready(function(){
    mainmenu();
});

function inicio(image){
	$(window).load(function(){       
            var parent_height = $(image).parent().height();
            var image_height = $(image).height();
            var top_margin = (parent_height - image_height)/2;
            $(image).css( 'margin-top' , top_margin);
     });
}


(function($){ 
     $.fn.extend({  
         airport: function(array) {
			
			var self = $(this);
			var chars = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ','A','B','C','D','E','F','G','H','I','J','K','L','M','N','Ñ','O','P','Q','R','S','T','U','V','Y','Z','-','+','@','0','1','2','3','4','5','6','7','8','9','.','(',')',','];
			var longest = 0;
			var items = items2 = array.length;

			function pad(a,b) { return a + new Array(b - a.length + 1).join(' '); }
			
			$(this).empty();
			
			while(items--)
				if(array[items].length > longest) longest = array[items].length;

			while(items2--)
				array[items2] = pad(array[items2],longest);
				
			spans = longest;
			while(spans--)
				$(this).prepend("<span class='c" + spans + "'></span>");
				
			
			function testChar(a,b,c,d){
				if(c >= array.length)
					setTimeout(function() { testChar(0,0,0,0); }, 500);				
				else if(d >= longest)
					setTimeout(function() { testChar(0,0,c+1,0); }, 500);
				else {
					$(self).find('.c'+a).html((chars[b]==" ")?"&nbsp;":chars[b]);
					setTimeout(function() {
						if(b > chars.length)
							testChar(a+1,0,c,d+1);
						else if(chars[b] != array[c].substring(d,d+1).toLowerCase())
							testChar(a,b+1,c,d);
						else
							testChar(a+1,0,c,d+1);
					}, 20);
				}
			}
			
			testChar(0,0,0,0);
        } 
    }); 
})(jQuery);



