// JavaScript Document
/*
 * ------------------------
 *  Hullera Vasco - Leonesa
 * ------------------------
*/
// ***   variables
// *
var ie=document.all
var ns6=document.getElementById&&!document.all
var ieNOTopera=document.all&&navigator.userAgent.indexOf("Opera")==-1
var pgyoffset=new Number(); 
var horzpos=new Number(); 
var vertpos=new Number();
var contenido = new String();
var arrastrando=false;
var verSi = new String();
var verNo = new String();

if (document.layers){ verSi = 'show'; verNo = 'hide'; }else if (document.all) { verSi = 'visible'; verNo = 'hidden';}

// Determinando el Browser para FLASH.SWF //
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var isFlashNS=(navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)?true:false;
var isMoz2=(navigator.userAgent.indexOf("Mozilla/2") != -1)?true:false;
var isIE=(navigator.appName == "Microsoft Internet Explorer")?true:false;
var isNetscape6 = (!document.all && !document.layers && navigator.appName == "Netscape" && parseInt(navigator.appVersion) >=5)?true:false;
var isDOM = (document.getElementById) ? true : false;
var isIE4 = (navigator.userAgent.indexOf("MSIE 4.0") != -1)?true:false;
var isIE45 = (navigator.userAgent.indexOf("MSIE 4.5") != -1)?true:false;
var isIE5 = (navigator.userAgent.indexOf("MSIE 5.0") != -1)?true:false;
var isIE6 = (navigator.userAgent.indexOf("MSIE 6.0") != -1)?true:false;
var isMac = (navigator.userAgent.indexOf("Mac") != -1)?true:false;
var isMacIE4 = (isMac && isIE4) ? true : false;
var isMacIE45 = (isMac && isIE45) ? true : false;
var isMacIE5 = (isMac && isIE5) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1)?true:false;
var isOpera3 = (navigator.userAgent.indexOf("Opera 3.")!= -1)?true:false;
var isOpera4 = (navigator.userAgent.indexOf("Opera 4.")!= -1)?true:false;
var isNetscape = (!isOpera && (navigator.appName.indexOf("Netscape") != -1 && navigator.userAgent.indexOf("4.") != -1))?true:false;
var isNS3 = (!isOpera && (navigator.userAgent.indexOf("Netscape") != -1 && navigator.userAgent.indexOf("3.") != -1)) ? true : false;
var isNSDIV = (!isOpera && (isNetscape && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("4.")+2)) > 5)) ? true : false;
var FlashLayers = new Array();
var flashlayers=0;
var CurrentFlashFiles = new Array();
// *
// ***   fin variables
// ***
// ***   funciones
// *

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body
}

function posi_ventanas(e,posicion,npos_y,imgwidth,imgheight){
		switch (posicion) {
			case "center" :
				pgyoffset=ns6? parseInt(pageYOffset) : parseInt(ietruebody().scrollTop);
				horzpos=ns6? pageXOffset+window.innerWidth/2-imgwidth/2 : ietruebody().scrollLeft+ietruebody().clientWidth/2-imgwidth/2;
				vertpos=ns6? pgyoffset+window.innerHeight/2-imgheight/2 : pgyoffset+ietruebody().clientHeight/2-imgheight/2;
				if (window.opera && window.innerHeight){ //compensa la toolbar de Opera 
					vertpos=pgyoffset+window.innerHeight/2-imgheight/2;
					vertpos=Math.max(pgyoffset, vertpos);
				}
				return(horzpos,vertpos);
				break;
			case "pos_y" :
				horzpos=ns6? pageXOffset+window.innerWidth/2-imgwidth/2 : ietruebody().scrollLeft+ietruebody().clientWidth/2-imgwidth/2;
				vertpos=npos_y; 
				break;						
			default :
				horzpos=ns6? pageXOffset+e.clientX : ietruebody().scrollLeft+event.clientX
				vertpos=ns6? pageYOffset+e.clientY : ietruebody().scrollTop+event.clientY   
				break;		
		}
}

function ventana_inv(url,id,subdiv,alinear,ancho,alto){ 
	// (which,nombre,sub_capa,imgalinear,imgwidth,imgheigh)
	contenido='<div id="'+subdiv+'" align="center" ';
	contenido+='style="height:'+alto+'px; width:'+ancho+'px">'+'\n';
	escrFlash(url,id,ancho,alto,alinear);
	contenido+='\n'+contenid1;
	contenido+='</div>'+'\n';
	//alert("contenido = "+contenido);
	return(contenido);
}

function ventana_swf(url,id,subdiv,alinear,ancho,alto){ 
	// (which,nombre,sub_capa,imgalinear,imgwidth,imgheigh)// height="36"
	//contenido+='<div id="movcuad" align="center" ';
	//contenido+='style="height:36px; width:340px">'+'\n';
	//contenido+='</div>'+'\n';	
	altoDiv=alto+36;
	contenido='<div id="'+subdiv+'" align="center" ';
	contenido+='style="height:'+altoDiv+'px; width:'+ancho+'px">'+'\n';
	contenido+='<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">';
	contenido+='<tr><td>'+'\n';	
	contenido+='<a href="javascript:;" onmousedown="inicio_arrastre();';
	contenido+='MM_swapImage('+"'imgMov','','hvl/bocamina/movVisor_f03.gif',1";
	contenido+=')" onmouseup="final_arrastre();MM_swapImage(';
	contenido+="'imgMov','','hvl/bocamina/movVisor_f02.gif',1";
	contenido+=')" onmouseover="MM_swapImage(';
	contenido+="'imgMov','','hvl/bocamina/movVisor_f02.gif',1";
	contenido+=')" onmouseout="MM_swapImgRestore()">';
	contenido+='<img src="hvl/bocamina/movVisor_f01.gif" name="imgMov" width="58" ';
	contenido+='height="36" border="0" align="middle" id="imgMov" /></a>'+'\n';
	contenido+='</tr></td>'+'\n';
	contenido+='<tr><td>'+'\n';	
	escrFlash(url,id,ancho,alto,alinear);
	contenido+='\n'+contenid1+'\n';
	contenido+='</tr></td></table>'+'\n';	
	contenido+='</div>'+'\n';
	//alert("contenido = "+contenido);
	return(contenido);
}

function escrFlash(url,id,ancho,alto,alinear)
{
	contenid1 ='<object'+'\n';
	contenid1+=' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'+'\n';
	contenid1+=' codebase='+'\n';
	contenid1+=' "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"'+'\n';
	contenid1+=' width="'+ancho+'" height="'+alto+' name="'+id+' id="'+id+'" align="'+alinear+'">'+'\n';
	contenid1+=' <param name="allowScriptAccess" value="sameDomain" />'+'\n';
	contenid1+='<param name="movie" value="'+ url+'"  />'+'\n';
	contenid1+='<param name="menu" value="false"  />'+'\n';
	contenid1+='<param name="quality" value="best"  />'+'\n';
	contenid1+='<param name="salign" value="lt"  />'+'\n';
	contenid1+='<param name="wmode" value="transparent"  />'+'\n';
	contenid1+='<param name="id" value="' + id +'"  />'+'\n';
	contenid1+='<param name="name" value="' + id +'"  />'+'\n';
	contenid1+='<embed'+'\n';
	contenid1+=' src="'+ url+'"'+'\n';
	contenid1+=' width="'+ancho+'"'+'\n';
	contenid1+=' height="'+alto+'"'+'\n';
	contenid1+=' id="'+id+'"'+'\n';
	contenid1+=' name="'+id+'"'+'\n';
	contenid1+=' align="'+alinear+'"'+'\n';
	contenid1+=' menu="false" quality="best" salign="lt" wmode="transparent"'+'\n';
	contenid1+=' allowScriptAccess="sameDomain" type="application/x-shockwave-flash"'+'\n';
	contenid1+=' pluginspage='+'\n';
	contenid1+=' "http://www.macromedia.com/go/getflashplayer">\n';
	contenid1+='</embed></object>'+'\n'
	return(contenid1);
}

function ventana_pdf(url,capa,subdiv){
	{
	// pgn_vacia.html
	// ventana_pdf(which,capa_hvl,sub_capa)
	// *
	figura_1="hvl/bocamina/botones_pdf/barraFrm1.gif";
	figura_2="hvl/bocamina/botones_pdf/cierreFrm1.gif";
	figura_3="hvl/bocamina/botones_pdf/barrafrm2.gif";
	figura_4="hvl/bocamina/botones_pdf/cierrefrm2_f2.gif";
	figura_5="hvl/bocamina/botones_pdf/barrafrm2_f2.gif";
	figura_6="hvl/bocamina/cierrefrm2.gif";
	// ***
	contenido='<div  id="'+subdiv+'" align="center">';
	contenido+='<table width="100%" border="0" align="center" cellpadding="0" '
	contenido+='cellspacing="0"><tr><td width="774"><img name="barraFrm1" '
	contenido+='src="'+figura_1+'" width="774" height="16" '
	contenido+='border="0" alt=""></td><td width="26"><img name="cierreFrm1" '
	contenido+='src="'+figura_2+'" width="26" height="16" '
	contenido+='border="0" alt=""></td></tr><tr><td width="774">'
	contenido+='<img src="'+figura_3+'" alt="" name="barrafrm2" '
	contenido+='width="774" height="30" border="0" align="middle"></td><td width="26">'
	contenido+='<a href="javascript:;" onClick="MM_callJS('+"'CerrarVentana("+capa+")'"+')" '
	contenido+='onMouseOver="MM_swapImage('
	contenido+="'cierrefrm2','','"+figura_4+"','barrafrm2'"
	contenido+=",'','"+figura_5+"',1);MM_displayStatusMsg("
	contenido+="'Sociedad Anónima Hullera Vasco-Leonesa')"
	contenido+=';return document.MM_returnValue" onMouseOut="MM_swapImgRestore();">'
	contenido+='<img name="cierrefrm2" src="'+figura_6+'" width="26" '
	contenido+='height="30" border="0" alt="cerrar"></a></td></tr><tr><td colspan="2">'
	contenido+='<iframe src="'+url+'" name="venpdf" width="100%" '
	contenido+='height="494" align="middle" scrolling="auto" frameborder="0" id="venpdf">'
	contenido+='</iframe></td></tr></table></div>'
	// ***
	// contenido='<div  id="'+subdiv+'" align="center">';
	// contenido+='</div>'
	}
}


function flotantes(which, tipo_hvl, capa_hvl, e, posicion, sub_capa, imgalinear, imgwidth, imgheight,cuadro){
	if (ie||ns6){
		crossobj=document.getElementById? eval('document.getElementById("'+capa_hvl+'")') : eval('document.all.'+capa_hvl);
		//alert("crossobj = "+crossobj);
		switch (tipo_hvl) {
			case "inversores" :
				qId=FIND_ID(which);
				ventana_inv(which,qId,sub_capa,imgalinear,imgwidth,imgheight);
				crossobj.innerHTML=contenido;
				//crossobj.reload;
				break;
				// ***
			case "pedefes" :
				crossobj.innerHTML="";
				ventana_pdf(which,capa_hvl,sub_capa);
				//alert("contenido =    "+contenido);
				crossobj.innerHTML=contenido;
				break;
				// ***
			case "flash" :
				qId=FIND_ID(which);
				ventana_swf(which,qId,sub_capa,imgalinear,imgwidth,imgheight);
				crossobj.innerHTML=contenido;
				imgheight=imgheight+36;
				break;
				// ***	
			default :
				crossobj.innerHTML='<div><iframe src="'+which+'" width="'+imgwidth+'" height="'+imgheight+'" scrolling="No" frameborder="0" style="padding: 0px 0px 0px 0px;"></iframe></div>'
				break;
				// ***
		}		
		// ***
		npos_y=Number(posicion);
		if(isNaN(npos_y)!=true){posicion="pos_y";}else{npos_y=0;}
		posi_ventanas(e,posicion,npos_y,imgwidth,imgheight);
		// ***
		crossobj.style.left=horzpos+"px"
		crossobj.style.top=vertpos+"px"
		// ***		
		crossobj.style.visibility=verSi; // "visible"
		// ***
	} else {
		//if NOT IE 4+ or NS 6+, simply display image in full browser window
		return true
	}
}

function CerrarVentana(capa_c){
	capa_c = capa_c.id;
	micapa_c=document.getElementById? eval('document.getElementById("'+capa_c+'")') : eval('document.all.'+capa_c);	
	//alert("estoy en CerrarVentana("+capa_c+") .....  =  " + micapa_c);
	micapa_c.innerHTML='';
	micapa_c.style.visibility=verNo; // "hidden"
	//window.location.reload()
}

function closeVen_conInv(){

//document.onmousemove=null;	
//document.onmousedown=null;
//document.onmouseup=null;	
if(capaUno.style.visibility==verSi){capaUno.innerHTML='';capaUno.style.visibility=verNo;}
if(capaDos.style.visibility==verSi){capaDos.innerHTML='';capaDos.style.visibility=verNo;}
if(capaTres.style.visibility==verSi){capaTres.innerHTML='';capaTres.style.visibility=verNo;}
// window.location.reload()
}

function closeVen_sinInv(){
// if(capaUno.style.visibility==verSi){capaUno.innerHTML='';capaUno.style.visibility=verNo;}
if(capaDos.style.visibility==verSi){capaDos.innerHTML='';capaDos.style.visibility=verNo;}
if(capaTres.style.visibility==verSi){capaTres.innerHTML='';capaTres.style.visibility=verNo;}	
// window.location.reload()
}

/* 
 * ini arrastre de la capa = popTres  *********************
*/

function arrastre_mov(e){
	if (ie&&arrastrando){
		crossobj.style.left=tempx+event.clientX-offsetx+"px"
		crossobj.style.top=tempy+event.clientY-offsety+"px"
	}
	else if (ns6&&arrastrando){
		crossobj.style.left=tempx+e.clientX-offsetx+"px"
		crossobj.style.top=tempy+e.clientY-offsety+"px"
	}
	return false
}

function final_arrastre(e){
	// pasoSgte=false;
	pasoSgte=true;
	/*
	if(ie){if(event.srcElement.id=="movcuad"){pasoSgte=true;}
	} else if(ns6) {if(e.target.id=="movcuad"){pasoSgte=true;}}
	*/
	if (pasoSgte){
		// *anchoVis=event.srcElement.width; althoVis=event.srcElement.height;
		// visorFotos y visorVideos
		/*
		var qVisor = FIND_ZP("visorVideos");
		if(qVisor==undefined){qVisor = FIND_ZP("visorFotos");}
		var anchoCuad=qVisor.width;
		var althoCuad=qVisor.height+20;		
		anchoVis=anchoCuad; althoVis=althoCuad;
		anchoTot=1000; althoTot=595;
		p_left=crossobj.style.left; 
		p_left=Number(p_left.substring(0,p_left.length-2));
		topeLeft=p_left; topeLeft_1=anchoTot-anchoVis; topeLeft_2=0;
		p_top=crossobj.style.top; 
		p_top=Number(p_top.substring(0,p_top.length-2));
	 	topeTop=p_top; topeTop_1=althoTot-althoVis; topeTop_2=0;
		// ***
		if(p_left>topeLeft_1){topeLeft=topeLeft_1; act_arr=true;} else {
		if(p_left<topeLeft_2){topeLeft=topeLeft_2; act_arr=true;}}
		// ***
		if(p_top>topeTop_1){topeTop=topeTop_1; act_arr=true;} else { 
		if(p_top<topeTop_2){topeTop=topeTop_2; act_arr=true;}}		
		// ***
		crossobj.style.left=topeLeft+"px";
		crossobj.style.top=topeTop+"px";
		*/
		arrastrando=false;
		document.onmousemove=null;
		return false
	}
}

function inicio_arrastre(e){
  // alert("event.srcElement.id = "+event.srcElement.id);
  if(capaTres.style.visibility==verSi){ // visorFotos y visorVideos
	// visorFotos y visorVideos
	pasoSgte=false; // movcuad ; imgMov
	elecual=event.srcElement.id; // visorFotos ; visorVideos
	//alert("cual = "+elecual);
	if(ie){if(event.srcElement.id=="imgMov"){pasoSgte=true;}
	} else if(ns6){if(e.target.id=="imgMov"){pasoSgte=true;}}
	if (pasoSgte){
		offsetx=ie? event.clientX : e.clientX;
		offsety=ie? event.clientY : e.clientY;

		tempx=parseInt(crossobj.style.left);
		tempy=parseInt(crossobj.style.top);
		
		arrastrando=true;
		if (document.layers) document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove=arrastre_mov;
	}
  }
}

/* 
 * fin arrastre de la capa = popTres *********************
*/

function FIND_HVL(miHvl){
	cqHvl="raiz";
	for(i=0; i<miHvl.length; i++){
		if(miHvl.substring(i,i+1) == "/"){cqHvl=miHvl.substring(0,i)};
	}
	if(cqHvl!="hvl"){miHvl="hvl/"+miHvl;}
	return(miHvl);
}

function FIND_ID(miNom){
  nomMi="";
  for(i=0; i<miNom.length; i++){if(miNom.substring(i,i+1) == "/"){nomMi=miNom.substring(i+1);}}
  miNom=nomMi; nomMi="";
  for(i=0; i<miNom.length; i++){if(miNom.substring(i,i+1) == "."){nomMi=miNom.substring(0,i);}}	
  miNom=nomMi;
  return(miNom);
}

function FIND_ZP(miDiv) {
	if( window.mmIsOpera ) return(document.getElementById(miDiv));
	if (document.all) return(document.all[miDiv]);
	if (document.getElementById) return(document.getElementById(miDiv));
	return(false);
}

/* --------------------------------------------------   Inico  Control: Flash.swf */
/* ============================================================================== */
/*
 *  poner_flash(0,0,"capa_menu_1","hvl/menu_principal.swf",800,47);
*/
function poner_flash(pos_x,pos_y,capa,swf,ancho,alto){
	contobj=document.getElementById? eval('document.getElementById("'+capa+'")') : eval('document.all.'+capa);
	if(contobj==null){return false;}
	id = FIND_ID(swf);
	alinear="top";
	contobj.style.left=pos_x+"px"
	contobj.style.top=pos_y+"px"
	// *
	objhtml='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
	objhtml+='codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/';
	objhtml+='swflash.cab#version=7,0,0,0" ';
	objhtml+='width="'+ancho+'" height="'+alto+' name="'+id+' id="'+id+'" align="';
	objhtml+=alinear+'"><param name="allowScriptAccess" value="sameDomain" />';
	objhtml+='<param name="movie" value="' + swf + '" />';
	objhtml+='<param name="menu" value="false" />';
	objhtml+='<param name="quality" value="best" />';
	objhtml+='<param name="salign" value="lt" />';
	objhtml+='<param name="wmode" value="transparent" />';
	objhtml+='<param name="id" value="' + id +'" />';
	objhtml+='<param name="name" value="' + id +'" />';
	objhtml+='<embed src="'+ swf+'" width="'+ancho+'" height="'+alto+'" ';
	objhtml+='id="'+id+'" name="'+id+'" align="' + alinear +'" ';
	objhtml+='menu="false" quality="best" salign="lt" wmode="transparent" ';
	objhtml+='allowScriptAccess="sameDomain" type="application/x-shockwave-flash" ';
	objhtml+='pluginspage="http://www.macromedia.com/go/getflashplayer"  />';
	objhtml+='</OBJECT></div>';
	// *
	contobj.innerHTML=objhtml;
	// *
	if(id=="menu_principal"){capamenu=FIND_ZP("menu_principal");}
}

// *
// ***   fin funciones
// ***
// FIN  JavaScript Document  