/**
Version: 1.1
*/

document.write('<scr'+'ipt src="_viewer/js/multimedia_conf.js"></scr'+'ipt>');
var iduvcms='uvcms';
var p=null;

if(parent.frames['mainFrame'] && parent.frames['h']){
	p=parent;
}else{
	p=window;  
}	
mie=navigator.appName.toLowerCase().indexOf('microsoft internet explorer')!=-1?true:false;
mac=navigator.userAgent.toLowerCase().indexOf('mac_powerpc')!=-1?true:false;
msie5=navigator.userAgent.toLowerCase().indexOf('msie 5')!=-1?true:false;

var aSCO=new Array();
var root='';
var totalFrames=1;
var totalSCO=0;
var currentsco=-1;
var sn=-1;

////////////////////////////////
function goSCO(slide,nSCO){
var mfdoc=p.frames['mainFrame'].document;
var shref=mfdoc.location.href;
var ret=false;
	deselMenuActual();	
	if(slide==-1){
		slide=1;
		ret=true;
	}
	if(sn!=slide && currentsco==nSCO && p.frames['mainFrame'].navigate){
		sn=slide;
		p.frames['mainFrame'].navigate(slide);
		//return;
	}
	currentsco=nSCO;
	pg=root+aSCO[currentsco].initialpage+'?slide='+slide;
	if(ret){
		if(aSCO[currentsco].finalpage!=null){
			pg=aSCO[currentsco].finalpage;
		}
	}
	shref=pg;
 	mfdoc.location.replace(shref);
	_initFinish();

}

function activeMenu(){
	//aux=p.frames["menu"].document.getElementById('sco_'+currentsco+'_'+1); 		
  aux=p.frames["menu"].document.getElementById('sco_'+currentsco+'_'+p.frames['mainFrame'].sn); 	

  if(!aux){
	  aux=p.frames["menu"].document.getElementById('sco_'+currentsco+'_1');
  }
  if(aux){ 
	 showSubItems(aux);
  }	
}

function _onMouseOver_img(_this,e){
	if(_this.uv_state=='enabled'){
		var s=_this.src;
		s=limpiar_img(s,'_hover');
		_this.src=s;
	}
}
function _onMouseOut_img(_this,e){
	if(_this.uv_state=='enabled'){
		var s=_this.src;
		s=limpiar_img(s,'_active');
		_this.src=s;
	}
}

var tbr=false;

function showToolbar(){
var imgtoolbar=p.frames['h'].document.getElementById('imgtoolbar');
	if(p.frames['mainFrame'].refreshToolbar){
		tbr=!tbr;	
		refreshToolbar();
		if(tbr){
			if(imgtoolbar)imgtoolbar.className=imgtoolbar.className.replace('show','hide');	
		}else{
			if(imgtoolbar)imgtoolbar.className=imgtoolbar.className.replace('hide','show');
		}
	}
}
function refreshToolbar(){
	p.frames['mainFrame'].refreshToolbar();
}
function colapseMenu(){
	if(window.BodyFrame){
		imgcolapseMenu=frames["h"].document.getElementById('bmenu');
		courseMenu=!courseMenu;
		var aux=imgcolapseMenu.src;
		if(!courseMenu){
			BodyFrame.cols= "0,*";
			imgcolapseMenu.src=aux.replace('hide','show');	
		}else{
			BodyFrame.cols= dimFrame;
			imgcolapseMenu.src=aux.replace('show','hide');
		}
		
	}else{
		var qs=new createQSO();
		nsCourseMenu=!nsCourseMenu;
		qs.setValue('courseMenu',String(nsCourseMenu));
		qs.setValue('slide',p.frames['mainFrame'].sn);
		
		qs.setValue('currentsco',p.currentsco);
		aux=qs.url+'?'+qs.qstring();
		document.location.replace(aux);
	}
}

function keyUp(){
var event=arguments[0];
var kright=39;
var kleft=37;
var kup=38;
var kdown=40;
var kpgd=34;
var kpgu=33;

	switch(event.keyCode){
	//case kdown:
	case kright:
	case kpgd:
		navigate('next');
	break;
	//case kup:
	case kleft:
	case kpgu:
		navigate('back');
	break;
	}
	return true;
}
mostrarError=true;
function showError(e){
	if(mostrarError){
		var r = '';
		for (var p in e)
			r += p + ': ' + e[p] + '\n';
		alert(r);	
	}
}
function testObj(e){

		var r = '';
		for (var p in e)
			r += p + ': ' + e[p] + '\n';
		alert(r);	

}

var menuActual=null;
var parActual=null;

function showSubItems(_this){
	if(menuActual){

	}else{
		menuActual=_this;
		if(menuActual.nextSibling){
			menuActual.estado='closed'
		}		
	}	
	deselMenuActual();
	menuActual=_this;

	openParentMenu(menuActual);//Abre todos los menues padres del item actual.
	
	closeOtherMenu(menuActual);//Cierra los menues que están en el mismo nivel (o sea, los hermanos).

	selMenuItem(menuActual);//Selecciona el item actual.

}
function deselMenuActual(){
	if(menuActual){
		menuActual.className=limpiar(menuActual.className);	
		switch(menuActual.estado){
			case 'open':	
			menuActual.style.backgroundImage='url(_viewer/images/niv01_open.gif)';
			menuActual.style.backgroundRepeat='no-repeat';		
			menuActual.style.fontWeight='bold';
			break;
			case 'closed':
			menuActual.style.backgroundImage='url(_viewer/images/niv01_closed.gif)';
			menuActual.style.backgroundRepeat='no-repeat';		
			menuActual.style.fontWeight='normal';
			break;
			default:
			menuActual.style.backgroundImage='url(_viewer/images/niv01_sin.gif)';
			menuActual.style.backgroundRepeat='no-repeat';		
			menuActual.style.fontWeight='normal';
		}	
		
	}
}
openfirstelement=false;// To open the first element of tree.
function selMenuItem(_this){
	//alert('activando la reputa madre');
	_this.focus();
	migas(_this);
	_this.className=limpiar(_this.className);
	_this.className+='_active';
	//alert(_this.estado);
	//menuActual.estado2="";
	switch(_this.estado){
		case 'open':
		_this.style.backgroundImage='url(_viewer/images/km_open.gif)';
		_this.style.backgroundRepeat='repeat-y';		
		_this.style.fontWeight='bold';

		break;
		case 'closed':
		

		_this.style.backgroundImage='url(_viewer/images/km_closed.gif)';
		_this.style.backgroundRepeat='repeat-y';		
		_this.style.fontWeight='normal';

		if(!openfirstelement){
			_this.nextSibling.style.display="";
			_this.estado="open";
			openfirstelement=true;
		}
		
		break;
		default:
		_this.style.backgroundImage='url(_viewer/images/km_sin.gif)';
		_this.style.backgroundRepeat='repeat-y';		
		_this.style.fontWeight='normal'
	}			
	
	par=_this.parentNode.parentNode.parentNode.childNodes[0];	
	if(par!=null && par.tagName.toLowerCase()=='li'){
		par.className=limpiar(par.className);
		//par.className+='_open';
		switchMenu(par,true);
		/*par.style.backgroundImage='url(_viewer/images/niv01_open.gif)';
		par.style.backgroundRepeat='no-repeat';			*/
	}
	
}
function openParentMenu(ob){
var o=ob.parentNode.parentNode;
var ox=null;
	while (o!=null){
		if(o.tagName!=null){
			if(o.tagName.toLowerCase()=='li'){		
				ox=o.childNodes[0];
				closeOtherMenu(ox);//Cierra los menues que están en el mismo nivel (o sea, los hermanos).
				switchMenu(ox,true);
			}
		}
		o=o.parentNode;
	}		
}


function closeOtherMenu(m){
var o=m.parentNode;
	closeMenu('previousSibling',o);
	closeMenu('nextSibling',o);	
	
}
function closeMenu(address,o){
var xx=null;	
	while (o!=null){
		if(address=='nextSibling')
			o=o.nextSibling;	
		else
			o=o.previousSibling;	
		if(o){
			if(o.tagName!=null){
				if(o.tagName.toLowerCase()=='li'){
					xx=o.childNodes[0];
					if(xx){
						
						switchMenu(xx,false);		
					}
				}
			}
		}
	}		
}
function migas(o){
var xx=null;	
var m=new Array();
var s='';
var cont=0;
	while (o!=null){
		o=o.parentNode;	
		if(o){
			if(o.tagName!=null){
				if(o.tagName.toLowerCase()=='li'){
					xx=o.childNodes[0];
					if(xx){
						m[cont]=xx.innerHTML;
						cont++;
					}
				}
			}
		}
	}		
	cont=0;
	for(var i=m.length-1; i>=0; i--){
		s+='<b>'+m[i]+'</b> / '
		cont++;
		if(cont==4)break;
	}
	var ob=p.frames['mainFrame'].document.getElementById('divmigas');
	if(ob){
		ob.innerHTML=s;
		//alert(s);
	}
}
function limpiar(s){
	s=String(s);
	s=s.replace("_active","");
	s=s.replace("_open","");
	return s;
}
function switchMenu(_this){
var displ=arguments[1];

	menudespl=_this.nextSibling;		
	if(menudespl){
		if(displ==null){
			if(menudespl.style.display=='')displ=false;
			else displ=true;
		} 
		if(!displ){
			_this.estado='closed';
			menudespl.style.display='none';	
			_this.className=limpiar(_this.className);
			_this.style.backgroundImage='url(_viewer/images/niv01_closed.gif)';
			_this.style.backgroundRepeat='no-repeat';		
			_this.style.fontWeight='normal';
		}else{
			_this.estado='open';
			menudespl.style.display='';
			_this.className=limpiar(_this.className);
			//_this.className+='_open';
			_this.style.backgroundImage='url(_viewer/images/niv01_open.gif)';
			_this.style.backgroundRepeat='no-repeat';	
			_this.style.fontWeight='bold';

		}
		
	}
}

function _onRollOver(ob){
var aux='';
	aux=ob.src;
	aux=aux.replace('.gif','_hover.gif');
	ob.src=aux;

}
function _onRollOut(ob){
var aux='';
	aux=ob.src;
	aux=aux.replace('_hover.gif','.gif');
	ob.src=aux;

}



function action(ac){
	switch(ac){
		case 'bprint':
			if(parent){
				parent.frames["mainFrame"].focus();
				parent.frames["mainFrame"].print();
			}
			break;
		case 'bglossary':
		 popUpWindow('glossary/glossary.htm',750, 600);
		break;
		case 'bhelp':
			var whelp=open('help.htm','','');
		break;		
		case 'btools':
			showToolbar();
		break;
		case 'bmenu':
			colapseMenu();			
		break;		
	}

}
var popUpWin=0;
function popUpWindow(URLStr, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+'');
}

