/*
*	Lista de navegadores malnacidos
*/
var ie52mac = (
	navigator.userAgent.indexOf('MSIE 5.2') != -1 &&
	navigator.userAgent.indexOf('Mac') != -1
);

/*
*	Función para inicializar diferentes módulos
*/
var window_onload = [];
window.onload = function()
{
	for(var i in window_onload) {
		eval(window_onload[i]);
	}
}

function setOpacity(elm, alfa)
{
	if(alfa == 0) {
		elm.style.visibility = 'hidden';
	} else if(elm.style.visibility == 'hidden') {
		elm.style.visibility = 'inherit';
	}
	if(typeof(elm.style.opacity) != 'undefined') elm.style.opacity = (alfa == 1) ? '0.999' : alfa;
	else if(typeof(elm.style.MozOpacity) != 'undefined') elm.style.MozOpacity = (alfa == 1) ? '0.999' : alfa;
	else if(typeof(elm.style.KhtmlOpacity) != 'undefined') elm.style.KhtmlOpacity = alfa;
	else if(!ie52mac && typeof(elm.style.filter) != 'undefined') elm.style.filter = (alfa == 1) ? '' : 'alpha(opacity=' + (alfa*100) + ')';
};

// Función para establecer el valor de un estilo dado el elemento
function setStyle(elm, style, value)
{
	elm.style[style] = value;
}



function BuscaKuki(nombre)
{  var n, f, ss, valor="";    ss = document.cookie;  n = ss.indexOf(nombre + "=");  if(n >= 0) {  n = ss.indexOf("=", n) + 1;  f = ss.indexOf(";", n);  if(f < 0)
 f = ss.length;  valor = unescape(ss.substring(n, f));  }  return valor;  }    function miTrim(str)
{  var n, ind1, ind2, ss;    ind1 = 0;  ind2 = str.length - 1;   for(n = 0; n <= ind2 && str.substr(n, 1) == " "; n++, ind1++)
 ;   for(n = ind2; n >= ind1 && str.substr(n, 1) == " "; n--, ind2--)
 ;  if(ind2 >= ind1)
 ss = str.substring(ind1, ind2+1);  else
 ss = "";  return ss;  }    function FormatInt(num)
{  var snum, tot, x;    snum = "" + num;  tot = snum.length;  x = "";  while(tot > 3) {  x = "." + snum.substr(tot-3, 3) + x;  snum = snum.substring(0, tot - 3);  tot = snum.length;  }  x = snum + x;  return x;  }    var LaVentana = null;    function AbreVentana(contenido, x, y, w, h)
{  var res;    LaVentana = window.open(contenido, "", "left="+x+",top="+y+",width="+w+",height="+h);  }    function RellenaHtml(doc, foto)
{  doc.open();  doc.writeln("<html>");  doc.writeln("<head>");  doc.writeln("<title>Foto</title>");  doc.writeln("</head>");  doc.writeln("<body leftmargin=0 topmargin=0>");    doc.writeln("<img name='imagen' src='" + foto + "'>");    doc.writeln("</body>");  doc.writeln("</html>");  doc.close();  }    var hwinflot;  var LaFoto;  function MuestraFoto(foto)
{  hwinflot = window.open("", "Foto", "left=0,top=0,width=10,height=10");  RellenaHtml(hwinflot.document, foto);    LaFoto = foto;   setTimeout("ProcesaFoto()", 100);  }    function ProcesaFoto()
{  var w, h;    if(hwinflot && hwinflot.document && hwinflot.document.imagen) {   w = hwinflot.document.imagen.width + 15;  h = hwinflot.document.imagen.height + 15;   if(Navegador == "nv") {  hwinflot.close();  hwinflot = window.open("", "Foto", "left=0,top=0,width="+w+",height="+h);  RellenaHtml(hwinflot.document, LaFoto);  }  else
 hwinflot.resizeTo(w - 6, h + 14);  hwinflot.focus();  }  else
 setTimeout("ProcesaFoto()", 100);  }    function FotoFija(foto, ancho, alto, spie)
{  if(hwinflot && !hwinflot.closed)
 hwinflot.close();    hwinflot = window.open("", "Foto", "left=0,top=0,width="+ancho+",height="+alto);    var doc = hwinflot.document;  doc.open();  doc.writeln("<html>");  doc.writeln("<head>");  doc.writeln("<title>Foto</title>");  doc.writeln("</head>");  doc.writeln("<body onBlur='focus()' leftmargin=0 topmargin=0 marginheight=0 marginwidth=0 bgcolor='#FFFFFF'>");    doc.writeln("<img name='imagen' src='" + foto + "' width="+ancho+" height="+alto+">");  if(spie && spie != "") {  doc.writeln("<div style='position: absolute; left: 8; top: "+(alto - 20)+"'>");  doc.writeln("<table border=0><tr><td bgcolor='#FFFFFF'>");  doc.writeln("<font face='Verdana, Arial, Helvetica, sans-serif' size=1>");  doc.writeln(spie);  doc.writeln("</font>");  doc.writeln("</td></tr></table>");  doc.writeln("</div>")
 }  doc.writeln("</body>");  doc.writeln("</html>");  doc.close();  }

 /*
	Función para abrir una ventana. Puede recibir los siguientes parámetros:

	url	-> Página web que mostrará la ventana. Por defecto página en blanco. Ejemplo: 'aviso.html'.
	target	-> Ventana en la que se abrirá la url. Por defecto en una nueva ventana cada vez. Ejemplo: '_blank'.
	width	-> Ancho en píxeles de la ventana. Por defecto 250 píxeles. Ejemplo: 300
	height	-> Alto en píxeles de la ventana. Por defecto 250 píxeles. Ejemplo: 125
	left	-> Distancia en píxeles al borde izquierdo de la pantalla. Por defecto centrada horizontalmente. Ejemplo: 100
	top	-> Distancia en píxeles al borde superior de la pantalla. Por defecto centrada verticalmente. Ejemplo: 100
	resizable	-> Indica si el usuario puede modificar el tamaño de la ventana. Por defecto no. Ejemplo: 'yes' o true
		Valores posibles: 'yes', 'no', '1', '0', true, false.
	scrollbars	-> Indica si la ventana tendrá barras de scroll. Por defecto no. Ejemplo: 'no' o false
		Valores posibles: 'yes', 'no', '1', '0', true, false.

	Poner un parámetro a null o no pasarlo es lo mismo.

	Ejemplo:

	// Abrir aviso.html en una nueva ventana, con tamaño 250x125, centrada horizontalmente
	// pero a 100 píxeles del borde superior.

	AbrirVentana('aviso.html', '_blank', 250, 125, null, 100);
*/
function AbrirVentana(url, target, width, height, left, top, resizable, scrollbars)
{
	if(typeof(url) == 'undefined' || url == null) url = '';
	if(typeof(target) == 'undefined' || target == null) target = '';

	if(typeof(width) == 'undefined' || width == null) width = 250;
	if(typeof(height) == 'undefined' || height == null) height = 250;

	if(typeof(window.screen) == 'undefined') {
		var sw = 800;
		var sh = 600;
	} else {
		var sw = window.screen.width;
		var sh = window.screen.height;
	}

	if(typeof(left) == 'undefined' || left == null) left = Math.round(0.5 * (sw - width));
	if(typeof(top) == 'undefined' || top == null) top = Math.round(0.5 * (sh - height));

	if(typeof(resizable) == 'undefined' || resizable == 'no' || !resizable) resizable = 0;
	else resizable = 1;

	if(typeof(scrollbars) == 'undefined' || scrollbars == 'no' || !scrollbars) scrollbars = 0;
	else scrollbars = 1;

	var win = window.open(url, target, 'left=' + left + ',top=' + top + ',width=' + width + ',height=' + height + ',directories=0,location=0,menubar=0,resizable=' + resizable +',scrollbars=' + scrollbars + ',status=0,toolbar=0');
	win.focus();
}
