var indice=0;

function set_Color(objName, fg, bg)
{
  obj = findObj(objName);
  if (obj.style)
  {
    obj.style.color = fg;
    obj.style.backgroundColor = bg;
  }
}

function setTextoColor(objName, fg)
{
  obj = findObj(objName);
  if (obj.style)
    obj.style.color = fg;
}

function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}

function switchImage(imgName, imgSrc) 
{
  if (document.images)
  {
    if (imgSrc != "none")
    {
      document.images[imgName].src = imgSrc;
    }
  }
}

function SetFrame(Name, Url)
{
	var frame;
	if (document.all)
		frame = frames[Name].document;
	else
		frame = document.getElementById(Name).document;
	frame.location.href = Url;
}

function Navegar(Name, Url, tIndice)
{
	indice = tIndice;
	var frame;
	if (document.all)
		frame = frames[Name].document;
	else
		frame = document.getElementById(Name).document;
	frame.location.href = Url+'indice='+indice;
}

function PopUp(Url, Name, Params)
{
	window.open(Url, Name, Params);
}

// Example:
// simplePreload( '01.gif', '02.gif' ); 
function simplePreload()
{ 
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

function AlignMenus()
{
	var adicional = 3;
	var ancho_tabla = 750;
	var	ancho_pantalla, left;
	ancho_pantalla = (document.body.clientWidth/2);
	left = (ancho_pantalla) - (ancho_tabla/2);
	if(left<0) left = 0;
	left +=  adicional;
	
	//Se comoda el left del perfil
	document.getElementById('perfil').style.left = left;

	//Se comoda el left del la encuesta
	//document.getElementById('encuesta').style.left = left+5;
	document.getElementById('encuesta').style.left = left-5;

	//Para acomodar el left de los menus principales
	var i;
	for(i=0;i<MaxMenus;i++)
		document.getElementById('Layer'+MENUS[i]).style.left = left;
		
	//Para acomodar el left de los menus secundarios
	for(i=0;i<MaxMenus2;i++)
		document.getElementById('Layer'+MENUS2[i]).style.left = left+menu_alto;
}

function MToolTip(Name, texto)
{
	document.getElementById(Name).innerHTML=texto;
}

function cambiarFondoPadre1(elem){
	var padre = elem.parentNode;
	padre.style.backgroundColor = "D7DFEC";
	padre.style.borderBottomColor = "#19638A";
}

function cambiarFondoPadre2(elem){
	var padre = elem.parentNode;
	padre.style.backgroundColor = "FFFFFF";
	padre.style.borderBottomColor = "#FFFFFF";
}
