//CLEAR INPUT
function change(input,word)
{
  if($(input).val()==word)
  {
	$(input).attr('value','')
  }
}

//ENFOCAR I DESENFOCAR FORMULARI	
function enfocar (quin)
{
  quin.className = 'focus';
}

function desenfocar (quin)
{
  quin.className = 'no_focus';
}

//FORUMLARIS
function quin_boto(opcio)
{
	document.getElementById("action").value=opcio;
}

function Abrir_ventana (pagina,ancho,alto) {
	var opciones="toolbar=no, location=no, directories=no, status=no, menubar=yes, scrollbars=no, resizable=yes, width="+ancho+", height="+alto+", top=85, left=140";
	window.open(pagina,"exp",opciones);
}

function comproba_document(checkboxes) {

	if (document.getElementById("titulo").value.length<3) {
		alert ("El titulo del documento no es valido.");
		return false;
	}
	if (document.getElementById("descripcion").value.length<3) {
		alert ("La descripcion del documento no es correcta.");
		return false;
	}
	if (document.getElementById("userfile").value.length<3) {
		if (document.getElementById("confirmacion")) {
			if (document.getElementById("confirmacion").checked==true) {
				alert ("La ruta del documento no es valida.");
				return false;
			}
		}
			else {
				alert ("La ruta del documento no es valida.");
				return false;
			}
	}
	if ( !checkboxes )
	{
	    if (document.getElementById("asignatura").value=="seleccionar")
	    {
		    alert ("Se debe seleccionar una asignatura.");
		    return false;
	    }
	} else {
	    var n = $("#insertar input:checked").length;
	    if ( n == 0 )
	    {
		    alert ("Se debe seleccionar una asignatura como mínimo.");
		    return false;
	    }
	}

	return true;
}

function activar_fichero() {
	if (document.getElementById("userfile").disabled==true) document.getElementById("userfile").disabled=false;
		else document.getElementById("userfile").disabled=true;
	if (document.getElementById("userfile2").disabled==true) document.getElementById("userfile2").disabled=false;
		else document.getElementById("userfile2").disabled=true;
}

function seleccionar(id) {
	var ini=parseInt(document.getElementById('cont_ini_'+id).value);
	var fin=parseInt(document.getElementById('cont_fin_'+id).value);
	
	for (var i=ini;i<ini+fin;i++) {
		document.getElementById("al_"+id+"id"+i).checked="checked";
	}
}

function deseleccionar(id) {
	var ini=parseInt(document.getElementById('cont_ini_'+id).value);
	var fin=parseInt(document.getElementById('cont_fin_'+id).value);
	
	for (var i=ini;i<ini+fin;i++) {
		document.getElementById("al_"+id+"id"+i).checked="";
	}
}

function invertir(id) {
	var ini=parseInt(document.getElementById('cont_ini_'+id).value);
	var fin=parseInt(document.getElementById('cont_fin_'+id).value);
	
	for (var i=ini;i<ini+fin;i++) {
		if (document.getElementById("al_"+id+"id"+i).checked!=null && document.getElementById("al_"+id+"id"+i).checked==false) document.getElementById("al_"+id+"id"+i).checked=true;
			else document.getElementById("al_"+id+"id"+i).checked=false;
	}
}

function alumnos_sent() {
	document.getElementById("alumnos_mail").submit;
}

function select_all(tipus) {
	for (var i=0;i<document.getElementById("numero_asig").value;i++) {
		if (tipus=='all') document.getElementById("asignatura_"+i).checked='checked';
			else document.getElementById("asignatura_"+i).checked='';
	}
}

function check_enviar_notificacion()
{
  if (document.getElementById('notificar').checked && !document.getElementById('activo').checked)
  {
    alert('No es pot enviar notificacions de documents no actius');
    document.getElementById('notificar').checked=false;
    return;
  }

}


