$(document).ready(function(){

  // Init Fancybox
  $('a[rel="lightbox"]').fancybox();

  // Append "module" parameter to "buy" links
  if(window.location.href.match(/moduli\-shopcms\/articles\/[^\/]+\.html/)) {
    // Get module name
    var pageTitle = $('title').html();
    var moduleName = pageTitle.match(/(.*)\s\-\s/);
    if(moduleName) {
      var moduleName = moduleName[1];
      $('a[href="contacts.html"]').each(function(index, element) {
        $(element).attr('href', $(element).attr('href') + '?module=' + moduleName);
      });
    }
  }

});

function twGetSelText() {
  var txt = '';
  if (window.getSelection) {
    txt = window.getSelection();
  } else if (document.getSelection) {
    txt = document.getSelection();
  } else if (document.selection) {
    txt = document.selection.createRange().text;
  }
  return String(txt);
}


