
function RequestQueryString(key){
   var docUrl = location.href;
   var startindice = docUrl.indexOf(key);
   var endindice;
   if (startindice !=-1){
      startindice = startindice + key.length + 1;
      endindice = docUrl.indexOf("&",startindice);
      if (endindice==-1){
         endindice = docUrl.length;
      }
      return unescape(docUrl.substring(startindice,endindice));
   } else {
      return "";
   }
}


function CallPrint(divID) {
  var WinPrint;
  var prtContent = document.getElementById(divID);
  var WinPrint = window.open('','','left=0,top=0,width=10,height=10,toolbar=0,scrollbars=yes,status=0');
  
  WinPrint.document.bgColor='EEEEEE';
  WinPrint.document.write('<LINK rel=stylesheet type="text/css" href="/facchini-theme/css/everything_packed.css">');

  // Per Test: una volta compilato funziona con everything_packed.css
  //WinPrint.document.write('<LINK rel=stylesheet type="text/css" href="/facchini-theme/css/custom.css">');
  
   
  WinPrint.document.write(commentaScript(prtContent.innerHTML));
  WinPrint.document.close();
  WinPrint.focus();
  WinPrint.print();
  WinPrint.close();
}

function SendToFriend() {
  var url = escape(window.location.href);
  window.location.href = "/web/guest/send2friend?url=" + url
}


function commentaScript(string){

  var strRitorno;
  strRitorno = string; // non posso fare toUpperCase o toLowerCase altrimento modifico la formattazione del testo

  strRitorno = strRitorno.replace(/\<script/g, "<!-- "); //espressione regolare
  strRitorno = strRitorno.replace(/\<SCRIPT/g, "<!-- "); //espressione regolare
  
  strRitorno = strRitorno.replace(/\<\/script>/g, " -->"); //espressione regolare
  strRitorno = strRitorno.replace(/\<\/SCRIPT>/g, " -->"); //espressione regolare

  //alert(strRitorno);

   return strRitorno;
  
}