// JavaScript Document
// JavaScript Document

function substitueix (objecte,cadena) {
d = document.getElementById(''+objecte+'');
d.innerHTML = ''+cadena+'';
}

function substitueix_arxiu(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='fitxer'><input type='hidden' name='eliminar" + nom_in + "' value='"+fitxer_original+"'><h3>Archivo "+numero_fitxer+"</h3><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='exparxiu"+ 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) {
var d= document.getElementById(''+iddiv+'');
d.innerHTML = "<div style='float:left;width:300px;'><div style='padding-left:125px;'><input type='hidden' name='tipus_fitxer_" + nom_in + "' value='foto'><input type='hidden' name='eliminar" + nom_in + "' value='"+fitxer_original+"'><strong>Foto</strong><br><input name='"+ nom_in +"' type='file' class='camps'></div><div style='margin-top:15px;float:left;width:400px;'><br></div>";
}
function eliminar_arxiu(iddiv,nom_in,fitxer_original,numero_fitxer) {
var d= document.getElementById(''+iddiv+'');
d.innerHTML = "<input type='hidden' name='eliminar" + nom_in + "' value='"+fitxer_original+"'><h4 style='color:red;padding-left:125px'>Fitxer eliminat</h4>";
}

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 textosQuadrats(quin,condicio) {
var textInicial = document.getElementById('nomproducte');
var nodeVariable = document.getElementById('indicador');
if (condicio==true){
	nodeVariable.style.color = "black"
	nodeVariable.innerHTML = quin.innerHTML;
	}
	else {
	nodeVariable.style.color = "#888"
	nodeVariable.innerHTML = textInicial.innerHTML;
	}

}

function canviaClasse(quin,condicio) {
	if (condicio){
	quin.style.backgroundColor = '#CCCCCC'	
	}
	else {
	quin.style.backgroundColor = '#99C2DB'	
	}
}

function confirmaEliminar(missatge,adreca){
var m = window.confirm(missatge)
	if (m==true){
	window.location = adreca
	}
}