﻿function doPermalink(origen, destino)
{  
  //var text = document.getElementById(origen).value.toLowerCase(); // without 'prototype' library 
  var text = $(origen).value.toLowerCase(); // with 'prototype' library
  text = text.replace(/[áàäâå]/g, 'a');
  text = text.replace(/[éèëê]/g, 'e');
  text = text.replace(/[íìïî]/g, 'i');
  text = text.replace(/[óòöô]/g, 'o');
  text = text.replace(/[úùüû]/g, 'u');
  text = text.replace(/[ýÿ]/g, 'y');
  text = text.replace(/[ñ]/g, 'n');
  text = text.replace(/[ç]/g, 'c');
  text = text.replace(/['"]/g, '');
  text = text.replace(/[^a-zA-Z0-9-]/g, ' '); //text = text.replace(/\W/g, ' ');  
  text = text.replace(/\s+/g, '_');
  text = text.replace(/(_)$/g, '');
  text = text.replace(/^(_)/g, '');  
  //document.getElementById(destino).value = text; // without 'prototype' library 
  $(destino).value = text; // with 'prototype' library
  return false;
}
