var yposition=10;           // Posición en que se carga la barra desde la posición
                             // de arriba de la ventana, en Pixels.
var loadedcolor='#009900' ;  // Color del progreso de la barra.
var unloadedcolor='#FFFFFF'; // Color del Fondo, del área que no ha sido cargada.
var barheight=25;            // Alto de la Barra de progreso en Pixels (Mínimo 25)
var barwidth=265;            // Ancho de la Barra en Pixels
var bordercolor='#006600';     // Color del Borde


var NS4 = (navigator.appName.indexOf("Netscape")>=0 && parseFloat(navigator.appVersion) >= 4 && parseFloat(navigator.appVersion) < 5)? true : false;
var IE4 = (document.all)? true : false;
var NS6 = (parseFloat(navigator.appVersion) >= 5 && navigator.appName.indexOf("Netscape")>=0 )? true: false;
var pagina="inicio.html"
var imagesdone=false;
var blocksize=barwidth/(imagenames.length);
barheight=Math.max(barheight,25);
var loaded=0, perouter, perdone, images=new Array();
var txt=(NS4)?'<layer name="perouter" bgcolor="'+bordercolor+'" visibility="hide">' : '<div id="perouter" style="position:absolute; visibility:hidden; background-color:'+bordercolor+'">';
txt+='<table cellpadding="0" cellspacing="1" border="0"><tr><td width="'+barwidth+'" height="'+barheight+'" valign="center">';
if(NS4)txt+='<ilayer width="100%" height="100%"><layer width="100%" height="100%" bgcolor="'+unloadedcolor+'" top="0" left="0">';
txt+='<table cellpadding="0" cellspacing="0" border="0"><tr><td valign="center" width="'+barwidth+'" height="'+barheight+'" bgcolor="'+unloadedcolor+'"><center><font color="'+loadedcolor+'" size="1" face="Verdana">Cargando imágenes...</font></center></td></tr></table>';
if(NS4) txt+='</layer>';
txt+=(NS4)? '<layer name="perdone" width="100%" height="'+barheight+'" bgcolor="'+loadedcolor+'" top="0" left="0">' : '<div id="perdone" style="position:absolute; top:1px; left:1px; width:'+barwidth+'px; height:'+barheight+'px; background-color:'+loadedcolor+'; z-index:100">';
txt+='<table cellpadding="0" cellspacing="0" border="0"><tr><td valign="center" width="'+barwidth+'" height="'+barheight+'" bgcolor="'+loadedcolor+'"><center><font color="'+unloadedcolor+'" size="1" face="Verdana">Cargando imágenes...</font></center></td></tr></table>';
txt+=(NS4)? '</layer></ilayer>' : '</div>';
txt+='</td></tr></table>';
txt+=(NS4)?'</layer>' : '</div>';
document.write(txt);
function loadimages(){
if(NS4){
perouter=document.perouter;
perdone=document.perouter.document.layers[0].document.perdone;
}
if(NS6){
perouter=document.getElementById('perouter');
perdone=document.getElementById('perdone');
}
if(IE4){
perouter=document.all.perouter;
perdone=document.all.perdone;
}
cliplayer(perdone,0,0,barheight,0);
window.onresize=setouterpos;
setouterpos();
for(n=0;n<imagenames.length;n++){
images[n]=new Image();
images[n].src=imagenames[n];
setTimeout('checkload('+n+')' ,n*100);
}}
function setouterpos(){
var ww=(IE4)? document.body.clientWidth : window.innerWidth;
var x=(ww-barwidth)/2;
if(NS4){
perouter.moveTo(x,yposition);
perouter.visibility="show";
}
if(IE4||NS6){
perouter.style.left=x+'px';
perouter.style.top=yposition+'px';
perouter.style.visibility="visible";
}}
function dispbars(){
loaded++;
window.status="Precarga de las imágenes ... "+loaded+" / "+imagenames.length;
cliplayer(perdone, 0, blocksize*loaded, barheight, 0);
if(loaded>=imagenames.length)setTimeout('hideperouter()', 800);
}
function checkload(index){
(images[index].complete)? dispbars() : setTimeout('checkload('+index+')', 100);
}
function hideperouter(){
(NS4)? perouter.visibility="hide" : perouter.style.visibility="hidden";
imagesdone=true;
window.status='';
}
function cliplayer(layer, ct, cr, cb, cl){
if(NS4){
layer.clip.left=cl;
layer.clip.top=ct;
layer.clip.right=cr;
layer.clip.bottom=cb;
}
if(IE4||NS6)layer.style.clip='rect('+ct+' '+cr+' '+cb+' '+cl+')';
}
//window.onload=loadimages;
function PF(txt,img){
  foto1= new Image();
  foto1.src=(img);
  Controlla(txt,img);
}
function Controlla(txt,img){
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(txt,img);
  }
  else{
    funzione="Controlla('"+img+"')";
    intervallo=setTimeout(funzione,20);
  }
}
function viewFoto(txt,img){
  largh=foto1.width+20;
  altez=foto1.height+35;
  stringa="width="+largh+",height="+altez;
  finestra=window.open("","",stringa);
  finestra.document.write("<HTML><TITLE>Cultura Asturiana</TITLE>");
  finestra.document.write("<IMG SRC="+img+"></A>")
finestra.document.write("<br><CENTER><font face='Verdana, Arial, Helvetica, sans-serif' size='0.5'>"+txt+"")
}

/*
		Picpreview.js 
		Version 1.1
		written by Christian Heilmann 
		Homepage: http://www.icant.co.uk/articles/picpreview/
		Licensed Creative Commons 2.5	
		http://creativecommons.org/licenses/by/2.5/		
	*/
	function picpreview()
	{
		// is PHP available? true of false
		
		
		var hasphp=true;
		// options for the url depending on the PHP availability
		var hasphpurl='thumb.php?i=';
		var thumb='tn_';
		// class to identify links to be enhanced
		var previewclass='preview';
		// link added to the newly created preview links
		var previewlinkclass='previewlink';
		// class added to the preview image
		var previewimageclass='previewimage';
		// image to show next to each preview link + alternative
		var previewimage='camera.gif';
		var previewalternative='vista previa de la imagen';
		// image to show while the thumb is loaded + alternative
		var loadingimage='loading.gif';
		var loadingalternative='Cargando...';

				
		// Loop over all links
		var links=document.getElementsByTagName('a');
		// Define "caching" array, as we will alter th links array
		var prevlinks=new Array();
		var c=0;
	
		// Define test pattern 	
		var previewTest = new RegExp("(^|\\s)" + previewclass + "(\\s|$)");

		// Loop over all links and filter out links without the necessary class
		for(var i=0;i<links.length;i++)
		{
			if(!previewTest.test(links[i].className)){continue;}
			prevlinks[c]=links[i];			
			c++;
		}
		
		// Loop over all links with the preview class
		for(var i=0;i<prevlinks.length;i++)
		{
		//  create new link, preview image and set the correct attributes		

			var newa=document.createElement('a');
			newa.className=previewlinkclass;
			var newimg=document.createElement('img');
			newimg.src=previewimage;
			
			newimg.alt=previewalternative;
			newimg.className=previewimageclass;
			newa.appendChild(newimg);
			newa.href="#";
		// add function when the preview link is  activated
			newa.onclick=function()
			{
		// If there is already a second image, remove it
		
				if(this.getElementsByTagName('img')[1])
				{
					this.removeChild(this.getElementsByTagName('img')[1]);

		// Otherwise create a new image and set the "loading" message attributes
				} else {
					var newimg=document.createElement('img');
					newimg.src=loadingimage;
					newimg.alt=loadingalternative;
					this.appendChild(newimg);
	
		// Create a new image and set its URL to thumb of the linked image 
		// depending on hasphp, this is a file url or one pointing to the php script	
		// Add a random value to prevent caching issues
					var newimg=document.createElement('img');
					this.appendChild(newimg);
					var rand=parseInt(777*Math.random(0,1));
					
					
					var ind0, ind1, parte ="";
					//var texto="";
					//texto=links[i].toString();
					ind0 = this.previousSibling.href.indexOf(",");
					if (ind0 >=0)
					{
					ind1 = this.previousSibling.href.indexOf(")");
					if (ind1>ind0)
					parte = this.previousSibling.href.substring(ind0+",".length+1, ind1-1);
					} 
				newimg.src=hasphp?geturl(parte)+"&r="+rand:geturl(parte);
		// If the image has successfully loaded, remove the loading image 
					newimg.onload=function()
					{
						this.parentNode.removeChild(this.parentNode.getElementsByTagName('img')[1]);
					}
				}
		//  don't follow the initial link
				return false;
			}

		//  add preview link after the real one
			prevlinks[i].parentNode.insertBefore(newa,prevlinks[i].nextSibling);
		}

		// Tool method to create the URL to  the thumb
		function geturl(url)
		{
			
			//url=url.split('/');
			url=hasphp?hasphpurl+url:thumb+url[url.length-1];
			
			return url;
		}
	}	

// When the window has loaded, test for DOM and execute script
	window.onload=function()
	{
		loadimages();
		if(!document.getElementById || !document.createTextNode){return;}
		picpreview()
	}



s=0;
function winopen (str,x,y) {

if(s==1){'msg.close()';s=0;}

msg=open("about:blank","","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,"+"width="+x+",height="+y);


msg.location = 'nav/tree.html';

//msg.location.href=str;
//document.title="Navegador"
}  
