function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function abrirPopUp(url, ancho, alto) {
    hWnd = window.open(url, "abrirPopup", "left=10,top=10,width="+ancho+",height="+alto+",resizable=no,scrollbars=no,status=no,help=no");
    if ((document.window != null) && (!hWnd.opener))
        hWnd.opener = window.open(url,'myWIndow','resizable=yes');
        hWnd.focus();
}


var files_fotos = new Array();
var files_fotop = new Array();
var files_videos = new Array();
function borrarItem(items,dest1,dest2,tipo,dir){
	//delete files[items];
	eval("files_"+tipo).splice(items,1);
	limpiarDiv(dest1,dest2);
	mostrarItem(dest1,dest2,tipo,dir);
}

function mostrarItem(dest1,dest2,tipo,dir){
	var estilo = 'par';
	for(i=0;i<eval("files_"+tipo).length;i++){
		if(eval("files_"+tipo)[i]!=undefined){
         if (tipo=="videos")
			 window.document.getElementById(dest1).innerHTML += "<table border='0' cellspacing='0' cellpadding='0'><tr class='verde_"+estilo+"'><td width='70'><a href='javascript:borrarItem("+i+",\""+dest1+"\",\""+dest2+"\",\""+tipo+"\",\""+dir+"\")' style='cursor:pointer'>x Eliminar</a></td><td width='250'>"+(i+1)+'. '+eval("files_"+tipo)[i]+"</td><td width='80'><a rel='lytebox'><img src='"+dir+"/"+eval("files_"+tipo)[i]+"_th.jpg' width=100 /></td></tr></table>";
         else
			 window.document.getElementById(dest1).innerHTML += "<table border='0' cellspacing='0' cellpadding='0'><tr class='verde_"+estilo+"'><td width='70'><a href='javascript:borrarItem("+i+",\""+dest1+"\",\""+dest2+"\",\""+tipo+"\",\""+dir+"\")' style='cursor:pointer'>x Eliminar</a></td><td width='250' align=left >"+(i+1)+'. '+eval("files_"+tipo)[i]+"</td><td width='80'><a href='"+dir+"/"+eval("files_"+tipo)[i]+"' rel='lytebox'><img src='"+dir+"/"+eval("files_"+tipo)[i]+"' width=80 border=0 align=absmiddle  /></td></tr><tr><td colspan=3 height=10 valign=middle ><hr style='border-bottom:1px dotted #c0c0c0;border-top:0px;border-left:0px;'></td></tr></table>";

//			 window.document.getElementById(dest1).innerHTML += "<table border='0' cellspacing='0' cellpadding='0'><tr class='verde_"+estilo+"'><td width='70'><a href='javascript:borrarItem("+i+",\""+dest1+"\",\""+dest2+"\",\""+tipo+"\",\""+dir+"\")' style='cursor:pointer'>x Eliminar</a></td><td width='250'>"+(i+1)+'. '+eval("files_"+tipo)[i]+"</td><td width='80'><a href='"+dir+"/"+eval("files_"+tipo)[i]+"' rel='lytebox'><img src='/image.php/"+eval("files_"+tipo)[i]+"?width=80&amp;height=116&amp;quality=100&amp;image=/"+dir+"/"+eval("files_"+tipo)[i]+"' /></td></tr></table>";


			window.document.getElementById(dest2).value += eval("files_"+tipo)[i]+",";
			myLytebox.updateLyteboxItems();
		}
		if(estilo == 'par'){estilo = 'impar';} else {estilo = 'par';}
	}
}

function limpiarDiv(dest1,dest2){
	window.document.getElementById(dest1).innerHTML = '';
	window.document.getElementById(dest2).value = '';
}

function agregarItem(it,tipoArchivo,tipo){
	if (tipoArchivo == 'tipoFotos'){
		maximo = 10;
 	 } else if(tipoArchivo == 'tipoVideos'){
 		 maximo = 2;
	 }
      else if(tipoArchivo == 'tipoFotoP'){
 		 maximo = 1;
	 }

	if (eval("files_"+tipo).length < maximo){
		eval("files_"+tipo).push(it);
	} else {
		alert ('Supera la cantidad maxima permitida.');
	}
}




