///// Explorador de archivos por Pedro Reyes ////////////////////////// 
var lastclicked=-1
var h = new Array()
var hindex = 0;
var startmessage;
var endmessage;
var restarea=10;
var maxspeed=14;
var thumbsloaded=new Array()
var imageObj=new Array()
var syncObj=false
var filearray


function getTree(filearr, location, containerid){
	var fl = filearr
	var inner=''
	var divs=0
	for(var i=0;i<fl.length;i++){
		var tipo = fl[i][0]
		if(tipo == "folder" || tipo == "audiofolder" || tipo == "videofolder" || tipo == "imgfolder"){	
			carpeta = fl[i][2]

			var folderid = location+"[0]"
			var m=15			
			if(folderid=="[0]")
				m=0
			divs++
			inner+='<div id="'+folderid+'" class="folderitem" style="width:'+(200-m)+'px;background-image:url(../img/icon_'+fl[i][0]+'closed.gif);margin-left:'+m+'px;overflow:hidden;"><nobr><span style="cursor:pointer;" onClick="showItem(\''+containerid+'\',\''+folderid+'\')"><img src="../img/bg_transparent.gif" height="12" width="31"/>'+carpeta+'</span></nobr>'
		}
		else if(tipo != "image" && tipo != "video" && tipo != "audio" && tipo != "file" && tipo != "subfolder")
			inner+=getTree(fl[i],location+"["+i+"]",containerid)		
	}
	for(var i=0;i<divs;i++)
		inner+='</div>'	
	return inner
}

function historycontrol(itemid){
	
	fl=eval(filearray+itemid)
	if(h[hindex-1]!=itemid){
		h[hindex] = itemid
		hindex = hindex + 1
		}
		
	if(lastclicked!=-1&&eval(filearray+lastclicked+'[0]') != "subfolder")
		document.getElementById(lastclicked).style.backgroundImage="url(../img/icon_"+eval(filearray+lastclicked+'[0]')+"closed.gif)"
	if(fl[0]=="folder"||fl[0]=="audiofolder"||fl[0]=="videofolder"||fl[0]=="imgfolder"){
		lastclicked=itemid			
		document.getElementById(itemid).style.backgroundImage="url(../img/icon_"+fl[0]+"open.gif)"	
	}
	else{			
		var itemid2=itemid.substring(1,itemid.length-1)
		var idarray = itemid2.split("][")
		var itemlink = "?show="
		itemid2 = ""
		for(var i=0;i<idarray.length-1;i++){
			itemid2+="[" + idarray[i] + "]"	
			itemlink+=idarray[i]+","
		}
		itemlink+=idarray[idarray.length-1]
		lastclicked=itemid2+"[0]"
		if(eval(filearray+lastclicked+'[0]') != "subfolder")
		document.getElementById(lastclicked).style.backgroundImage="url(../img/icon_"+eval(filearray+lastclicked+'[0]')+"open.gif)"
		return itemlink
	}		
}

function showItem(containerid, itemid){
if(itemid==-1){
		hindex = hindex-2
		itemid = h[hindex]
	}
	
	fl=eval(filearray+itemid)
	
	if(fl[0] == "video"){
		itemlink = historycontrol(itemid)
		
		var srct = "../video/"+fl[1]+".flv"
		var timage = "video/"+fl[1]+".gif"
		var rarsrc = "video/"+fl[1]+".rar"
		var nombre = fl[2]
		var descripcion = fl[3].split('&')
		var duracion = ''
		if(descripcion.length>1)
			duracion = descripcion[1]
		descripcion = descripcion[0]
		var inner='<div style="width:576px;height:20px;text-align:left;">'
		inner+='<div class="folderitem" style="position:absolute;background-image:url(../img/icon_fileopen.gif);padding-left: 35px"><span style="cursor:pointer;" onClick="showItem(\''+containerid+'\',\''+itemid+'\')">'+nombre+'</span></div>'
		if(hindex>1)
			inner+='<div class="contentview" style="background-image:url(../img/icon_item5.gif);margin-left:525px;"><span style="cursor:pointer;" onClick="showItem(\''+containerid+'\',\'-1\')">Volver</span></div>'	
		inner+='</div><div style="width:576px;background-color:#1F1F1F;height:1px"></div><div style="width:576px;height:10px"></div>'
		if(descripcion=="")
			descripcion="No hay descripción disponible para este video."
		inner+='<div class="itemdescription">'+descripcion+'</div>'
		inner+='<div class="itemdescription"><font color="#666666">'+duracion+'</font></div>'	
		inner+='<div class="fileitem" style="background-image:url(../img/icon_link.jpg);height:19px;padding-left:23px"><a href="'+window.location.href.split("?")[0]+itemlink+'" class="content_link">'
		inner+='<strong>Enlace permanente</a></strong></div>'
		inner+='<div class="fileitem" style="background-image:url(../img/icon_downloadmini.jpg);height:19px;padding-left:23px">'
		inner+='<strong><a href="'+rarsrc+'" class="content_link">Descargar video original</a></strong></div>'	
		inner+='<div style="width:576px;height:20px;text-align:left;">'
		inner+='<div class="contentview">Video</div></div><div style="width:576px;background-color:#1F1F1F;height:1px"></div>'
		inner+='<div style="width:576px;height:10px"></div>'		
		inner+='<div class="itemdescription">'
		inner+='<embed src="http://www.estebangumucio.cl/gallery/embed/mediaplayer.swf"'
		inner+=' width="500" height="375" allowscriptaccess="always" allowfullscreen="true"'
		inner+=' flashvars="height=375&width=500&'
		inner+='file='+srct
		inner+='&image='+timage
		inner+='&showstop=true"/>'
		inner+='</div>'
		inner+='<p>&nbsp;</p>'	
		
		document.getElementById(containerid).innerHTML=inner
		}
	else if(fl[0] == "audio"){
		itemlink = historycontrol(itemid)
		
		var srct = "audio/"+fl[1]+".mp3"
		var nombre = fl[2]
		var descripcion = fl[3].split('&')
		var duracion = ''
		if(descripcion.length>1)
			duracion = descripcion[1]
		descripcion = descripcion[0]
		var inner='<div style="width:576px;height:20px;text-align:left;">'
		inner+='<div class="folderitem" style="position:absolute;background-image:url(../img/icon_fileopen.gif);padding-left: 35px"><span style="cursor:pointer;" onClick="showItem(\''+containerid+'\',\''+itemid+'\')">'+nombre+'</span></div>'
		if(hindex>1)
			inner+='<div class="contentview" style="background-image:url(../img/icon_item5.gif);margin-left:525px;"><span style="cursor:pointer;" onClick="showItem(\''+containerid+'\',\'-1\')">Volver</span></div>'	
		inner+='</div><div style="width:576px;background-color:#1F1F1F;height:1px"></div><div style="width:576px;height:10px"></div>'
		if(descripcion=="")
			descripcion="No hay descripci&oacute;n disponible para este audio."
		inner+='<div class="itemdescription">'+descripcion+'</div>'
		inner+='<div class="itemdescription"><font color="#666666">'+duracion+'</font></div>'	
		inner+='<div class="fileitem" style="background-image:url(../img/icon_link.jpg);height:19px;padding-left:23px"><a href="'+window.location.href.split("?")[0]+itemlink+'" class="content_link">'
		inner+='<strong>Enlace permanente</a></strong></div>'
		inner+='<div class="fileitem" style="background-image:url(../img/icon_downloadmini.jpg);height:19px;padding-left:23px"><a href="http://www.estebangumucio.cl/gallery/'+srct+'" class="content_link">'
		inner+='<strong>Descargar audio original</a></strong></div>'
		inner+='<div style="width:576px;height:10px"></div>'
		inner+='<div style="width:576px;height:20px;text-align:left;">'
		inner+='<div class="contentview">Escuchar On-line</div></div><div style="width:576px;background-color:#1F1F1F;height:1px"></div>'
		inner+='<div style="width:576px;height:10px"></div>'
		inner+='<div class="itemdescription">'
		inner+='<embed src="http://www.estebangumucio.cl/gallery/embed/mediaplayer.swf"'
		inner+=' width="500" height="20" allowscriptaccess="always" allowfullscreen="true"'
		inner+=' flashvars="height=20&width=500&'
		inner+='file='+srct
		inner+='&showstop=true"/></div>'
		inner+='<p>&nbsp;</p>'	
		
		document.getElementById(containerid).innerHTML=inner
		}
	else if(fl[0] == "file"){
		
		itemlink = historycontrol(itemid)
		
		var src = fl[1]
		var nombre = fl[2]
		var descripcion = fl[3]
		var inner='<div style="width:576px;height:20px;text-align:left;">'
		inner+='<div class="folderitem" style="position:absolute;background-image:url(../img/icon_fileopen.gif);padding-left: 35px"><span style="cursor:pointer;" onClick="showItem(\''+containerid+'\',\''+itemid+'\')">'+nombre+'</span></div>'
		if(hindex>1)
			inner+='<div class="contentview" style="background-image:url(../img/icon_item5.gif);margin-left:525px;"><span style="cursor:pointer;" onClick="showItem(\''+containerid+'\',\'-1\')">Volver</span></div>'	
		inner+='</div><div style="width:576px;background-color:#1F1F1F;height:1px"></div><div style="width:576px;height:10px"></div>'
		if(descripcion=="")
			descripcion="No hay descripci&oacute;n disponible para este archivo."
		inner+='<div class="itemdescription">'+descripcion+'</div>'
		var emailriddlerarray=[101,46,103,117,109,117,99,105,111,64,115,115,99,99,46,99,108]
		var encryptedemail_id96='' //variable to contain encrypted email 
		for (var i=0; i<emailriddlerarray.length; i++)
			encryptedemail_id96+=String.fromCharCode(emailriddlerarray[i])
		inner+='<div class="itemdescription">Si el enlace no funciona, por favor notifícalo a  <a class="content_link" href="mailto:'+encryptedemail_id96+'">'+encryptedemail_id96+'</a>.</div>'
		if(src=="")
			src="#"		
		inner+='<p><div style="width:576px;height:20px;text-align:left;"><div class="contentview">Contenido</div></div><div style="width:576px;background-color:#1F1F1F;height:1px"></div><div style="width:576px;height:10px"></div>'			
		inner+='<div class="fileitem" style="background-image:url(../img/icon_downloadmini.jpg);height:19px;padding-left:23px"><strong><a href="'+src+'" class="content_link">Ver/Descargar</a></strong></div>'	
		document.getElementById(containerid).innerHTML=inner
		}
	else if(fl[0]=="folder"||fl[0]=="audiofolder"||fl[0]=="videofolder"||fl[0]=="imgfolder"||fl[0]=="subfolder"){
		historycontrol(itemid)
		var inner=""
		var nombre = fl[2]
		var description = fl[3]
		if(itemid=='[0]'){
			description=startmessage
			if(description!="")
				description += '<p>' + fl[3]
		}
		else if(description=="")
			description="No hay descripción disponible para esta carpeta"
		if(fl[0] == "imgfolder"){
			description+='<p><span style="cursor:pointer;" onClick="showThumbslist(\''+containerid+'\',\''+itemid+'\',0)">Ver lista</span> | '
			description+='<span style="cursor:pointer;" onClick="showThumbs(\''+containerid+'\',\''+itemid+'\',0)">Ver miniaturas</span> | '
			description+='<span style="cursor:pointer;" onClick="showStrip(\''+containerid+'\',\''+itemid+'\',0)">Ver tira de Imágenes</span>'
			}
		var tipo=fl[0]
		if(tipo=="subfolder")
			tipo="folder"
		inner+='<div style="width:576px;height:20px;text-align:left;">'			
		inner+='<div class="folderitem" style="position:absolute;background-image:url(../img/icon_'+tipo+'open.gif);padding-left: 35px"><span style="cursor:pointer;" onClick="showItem(\''+containerid+'\',\''+itemid+'\')">'+nombre+'</span></div>'			
		if(hindex>1)
			inner+='<div class="contentview" style="background-image:url(../img/icon_item5.gif);margin-left:525px;"><span style="cursor:pointer;" onClick="showItem(\''+containerid+'\',\'-1\')">Volver</span></div>'				
		inner+='</div><div style="width:576px;background-color:#1F1F1F;height:1px"></div><div style="width:576px;height:10px"></div>'
		inner+='<div class="itemdescription"><p>'+description+'<p></div>'			
		inner+='<div id="contentdiv"></div>'
		if(endmessage!=null)
		inner+=endmessage
		inner+='<p>&nbsp;</p>'
		document.getElementById(containerid).innerHTML=inner
		if(fl[0] == "videofolder")
			showThumbs(containerid,itemid,0)
		else if(fl[0] == "imgfolder")
			showThumbslist(containerid,itemid,0)
		else
			showFileList(containerid,itemid,0)
		}
}

function showStrip(containerid, itemid, page){
	var inner = '<div style="width:576px;height:20px;text-align:left;">'
	inner += '<div id="contenttitle" class="contentview">Tira de imágenes</div>'
	inner += '</div><div style="width:576px;background-color:#1F1F1F;height:1px"></div>'
	inner += '<div style="width:576px;height:10px"></div>'	
	
	itemid = itemid.substring(1,itemid.length-1)		
	var idarray = itemid.split("][")
	itemid = ""
	for(var i = 0; i < idarray.length - 1; i++)
		itemid = itemid + "[" + idarray[i] + "]"
	fl = eval(filearray + itemid)
	
	var foldertype = fl[0][0]
	var nitems = 20
	var pagecount = (fl.length-1)/nitems;
	var startindex = page*nitems+1
	var left = 0
	var top = 0
	thumbsloaded[page] = 0
	if(pagecount>1){
		inner += '<div style="width:576px;height:20px;text-align:left;"><div class="contentview">Página '
		inner += '<select onchange="showStrip(\''+containerid+'\',\''+itemid+'[0]\',this.selectedIndex)">'
		var ultimo
		for(var i=0;i<pagecount;i++){
			ultimo=i+1
			if(page==i)
				inner += '<option selected="true">'+ultimo+'</option>'
			else
				inner += '<option>'+ultimo+'</option>'
			}
		inner+='</select> de '+ultimo+' '
		if(page>0)
			inner+='|<span style="cursor:pointer;" onClick="showStrip(\''+containerid+'\',\''+itemid+'[0]\','+(page-1)+')"> &lt; anterior </span>'
		if(page<ultimo-1)
			inner+='|<span style="cursor:pointer;" onClick="showStrip(\''+containerid+'\',\''+itemid+'[0]\','+(page+1)+')"> siguiente &gt; </span>'
		inner+='</div></div><div style="width:576px;height:10px"></div>'
		}
	inner += '<div id="preload" style="position:absolute;width:576px;">'
	inner += '<p align="center">'+returnloading()+'</p><p align="center">Cargando...</p><div id="preloadtxt" style="width:576px;"></div></div>'
	inner += '<div id="thumbsc" style="width:576px;height:155px;visibility:hidden;">'
	inner += '<table width="575" border="0" cellspacing="0" cellpadding="0"><tr>'
inner += '<td><div align="center"><span onmouseover="absmove(\'right\')" onmouseout="absmove(null)"><img src="../img/icon_arrow_l.gif" width="22" height="27"></span></div></td>'
inner += '<td width="450">'
	inner+='<div id="motioncontainer" style="width:450px;position:relative;overflow:hidden;">'
	inner+='<div id="motiongallery" style="position:absolute;left:0;top:0;white-space: nowrap;"><nobr id="trueContainer">'
	var itemsloaded=0
	for(var i=startindex;i<fl.length&&i<(startindex+nitems);i++){	
	if(fl[i][0] == "image"){
		var linksrc = fl[i][1]
		imageObj[i]=new Image()
		imageObj[i].name=linksrc
		imageObj[i].onload = function()	{
		thumbsloaded[page]=thumbsloaded[page]+1
		}	
		imageObj[i].src = '/gallery/thumb/'+linksrc+'_thumb.jpg'
		itemsloaded++
		inner+='<span style="cursor:pointer;" onClick="showImage(\'enlargearea\',\''+itemid+'['+i+']\')">'
		inner+='<img src="/gallery/thumb/'+linksrc+'_thumb.jpg" height="150" hspace="1"/></span>'
		}
	}
	var firstlink = 'showImage(null,\''+itemid+'['+startindex+']\')'
	inner+='</nobr></div></div>'
inner += '</td>'
inner += '<td><div align="center"><span onmouseover="absmove(\'left\')" onmouseout="absmove(null)"><img src="../img/icon_arrow_r.gif" width="22" height="27"></span></div></td></tr></table></div>'
inner += '<div id="enlargearea" style="width:450px;margin:0 auto;vertical-align:middle">'+eval(firstlink)+'</div>'
		
	document.getElementById("contentdiv").innerHTML = inner		
	endload(page,itemsloaded,"fillup()",true)	
}

function showImage(containerid,itemid){
	fl = eval(filearray + itemid)
	var inner ='<a href="/gallery/medium/'+fl[1]+'_medium.jpg" onClick="myLightbox.start(this); return false;" '
	inner+='rel="lightbox" title="'+fl[3]+'">'
	inner+='<p><img src="/gallery/thumb/'+fl[1]+'_thumb.jpg" hspace="10" align="left"></a>'
	inner+='<a href="/gallery/medium/'+fl[1]+'_medium.jpg" onClick="myLightbox.start(this); return false;" '
	inner+='rel="lightbox" title="'+fl[3]+'" class="content_link">'
	inner+='<strong>'+fl[2]+'</strong></a><br />'
	inner+='<a href="/gallery/medium/'+fl[1]+'_medium.jpg" onClick="myLightbox.start(this); return false;" '
	inner+='rel="lightbox" title="'+fl[3]+'">'
	inner+=fl[3]+'<br /><font color="#666666"></p><p><strong>Ampliar</strong></font></p></a>'
	if(containerid!=null)
		document.getElementById(containerid).innerHTML=inner
	else 
		return inner
}

function showThumbs(containerid, itemid, page){
	var inner = '<div style="width:576px;height:20px;text-align:left;">'
	inner += '<div id="contenttitle" class="contentview">Vistas en miniatura</div>'
	inner += '</div><div style="width:576px;background-color:#1F1F1F;height:1px"></div>'
	inner += '<div style="width:576px;height:10px"></div>'	
	
	itemid = itemid.substring(1,itemid.length-1)		
	var idarray = itemid.split("][")
	itemid = ""
	for(var i = 0; i < idarray.length - 1; i++)
		itemid = itemid + "[" + idarray[i] + "]"
	fl = eval(filearray + itemid)
	
	var foldertype = fl[0][0]
	var nitems = 0		
	if(foldertype == "imgfolder")
		nitems = 6
	else if(foldertype == "videofolder")
		nitems = 5
	var pagecount = (fl.length-1)/nitems;
	var startindex = page*nitems+1
	var left = 0
	var top = 0
	thumbsloaded[page] = 0
	if(pagecount>1){
		inner += '<div style="width:576px;height:20px;text-align:left;"><div class="contentview">Página '
		inner += '<select onchange="showThumbs(\''+containerid+'\',\''+itemid+'[0]\',this.selectedIndex)">'
		var ultimo
		for(var i=0;i<pagecount;i++){
			ultimo=i+1
			if(page==i)
				inner += '<option selected="true">'+ultimo+'</option>'
			else
				inner += '<option>'+ultimo+'</option>'
			}
		inner+='</select> de '+ultimo+' '
		if(page>0)
			inner+='|<span style="cursor:pointer;" onClick="showThumbs(\''+containerid+'\',\''+itemid+'[0]\','+(page-1)+')"> &lt; anterior </span>'
		if(page<ultimo-1)
			inner+='|<span style="cursor:pointer;" onClick="showThumbs(\''+containerid+'\',\''+itemid+'[0]\','+(page+1)+')"> siguiente &gt; </span>'
		inner+='</div></div><div style="width:576px;height:10px"></div>'
		}
	inner += '<div id="preload" style="position:absolute;width:576px;">'
	inner += '<p align="center">'+returnloading()+'</p><p align="center">Cargando...</p><div id="preloadtxt" style="width:576px;"></div></div>'
	inner += '<div id="thumbsc" style="width:576px;height:320px;visibility:hidden;">'
	var itemsloaded=0
	for(var i=startindex;i<fl.length&&i<(startindex+nitems);i++){	
	if(fl[i][0] == "video"){
		var nombre = fl[i][2]
		var desc = fl[i][3].split('&')
		var linksrc = fl[i][1]
		var duracion = ''
		if(desc.length>1)
			duracion = desc[1]
		desc = desc[0]
		if(desc.length>60)
			desc = desc.substring(0,60)+"..."
		imageObj[i]=new Image()
		imageObj[i].name=linksrc
		imageObj[i].onload = function()	{
		thumbsloaded[page]=thumbsloaded[page]+1
		}	
		imageObj[i].src = '/gallery/video/'+linksrc+'.gif'
		itemsloaded++
		inner+='<div style="width:550px;height:40px;margin-left:25px;">'
		inner+='<p><span style="cursor:pointer;" onClick="showItem(\''+containerid+'\',\''+itemid+'['+i+']\')">'
		inner+='<img src="/gallery/video/'+linksrc+'.gif" alt="" width="60" height="40" align="left" hspace="10">'
		inner+='<a class="content_link"><strong>'+nombre+'</strong></a><br />'
		inner+=desc+'<br />'
		inner+='<font color="#666666">'+duracion+'</font></p>'
		inner+='</span>'		
		inner+='</div>'
		inner+='<div style="width:576px;height:10px"></div>'	
	}

	else if(fl[i][0] == "image"){	
		var nombre = fl[i][2]
		var desc = fl[i][3]
		if(desc.length>20)
			desc = desc.substring(0,20)+"..."
		var linksrc = fl[i][1]
		inner+='<div style="height:150px;position:absolute;'
		inner+='margin-left:'+(25+left*200)+'px;margin-top:'+(170*top)+'px">'
		left++
		if(left==3){
			left = 0
			top++
			}			
		imageObj[i] = new Image()
		imageObj[i].name = linksrc
		imageObj[i].onload = function()
		{
			thumbsloaded[page]++
		}	
		imageObj[i].src = '/gallery/thumb/'+linksrc+'_thumb.jpg'
		itemsloaded++
		inner += '<a href="/gallery/medium/'+linksrc+'_medium.jpg" onClick="myLightbox.start(this); return false;" rel="lightbox[id'+page+']" title="'+desc+'">'
		inner += '<span><img src="'+imageObj[i].src+'"/></span></a></div>'			
		}
	}
	inner+='</div>'
	document.getElementById("contentdiv").innerHTML = inner	
	endload(page,itemsloaded,null,true)

}

function showThumbslist(containerid, itemid, page){
	var inner = '<div style="width:576px;height:20px;text-align:left;">'
	inner += '<div id="contenttitle" class="contentview">Lista de Imágenes</div>'
	inner += '</div><div style="width:576px;background-color:#1F1F1F;height:1px"></div>'
	inner += '<div style="width:576px;height:10px"></div>'
	
	itemid = itemid.substring(1,itemid.length-1)		
	var idarray = itemid.split("][")
	itemid = ""
	for(var i = 0; i < idarray.length - 1; i++)
		itemid = itemid + "[" + idarray[i] + "]"
	fl = eval(filearray + itemid)
	
	var foldertype = fl[0][0]
	var nitems = 10
	var pagecount = (fl.length-1)/nitems
	var startindex = page*nitems+1
	var left = 0
	var top = 0
	thumbsloaded[page] = 0
	if(pagecount>1){
		inner += '<div style="width:576px;height:20px;text-align:left;"><div class="contentview">Página '
		inner += '<select onchange="showThumbslist(\''+containerid+'\',\''+itemid+'[0]\',this.selectedIndex)">'
		var ultimo
		for(var i=0;i<pagecount;i++){
			ultimo=i+1
			if(page==i)
				inner += '<option selected="true">'+ultimo+'</option>'
			else
				inner += '<option>'+ultimo+'</option>'
			}
		inner+='</select> de '+ultimo+' '
		if(page>0)
			inner+='|<span style="cursor:pointer;" onClick="showThumbslist(\''+containerid+'\',\''+itemid+'[0]\','+(page-1)+')"> &lt; anterior </span>'
		if(page<ultimo-1)
			inner+='|<span style="cursor:pointer;" onClick="showThumbslist(\''+containerid+'\',\''+itemid+'[0]\','+(page+1)+')"> siguiente &gt; </span>'
		inner+='</div></div><div style="width:576px;height:10px"></div>'
		}
	inner += '<div id="preload" style="position:absolute;width:576px;">'
	inner += '<p align="center">'+returnloading()+'</p><p align="center">Cargando...</p><div id="preloadtxt" style="width:576px;"></div></div>'
	inner += '<div id="thumbsc" style="width:576px;height:320px;visibility:hidden;">'
	inner +='<div id="rside" style="padding-top:1px;position:absolute;margin-left:300px;"></div>'
	inner +='<div id="lside" style="padding-top:1px;width:300px"></div>'
	inner +='</div>'
	document.getElementById("contentdiv").innerHTML = inner	
	var side="lside"
	
	var itemsloaded=0
	for(var i=startindex;i<fl.length&&i<(startindex+nitems);i++){
		if(fl[i][0] == "image"){
			inner=''
			var nombre = fl[i][2]
			var desc = fl[i][3]
			var linksrc = fl[i][1]
			if(desc.length>60)
				desc = desc.substring(0,60)+"..."
			imageObj[i]=new Image()
			imageObj[i].name=linksrc
			imageObj[i].onload = function()	{
				thumbsloaded[page]++
			}	
			imageObj[i].src = '/gallery/thumb/'+linksrc+'_thumb.jpg'
			itemsloaded++
			inner+='<div style="width:550px;height:55px;margin-left:25px;">'
			inner+='<p>'
			inner +='<a href="/gallery/medium/'+linksrc+'_medium.jpg" onClick="myLightbox.start(this); return false;" '
			inner+='rel="lightbox" title="'+desc+'">'
			inner+='<p><img src="'+imageObj[i].src+'" alt="" width="50" height="50" align="left" hspace="10"></a>'
			inner+='<a href="/gallery/medium/'+linksrc+'_medium.jpg" onClick="myLightbox.start(this); return false;" '
			inner+='rel="lightbox" title="'+desc+'" class="content_link">'
			inner+='<strong>'+nombre+'</strong></a><br />'
			inner+='<a href="/gallery/medium/'+linksrc+'_medium.jpg" onClick="myLightbox.start(this); return false;" '
			inner+='rel="lightbox" title="'+desc+'">'
			inner+=desc+'<br /><font color="#666666">Agrandar</font></p></a>'		
			inner+='</div>'
			document.getElementById(side).innerHTML += inner			
			if((i-startindex)==4)
						side="rside"
		}
	}	
	endload(page,itemsloaded,null,true)
}

function showFileList(containerid, itemid, page){
		var inner = '<div style="width:576px;height:20px;text-align:left;">'
		inner += '<div class="contentview">Lista de archivos</div></div>'
		inner += '<div style="width:576px;background-color:#1F1F1F;height:1px"></div>'
		inner += '<div style="width:576px;height:10px"></div>'	
		
		itemid=itemid.substring(1,itemid.length-1)
		var idarray = itemid.split("][")
		itemid=""
		for(var i=0;i<idarray.length-1;i++)
			itemid = itemid + "[" + idarray[i] + "]"
		fl=eval(filearray+itemid)
		
		var nitems = 18
		var foldertype = fl[0][1]
		if(foldertype != "")
			nitems = eval(foldertype)
		var pagecount = Math.floor((fl.length-1)/nitems);
		if(pagecount<((fl.length-1)/nitems))
			pagecount++
		var startindex = page*nitems+1		
		var endindex = startindex+nitems
		if(pagecount>1){
			inner+='<div style="width:576px;height:20px;text-align:left;"><div class="contentview">Página '
			inner+='<select onchange="showFileList(\''+containerid+'\',\''+itemid+'[0]\',this.selectedIndex)">'
		var ultimo
		for(var i=0;i<pagecount;i++){
			ultimo=i+1
			if(page==i)
				inner += '<option selected="true">'+ultimo+'</option>'
			else
				inner += '<option>'+ultimo+'</option>'
			}
			inner+='</select> de '+ultimo+' '
		if(page>0)
			inner+='|<span style="cursor:pointer;" onClick="showFileList(\''+containerid+'\',\''+itemid+'[0]\','+(page-1)+')"> &lt; anterior </span>'
		if(page<ultimo-1)
			inner+='|<span style="cursor:pointer;" onClick="showFileList(\''+containerid+'\',\''+itemid+'[0]\','+(page+1)+')"> siguiente &gt; </span>'
		inner+='</div></div><div style="width:576px;height:10px"></div>'
			}
		inner+='<div id="thumbsc" style="width:576px;height:320px;">'		
		inner+='</div>'
		document.getElementById("contentdiv").innerHTML = inner		
		var side="thumbsc"
		if(startindex==fl.length||startindex==endindex)
			document.getElementById(side).innerHTML += '<div class="fileitem" style="background-image:none;padding-left:0px;">No hay archivos disponibles</div>'
		else{
			for(var i=startindex;i<fl.length&&i<endindex;i++){
				var inner2=''
				if(fl[i][0][0]=="folder"||fl[i][0][0]=="subfolder"||fl[i][0][0]=="audiofolder"||fl[i][0][0]=="videofolder"||fl[i][0][0]=="imgfolder"){
					var nombre = fl[i][0][2]
					var linksrc = fl[i][0][1]
					inner2+='<div class="fileitem" style="padding-left: 0px;background-image:url(../img/icon_folder.gif);"><span style="cursor:pointer;" onClick="showItem(\''+containerid+'\',\''+itemid+'['+i+'][0]\')"><img src="../img/bg_transparent.gif" height="12" width="17"/>'+nombre+'</span></div>'
				}
				else if(fl[i][0] == "file"){	
					var nombre = fl[i][2]
					var linksrc = fl[i][1]
					inner2+='<div class="fileitem" style="padding-left: 0px;overflow:hidden;width:525px"><span style="cursor:pointer;" onClick="showItem(\''+containerid+'\',\''+itemid+'['+i+']\')"><img src="../img/bg_transparent.gif" height="12" width="17"/><nobr>'+nombre+'</nobr></span></div>'
				}
				else if(fl[i][0] == "audio"){
					var nombre = fl[i][2]
					var desc = fl[i][3].split('&')
					var linksrc = fl[i][1]
					var duracion = ''
					if(desc.length>1)
						duracion = desc[1]
					desc = desc[0]
					if(desc.length>60)
						desc = desc.substring(0,60)+"..."
					inner2+='<div style="width:550px;height:45px;margin-left:25px;">'
					inner2+='<p><span style="cursor:pointer;" onClick="showItem(\''+containerid+'\',\''+itemid+'['+i+']\')">'
					inner2+='<img src="/img/icon_sound.jpg" alt="" width="56" height="40" align="left" hspace="10">'
					inner2+='<a class="content_link"><strong>'+nombre+'</strong></a><br />'
					inner2+=desc+'<br />'
					inner2+='<font color="#666666">'+duracion+'</font></p>'
					inner2+='</span>'		
					inner2+='</div>'
				}
				document.getElementById(side).innerHTML += inner2
			}
		}
}

function generateExplorer(treeid, containerid, filearr){
	window.onload=function(){
		initLightbox()
		filearray = filearr
		startmessage = document.getElementById(containerid).innerHTML
		document.getElementById(treeid).innerHTML = getTree(eval(filearr),"", containerid)
		var direccion = window.location.search
		if(direccion.indexOf("show=")!=-1){
			direccion=direccion.substring(direccion.lastIndexOf("show=")+5,direccion.length)
			var dirarray = direccion.split(",")
			direccion=""
			for(var i=0;i<dirarray.length;i++)
				direccion = direccion + "[" + dirarray[i] + "]"
			showItem(containerid,direccion)	
			}
		else
			showItem(containerid, '[0]')
		}	
}

function endload(page,totalitems,execute,restart){
	
	if(thumbsloaded[page]==totalitems){
	clearInterval(syncObj)
	document.getElementById("thumbsc").style.visibility='visible'
	document.getElementById("preload").innerHTML=''
	document.getElementById("preload").style.visibility='hidden'
	thumbsloaded[page]=0
	if(execute!=null)
		eval(execute)	
	}
	else if(restart){
		clearInterval(syncObj)		
		syncObj=setInterval("endload("+page+","+totalitems+","+execute+",false)",100)		
	}
	else 
		document.getElementById("preloadtxt").innerHTML='<p align="center">Imagen '+(thumbsloaded[page]+1)+' de '+totalitems+'</p>'
}

var iedom=document.all||document.getElementById, scrollspeed=0, movestate='', cross_scroll, ns_scroll, statusdiv, loadedyes=0, lefttime, righttime;

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft: what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function moveleft(){
if (loadedyes){
movestate="left";
if (iedom&&parseInt(cross_scroll.style.left)>(menuwidth-getActualWidth()))
cross_scroll.style.left=parseInt(cross_scroll.style.left)-scrollspeed+"px";
}
lefttime=setTimeout("moveleft()",10);
}

function moveright(){
if (loadedyes){
movestate="right";
if (iedom&&parseInt(cross_scroll.style.left)<0)
cross_scroll.style.left=parseInt(cross_scroll.style.left)+scrollspeed+"px";
}
righttime=setTimeout("moveright()",10);
}

function absmove(direccion){
	scrollspeed=maxspeed
	if(direccion=="left"){
		clearTimeout(righttime)
		if (movestate!="left") moveleft();
	}
	else if(direccion=="right"){
		clearTimeout(lefttime);
		if (movestate!="right") moveright();
	}
	else{
	scrollspeed=0;
	clearTimeout(lefttime);
	clearTimeout(righttime);
	movestate="";
	}
}

function motionengine(e){
var mainobjoffset=getposOffset(crossmain, "left"),
dsocx=(window.pageXOffset)? pageXOffset: ietruebody().scrollLeft,
dsocy=(window.pageYOffset)? pageYOffset : ietruebody().scrollTop,
curposy=window.event? event.clientX : e.clientX? e.clientX: "";
curposy-=mainobjoffset-dsocx;
var leftbound=(menuwidth-restarea)/2;
var rightbound=(menuwidth+restarea)/2;
if (curposy>rightbound){
scrollspeed=(curposy-rightbound)/((menuwidth-restarea)/2) * maxspeed;
clearTimeout(righttime);
if (movestate!="left") moveleft();
}
else if (curposy<leftbound){
scrollspeed=(leftbound-curposy)/((menuwidth-restarea)/2) * maxspeed;
clearTimeout(lefttime);
if (movestate!="right") moveright();
}
else
scrollspeed=0;
}

function contains_ns6(a, b) {
if (b!==null)
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function stopmotion(e){
if (!window.opera||(window.opera&&e.relatedTarget!==null))
if ((window.event&&!crossmain.contains(event.toElement)) || (e && e.currentTarget && e.currentTarget!= e.relatedTarget && !contains_ns6(e.currentTarget, e.relatedTarget))){
clearTimeout(lefttime);
clearTimeout(righttime);
movestate="";
}
}

function getActualWidth(){
return document.getElementById? document.getElementById("trueContainer").offsetWidth : document.all['trueContainer'].offsetWidth
}

function fillup(){
if (iedom){
crossmain=document.getElementById? document.getElementById("motioncontainer") : document.all.motioncontainer;
menuwidth=crossmain.offsetWidth;
cross_scroll=document.getElementById? document.getElementById("motiongallery") : document.all.motiongallery;
crossmain.onmousemove=function(e){
motionengine(e);

}
crossmain.onmouseout=function(e){
stopmotion(e);
}
}
loadedyes=1
}

var fileLoadingImage = "/img/loading.gif";		
var fileBottomNavCloseImage = "/img/closelabel.gif";

var animate = true;
var resizeSpeed = 7;
var borderSize = 10;

var imageArray = new Array;
var activeImage;

if(animate == true){
	overlayDuration = 0.2;
	if(resizeSpeed > 10){ resizeSpeed = 10;}
	if(resizeSpeed < 1){ resizeSpeed = 1;}
	resizeDuration = (11 - resizeSpeed) * 0.15;
} else { 
	overlayDuration = 0;
	resizeDuration = 0;
}

Object.extend(Element, {
getWidth: function(element) {
element = $(element);
return element.offsetWidth; 
},
setWidth: function(element,w) {
element = $(element);
element.style.width = w +"px";
},
setHeight: function(element,h) {
element = $(element);
element.style.height = h +"px";
},
setTop: function(element,t) {
element = $(element);
element.style.top = t +"px";
},
setSrc: function(element,src) {
element = $(element);
element.src = src; 
},
setHref: function(element,href) {
element = $(element);
element.href = href; 
},
setInnerHTML: function(element,content) {
element = $(element);
element.innerHTML = content;
}
});

Array.prototype.removeDuplicates = function () {
for(i = 0; i < this.length; i++){
for(j = this.length-1; j>i; j--){        
if(this[i][0] == this[j][0]){
this.splice(j,1);
}
}
}
}

Array.prototype.empty = function () {
for(i = 0; i <= this.length; i++){
this.shift();
}
}

var Lightbox = Class.create();

Lightbox.prototype = {

initialize: function() {	
if (!document.getElementsByTagName){ return; }
var anchors = document.getElementsByTagName('a');
var areas = document.getElementsByTagName('area');

for (var i=0; i<anchors.length; i++){
var anchor = anchors[i];

var relAttribute = String(anchor.getAttribute('rel'));

if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
anchor.onclick = function () {myLightbox.start(this); return false;}
}
}
for (var i=0; i< areas.length; i++){
var area = areas[i];

var relAttribute = String(area.getAttribute('rel'));
if (area.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
area.onclick = function () {myLightbox.start(this); return false;}
}
}

var objBody = document.getElementsByTagName("body").item(0);		var objOverlay = document.createElement("div");
objOverlay.setAttribute('id','overlay');
objOverlay.style.display = 'none';
objOverlay.onclick = function() { myLightbox.end(); }
objBody.appendChild(objOverlay);		var objLightbox = document.createElement("div");
objLightbox.setAttribute('id','lightbox');
objLightbox.style.display = 'none';
objLightbox.onclick = function(e) {	// close Lightbox is user clicks shadow overlay
if (!e) var e = window.event;
var clickObj = Event.element(e).id;
if ( clickObj == 'lightbox') {
myLightbox.end();
}
};
objBody.appendChild(objLightbox);

var objOuterImageContainer = document.createElement("div");
objOuterImageContainer.setAttribute('id','outerImageContainer');
objLightbox.appendChild(objOuterImageContainer);

if(animate){
Element.setWidth('outerImageContainer', 250);
Element.setHeight('outerImageContainer', 250);			
} else {
Element.setWidth('outerImageContainer', 1);
Element.setHeight('outerImageContainer', 1);			
}

var objImageContainer = document.createElement("div");
objImageContainer.setAttribute('id','imageContainer');
objOuterImageContainer.appendChild(objImageContainer);

var objLightboxImage = document.createElement("img");
objLightboxImage.setAttribute('id','lightboxImage');
objImageContainer.appendChild(objLightboxImage);

var objHoverNav = document.createElement("div");
objHoverNav.setAttribute('id','hoverNav');
objImageContainer.appendChild(objHoverNav);

var objPrevLink = document.createElement("a");
objPrevLink.setAttribute('id','prevLink');
objPrevLink.setAttribute('href','#');
objHoverNav.appendChild(objPrevLink);		var objNextLink = document.createElement("a");
objNextLink.setAttribute('id','nextLink');
objNextLink.setAttribute('href','#');
objHoverNav.appendChild(objNextLink);

var objLoading = document.createElement("div");
objLoading.setAttribute('id','loading');
objImageContainer.appendChild(objLoading);

var objLoadingLink = document.createElement("a");
objLoadingLink.setAttribute('id','loadingLink');
objLoadingLink.setAttribute('href','#');
objLoadingLink.onclick = function() { myLightbox.end(); return false; }
objLoading.appendChild(objLoadingLink);

var objLoadingImage = document.createElement("img");
objLoadingImage.setAttribute('src', fileLoadingImage);
objLoadingLink.appendChild(objLoadingImage);

var objImageDataContainer = document.createElement("div");
objImageDataContainer.setAttribute('id','imageDataContainer');
objImageDataContainer.className = 'clearfix';
objLightbox.appendChild(objImageDataContainer);

var objImageData = document.createElement("div");
objImageData.setAttribute('id','imageData');
objImageDataContainer.appendChild(objImageData);

var objImageDetails = document.createElement("div");
objImageDetails.setAttribute('id','imageDetails');
objImageData.appendChild(objImageDetails);

var objCaption = document.createElement("span");
objCaption.setAttribute('id','caption');
objImageDetails.appendChild(objCaption);

var objNumberDisplay = document.createElement("span");
objNumberDisplay.setAttribute('id','numberDisplay');
objImageDetails.appendChild(objNumberDisplay);		var objBottomNav = document.createElement("div");
objBottomNav.setAttribute('id','bottomNav');
objImageData.appendChild(objBottomNav);

var objBottomNavCloseLink = document.createElement("a");
objBottomNavCloseLink.setAttribute('id','bottomNavClose');
objBottomNavCloseLink.setAttribute('href','#');
objBottomNavCloseLink.onclick = function() { myLightbox.end(); return false; }
objBottomNav.appendChild(objBottomNavCloseLink);

var objBottomNavCloseImage = document.createElement("img");
objBottomNavCloseImage.setAttribute('src', fileBottomNavCloseImage);
objBottomNavCloseLink.appendChild(objBottomNavCloseImage);
},

start: function(imageLink) {	

function getImageTitle(anchor){ //DynamicDrive.com added function that allows the caption("title") to be linked ("rev").
var ddimageTitle=anchor.getAttribute('title')
var ddimageTitleURL=(ddimageTitle!=null && ddimageTitle!="")? anchor.getAttribute('rev') : null
return ddimageTitleFinal=(ddimageTitleURL!=null && ddimageTitleURL!="")? '<a href="'+ddimageTitleURL+'" class="ddcaptionurl">'+ddimageTitle+'</a>' : ddimageTitle
};

hideSelectBoxes();
hideFlash();

var arrayPageSize = getPageSize();
Element.setHeight('overlay', arrayPageSize[1]);

new Effect.Appear('overlay', { duration: overlayDuration, from: 0.0, to: 0.8 });

imageArray = [];
imageNum = 0;		

if (!document.getElementsByTagName){ return; }
var anchors = document.getElementsByTagName('a');

if((imageLink.getAttribute('rel') == 'lightbox')){
imageArray.push(new Array(imageLink.getAttribute('href'), getImageTitle(imageLink)));			
} else {

for (var i=0; i<anchors.length; i++){
var anchor = anchors[i];
if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))){
imageArray.push(new Array(anchor.getAttribute('href'), getImageTitle(anchor)));
}
}
imageArray.removeDuplicates();
while(imageArray[imageNum][0] != imageLink.getAttribute('href')) { imageNum++;}
}

// calculate top offset for the lightbox and display 
var arrayPageScroll = getPageScroll();
var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);

Element.setTop('lightbox', lightboxTop);
Element.show('lightbox');		this.changeImage(imageNum);
},

changeImage: function(imageNum) {			activeImage = imageNum;	// update global var
if(animate){ Element.show('loading');}
Element.hide('lightboxImage');
Element.hide('hoverNav');
Element.hide('prevLink');
Element.hide('nextLink');
Element.hide('imageDataContainer');
Element.hide('numberDisplay');				imgPreloader = new Image();		imgPreloader.onload=function(){
Element.setSrc('lightboxImage', imageArray[activeImage][0]);
myLightbox.resizeImageContainer(imgPreloader.width, imgPreloader.height);
}
imgPreloader.src = imageArray[activeImage][0];
},

resizeImageContainer: function( imgWidth, imgHeight) {
// get curren width and height
this.widthCurrent = Element.getWidth('outerImageContainer');

this.heightCurrent = Element.getHeight('outerImageContainer');

// get new width and height
var widthNew = (imgWidth  + (borderSize * 2));
var heightNew = (imgHeight  + (borderSize * 2));

// scalars based on change from old to new
this.xScale = ( widthNew / this.widthCurrent) * 100;
this.yScale = ( heightNew / this.heightCurrent) * 100;

// calculate size difference between new and old image, and resize if necessary
wDiff = this.widthCurrent - widthNew;
hDiff = this.heightCurrent - heightNew;

if(!( hDiff == 0)){ new Effect.Scale('outerImageContainer', this.yScale, {scaleX: false, duration: resizeDuration, queue: 'front'}); }
if(!( wDiff == 0)){ new Effect.Scale('outerImageContainer', this.xScale, {scaleY: false, delay: resizeDuration, duration: resizeDuration}); }

// if new and old image are same size and no scaling transition is necessary, 
// do a quick pause to prevent image flicker.
if((hDiff == 0) && (wDiff == 0)){
if (navigator.appVersion.indexOf("MSIE")!=-1){ pause(250); } else { pause(100);} 
}

Element.setHeight('prevLink', imgHeight);
Element.setHeight('nextLink', imgHeight);
Element.setWidth( 'imageDataContainer', widthNew);

this.showImage();
},

//
//	showImage()
//	Display image and begin preloading neighbors.
//
showImage: function(){
Element.hide('loading');
new Effect.Appear('lightboxImage', { duration: resizeDuration, queue: 'end', afterFinish: function(){	myLightbox.updateDetails(); } });
this.preloadNeighborImages();
},

//
//	updateDetails()
//	Display caption, image number, and bottom nav.
//
updateDetails: function() {

Element.show('caption');
var linksrc = imageArray[activeImage][0].substring(imageArray[activeImage][0].lastIndexOf('/')+1,imageArray[activeImage][0].lastIndexOf('_'))
Element.setInnerHTML( 'caption', imageArray[activeImage][1] +'<br /><a href="/gallery/normal/'+linksrc+'_normal.jpg" target="_blank">Ver en tamaño completo</a>');		// if image is part of set display 'Image x of x' 
if(imageArray.length > 1){
Element.show('numberDisplay');
Element.setInnerHTML( 'numberDisplay', "Imagen " + eval(activeImage + 1) + " de " + imageArray.length);
}

new Effect.Parallel(
[ new Effect.SlideDown( 'imageDataContainer', { sync: true, duration: resizeDuration, from: 0.0, to: 1.0 }), 
new Effect.Appear('imageDataContainer', { sync: true, duration: resizeDuration }) ], 
{ duration: resizeDuration, afterFinish: function() {
// update overlay size and update nav
var arrayPageSize = getPageSize();
Element.setHeight('overlay', arrayPageSize[1]);
myLightbox.updateNav();
}
} 
);
},

//
//	updateNav()
//	Display appropriate previous and next hover navigation.
//
updateNav: function() {

Element.show('hoverNav');				

// if not first image in set, display prev image button
if(activeImage != 0){
Element.show('prevLink');
document.getElementById('prevLink').onclick = function() {
myLightbox.changeImage(activeImage - 1); return false;
}
}

// if not last image in set, display next image button
if(activeImage != (imageArray.length - 1)){
Element.show('nextLink');
document.getElementById('nextLink').onclick = function() {
myLightbox.changeImage(activeImage + 1); return false;
}
}		this.enableKeyboardNav();
},

//
//	enableKeyboardNav()
//
enableKeyboardNav: function() {
document.onkeydown = this.keyboardAction; 
},

//
//	disableKeyboardNav()
//
disableKeyboardNav: function() {
document.onkeydown = '';
},

//
//	keyboardAction()
//
keyboardAction: function(e) {
if (e == null) { // ie
keycode = event.keyCode;
escapeKey = 27;
} else { // mozilla
keycode = e.keyCode;
escapeKey = e.DOM_VK_ESCAPE;
}

key = String.fromCharCode(keycode).toLowerCase();		if((key == 'x') || (key == 'o') || (key == 'c') || (keycode == escapeKey)){	// close lightbox
myLightbox.end();
} else if((key == 'p') || (keycode == 37)){	// display previous image
if(activeImage != 0){
myLightbox.disableKeyboardNav();
myLightbox.changeImage(activeImage - 1);
}
} else if((key == 'n') || (keycode == 39)){	// display next image
if(activeImage != (imageArray.length - 1)){
myLightbox.disableKeyboardNav();
myLightbox.changeImage(activeImage + 1);
}
}

},

//
//	preloadNeighborImages()
//	Preload previous and next images.
//
preloadNeighborImages: function(){

if((imageArray.length - 1) > activeImage){
preloadNextImage = new Image();
preloadNextImage.src = imageArray[activeImage + 1][0];
}
if(activeImage > 0){
preloadPrevImage = new Image();
preloadPrevImage.src = imageArray[activeImage - 1][0];
}

},

//
//	end()
//
end: function() {
this.disableKeyboardNav();
Element.hide('lightbox');
new Effect.Fade('overlay', { duration: overlayDuration});
showSelectBoxes();
showFlash();
}
}

// -----------------------------------------------------------------------------------

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

var yScroll;

if (self.pageYOffset) {
yScroll = self.pageYOffset;
} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
yScroll = document.documentElement.scrollTop;
} else if (document.body) {// all other Explorers
yScroll = document.body.scrollTop;
}

arrayPageScroll = new Array('',yScroll) 
return arrayPageScroll;
}

// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){

var xScroll, yScroll;

if (window.innerHeight && window.scrollMaxY) {	
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}

var windowWidth, windowHeight;
if (self.innerHeight) {	// all except Explorer
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}	

// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else { 
pageHeight = yScroll;
}

// for small pages with total width less then width of the viewport
if(xScroll < windowWidth){	
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
}

arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
return arrayPageSize;
}

// -----------------------------------------------------------------------------------

//
// getKey(key)
// Gets keycode. If 'x' is pressed then it hides the lightbox.
//
function getKey(e){
if (e == null) { // ie
keycode = event.keyCode;
} else { // mozilla
keycode = e.which;
}
key = String.fromCharCode(keycode).toLowerCase();

if(key == 'x'){
}
}

// -----------------------------------------------------------------------------------

//
// listenKey()
//
function listenKey () {	document.onkeypress = getKey; }

// ---------------------------------------------------

function showSelectBoxes(){
var selects = document.getElementsByTagName("select");
for (i = 0; i != selects.length; i++) {
selects[i].style.visibility = "visible";
}
}

// ---------------------------------------------------

function hideSelectBoxes(){
var selects = document.getElementsByTagName("select");
for (i = 0; i != selects.length; i++) {
selects[i].style.visibility = "hidden";
}
}

// ---------------------------------------------------

function showFlash(){
var flashObjects = document.getElementsByTagName("object");
for (i = 0; i != flashObjects.length; i++) {
flashObjects[i].style.visibility = "visible";
}

var flashEmbeds = document.getElementsByTagName("embeds");
for (i = 0; i != flashEmbeds.length; i++) {
flashEmbeds[i].style.visibility = "visible";
}
}

function hideFlash(){
var flashObjects = document.getElementsByTagName("object");
for (i = 0; i != flashObjects.length; i++) {
flashObjects[i].style.visibility = "hidden";
}

var flashEmbeds = document.getElementsByTagName("embeds");
for (i = 0; i != flashEmbeds.length; i++) {
flashEmbeds[i].style.visibility = "hidden";
}
}
function pause(ms){
var date = new Date();
curDate = null;
do{var curDate = new Date();}
while( curDate - date < ms);
}
function initLightbox() { myLightbox = new Lightbox(); }
