function popup(url, w,h)
{
	
	x=(screen.width-w)/2;
	y=(screen.height-h)/2;
	
	var newwindow;
	newwindow = window.open(url,'name','height=' + h + ', width=' + w + ', left=' + x + ', top=' + y + ', menubar=0,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
	
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///// FUNCIONS DE DATES / HORES
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function esFecha(Cadena){
	
	//Format correcte dd/mm/aaaa
	
	var Fecha= new String(Cadena)	// Crea un string
	var RealFecha= new Date()	// Para sacar la fecha de hoy
	
	
	// comprovar si té el format adecuat amb barres "/"
	
	if (Fecha.lastIndexOf("/")==-1) return false;	
	
	// Cadena Año
	var Ano= new String(Fecha.substring(Fecha.lastIndexOf("/")+1,Fecha.length))
	// Cadena Mes
	var Mes= new String(Fecha.substring(Fecha.indexOf("/")+1,Fecha.lastIndexOf("/")))
	// Cadena Día
	var Dia= new String(Fecha.substring(0,Fecha.indexOf("/")))

	// Valido el año
	if (isNaN(Ano) || Ano.length<4 || parseFloat(Ano)<1900 || parseFloat(Ano)>3000 ){
        alert('Año inválido')
		return false
	}
	// Valido el Mes
	if (isNaN(Mes) || parseFloat(Mes)<1 || parseFloat(Mes)>12){
		alert('Mes inválido')
		return false
	}
	// Valido el Dia
	if (isNaN(Dia) || parseFloat(Dia)<1 || parseFloat(Dia)>31){
		alert('Día inválido')
		return false
	}
	if (Mes==4 || Mes==6 || Mes==9 || Mes==11 || Mes==2) {
		if (Mes==2 && Dia > 28 || Dia>30) {
			alert('Día inválido')
			return false
		}
	}
	
  return true;

}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///// FUNCIONS DE VALIDACIO DE FORMULARIS
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function validarFormInsertar(form){
	
	if(form.areaComentario.value==""){
		alert("El comentario en castellano es obligatorio!");
		return false;
	}
	else
		if(form.areaComentarioCat.value==""){
			alert("El comentario en catalán es obligatorio!");
			return false;
		}
	else
		if(form.fileArchivo.value==""){
			alert("Debe especificar un archivo de imagen!\nPulse el boton 'Examinar...'");
			return false;
		}
		
	alert("OK");
	return true;	
}

function validarFormModificar(form){
	
	if(form.areaComentario.value==""){
		alert("El comentario en castellano es obligatorio!");
		return false;
	}
	else
		if(form.areaComentarioCat.value==""){
			alert("El comentario en catalán es obligatorio!");
			return false;
		}
	alert("OK");
	return true;
}

