// showhidediv.js
// Función que oculta y aparece los DIV's
var last = null;
function viewHide(name) {
	tgtDiv = document.getElementById(name);//Seleciona la capa
	if (name) {
		if (tgtDiv != null) {
			if (tgtDiv.style.display == "block") {//Si se ve ocultala
				tgtDiv.style.display = "none";
				//y muestra los botones de player
				showBotones();
			}else {//Si no muestrala
				tgtDiv.style.display = "block";
				//oculta los botones de player
				hideBotones(tgtDiv);
			}
			colocarDiv();//Coloca la capa
		}
	}else{
		//aqui llega al dar al boton de cerrar
		showBotones();
	}
	//
	if (last) {
		if (last.style.display == "block") {
			last.style.display = "none"; //Si hay una capa anterior ocultala
		}else{
			last.style.display = "block";
			hideBotones(last);
		}
	}
	last = tgtDiv;
}

//funciones que ocultan y muestran botones de player
function hideBotones(sobreCapa){
	for(f=0;f<20;f++){
		var boton = document.getElementById("boton"+f);
		if (boton != null && sobreCapa != null) {
			//if (colisiona(sobreCapa, boton)) {
				boton.style.display = "none";
			//}
		}
	}
}

function showBotones(){
	for(f=0;f<20;f++){
		var boton = document.getElementById("boton"+f);
		if (boton != null){
			boton.style.display = "block";
		}
	}
}

//comprueba si colisionan dos capas entre si
function colisiona(capa1, capa2){
	if (capa1.style.left > capa2.style.right || capa2.style.left > capa1.style.right ||
		capa1.style.up > capa2.style.bottom || capa2.style.up > capa1.style.bottom ){
		return false;
	}
	return true;
}

//Funcion que detecta la posicion del cursor
function posCursor(ev) {
	if (!document.all) {//Si windows
		event = ev;
		py = event.pageY;
		px = event.pageX;
	} else {//Si no windows
		py = event.clientY +document.body.scrollTop;
		px = event.clientX +document.body.scrollLeft;
	}
	//window.status = "X: "+px+" Y: "+py;
}

function dameAltura(){
	<!--
 var viewportwidth;
 var viewportheight;
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 if (typeof window.innerWidth != 'undefined') {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
	viewportwidth = document.documentElement.clientWidth,
	viewportheight = document.documentElement.clientHeight
 } else {  // older versions of IE
	viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
	viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }
//-->
return viewportheight;
}


//Funcion que posiciona las capas a mostrar
function colocarDiv() {//Calcula la posición relativa de los popups con respecto al cursor
	var hh = dameAltura();
	var topeUp = (py-150);
	var topeDw = topeUp + tgtDiv.offsetHeight - document.body.scrollTop + 15;
	//
	if (topeUp - document.body.scrollTop < 10){
		//salio por arriba (scroll incluido)
		topeUp = 10 + document.body.scrollTop;
	}else if (topeDw >  hh){
		//tampoco por abajo (parte visible de la ventana)
		do{
			topeUp -= 20;
			topeDw = topeUp + tgtDiv.offsetHeight - document.body.scrollTop + 15;
		}while(topeDw > hh);
	}
	//
	tgtDiv.style.top = topeUp+"px"; 
	//tgtDiv.style.left = (px+50)+"px";
	//tgtDiv.style.top=(window.outerHeight/2)-300;
	//tgtDiv.style.left=(window.outerWidth/2)-300;
//tgtDiv.style.top=(screen.height/2)-300;
	//
	//
	tgtDiv.style.left=(screen.width/2)-245;
	//tgtDiv.style.left=(px)+(245/4);
}