// JavaScript Document

/******* Colocación del menu ******/
var posicionX = 578;
var posicionY = 62;
var minWidth = 779;

function truebody() {
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function onLoad() {
	var capa = MM_findObj("Menu_Principal");
	if (capa)
	{
		var width = truebody().clientWidth;
		var position = posicionX;
		if (width>minWidth)
		{
			position += (width-minWidth) / 2;
		}
		capa.style.left = position;
		capa.style.top = posicionY;
		window.onresize = onLoad;
	}
}

window.onload = onLoad;
/******* FIN Colocación del menu ******/

var menuExpandir = '';
var subMenuExpandir = '';

function separar(cadena){
	var splitIndex = 0;
	var splitArray = new Array();
	var separator = '<A ';

	while ((cadena.length > 0) && (separator.length > 0)) {
	    var i = cadena.indexOf(separator);
	    if ((!i) && (separator != cadena.substring(0,separator.length))) break;
	    if (i == -1) {
	        splitArray[splitIndex++] = cadena;
	        break;
	    }
	    splitArray[splitIndex++] = cadena.substring(0,i) + separator;
	    cadena = cadena.substring(i+separator.length,cadena.length);
	}
	return splitArray;
}

function expandirMenu(menu, subMenu){
	menuExpandir = menu;
	subMenuExpandir = subMenu;
}

function doMenu(){
	var capaMenu = MM_findObj(menuExpandir);
	if (capaMenu!=null)
	{
		expandcontent(menuExpandir);
		if (subMenuExpandir)
		{
			splitArray = separar(capaMenu.innerHTML);
			var html = "";
			for (var i=0; i < splitArray.length; i++)
			{
				if (i==subMenuExpandir)
				{
					html += "id='menu_Selected' "
				}
				html += splitArray[i];
			}
		  capaMenu.innerHTML = html;
		}
	}
}

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 Abrir_Ventana(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

function CheckControl(controlId, value)
{
	var obj = MM_findObj(controlId);
	if (obj.value==value)
	{
		obj.value = "";
	}
}

/***********************************************
* Contractible Headers script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated Oct 21st, 2003.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var enablepersist="off" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="yes" //Collapse previously open content when opening present? (yes/no)

if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{display:none; width:150px; float:left;}')
document.write('</style>')
}

function getElementbyClass(classname){
ccollect=new Array()
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
ccollect[inc++]=alltags[i]
}
}

function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(cid){
if (typeof ccollect!="undefined"){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
document.getElementById(cid).style.width="182px"
}
}

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
document.getElementById(selectedComponents[i]).style.width="290px"
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload(){
getElementbyClass("switchcontent")
if (enablepersist=="on" && typeof ccollect!="undefined")
revivecontent();
doMenu();

}


if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate


/* Borrar contenido de la caja de búsqueda */
function borracontenidobus(i)
{
	if (i.value.length==8 && i.value.charAt(0)=="B" && i.value.charCodeAt(1)==250 && i.value.substring(2,8)=="squeda")
	{
		i.value="";
	}
}


/***********************************************
* Contractible Headers script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated Oct 21st, 2003.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/