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 MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
// ----------------------------------------------------------------
function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
// ----------------------------------------------------------------
function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
// ----------------------------------------------------------------
function TellFriend() {
var cgiRecomienda = '/cgi/recomienda.pl';
        cgiRecomienda = cgiRecomienda + "?url=" + document.URL;
        location.href = cgiRecomienda;
        return false;
}
// ----------------------------------------------------------------
function PrintThisPage() {
	window.print();
	return false;
}
// ----------------------------------------------------------------
function copyInnerHTML(fromId, toId, joinContent, clearContent) {
	var objFrom = MM_findObj(fromId);
	var objTo   = MM_findObj(toId);

	if (objFrom && objTo) {
		if (joinContent) {
			objTo.innerHTML = objTo.innerHTML + objFrom.innerHTML;
		} else {
			objTo.innerHTML = objFrom.innerHTML;
		}

		if (clearContent) { objFrom.innerHTML = ' '; }

		return true;
	} else {
		return false;
	}
}
// ----------------------------------------------------------------
function getInnerHTML(fromId) {
	var objFrom = MM_findObj(fromId);
	if (objFrom) {
		return objFrom.innerHTML;
	} else {
		return '';
	}
}
// ----------------------------------------------------------------
function pushHintsInnerHTML(arrObject, fromId) {
	arrObject.push(getInnerHTML(fromId));
}
// ----------------------------------------------------------------
function demeIdRecomendacionHoy(arrIds) {
var curDate = new Date();
var id = -1;

	if (arrIds.length > 0){
		// Por default se selecciona el primer ID del arreglo
		id = arrIds[0];
		// Asume que el arreglo esta ordenado de domingo a sabado
		if (curDate.getDay() < arrIds.length) {
			id = arrIds[curDate.getDay()];
		}
	}

	return id;
}
/*************************************************************************
** Prototipos para manejar arreglos con funciones de Push y Pop
*/
Array.prototype.push = function() {
	var n = this.length >>> 0;
	for (var i = 0; i < arguments.length; i++) {
		this[n] = arguments[i];
		n = n + 1 >>> 0;
	}
	this.length = n;
	return n;
};

Array.prototype.pop = function() {
	var n = this.length >>> 0, value;
	if (n) {
		value = this[--n];
		delete this[n];
	}
	this.length = n;
	return value;
};

/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  Copyright 2001-3 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

// resize fix for ns4
var origWidth, origHeight;
if (document.layers) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

// link style change
var cur_link = new Array();
function doLinkClass(groupid, lnk) {
  if (lnk && lnk.blur) lnk.blur();	// remove marquee
  if (!lnk || cur_link[groupid] == lnk) return;
  if (cur_link[groupid]) cur_link[groupid].className = "done";
  lnk.className = "tabOn";
  cur_link[groupid] = lnk;
}

var cur_lyr = new Array();	// holds id of currently visible layer
function swapLayers(groupid, lnk,id) {
  doLinkClass(groupid, lnk);
  if (cur_lyr[groupid]) hideLayer(cur_lyr[groupid]);
  showLayer(id);
  cur_lyr[groupid] = id;
}

function showLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "visible";
  if (lyr && lyr.style) lyr.style.display = 'block';
}

function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "hidden";
  if (lyr && lyr.style) lyr.style.display = 'none';
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getLyrRef(id,document): null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

// get reference to nested layer for ns4
// from old dhtmllib.js by Mike Hall of www.brainjar.com
function getLyrRef(lyr,doc) {
	if (document.layers) {
		var theLyr;
		for (var i=0; i<doc.layers.length; i++) {
	  	theLyr = doc.layers[i];
			if (theLyr.name == lyr) return theLyr;
			else if (theLyr.document.layers.length > 0) 
	    	if ((theLyr = getLyrRef(lyr,theLyr.document)) != null)
					return theLyr;
	  }
		return null;
  }
}

function initTabs(groupid, id,lyr) {
  var lnk = getElemRefs(id);
  swapLayers(groupid, lnk,lyr);
}