function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}


/* popup centrat */
function popup(url,windowname,width,height,features) { 
width=(width)?width:screen.width/2; 
height=(height)?height:screen.height/2; 
var screenX = (screen.width/2 - width/2); 
var screenY = (screen.height/2 - height/2); 
if (features) {
var features= "width=" + width + ",height=" + height + "," + features; 	
} 
else {
var features= "width=" + width + ",height=" + height +",scrollbars=yes,status=no,resizable=no"; 
}
features += ",screenX=" + screenX + ",left=" + screenX; 
features += ",screenY=" + screenY + ",top=" + screenY; 

var mywin=window.open(url, windowname, features); 
if (mywin) 
mywin.focus(); 
return mywin; 
} 


function comprueba_extension_jpg(formulario, archivo) {
	
		extensiones_permitidas = new Array(".jpg");
		mierror = "";
		if (!archivo) {
			//mierror = "Es obligatorio añadir una foto.";
			formulario.submit();
			return 1;
		}else{
			extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase();
			permitida = false;
			for (var i = 0; i < extensiones_permitidas.length; i++) {
				if (extensiones_permitidas[i] == extension) { 
					permitida = true;
					break;
				}
			}
			if (!permitida) {
				mierror = "Comprueba la extensión de los archivos a subir. \nSólo se pueden subir archivos con extension: " + extensiones_permitidas.join();
			}else{
				formulario.submit();
				return 1;
			}
		}
		alert (mierror);
		return false;
}	

