/*function comprueba_extension(formulario, archivo) {

	permitida = true;
	if(document.agenda_abm_3.file2.value!=''&&document.agenda_abm_3.idpost.value!=''){
		extensiones_permitidas = new Array(".mov",".avi",".mpg","mpeg");

	   	extension = (document.agenda_abm_3.file2.value.substring(document.agenda_abm_3.file2.value.lastIndexOf("."))).toLowerCase();

	   	permitida = false;
	      for (var i = 0; i < extensiones_permitidas.length; i++) {

	         if (extensiones_permitidas[i] == extension) {
		         permitida = true;

		         break;
	    	}
		}
	}
    var ok 		= 1;
    var mierror = "ATENCION:\r\n ";
	if(!permitida){
		mierror += "- Sólo se pueden subir videos con extensiones: " + extensiones_permitidas.join() +"\r\n";
		ok = 0;
	}
	if(!document.agenda_abm_3.f_chk_1.checked&&!document.agenda_abm_3.f_chk_2.checked&&document.agenda_abm_3.f_titulo_1.value==""&&document.agenda_abm_3.f_titulo_2.value==""){
    	mierror += "- Debe escribir el epígrafe en algún idioma\r\n";
    	ok = 0;
	}
	if(!document.agenda_abm_3.f_chk_1.checked&&document.agenda_abm_3.f_titulo_1.value!=""){
    	mierror += "- Debe seleccionar el idioma español\r\n";
    	ok = 0;
    }
	if(document.agenda_abm_3.f_chk_1.checked&&document.agenda_abm_3.f_titulo_1.value==""){
    	mierror += "- Debe escribir el epígrafe en español\r\n";
    	ok = 0;
	}
    if(document.agenda_abm_3.f_chk_2.checked&&document.agenda_abm_3.f_titulo_2.value==""){
    	mierror += "- Debe escribir el epígrafe en inglés\r\n";
    	ok = 0;
    }
    if(!document.agenda_abm_3.f_chk_2.checked&&document.agenda_abm_3.f_titulo_2.value!=""){
    	mierror += "- Debe seleccionar el idioma inglés\r\n";
    	ok = 0;
    }

    if(ok==1){
    	agenda_abm_3.submit();
    	document.getElementById('mensaje_procesando').style.display='block';
    	document.getElementById('formulario').style.display='none';
		return 1;
    }
	alert (mierror);
	return 0;
}*/
var exts = "mp3|iso|mov|mpg|mpeg|bmp|jpg|jpeg|gif|tiff";
//var exts = ".*"; //Use this to accept all Extensions

//- Fix for Netscape 6/Mozilla ------------
if(typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentElement)
{
HTMLElement.prototype.insertAdjacentElement = function
(where,parsedNode)
{
switch (where){
case 'beforeBegin':
this.parentNode.insertBefore(parsedNode,this)
break;
case 'afterBegin':
this.insertBefore(parsedNode,this.firstChild);
break;
case 'beforeEnd':
this.appendChild(parsedNode);
break;
case 'afterEnd':
if (this.nextSibling)
this.parentNode.insertBefore(parsedNode,this.nextSibling);
else this.parentNode.appendChild(parsedNode);
break;
}
}

HTMLElement.prototype.insertAdjacentHTML = function
(where,htmlStr)
{
var r = this.ownerDocument.createRange();
r.setStartBefore(this);
var parsedHTML = r.createContextualFragment(htmlStr);
this.insertAdjacentElement(where,parsedHTML)
}
}
//---------------------


var UID,NF=0,cx=0;
function openStatusWindow()
{
   win1 = window.open('/cgi-bin/upload_status.cgi?upload_id='+UID+'&num_files='+NF+'&css_name='+document.F1.css_name.value+'&tmpl_name='+document.F1.tmpl_name.value,'win1','width=320,height=240,resizable=1');
   
   win1.window.focus();
}

function generateSID()
{
 UID = Math.round(10000*Math.random())+'0'+Math.round(10000*Math.random());
 var f1=document.F1;
 f1.action = f1.action.split('?')[0]+'?upload_id='+UID;
 //for (var i=0;i<document.F1.length;i++)
 //{
 //    current = document.F1.elements[i];
 //    if(current.type=='file' && current.value!='')NF++;
 //}
}

function StartUpload()
{
	alert('asdasd')
    NF=0;
    for (var i=0;i<document.F1.length;i++)
    {
     current = document.F1.elements[i];

     if(current.type=='file' && current.value!='')
      {
         if(!checkExt(current.value))return false;
         NF++;
      }
    }
    generateSID();
    openStatusWindow();
}

function checkExt(value)
{
    if(value=="")return true;
    var re = new RegExp("^.+\.("+exts+")$","i");
    if(!re.test(value))
    {
        alert("Extension no permitida para el video: \"" + value + "\"\nSolo se permiten: "+exts.replace(/\|/g,',')+" \n\n");
        return false;
    }
    return true;
}

