var my_window =1;

var timer_id;

// INICIO CUENTA REGRESIVA

//I chose a div as the container for the timer, but
//it can be an input tag inside a form, or anything
//who is displayed content can be changed through
//client-side scripting.
function countdown_clock(year, month, day, hour, minute, format){
html_code = '<div id=\"countdown\"></div>';
document.write(html_code);
countdown(year, month, day, hour, minute, format);                
}
         
function countdown(year, month, day, hour, minute, format){
Today = new Date();
Todays_Year = Today.getFullYear() - 2000;
Todays_Month = Today.getMonth() + 1;                  
         
//Convert both today's date and the target date into miliseconds.                           
Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(), 
Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();                                 
Target_Date = (new Date(year, month, day, hour, minute, 00)).getTime();                  
         
//Find their difference, and convert that into seconds.                  
Time_Left = Math.round((Target_Date - Todays_Date) / 1000);
         
if(Time_Left < 0)
   Time_Left = 0;

switch(format){
case 0:
     //The simplest way to display the time left.
     document.getElementById("countdown").innerHTML = Time_Left + ' segundos';
     break;
case 1:
     //More datailed.
     days = Math.floor(Time_Left / (60 * 60 * 24));
     Time_Left %= (60 * 60 * 24);
     hours = Math.floor(Time_Left / (60 * 60));
     Time_Left %= (60 * 60);
     minutes = Math.floor(Time_Left / 60);
     Time_Left %= 60;
     seconds = Time_Left;
     
     dps = 's'; hps = 's'; mps = 's'; sps = 's';
     //ps is short for plural suffix.
     if(days == 1) dps ='';
     if(hours < 10) hps ='0';
     if(minutes < 10) mps ='0';
     if(seconds < 10) sps ='0';
     
     document.getElementById("countdown").innerHTML = days + ' día' + dps + ' ';
     document.getElementById("countdown").innerHTML += hours + ':';
     document.getElementById("countdown").innerHTML += minutes + ':';
     document.getElementById("countdown").innerHTML += seconds;
//     document.getElementById("countdown").innerHTML += hours + ' hora' + hps + ' ';
//     document.getElementById("countdown").innerHTML += minutes + ' minuto' + mps + ' y ';
//     document.getElementById("countdown").innerHTML += seconds + ' segundo' + sps;
     break;
default: 
     document.getElementById('countdown').countdown.innerHTML = Time_Left + ' segundos';
}
      
//Recursive call, keeps the clock ticking.
setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
}

// FIN CUENTA - REGRESIVA

function scroll_iframe(frm,inc,dir) {
  if (timer_id) clearTimeout(timer_id);
  if (window.frames[frm]) {
    if (dir == "v") window.frames[frm].scrollBy(0, inc);
    else window.frames[frm].scrollBy(inc, 0);
    timer_id = setTimeout("scroll_iframe('" + frm + "'," + inc + ",'" + dir + "')", 20);
  }
}

function stopScroll() { if (timer_id) clearTimeout(timer_id); }

function changeto(highlightcolor){
source=event.srcElement
source.style.backgroundColor=highlightcolor
}

function changeback(originalcolor){
source.style.backgroundColor=originalcolor
}

function framePrint(whichFrame){
parent[whichFrame].focus();
parent[whichFrame].print();
}

function contar() {
var cont = 0; 
for (var i=0;i < document.forms[0].elements.length;i++)
{ if (document.forms[0].elements[i].checked) {
	cont = cont + 1;
  }
};
document.form.contador.value = cont
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2)
eval(args[i]+".location='"+args[i+1]+"'");
}

function confirma(msgStr) { //v1.0

var agree=confirm(msgStr);
if (agree)  parent.close(); 

}

function cierra() { //v1.0

opener.parent.location.reload();
self.close(); 

}

function cierra_ventana(msgStr) { //v1.0
self.close()
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status = msgStr;
  document.MM_returnValue = true;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  var my_window = window.open(theURL,winName,features);
  my_window.focus();
}

function abrirventana (href,target,ancho,alto,resizable,scrollbars) {
	var x, y;

	if (ancho != null && alto != null) {
		x = (screen.width - ancho) / 2;
		y = (screen.height - alto) / 2.5;
	}

	ventana = window.open(href,
						  target,
						  "width=" + ancho +
						  ",height=" + alto +
						  ",menubar=0" +
						  ",toolbar=0" +
						  ",resizable=" + resizable +
						  ",scrollbars=" + scrollbars +
						  ",status=0" +
						  ",left=" + x +
						  ",top=" + y);

	ventana.focus();
	return ventana

}

function closepopup()
{	if(false == my_window.closed)
	{
	my_window.close();
	}
}

function aviso()
{ alert('Esta sesión será cerrada en un minuto, si Ud. está modificando este formulario, proceda a grabar en este momento');
}

function temporizador(tiempo)
{
timeout = setTimeout('aviso()',tiempo);
}

function volver()
{
  if (history.length > 0)
    {history.back()};
}

function MM_popupMsg(msg) { //v1.0
  alert(msg);
}

function cambia()
{
  document.form.patron.value=document.form.patron.value.toUpperCase();

  if (document.form.patron.value.length < 3 )
  {  alert('El patrón ingresado debe tener más de 2 caracteres !!');
     return false;
  }
  else
  {
  return true ;
  }
}

function volver() {
timeout = setTimeout('javascript:back()',2000);
}

function enlace(seleccion, ventana)
{
if (seleccion.selectedIndex > 0)
{ ventana.location.href = seleccion.options[seleccion.selectedIndex].value}
}

function NoIngresaObservacion()
{
return confirm('Ud. no ha ingresado sus observaciones a las calificaciones. De todas formas las acepta ...')
}

function graba()
{
return confirm('Seguro de Grabar información ?')
}

function elimina()
{
return confirm('Seguro de Eliminar información ?')
}

function eliminaOpinion(){
	return confirm('Seguro de eliminar su opinión del foro ?')
}

function GrabarConfiguracionCurso()
{
return confirm('Desea Grabar la Configuración del Curso?, Observ.: La distribución uniforme de las evaluaciones serán recalculados, para que usted modifique tal distribución posteriormente')
}

function SeleccionarTodos(chkbox)
{
	var mensaje = '';
	for (var i=0;i < document.forms[0].elements.length;i++)
	{
		var elemento = document.forms[0].elements[i];
		if (elemento.type == 'checkbox')
		{
			elemento.checked = true;
		};
	};
}

function SeleccionarNada(chkbox)
{
	var mensaje = '';
	for (var i=0;i < document.forms[0].elements.length;i++)
	{
		var elemento = document.forms[0].elements[i];
		if (elemento.type == 'checkbox')
		{
			elemento.checked = false; //chkbox.checked
		};
	};
}

function SeleccionarTodo(chkbox)
{
	var mensaje = '';
	for (var i=0;i < document.forms[0].elements.length;i++)
	{
		var elemento = document.forms[0].elements[i];
		if (elemento.type == 'checkbox')
		{
			elemento.checked = true; //chkbox.checked
		};
	};
}

function SeleccionarAll(chkbox)
{
	var mensaje = '';
	for (var i=0;i < chkbox.elements.length;i++)
	{
		var elemento = chkbox.elements[i];
		if (elemento.type == 'checkbox')
		{
			elemento.checked = true;
		};
	};
}

function SeleccionarNone(chkbox)
{
	var mensaje = '';
	for (var i=0;i < chkbox.elements.length;i++)
	{
		var elemento = chkbox.elements[i];
		if (elemento.type == 'checkbox')
		{
			elemento.checked = false; //chkbox.checked
		};
	};
}

function revisaCheckbox(f) {
// Creado por: Freddy Castro (freddy76@gmail.com)
// Descripción: revisa que todos al menos un campo checkbox de un form esté chequeado.
// Modo de uso: onClick='return revisaCheckbox(document.nombreForm)'
// Salida: retorna TRUE (cuando se chequeo al menos una checkbox) o FALSE (si no hay ninguna chequeada)
var msg = 0;
var i;
for(i=0;i<f.elements.length;i++){
	var elemento = f.elements[i];
	if(elemento.type == 'checkbox' && elemento.checked == true){ 
		// Si el elemento es checkbox y está chequeado, acumulamos.
		msg++;
	}
}
if(msg == 0){
	alert('Debe seleccionar al menos un elemento de la lista.');
	return false;	
}
return true;
}

function deshabilita(chkbox)
{
	var mensaje = '';
	for (var i=0;i < document.forms[0].elements.length;i++)
	{
	   var elemento = document.forms[0].elements[i];
	   if (elemento.type == 'checkbox')
		{
		  elemento.disabled = true; 
		};
	};
}

function sololectura(chkbox)
{
	var mensaje = '';
	for (var i=0;i < document.forms[0].elements.length;i++)
	{
	   var elemento = document.forms[0].elements[i];
	   if (elemento.type == 'checkbox')
		{
		  elemento.onclick  = function() {this.checked=true;};
		};
	};
}

function chequea_campo(formulario,campo){
if (Empty(document.forms[formulario].elements[campo].value))
{    alert('El campo está vacío!!');
     document.forms[formulario].elements[campo].focus();    
     return false;	
}
return true;
}

function abrirCerrarTit(tr,ver) {
  var filaTr = eval('document.all.' + tr);
  if (ver.checked) {
    filaTr.style.display = 'block';
  }else{
    filaTr.style.display = 'none';
  }
}

function abrirCerrar(tr,img) {
  var filaTr = eval('document.all.' + tr);
  if (filaTr.style.display=='block' || filaTr.style.display=='' ) {
    filaTr.style.display='none';
    img.children[1].children[0].src='/intranet/imagenes/PLUS.GIF';
  }else{
    filaTr.style.display='block';
    img.children[1].children[0].src='/intranet/imagenes/MINUS.GIF';
  }
}

function abrirCerrarAnuncio(tr,img) {
  var filaTr = eval('document.all.' + tr);
  if (filaTr.style.display=='block' || filaTr.style.display=='' ) {
    filaTr.style.display='none';
    img.children[1].children[0].src='/intranet/imagenes/PLUS.GIF';
  }else{
    filaTr.style.display='block';
    img.children[1].children[0].src='/intranet/imagenes/MINUS.GIF';
  }
}

function abrirCerrarCursos(tr,img) {
var filaTr = eval('document.all.' + tr);
  if (filaTr.style.display=='block' || filaTr.style.display=='' ) {
    filaTr.style.display='none';
    img.children[0].children[0].src='/intranet/imagenes/PLUS.GIF';
  }else{
    filaTr.style.display='block';
    img.children[0].children[0].src='/intranet/imagenes/MINUS.GIF';
  }
}

function expandirTodos(Fila,Obj){
	var elementos = document.getElementsByTagName('tr');
	var ident			= Obj.id;
	var visible;
  opcion = ident.slice(5,6);
  
	if(opcion == 1){ 
	  for (var i = 0; i < elementos.length; i++) {
	  	if(elementos[i].name == Fila){
	  		if(navigator.appName.toUpperCase().indexOf('MICROSOFT') >= 0){
	  			visible = 'block';
	  		} else {
	  			visible = 'table-row';
	  		}
	  		elementos[i].style.display = visible;
	  		//elementos[i].children[0].children[0].src='/intranet/imagenes/MINUS.GIF';
	   	}
	  }
		Obj.value = 'Contraer Todos';
		Obj.id		= 'boton2';
	}
	else if(opcion == 2){
  	for (k = 0; k < elementos.length; k++) {
			if(elementos[k].name == Fila){
  			elementos[k].style.display = 'none';
  			//elementos[k].children[0].children[0].src='/intranet/imagenes/PLUS.GIF';
  		}
  	}
  	Obj.value = 'Expandir Todos';
  	Obj.id		= 'boton1';
	}
}
	
function contraerTodos(Fila){
var elementos = document.getElementsByTagName('tr');
	for (k = 0; k < elementos.length; k++) {
		if(elementos[k].name == 'Op'){
  		elementos[k].style.display = 'none';
  	}
  }
}

function ieExecWB( intOLEcmd, intOLEparam )
{         var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
          document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
          if ( ( ! intOLEparam ) || ( intOLEparam < -1 )  || ( intOLEparam > 1) )
           intOLEparam = 1;
          WebBrowser1.ExecWB( intOLEcmd, intOLEparam );
          WebBrowser1.outerHTML = "";
}

function printAll()
{	ieExecWB(6,-1); 
}

function getCookie(name){
  var cname = name + "=";               
  var dc = document.cookie;             
  if (dc.length > 0) {              
    begin = dc.indexOf(cname);       
    if (begin != -1) {           
      begin += cname.length;       
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
        return unescape(dc.substring(begin, end));
    } 
  }
  return null;
}

function setCookie(name, value, expires, path, domain, secure) {
  document.cookie = name + "=" + escape(value) + 
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null) ? "" : "; path=" + path) +
  ((domain == null) ? "" : "; domain=" + domain) +
  ((secure == null) ? "" : "; secure");
}

function delCookie (name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path == null) ? "" : "; path=" + path) +
    ((domain == null) ? "" : "; domain=" + domain) +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

// Función creada por: Freddy Castro
// Esta función revisa si los campos ingresados en el ingreso a la Intranet están vacíos
function chequeaCamposVacios(login,pass){
var msg;
var error1;
var error2;
error1 = 0;
error2 = 0;
msg = "";
if(Empty(login)){
	error1 = 1;
	msg += "\nEl campo USUARIO está vacío\n";
}
if(!isInteger(login)){
	error1 = 1;
	msg += "\nEl campo USUARIO debe ser numérico\n\nUse su RUT sin puntos ni digito verificador.\n";
}
if(Empty(pass)){
	error2 = 1;
	msg += "\nEl campo CLAVE está vacío\n";
}
if(msg == ""){
	return true;
}
alert(msg);
if(error1 == 0 && error2 == 1){
	document.form1.pass.value = "";
	document.form1.pass.focus();
}else{
	document.form1.usuario.value = "";
	document.form1.pass.value = "";
	document.form1.usuario.focus();
}
return false;
}	

function detectaBrowser(){
	var detect = navigator.userAgent.toLowerCase();
	var OS,browser,version,total,thestring='';
	var msg = '';
	
	if (checkIt('konqueror',detect)){
		browser = "Konqueror";
		OS = "Linux";
		thestring = "konqueror"
	}
	else if (checkIt('safari',detect)){ browser = "Safari"; thestring = "safari" }
	else if (checkIt('omniweb',detect)){ browser = "OmniWeb"; thestring = "omniweb" }
	else if (checkIt('opera',detect)){ browser = "Opera"; thestring = "opera" }
	else if (checkIt('webtv',detect)){ browser = "WebTV"; thestring = "webtv" }
	else if (checkIt('icab',detect)){ browser = "iCab"; thestring = "icab" }
	else if (checkIt('msie',detect)){ browser = "Internet Explorer"; thestring = "msie" }
	else if (!checkIt('compatible',detect)){
		browser = "Netscape Navigator";
		version = detect.charAt(8);
		thestring = "compatible"
	}
	else browser = "An unknown browser";
	
	if (!version) 
		version = detect.charAt(place + thestring.length);
	
	if (!OS){
		if (checkIt('linux',detect)) OS = "Linux";
		else if (checkIt('x11',detect)) OS = "Unix";
		else if (checkIt('mac',detect)) OS = "Mac"
		else if (checkIt('win',detect)) OS = "Windows"
		else OS = "Sistema Operativo no registrado en nuestra base de datos.";
	}
	if(((thestring == 'msie') && (version < 6)) || (thestring != 'msie')){
		document.write("<BR><TABLE WIDTH='60%' class='sideblock02' BORDER='0' ALIGN='CENTER'>");
		document.write("<TR><TD><BR><U>Información Importante</U><BR></TD></TR>");
		msg = "<TR><TD>Ud. está usando " + browser + " " + version + "(" + OS + ")<BR><BR>Se recomienda usar Internet Explorer 6.02 o superior.<BR></TD></TR>";
		document.write(msg);	
		document.write("<TR><TD>Bájelo acá</TD></TR>");
		document.write("</TABLE>");
	}
}

function checkIt(string,detect)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

function verificaRut(T,d,f){
	var M=0,S=1;
	var digito;
	if(isAlpha(d)){
		d = d.toUpperCase();	
	}
	if(!Empty(T)&&!Empty(d)){
		for(;T;T=Math.floor(T/10)) 
		S =(S+T%10*(9-M++%6))%11;
		digito = S?S-1:'K';
		if(digito != d){
			alert('RUT ERRONEO, VERIFIQUE');
			return false;	
		}
	}else{
		if(Empty(T)){
			alert('Debe ingresar el RUT');
		}else{
			alert('Debe ingresar el dígito verificador');
		}
		return false;
	}
	return true;
}

function verificaRutFocus(T,d,f,elem){
	var M=0,S=1;
	var digito;
	var nombre = elem.name;
	
	if(isAlpha(d)){
		d = d.toUpperCase();	
	}
	if(!Empty(T)&&!Empty(d)){
		for(;T;T=Math.floor(T/10)) 
		S =(S+T%10*(9-M++%6))%11;
		digito = S?S-1:'K';
		if(digito != d){
			alert('RUT ERRONEO, VERIFIQUE');
			elem.select();
			elem.focus();
			return false;	
		}
	}else{
		if(Empty(T)){
			alert('Debe ingresar el RUT');
		}else{
			alert('Debe ingresar el dígito verificador');
		}
		return false;
	}
	return true;
}

function verificaRutSinAlert(T,d,f){
	var M=0,S=1;
	var digito;
	if(isAlpha(d)){
		d = d.toUpperCase();	
	}
	if(!Empty(T)&&!Empty(d)){
		for(;T;T=Math.floor(T/10)) 
		S =(S+T%10*(9-M++%6))%11;
		digito = S?S-1:'K';
		if(digito != d){
			//alert('RUT ERRONEO, VERIFIQUE');
			return false;	
		}
	}else{
		return false;
	}
	return true;
}

function verificaRutARAregis(T,f){
	var M=0,S=1;
	var digito;
	if(!Empty(T)){
		for(;T;T=Math.floor(T/10)) 
		S =(S+T%10*(9-M++%6))%11;
		digito = S?S-1:'K';
		document.form.admdv.value = digito;
	}else{
		document.form.admdv.value = '';
		document.form.admrut.focus();
	}
}
function checkCampoRut(rut,dv){
	   	var msg = '';
	   	if(Empty(rut)){
	   		msg += 'Debe ingresar el rut\n';
	   	}
	   	if(!isInteger(rut)){
	   		msg += 'El rut debe ser numérico\n';
	   	}
	   	if(Empty(dv)){
	   		msg += 'Debe ingresar el dígito verificador\n';
	   	}
	   	if(msg != ''){ alert(msg);return false; }
	   	return true;
	   }

function BeforePrint() {
  var div = document.getElementById('overflow');
  var tab = document.getElementById('tabla');
  div.parentNode.insertBefore(tab,div);
  div.style.height='0px';
}

function AfterPrint(alto) {
  var div = document.getElementById('overflow');
  var tab = document.getElementById('tabla');
  if (alto == 0) { alto = 450 };
  div.style.height = alto+'px';
  div.appendChild(tab);
}

function habilitaDeshabilita(chkbox,tf){
	// Esta función trabaja con forms[0], es decir, el primer objeto FORM que encuentre en el script, por lo que 
	// hay que tener cuidado con eso, a veces no funciona, sobre todo cuando hay más de un form en el script.
	if(tf == 3){
		for (var i=0;i < document.forms[0].elements.length;i++)
		{
			var elemento = document.forms[0].elements[i];
			if (elemento.type == "checkbox")
			{
				document.forms[0].elements[i].disabled = false;
			}
		}
	}else{
		for (var i=0;i < document.forms[0].elements.length;i++)
		{
			var elemento = document.forms[0].elements[i];
			if (elemento.type == "checkbox")
			{
				elemento.checked = false;
				document.forms[0].elements[i].disabled = true;
			}
		}
	}
}


var VentanaModal = {
	
	inicializado		: false,
	creado			: false,
	ancho			: 0,
	alto			: 0,
	sombra			: false,
	csombra			: null,
	tsombra			: 0,
	claseSombra		: "",
	ventana			: null,
	idVentana		: "",
	claseVentana		: "",
	MSIE			: false,
	fondo			: null,
	iframe			: null, 
	claseFondo		: "",
	
	getInstancia: function() {
		this.inicializar();
		this.crear();
		return this;
	},
	
	setSize: function(ancho, alto) {
		this.alto = parseInt(alto);
		this.ancho = parseInt(ancho);
		this.ventana.style.width = this.ancho + "px";
		this.ventana.style.height = this.alto + "px";
		this.csombra.style.width = this.ancho + "px";
		this.csombra.style.height = this.alto + "px";
		this.redimensionar();
		
	},
	
	setClaseVentana: function(nombreClaseVentana) {
		this.claseVentana = nombreClaseVentana;
		this.ventana.className = this.claseVentana;
	},
	
	setSombra: function(sombra) {
		if (sombra == true) {
			this.sombra = true;
			this.csombra.style.display = "inline";
		}
		else {
			this.sombra = false;
			this.csombra.style.display = "none";
		}
	},
	
	setSombraSize: function(tsombra) {
		this.tsombra = tsombra;
		this.redimensionar();
	},
	
	setClaseSombra: function(claseSombra) {
		this.claseSombra = claseSombra;
		this.csombra.className = this.claseSombra;
	},
	
	setIdVentana: function(id) {
		this.idVentana = id;
		this.ventana.id = this.idVentana;
	},
	
	setClaseFondo: function(claseFondo) {
		this.claseFondo = claseFondo;
		this.fondo.className = this.claseFondo;
		if (this.MSIE)
			this.iframe.className = this.claseFondo;
	},
	
	setContenido: function(html) {
		this.ventana.innerHTML = html;
	},
	
	mostrar: function() {
		this.fondo.style.display = "inline";
		this.ventana.style.display = "inline";
		if (this.sombra)
			this.csombra.style.display = "inline";
	},

	cerrar: function() {
		this.ventana.style.display = "none";
		this.csombra.style.display = "none";
		this.fondo.style.display = "none";
	},
	
	medio: function(v1, v2) {
		if (isNaN(v1) && v1.indexOf("px") != -1)
			v1 = v1.replace("px", "");
		if (isNaN(v2) && v2.indexOf("px") != -1)
			v2 = v2.replace("px", "");
		var aux = parseInt(v1) / 2;
		aux = aux - (parseInt(v2) / 2);
		return parseInt(aux) * (+1);
	},
	
	inicializar: function() {
		if (this.inicializado) 
			return;
		window.onresize = function() {
			VentanaModal.redimensionar();
		};
		
		this.ancho = 300;
		this.alto = 200;
		this.sombra = true;
		this.tsombra = 5;
		this.claseSombra = "ventana-modal-sombra";
		this.claseFondo = "ventana-modal-fondo";
		this.claseVentana = "ventana-modal-ventana";
		
		if (navigator.userAgent.indexOf('MSIE') >= 0) 
			this.MSIE = true;
			
		this.inicializado = true;
		this.crear();
	},
	
	redimensionar: function() {
		var top = 0;
		var left = 0;
		var alto = 0;
		var ancho = 0;
		var array = this.getAnchoAlto();
		var anchoVentana = array[0];
		var anchoDocumento = array[2];
		var altoVentana = array[1];
		var altoDocumento = array[3];
		
		if (this.MSIE) ancho = anchoVentana + "px";
		else ancho = "100%";
		
		alto = altoVentana + "px";

		if (this.MSIE) {
			this.fondo.style.width = ancho;
			this.fondo.style.height = alto;
			this.iframe.style.width = ancho;
			this.iframe.style.height = alto;
		}
		else {
			this.fondo.style.width = ancho;
			this.fondo.style.height = alto;
		}
		if (this.MSIE) {
			top = this.medio(altoDocumento, this.alto);
			left = this.medio(anchoVentana, this.ancho);
		}
		else {
			top = this.medio(altoDocumento, this.alto);
			left = this.medio(anchoVentana, this.ancho);
		}
		
		top = top + this.getScrollAlto();
		
		this.ventana.style.top = top + "px";
		this.ventana.style.left = left + "px";
		this.csombra.style.top = (parseInt(top) + this.tsombra) + "px";
		this.csombra.style.left = (parseInt(left) + this.tsombra) + "px";
	},
	
	crear: function() {
		if (this.creado) 
			return;
		this.fondo = document.createElement("DIV");
		this.fondo.style.position = "absolute";
		this.fondo.style.left = "0px";
		this.fondo.style.top = "0px";
		this.fondo.style.display = "none";
		this.fondo.className = this.claseFondo;
		this.fondo.style.zIndex = 90000;
		this.fondo.style.textAlign = "center";
		document.body.appendChild(this.fondo);
		
		if (this.MSIE) {
			this.iframe = document.createElement("IFRAME");
			this.fondo.appendChild(this.iframe);
			this.iframe.src = "about:blank";
			this.iframe.frameBorder = "0";
			this.iframe.className = this.claseFondo;
		}
		
		this.ventana = document.createElement("DIV");
		document.body.appendChild(this.ventana);
		this.ventana.style.display = "none";
		this.ventana.style.position = "absolute";
		this.ventana.style.zIndex = 100000;
		this.ventana.style.width = this.ancho + "px";
		this.ventana.style.height = this.alto + "px";
		this.ventana.className = this.claseVentana;
		
		this.csombra = document.createElement("DIV");
		document.body.appendChild(this.csombra);
		this.csombra.style.display = "none";
		this.csombra.style.position = "absolute";
		this.csombra.style.zIndex = 95000;
		this.csombra.style.width = this.ancho + "px";
		this.csombra.style.height = this.alto + "px";
		this.csombra.className = this.claseSombra;
		
		this.creado = true;
		this.redimensionar();
	}, 
	
	getScrollAlto: function() {
		var scrollAlto;

		if (self.pageYOffset) {
			scrollAlto = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop) {
			scrollAlto = document.documentElement.scrollTop;
		} else if (document.body) {
			scrollAlto = document.body.scrollTop;
		}
	
		return scrollAlto;
	}, 
	
	getAnchoAlto: function() {
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else {
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var ventanaAncho, ventanaAlto;
		if (self.innerHeight) {
			ventanaAncho = self.innerWidth;
			ventanaAlto = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			ventanaAncho = document.documentElement.clientWidth;
			ventanaAlto = document.documentElement.clientHeight;
		} else if (document.body) {
			ventanaAncho = document.body.clientWidth;
			ventanaAlto = document.body.clientHeight;
		}	
		
		if(yScroll < ventanaAlto){
			paginaAlto = ventanaAlto;
		} else { 
			paginaAlto = yScroll;
		}
	
		if(xScroll < ventanaAncho){	
			paginaAncho = ventanaAncho;
		} else {
			paginaAncho = xScroll;
		}
	
	
		arrayAnchoAltoPagina = new Array(paginaAncho, paginaAlto, ventanaAncho, ventanaAlto);
		return arrayAnchoAltoPagina;
	}
};

function abrirVentanaFija(pagina, ancho, alto, nombre, titulo) {
    VentanaModal.inicializar();
    VentanaModal.setSize(ancho, alto);
    VentanaModal.setClaseVentana("");
	VentanaModal.setIdVentana("ventana-modal-ventana");
	
	var src = 'img/ventana/';
	var iframe = '<iframe src="' + pagina + '" name="' + nombre + '" style="width: ' + (ancho - 22) + 'px; height: ' + (alto - 75) + 'px;"  frameborder="0"></iframe>';
	var over = 'onMouseOver="this.src=\'' + src + 'cerrarover.gif\'"';
	var out = 'onMouseOut="this.src=\'' + src + 'cerrar.gif\'"';
	var onClick = 'onclick="VentanaModal.cerrar()"';
	var atributos = 'alt="Cerrar" title="Cerrar ventana" style="cursor: pointer;"';
	var cerrar = '<img src="' + src + 'cerrar.gif" ' + atributos + ' ' + onClick + ' ' + over + ' ' + out + ' />';
	var tabla = ' border="0" cellspacing="0" cellpadding="0"';
	var texto = 'font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color: #ffffff;';
	
	var superiorIzquierda = 'style="width: 15px; height: 35px; cursor: default; background-image: url(' + src + 'superior-izquierda.png);"';
	var superior = 'id="draggable" style="width: ' + (ancho - 51) + 'px; height: 35px; cursor: default; background-image: url(' + src + 'superior.png); ' + texto + '"';
	var celdaImagen = 'style="width: 15px; height: 35px; background-image: url(' + src + 'superior.png); ' + texto + '"';
	var superiorDerecha = 'style="width: 20px; height: 35px; cursor: default; background-image: url(' + src + 'superior-derecha.png);"';
	var izquierda = 'style="width: 7px; height: ' + (alto - 75) + 'px; cursor: default; background-image: url(' + src + 'izquierda.png);"';
	var centro = 'style="width: ' + (ancho - 22) + 'px; height: ' + (alto - 75) + 'px; background-color: #ffffff;"';
	var derecha = 'style="width: 15px; height: ' + (alto - 75) + 'px; cursor: default; background-image: url(' + src + 'derecha.png);"';
	var inferiorIzquierda = 'style="width: 15px; height: 40px; cursor: default; background-image: url(' + src + 'inferior-izquierda.png);"';
	var inferior = 'style="width: ' + (ancho - 36) + 'px; height: 40px; cursor: default; background-image: url(' + src + 'inferior.png);"';
	var inferiorDerecha = 'style="width: 20px; height: 40px; cursor: default; background-image: url(' + src + 'inferior-derecha.png);"';
	
	if (VentanaModal.MSIE) {
		superiorIzquierda = 'style="width: 15px; height: 35px; cursor: default; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src=\'' + src + 'superior-izquierda.png\');"'
		superiorDerecha = 'style="width: 20px; height: 35px; cursor: default; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src=\'' + src + 'superior-derecha.png\');"';
		derecha = 'style="width: 15px; height: ' + (alto - 75) + 'px; cursor: default; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src=\'' + src + 'derecha.png\');"';
		inferiorIzquierda = 'style="width: 15px; height: 40px; cursor: default; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src=\'' + src + 'inferior-izquierda.png\');"';
		inferior = 'style="width: ' + (ancho - 36) + 'px; height: 40px; cursor: default; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src=\'' + src + 'inferior.png\');"';
		inferiorDerecha = 'style="width: 20px; height: 40px; cursor: default; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src=\'' + src + 'inferior-derecha.png\');"';
	}
	var html = ''
	+ '<table' + tabla + '>'
	+ '<tr><td><table' + tabla + '>'
	+ '<tr><td ' + superiorIzquierda + '>&nbsp;</td>'
	+ '<td ' + superior + '>' + titulo + '</td>'
	+ '<td ' + celdaImagen + '>' + cerrar + '</td>'
	+ '<td ' + superiorDerecha + '>&nbsp;</td>'
	+ '</tr></table></td></tr><tr><td>'
	+ '<table ' + tabla + '>'
	+ '<tr><td ' + izquierda + '>&nbsp;</td>'
	+ '<td ' + centro + '>' + iframe + '</td>'
	+ '<td ' + derecha + '>&nbsp;</td>'
	+ '</tr></table></td></tr><tr><td>'
	+ '<table ' + tabla + '>'
	+ '<tr><td ' + inferiorIzquierda +'>&nbsp;</td>'
	+ '<td ' + inferior + '>&nbsp;</td>'
	+ '<td ' + inferiorDerecha + '>&nbsp;</td>'
	+ '</tr></table></td></tr></table>';
	
    VentanaModal.setContenido(html);
    VentanaModal.mostrar();
}