// Fechas
function MostrarFecha()
   {
   var nombres_dias = new Array("Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado")
   var nombres_meses = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre")

   var fecha_actual = new Date()

   dia_mes = fecha_actual.getDate()		//dia del mes
   dia_semana = fecha_actual.getDay()		//dia de la semana
   mes = fecha_actual.getMonth() + 1
   anio = fecha_actual.getYear()

   if (anio < 100)					//pasa el año a 4 digitos
      anio = '19' + anio
   else if ( ( anio > 100 ) && ( anio < 999 ) ) {	//efecto 2000
      var cadena_anio = new String(anio)
      anio = '20' + cadena_anio.substring(1,3)
   }

   //escribe en pagina
   document.write(nombres_dias[dia_semana] + ", " + dia_mes + " de " + nombres_meses[mes - 1] + " de " + anio)
   }

// Fin Fechas


// Editor de Textos

<!-- Begin
function View(form) {
msg=open("","DisplayWindow","status=1,scrollbars=1");
msg.document.write(form.Text2.value);
}
function Generate(form) {
var txt="<html><HEAD><TITLE>"+form.Name.value+"</TITLE></HEAD>\r\n";
txt+=
"<CENTER><h1><font color=red>"+form.Name.value+"</font></h1></CENTER><hr>\r\n";
txt+="<body><font size=4>\r\n";
if(form.descripcion.value)    
txt+=form.descripcion.value+"\r\n";    if(form.Fav1URL.value||form.Fav2URL.value||form.Fav3URL.value||form.Fav4URL.value||form.Fav5URL.value||form.Fav6URL.value) {
txt+="<hr><font>Some of my favorite links:<BR><ul>\r\n<LI><a href=http://javascriptsource.com>The JavaScript Source</a><BR>\r\n";
if(form.Fav1URL.value)          
txt+="<LI><a href="+form.Fav1URL.value+">"+form.Fav1Title.value+"</a><BR>\r\n";
if(form.Fav2URL.value)          
txt+="<LI><a href="+form.Fav2URL.value+">"+form.Fav2Title.value+"</a><BR>\r\n"; 
if(form.Fav3URL.value)          
txt+="<LI><a href="+form.Fav3URL.value+">"+form.Fav3Title.value+"</a><BR>\r\n"; 
if(form.Fav4URL.value)          
txt+="<LI><a href="+form.Fav4URL.value+">"+form.Fav4Title.value+"</a><BR>\r\n"; 
if(form.Fav5URL.value)          
txt+="<LI><a href="+form.Fav5URL.value+">"+form.Fav5Title.value+"</a><BR>\r\n"; 
if(form.Fav6URL.value)          
txt+="<LI><a href="+form.Fav6URL.value+">"+form.Fav6Title.value+"</a><BR>\r\n"; 
txt+="</ul></font>";    
}
if(form.EMail.value){   
txt+="<hr>Questions? Comments? E-Mail me:\r\n"; 
txt+="<address><a href=mailto:"+form.EMail.value+">"+form.EMail.value+"</address>\r\n"; 
}
txt+="</font></body></html>";
form.Text2.value=txt;
}
function AddText(form, Action){
var AddTxt="";
var txt="";
if(Action==1){  
txt=prompt("Text for the level 1 header.","Text");      
if(txt!=null)           
AddTxt="<h1>"+txt+"</h1>\r\n";  
}
if(Action==2){  
txt=prompt("Text for the level 2 header.","Text");      
if(txt!=null)           
AddTxt="<h2>"+txt+"</h2>\r\n";  
}
if(Action==3){  
txt=prompt("Text for the level 3 header.","Text");      
if(txt!=null)           
AddTxt="<h3>"+txt+"</h3>\r\n";  
}
if(Action==4) {  
txt=prompt("Text to be made BOLD.","Text");     
if(txt!=null)           
AddTxt="<b>"+txt+"</b>";        
}
if(Action==5) {  
txt=prompt("Text to be italicized","Text");     
if(txt!=null)           
AddTxt="<i>"+txt+"</i>";        
}
if(Action==6) AddTxt="\r\n<p>";
if(Action==7) AddTxt="<BR>\r\n";
if(Action==8) AddTxt="<hr>\r\n";
if(Action==9) {  
txt=prompt("URL for the link.","http://");      
if(txt!=null){          
AddTxt="<a href="+txt+">";              
txt=prompt("Text to be show for the link","Text");              
AddTxt+=txt+"</a>\r\n";         
   }
}
if(Action==10) { 
txt=prompt("URL for graphic","URL");    
if(txt!=null)           
AddTxt="<img src="+txt+">\r\n"; 
}
form.descripcion.value+=AddTxt;
}
function ResetPage(form) {
if(confirm("Reset the page?")) { 
form.descripcion.value="";    
form.Text2.value="";    
form.Name.value="";     
form.EMail.value="";    
form.Fav1URL.value="";  
form.Fav1Title.value="";        
form.Fav2URL.value="";  
form.Fav2Title.value="";        
form.Fav3URL.value="";  
form.Fav3Title.value="";        
form.Fav4URL.value="";  
form.Fav4Title.value="";        
form.Fav5URL.value="";  
form.Fav5Title.value="";        
form.Fav6URL.value="";  
form.Fav6Title.value="";        
   }
}

// End -->  

// Editor de Textos

// Mostrar Textos en Capas

var OpacidadInicial=0

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 MostrarTexto(TextoAMostrar){
	if (!document.getElementById)
		return
		textcontainerobj=document.getElementById("descripcion")
		browserdetect=textcontainerobj.filters? "ie" : typeof    
		textcontainerobj.style.MozOpacity=="string"? "mozilla" : ""
		instantset(OpacidadInicial)
		document.getElementById("descripcion").innerHTML=TextoAMostrar
		highlighting=setInterval("gradualfade(textcontainerobj)",70)
}
 
function OcultarTexto(){
	LimpiarTiempo()
	instantset(OpacidadInicial)
}

function instantset(degree){
	if (browserdetect=="mozilla")
    	textcontainerobj.style.MozOpacity=degree/100
	else if (browserdetect=="ie")
		textcontainerobj.filters.alpha.opacity=degree
    else if (document.getElementById && OpacidadInicial==0)
    	document.getElementById("descripcion").innerHTML=""
}
function LimpiarTiempo(){
	if (window.highlighting) clearInterval(highlighting)
}

function gradualfade(cur2){
	if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
		cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.2, 0.99)
	else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
		cur2.filters.alpha.opacity+=30
	else if (window.highlighting)
		clearInterval(highlighting)
}

// Fin Mostrar Textos en Capas

// Rutinas AJAX

function actualizar_ajax(rutina,formulario,parametro,valor,tag){

        if (!tag) tag='cuerpo';
		var url,argumentos,argumento;	

		if (parametro!=''){
			argumento='&'+escape(parametro)+'='+escape(valor);
		}else{
			argumento='';			
		}
	
		url = 'index.php?jump='+escape(rutina)+argumento;

		if (formulario!=''){
			argumentos={asynchronous:true, evalScripts:true, parameters:Form.serialize(formulario)};
		}else {
			argumentos={asynchronous:true, evalScripts:true};
		}
        var myAjax = new Ajax.Updater(tag, 
		url,
		argumentos);

}

function actualizar_ajax_test(rutina,formulario,parametro,valor,tag){

        if (!tag) tag='cuerpo';
		var url,argumentos,argumento;	

		if (parametro!=''){
			argumento='&'+escape(parametro)+'='+escape(valor);
		}else{
			argumento='';			
		}
	
		url = 'index.php?jump='+escape(rutina)+argumento;

		if (formulario!=''){
			argumentos={asynchronous:true, evalScripts:true, parameters:Form.serialize(formulario)};
		}else {
			argumentos={asynchronous:true, evalScripts:true};
		}

        new Ajax.Request(url, {
            method: 'get',
            onSuccess: function(transport) {
                var notice = $(tag);
                setAndExecute(tag, transport);
                notice.update(transport.responseText);
            }
        });

}

function setAndExecute(divId, t)
{
    var div = document.getElementById(divId);
    div.innerHTML = t.responseText;
    var x = div.getElementsByTagName("script"); 
    for(var i=0;i<x.length;i++)
    {
        if (x[i].src) {
            alert(x[i].src);
            // nos piden incluir un fichero js
            var e = document.createElement("script");
            e.src = x[i].src;
            e.type = "text/javascript";
            document.getElementsByTagName("head")[0].appendChild(e);
        } else {
            //alert(x[i].text);
            // ejecutamos el script
            //window.eval(x[i].text);
            eval(x[i].text);
            //var a=t.evalScripts();
        }
    }
}


function call_ajax(url,formulario,tag)
{
        if (!tag) tag='cuerpo';

		if (formulario!=''){
			argumentos={asynchronous:true, evalScripts:true, parameters:Form.serialize(formulario)};
		}else {
			argumentos={asynchronous:true, evalScripts:true};
		}
        var myAjax = new Ajax.Updater(tag, 
		url,
		argumentos);

        var d = document.getElementById(tag);
        var scripts = d.getElementsByTagName('script');
        for (var ix = 0; ix < scripts.length; ix++) {
            eval(scripts[ix].text);
        }

}



