//Yoana 31/07/2006: Función que cambia el class de on a outon, para el caso de que sí tengamos javascript
// y el menú aparezca oculto. Por defecto pensamos que no va a haber javascript y tiene que salir desplegado
/*
function inicializarClass(idRepaso) {
	var elemento = document.getElementById(idRepaso);
	if (!elemento.className) {
		elemento.setAttribute("class","outon");
	} else {
		if ( elemento.className =="on") 
			elemento.className="outon"; 
	}
}
*/

function compruebaPopup(className, features) {

  var as = document.getElementsByTagName('a');

	for(i = 0; i < as.length; i++) {
		var a = as[i];
      r = new RegExp("(^| )"+className+"($| )");
      if(r.test(a.className)) {
			a.title= a.title + " Se abre en una nueva ventana";
			a.onclick = function() {
				window.open(this.href, 'nueva', features);
				return false;
		 	}
		}
	}
}

function reescribirEnlaces() {
	features='toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no';
	
	$A($$('a.nuevaVentana')).each(function(el, i) {
		var title = (el.getProperty('title') != null) ? el.getProperty('title') : '';
		el.setProperty('title', title  + " (se abre en una nueva ventana)");
		el.addEvent('click', function(e) {
			var ev = new Event(e);
			window.open(this.href, 'nuevaVentana', features);
			ev.stop();			
		});
	});
}

function compruebaPopup2(className,features){

  var as = document.getElementsByTagName('a');

   for(i=0;i<as.length;i++){
      var a = as[i];
      r=new RegExp("(^| )"+className+"($| )");
      if(r.test(a.className)){
			a.title= a.title + " Se abre en una nueva ventana";
			 a.onclick = function(){
             window.open(this.href, 'nueva2', features);
             return false;
		 }
        /* a.onkeypress = function(){
             window.open(this.href, 'nueva', features);
             return false;
         }*/
      }
    }
}

function ventanaNueva(className,features) {
	var as = document.getElementsByTagName('a');
 	for(i=0;i<as.length;i++) {
   	var a = as[i];
      r=new RegExp("(^| )"+className+"($| )");
      if(r.test(a.className)) {
			a.title= a.title + " Se abre en una nueva ventana";
			a.onclick = function() {
             window.open(this.href, 'nuevaVentana', features);
             return false;
			}
		}
	}
}


function abrirPopup(){
	var className = '';
	var features ='';
	
   className = 'nuevaVentana';
	features='toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no';
	ventanaNueva(className,features);
	
   className = 'abrirRegistro';
	features ='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=450,height=420';
	compruebaPopup(className,features);
	
	
	className = 'abrirFicha';
	features ='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=520,height=590';
	compruebaPopup(className,features);
	
	className = 'abrirPopup2';
	features ='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=520,height=550';
	compruebaPopup2(className,features);

	
	className = 'abrirDetalle';
	features ='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=520,height=590';
	compruebaPopup(className,features);
	
	className = 'abrirExplicar';
	features ='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=570,height=590';
	compruebaPopup(className,features);

}

Window.onDomReady(function() {
	abrirPopup();
});
