/**
 * newPopup v1.1: Obrir pop-up's amb diferents opcions
 */

function newPopup(url, ample, alt, center, scroll, nom) {
  if (center != false){   
	esquerra = (screen.width) ? (screen.width-ample)/2 : 100;
	dalt = (screen.height) ? (screen.height-alt)/2 : 100;
  } else {
      esquerra = 100;
	dalt = 100;
  }
  opciones = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=' + scroll + ',resizable=0,width=' + ample + ',height=' + alt + ',left=' + esquerra + ',top=' + dalt + '';
  miPopup = window.open(url, nom, opciones);
  miPopup.focus() 
}

function submitform(theForm){
  document.getElementById(theForm).submit();
}

/**
 * Trim v1.0: Eliminar espais inici i final d'una cadena
 */

function trim(string) {
  return string.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

/**
 * Menu Desplegable Javascript+CSS v1.0: Desplegar subcategories
 */
 
function subCat(thingId) {
  targetElement = document.getElementById("subcat" + thingId);
  targetElement.style.display=(targetElement.style.display!="block")? "block" : "none"	
}

/**
 * Menu Desplegable Javascript+CSS v1.0: Desplegar subcategories
 */

function amagar(thingId) {
  targetElement = document.getElementById(thingId);
  targetElement.style.display= "none";
}
 
function mostrar(thingId) {
  targetElement = document.getElementById(thingId);
  targetElement.style.display= "block";
}

/**
 * Imprimir Selecció Javascript+CSS v1.0: Desplegar subcategories
 */

function imprSelec(nombre) {
  var ficha = document.getElementById(nombre);
  var ventimp = window.open(' ', 'popimpr');
  ventimp.document.write( ficha.innerHTML );
  ventimp.document.close();
  ventimp.print( );
  ventimp.close();
} 
