function mostrar(id){
getById(id).style.display = 'inline';
}

function mostrarBloque(id){
document.getElementById(id).style.display = 'block';
}

function ocultar(id){
document.getElementById(id).style.display = 'none';
}

function limpiar(inp){
if ( inp.value != '' ) inp.value = '';
}

function mostrarOcultar(id){
if ( document.getElementById(id).style.display == 'inline' )
	ocultar(id);
else
	mostrar(id);
}

function mostrarOcultarBloque(id){
if ( document.getElementById(id).style.display == 'block' )
	ocultar(id);
else
	mostrarBloque(id);
}

function getById(id){
	return document.getElementById(id);
}

function convierteEuros(id) {
	var pesetas = getById(id).value;
	
	pesetas = pesetas.replace(/\./g,'');
	pesetas = pesetas.replace(/\,/g,'.');
	
	var euros = Math.round(parseInt(pesetas) * 100 / 166.386) / 100;
	
	getById(id).value = formatNumber(euros);
}

function formatNumber(num){
	num = Math.round(parseFloat(num)*Math.pow(10,2))/Math.pow(10,2)

	num += '';
	var splitStr = num.split('.');
	var splitLeft = splitStr[0];
	var splitRight = splitStr.length > 1 ? ',' + splitStr[1] : ',00';
	splitRight = splitRight + '00';
	splitRight = splitRight.substr(0,3);
	var regx = /(\d+)(\d{3})/;
	while (regx.test(splitLeft)) {
		splitLeft = splitLeft.replace(regx, '$1' + '.' + '$2');
	}
	return splitLeft + splitRight;
}

function esEntero(valor){

  if(!isNaN(valor)){
   for(var i = 0; i<valor.length;i++){
    if(valor.charCodeAt(i)<48 || valor.charCodeAt(i)>57)
     return false; 
   }
  }else{
   return false;
  }
  
  return true;
}

/*Especificas*/
function cambiaCategoria(id){
    mostrarOcultarBloque('subcategorias_1_'+id);
}

function cambiaSubCategoria(id){
    mostrarOcultarBloque('subcategorias_1_2'+id);
}