// JavaScript Document

function substitueix (objecte,cadena) {
d = document.getElementById(''+objecte+'');
d.innerHTML = ''+cadena+'';
}

function substitueix_arxiu(iddiv,nom_in,fitxer_original,numero_fitxer,estil,idioma) {
var d= document.getElementById(''+iddiv+'');
if (idioma=='ca') {
d.innerHTML = "<div style='float:left;width:300px;'><input type='hidden' name='tipus_fitxer_" + nom_in + "' value='fitxer'><input type='hidden' name='eliminar" + nom_in + "' value='"+fitxer_original+"'><" + estil + ">Arxiu "+numero_fitxer+"</" + estil + "><input name='"+ nom_in +"' type='file' class='camps'></div><div style='margin-top:15px;float:left;width:400px;'>Descripció de l'arxiu:<br><textarea name='peuarxiu"+ numero_fitxer +"' class='camps' style='width:250px;height:50px;'></textarea></div><br><br style='clear:left;'><br>";
} else {
d.innerHTML = "<div style='float:left;width:300px;'><input type='hidden' name='tipus_fitxer_" + nom_in + "' value='fitxer'><input type='hidden' name='eliminar" + nom_in + "' value='"+fitxer_original+"'><" + estil + ">Arxivo "+numero_fitxer+"</" + estil + "><input name='"+ nom_in +"' type='file' class='camps'></div><div style='margin-top:15px;float:left;width:400px;'>Descripción del archivo:<br><textarea name='peuarxiu"+ numero_fitxer +"' class='camps' style='width:250px;height:50px;'></textarea></div><br><br style='clear:left;'><br>";
}}

function substitueix_foto(iddiv,nom_in,fitxer_original,numero_fitxer,estil,idioma) {
var d= document.getElementById(''+iddiv+'');
if (idioma=='ca') {
d.innerHTML = "<div style='float:left;width:300px;'><input type='hidden' name='tipus_fitxer_" + nom_in + "' value='foto'><input type='hidden' name='eliminar" + nom_in + "' value='"+fitxer_original+"'><" + estil + ">Foto "+numero_fitxer+"</" + estil + "><input name='"+ nom_in +"' type='file' class='camps'></div><div style='margin-top:15px;float:left;width:400px;'>Peu de foto: <input name='peufoto"+numero_fitxer+"' type='text' class='camps' style='width:300px' value=''></div><br style='clear:left;'><br>";
} else {
d.innerHTML = "<div style='float:left;width:300px;'><input type='hidden' name='tipus_fitxer_" + nom_in + "' value='foto'><input type='hidden' name='eliminar" + nom_in + "' value='"+fitxer_original+"'><" + estil + ">Foto "+numero_fitxer+"</" + estil + "><input name='"+ nom_in +"' type='file' class='camps'></div><div style='margin-top:15px;float:left;width:400px;'>Pie de foto: <input name='peufoto"+numero_fitxer+"' type='text' class='camps' style='width:300px' value=''></div><br style='clear:left;'><br>";
}}
function substitueix_arxiu_sense_peu(iddiv,nom_in,fitxer_original,numero_fitxer) {
var d= document.getElementById(''+iddiv+'');
d.innerHTML = "<div style='float:left;width:300px;'><input type='hidden' name='tipus_fitxer_" + nom_in + "' value='foto'><input type='hidden' name='eliminar" + nom_in + "' value='"+fitxer_original+"'><input name='"+ nom_in +"' type='file' class='camps'></div><br style='clear:left;'><br>";
}

function eliminar_arxiu(iddiv,nom_in,fitxer_original,estil,idioma) {
var d= document.getElementById(''+iddiv+'');
if (idioma=='ca') {
d.innerHTML = "<input type='hidden' name='eliminar" + nom_in + "' value='"+fitxer_original+"'><" + estil + " style='color:red;'>Fitxer eliminat </"+ estil +">";
} else {
d.innerHTML = "<input type='hidden' name='eliminar" + nom_in + "' value='"+fitxer_original+"'><" + estil + " style='color:red;'>Fichero eliminado </"+ estil +">";
}
}


function confirmaEliminar(missatge,adreca){
var m = window.confirm(missatge)
	if (m==true){
	window.location = adreca
	}
}

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); 
var features= "width=" + width + ",height=" + height +",scrollbars=no,status=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 valor_check(check,camp){
	if(check.checked==1){
		document.getElementById(camp).value=1;
	}else{
		document.getElementById(camp).value=0;
	}
}
