	
	function ActualizaCheck(ID)
	{

		if( $(ID).checked )
		{
			$("CHK_Hidden_"+ID).value='true';	
		}
		else
		{
			$("CHK_Hidden_"+ID).value='false';	
		}
		
	} // ActualizaCheck

	function ActualizaCheckCombinado(ID, i)
	{	
	
		if( $('CHK_'+ID+'_'+i).checked )
		{
			var texto=$('TXT_'+ID+'_'+i).value;
			$('VAR_'+ID+'_'+i).value=texto;
		}
		else
		{
			$('VAR_'+ID+'_'+i).value='';
			$('TXT_'+ID+'_'+i).value='';	
		}
	}


	function OnCalendario(id)
	{
		if($(id))
		{
			Calendar.setup(
			{
				inputField  : id,         // id of the input field
				ifFormat    : "%d/%m/%Y",    // the date format
				button      : "boton_fecha",       // id of the button
				align		  : "Bl"
			} );
		}
	}

	/**
	 * 
	 */
	function AmpliaHorario()
	{
		if( $$('.weekScheduler_anAppointment') )
		{
			$$('.weekScheduler_anAppointment').setStyle('width','120px');
			$$('.weekScheduler_appointments_day').setStyle('width', '125px');		
			$$('.DiaSemanaHorario').setStyle('width', '125px');			
		}		
	} // Final de AmpliaHorario
	



	/**
	 * 
	 */
	function ReduceHorario()
	{
		if( $$('.weekScheduler_anAppointment') )
		{
			$$('.weekScheduler_anAppointment').setStyle('width','94px');
			$$('.weekScheduler_anAppointment').setStyle('width','94px');
			$$('.weekScheduler_appointments_day').setStyle('width', '97px');		
			$$('.DiaSemanaHorario').setStyle('width', '97px');		
		}
	} // Final de ReduceHorario




	function ActualizaCheckCombinadoEx(ID, i)
	{	
	
		if( $('CHK_'+ID+'_'+i).checked )
		{
			var z=0;
			
			var texto=$('TXT1_'+ID+'_'+i).value;
			texto+=' '+$('TXT2_'+ID+'_'+i).value;
			$('VAR_'+ID+'_'+i).value=texto;
		}
		else
		{
			$('VAR_'+ID+'_'+i).value='';
			$('TXT1_'+ID+'_'+i).value='';	
			$('TXT2_'+ID+'_'+i).value='';	
		}
	}
	
	function VisualizacionImprimir(oculta)
	{
		if(oculta)
		{
			$('ubicacion1').setStyle('display','none');
			$('ubicacion2').setStyle('display','none');
			$('ubicacion5').setStyle('display','none');

			$('ubicacion3').setStyle('width','999px');

			if( $('Tabs') )
			{
				$('Tabs').setStyle('width','949px');
				$('Tabs').setStyle('margin-left','24px');
			}

			if( $('MIyui-content') )
			{
				$('MIyui-content').setStyle('width','936px');
			}
			
			if( $('contenedor_centralSTD') )
			{
				$('contenedor_centralSTD').setStyle('width','999px');	
			}
			
			// Para la visualizacion del horario
			
			
		}
		else
		{
			$('ubicacion1').setStyle('display','');
			$('ubicacion2').setStyle('display','');
			$('ubicacion5').setStyle('display','');

			$('ubicacion3').setStyle('width','755px');

			if($('Tabs'))
			{
				$('Tabs').setStyle('width','750px');
				$('Tabs').setStyle('margin-left','0px');
			}
			
			if( $('MIyui-content') )
			{
				$('MIyui-content').setStyle('width','738px');
			}

			if( $('contenedor_centralSTD') )
			{
				$('contenedor_centralSTD').setStyle('width','750px');	
			}
			
			
			// Para la visualizacion del horario
			if( $('weekScheduler_container') )
			{
				$('weekScheduler_container').setStyle('margin-left', '0');
			}

		}	
		
	} // VisualizacionImprimir


	function chImg(id, newsrc)
	{
		if ( typeof ( activo_boton_enviar ) != "undefined" )
		{
			if( activo_boton_enviar && document.getElementById(id) )
			{
				document.getElementById(id).src=newsrc;
			}
		}
		else
		{
			if( document.getElementById(id) )
			{
				document.getElementById(id).src=newsrc;
			}
		}
	}


        function displayKeyCode(evt)
        {

        var charCode = (evt.which) ? evt.which : event.keyCode

        if (charCode == 8) return  "backspace"; //  backspace
        if (charCode == 9) return  "tab"; //  tab
        if (charCode == 13) return  "enter"; //  enter
        if (charCode == 16) return  "shift"; //  shift
        if (charCode == 17) return  "ctrl"; //  ctrl
        if (charCode == 18) return  "alt"; //  alt
        if (charCode == 19) return  "pause/break"; //  pause/break
        if (charCode == 20) return  "caps lock"; //  caps lock
        if (charCode == 27) return  "escape"; //  escape
        if (charCode == 33) return  "page up"; // page up, to avoid displaying alternate character and confusing people
        if (charCode == 34) return  "page down"; // page down
        if (charCode == 35) return  "end"; // end
        if (charCode == 36) return  "home"; // home
        if (charCode == 37) return  "left arrow"; // left arrow
        if (charCode == 38) return  "up arrow"; // up arrow
        if (charCode == 39) return  "right arrow"; // right arrow
        if (charCode == 40) return  "down arrow"; // down arrow
        if (charCode == 45) return  "insert"; // insert
        if (charCode == 46) return  "delete"; // delete
        if (charCode == 91) return  "left window"; // left window
        if (charCode == 92) return  "right window"; // right window
        if (charCode == 93) return  "select key"; // select key
        if (charCode == 96) return  "numpad 0"; // numpad 0
        if (charCode == 97) return  "numpad 1"; // numpad 1
        if (charCode == 98) return  "numpad 2"; // numpad 2
        if (charCode == 99) return  "numpad 3"; // numpad 3
        if (charCode == 100) return  "numpad 4"; // numpad 4
        if (charCode == 101) return  "numpad 5"; // numpad 5
        if (charCode == 102) return  "numpad 6"; // numpad 6
        if (charCode == 103) return  "numpad 7"; // numpad 7
        if (charCode == 104) return  "numpad 8"; // numpad 8
        if (charCode == 105) return  "numpad 9"; // numpad 9
        if (charCode == 106) return  "multiply"; // multiply
        if (charCode == 107) return  "add"; // add
        if (charCode == 109) return  "subtract"; // subtract
        if (charCode == 110) return  "decimal point"; // decimal point
        if (charCode == 111) return  "divide"; // divide
        if (charCode == 112) return  "F1"; // F1
        if (charCode == 113) return  "F2"; // F2
        if (charCode == 114) return  "F3"; // F3
        if (charCode == 115) return  "F4"; // F4
        if (charCode == 116) return  "F5"; // F5
        if (charCode == 117) return  "F6"; // F6
        if (charCode == 118) return  "F7"; // F7
        if (charCode == 119) return  "F8"; // F8
        if (charCode == 120) return  "F9"; // F9
        if (charCode == 121) return  "F10"; // F10
        if (charCode == 122) return  "F11"; // F11
        if (charCode == 123) return  "F12"; // F12
        if (charCode == 144) return  "num lock"; // num lock
        if (charCode == 145) return  "scroll lock"; // scroll lock
        if (charCode == 186) return  ";"; // semi-colon
        if (charCode == 187) return  "="; // equal-sign
        if (charCode == 188) return  ","; // comma
        if (charCode == 189) return  "-"; // dash
        if (charCode == 190) return  "."; // period
        if (charCode == 191) return  "/"; // forward slash
        if (charCode == 192) return  "`"; // grave accent
        if (charCode == 219) return  "["; // open bracket
        if (charCode == 220) return  "\\"; // back slash
        if (charCode == 221) return  "]"; // close bracket
        if (charCode == 222) return  "'"; // single quote

        }
      function getObject(obj)
      {
      var theObj;
      if (document.all) {
      if (typeof obj=='string') {
      return document.all(obj);
      } else {
      return obj.style;
      }
      }
      if (document.getElementById) {
      if (typeof obj=='string') {
      return document.getElementById(obj);
      } else {
      return obj.style;
      }
      }
      return null;
      }
    

	function grow(targetid, x,y)
	{
		theheight=document.getElementById(targetid).offsetHeight;
		thewidth=document.getElementById(targetid).offsetWidth;		
		if(theheight<200)
		{
			document.getElementById(targetid).style.height=theheight+y+'px';
			document.getElementById(targetid).style.width=thewidth+x+'px';		
		}
		else
		{
			
		}
	}
	
	function crece(div,x,y)
	{
			var id = setInterval("grow('"+div+"',"+x+","+y+")",10);	
			setTimeout("clearInterval("+id+")",1000);	
	}


	function grow2(targetid, x,y,destino_x, destino_y)
	{
		theheight=parseInt(document.getElementById(targetid).style.height);
		thewidth=parseInt(document.getElementById(targetid).style.width);
		if(theheight<destino_y)
		{
			document.getElementById(targetid).style.height=theheight+y+'px';
		}
		if(thewidth<destino_x)
		{
			document.getElementById(targetid).style.width=thewidth+x+'px';		
		}
	}
	
	function amplia(div,destino_x,destino_y,pasos)		
	{

		
			var id = setInterval("grow2('"+div+"',"+destino_x/pasos+","+(destino_y)/pasos+","+destino_x+","+(destino_y)+")",10);	
			setTimeout("clearInterval("+id+")",100*pasos);		
		
	}
	
	function findTop(obj) 
	{
		var curtop = 0;
		if (obj.offsetParent) 
		{
			curtop = obj.offsetTop
			while (obj = obj.offsetParent) 
			{
				curtop += obj.offsetTop
			}
		}
		return curtop;
	
	}
	
	function grow2up(targetid, x,y,destino_x, destino_y)
	{
		theheight=parseInt(document.getElementById(targetid).style.height);
		thewidth=parseInt(document.getElementById(targetid).style.width);
		if(theheight<destino_y)
		{
			document.getElementById(targetid).style.height=theheight+y+'px';
			document.getElementById(targetid).style.top = (document.getElementById(targetid).offsetTop - y) + 'px';
		}
		if(thewidth<destino_x)
		{
			document.getElementById(targetid).style.width=thewidth+x+'px';		
		}
	}
	
	function amplia_arriba(div,destino_x,destino_y,pasos)		
	{
			var id = setInterval("grow2up('"+div+"',"+destino_x/pasos+","+(destino_y)/pasos+","+destino_x+","+(destino_y)+")",10);	
			setTimeout("clearInterval("+id+")",100*pasos);		
		
	}	
	
	
	function reduce(div,x,y,destino_x,destino_y)
	{
		var theheight=parseInt(document.getElementById(div).style.height);
		var thewidth=parseInt(document.getElementById(div).style.width);
		if(theheight>destino_y)
		{
			document.getElementById(div).style.height=theheight-y+'px';
		}
		if(thewidth>destino_x)
		{
			document.getElementById(div).style.width=thewidth-x+'px';		
		}
		
				
	}
	
	function estrecha(div,destino_x, pasos)
	{
//			var id = setInterval("reduce('"+div+"',"+destino_x/pasos+",0,"+destino_x+",1000)",10);	
			var id = setInterval("reduce('ubicacion2',10,10,100,100)",10);	
			setTimeout("clearInterval("+id+")",100*pasos);		
	}


	function oculta(div)
	{
		$(div).setStyle('display', 'none');
	}

function AsignarVideo2(div, url) // se incluye por motivos de retrocompatibilidad
{
	AsignarVideoConBarra(div, url);
}
	
function AsignarVideoConBarra(div, url)
{	
	var barra="<div id=\"barra\" class=\"barra_cabecera\" ><img onClick=\"VaciaDiv('"+div+"')\" src=\""+urlbase+"/funciones/imagenes/aspa.jpg\"></div>";

	var macro='<div id=\"player_menu\"><a href=\"http://www.macromedia.com/go/getflashplayer\">Get the Flash Player</a> to see this player.</div>';

	document.getElementById(div).innerHTML =barra+macro;

	var ancho = $(div).getSize().x;
	var alto_total = $(div).getSize().y;
	var alto = alto_total - $('barra').getSize().y;		
		
	
	document.getElementById(div).style.zIndex=7;
	document.getElementById(div).style.backgroundColor="#000000";
	document.getElementById(div).style.overflow = 'hidden';
   	
   	var FO = {	movie:"./funciones/mediaplayer-3-14/mediaplayer.swf",width:ancho,height:alto,majorversion:"7",build:"0",bgcolor:"#FFFFFF", flashvars:"file="+url+"&showdigits=true&autostart=true&showfsbutton=false&repeat=true&backcolor=0xB7D30B&frontcolor=0x000000&logo=logoender.png&fullscreenmode=false" };			
	UFO.create(	FO, "player_menu");
	 
	$(div).makeDraggable();
	document.getElementById(div).style.height = 0;
	document.getElementById(div).style.width = 0;			
	document.getElementById(div).style.left = 0;
    amplia(div,ancho,alto_total,10);
    
    

} 	


function InsertarVideo(div, url,ancho,alto)
{	
	var barra="<div id=\"barra\" class=\"barra_cabecera\" onDblClick=\"VaciaDiv('"+div+"')\"><img src=\"/funciones/imagenes/aspa.jpg\"></div>";

	var macro='<div id=\"player_menu\"><a href=\"http://www.macromedia.com/go/getflashplayer\">Get the Flash Player</a> to see this player.</div>';
		
	document.getElementById(div).innerHTML =barra+macro;
	
	document.getElementById(div).style.zIndex=7;
	document.getElementById(div).style.backgroundColor="#000000";
	document.getElementById(div).style.overflow = 'hidden';
   	
   	var FO = {	movie:"./funciones/flash_flv_player/flvplayer.swf",width:ancho,height:alto,majorversion:"7",build:"0",bgcolor:"#FFFFFF", flashvars:"file="+url+"&showdigits=true&autostart=true&showfsbutton=false&repeat=true&backcolor=0xB7D30B&frontcolor=0x000000&logo=logoender.png&fullscreenmode=false" };			
	UFO.create(	FO, "player_menu");
	 
    

} 



function AsignarVideoLSE(div, url)
{	
	var barra="<div id=\"barra\" class=\"barra_cabecera\" onClick=\"VaciaDiv('"+div+"')\"><img src=\"../../archivos/aspa.jpg\"></div>";

	var macro='<div id=\"player_menu\"><a href=\"http://www.macromedia.com/go/getflashplayer\">Get the Flash Player</a> to see this player.</div>';
		
	document.getElementById(div).innerHTML =barra+macro;
	
	document.getElementById(div).style.zIndex=7;
	document.getElementById(div).style.backgroundColor="#000000";
	document.getElementById(div).style.overflow = 'hidden';
   	
   	var FO = {	movie:"./funciones/flash_flv_player/flvplayer.swf",width:"720",height:"480",majorversion:"7",build:"0",bgcolor:"#FFFFFF", flashvars:"file="+url+"&showdigits=true&autostart=true&showfsbutton=false&repeat=true&backcolor=0xB7D30B&frontcolor=0x000000&logo=logoender.png&fullscreenmode=false" };			
	UFO.create(	FO, "player_menu");
	 

	document.getElementById(div).style.height = 0;
	document.getElementById(div).style.width = 0;			
	document.getElementById(div).style.left = 0;

    if(navigator.appName == 'Microsoft Internet Explorer')
    {
	    document.getElementById(div).style.height = '500px';
	    document.getElementById(div).style.width = '720px';
	    document.getElementById(div).style.zIndex = '9';
    }
    else
    {
    	amplia(div,720,500,5);
    }
    

}


function toCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? ',' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function toDots(nStr)
{
	nStr += '';
	x = nStr.split(',');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + '.' + '$2');
	}
	return x1 +x2;
}

function cambiaFondo(div,color)
{
	document.getElementById(div).style.backgroundColor = color;
}

function getElementsByClassName(elm, tag, className){
	var testClass = new RegExp("(^|\\s)" + className + "(\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}

function MostrarAlerta(texto,tiempo,funcionRetorno)
{
		var html = "<div class='fondo_alerta'></div><div id='texto_aviso_1' class='texto_alerta'>"+texto+"</div>";
		var nueva_div = document.createElement('div');
		nueva_div.id = 'aviso_alerta';
		
		nueva_div.className ='contenedor_alerta';
		nueva_div.innerHTML = html;
		// nueva_div.onclick = function(){document.getElementById('contenedor_alai').removeChild(nueva_div);};
		nueva_div.onclick = function(){CerrarAlerta();}; 
		nueva_div_temp = $(nueva_div);
		nueva_div_temp.injectBefore('contenedor_alai');
		settings = {
			tl: { radius: 20 },
			tr: { radius: 20 },
			bl: { radius: 20 },
			br: { radius: 20 },
			antiAlias: true, autoPad: true
			} 
		var divObj = document.getElementById("texto_aviso_1"); 
		var cornersObj = new curvyCorners(settings, divObj);
		cornersObj.applyCornersToAll();
		if(tiempo>0)
		{

			if(funcionRetorno)
			{
				setTimeout("CerrarAlerta('"+funcionRetorno+"')",tiempo*1000);			
			}
			else
			{
				setTimeout("CerrarAlerta()",tiempo*1000);			
			}
		}

}

function CerrarAlerta(funcionRetorno)
{
	if($('aviso_alerta'))
	{
		$('aviso_alerta').remove();
	}	
	
	if( funcionRetorno )
	{
		eval(funcionRetorno+"();");
	}	
}


function DiaDeLaSemana(day,month,year) 
{
	var oyear=year
	var dob = " "+ year +", "+month + ",  "+day;
	var thenx = new Date(dob);

	var year=thenx.getYear();
	if (year<100) year="19" + thenx.getYear();
	else year=thenx.getYear();

	if (year > 1969) wyear=year;
	else 
	{
		if (oyear<1900) 
		{
			if (oyear>1800) 
			{
				wrelyear= (eval(oyear)-1801)%(28);
				wyear = wrelyear+1981;
			}
			else 
				wyear = 1970
		}
		else
		if (oyear>1900) 
		{	
			wrelyear= (eval(oyear)-1901)%(28); 
			wyear= wrelyear+1985
		}
		else if (oyear==1900) 
		{
			wyear= 1990;
   		}              
	}
	var dob = " "+ wyear +", "+month + ",  "+day;
	var thenx = new Date(dob);

	var theday = thenx.getDay()+1;
	var date=thenx.getDate();

	var weekday = new Array(6);
	weekday[1]="Domingo";
	weekday[2]="Lunes";
	weekday[3]="Martes";
	weekday[4]="Mi�rcoles";
	weekday[5]="Jueves";
	weekday[6]="Viernes";
	weekday[7]="S�bado";

	return weekday[theday];
}

function UltimoCaracter(texto)
{
	return texto.charAt(texto.length-1);
}

function aLog(texto)
{
	document.getElementById('log_alai').innerHTML += '<li>'+texto+'</li>';
}

function ExisteId(elemento)
{
	var array_elemento = $$('#'+elemento);
	if(array_elemento.length > 0)
	{
		return true;
	}
	else
	{
		return false;
	}
	
}

function AsignarMP3(div, url,autostart)
{	
	
	document.getElementById(div).style.zIndex=7;
	document.getElementById(div).style.backgroundColor="#000000";
	document.getElementById(div).style.overflow = 'hidden';
	document.getElementById(div).style.display = 'block';
	var ancho = $(div).getSize().x;
	var alto = $(div).getSize().y;
   	if(autostart)
   	{
   		var FO = {	wmode:"transparent",movie:"./funciones/mediaplayer-3-14/mediaplayer.swf",width:ancho,height:alto,majorversion:"7",build:"0",bgcolor:"#FFFFFF", flashvars:"file="+url+"&autostart=true&repeat=false" };
   	}
   	else
   	{
   		var FO = {	wmode:"transparent",movie:"./funciones/mediaplayer-3-14/mediaplayer.swf",width:ancho,height:alto,majorversion:"7",build:"0",bgcolor:"#FFFFFF", flashvars:"file="+url+"&autostart=false&repeat=false" };
   	}			
	UFO.create(	FO, div);

} 	






function AsignarVideo(div,url)
{
	var ancho = $(div).getSize().x;
	var alto = $(div).getSize().y;
	AsignarVideoParametros(div,url,'false','false',ancho,alto);
}

function AsignarVideoParametros(div,url,autostart,repeat,ancho,alto)
{
	document.getElementById(div).style.zIndex=7;
	document.getElementById(div).style.backgroundColor="#000000";
	document.getElementById(div).style.overflow = 'hidden';
   	
   	var FO = {	wmode:"transparent",movie:"./funciones/flash_flv_player/flvplayer.swf",width:ancho,height:alto,majorversion:"7",build:"0",bgcolor:"#FFFFFF", flashvars:"file="+url+"&autostart="+autostart+"&repeat="+repeat };			
	UFO.create(	FO, div);
}



function Redondea(div,tl,tr,bl,br)
{
	settings = {
	tl: { radius: tl},
	tr: { radius: tr },
	bl: { radius: bl },
	br: { radius: br },
	antiAlias: true, autoPad: true
	}
	var divObj = document.getElementById(div);
	var cornersObj = new curvyCorners(settings, divObj);
	cornersObj.applyCornersToAll();

}

function RedondeaA10(div)
{
	Redondea(div,10,10,10,10);
	
}



function LanzarScript(identificador,url_script)
{
	 var nuevo_contenedor = new Element('div',{id:identificador,name:identificador});
	 nuevo_contenedor.innerHTML = "<iframe src='"+url_script+"'></iframe>";
 	 nuevo_contenedor.setStyle('height','0');
 	 nuevo_contenedor.addClass('oculto');
	 nuevo_contenedor.injectInside('contenedor_alai');

}



function AumentarTexto(clase)
{
	
	var tamanyo = jQuery(clase).css('font-size').toInt();
	
	jQuery(clase).css('font-size',(tamanyo+2)+'px');
}


function DisminuirTexto(clase)
{
	var tamanyo = jQuery(clase).css('font-size').toInt();
	
	jQuery(clase).css('font-size',(tamanyo-2)+'px');
}




