/* utility.js */

// torna indietro di una pagina
function back1page() {
   history.go(-1);
   //history.go('home.newco.com');
}
/*
history.back() torna alla pagina precedente
history.forward() va alla pagina successiva
history.go(n) (con "n" positivo o negativo) va alla pagina indicata da "n" 
dove n è un numero che specifica l'ordine cronologico
Ovviamente non si avrà alcun effetto se le posizioni cercate non esistono.
*/
function scroll(x) {
   //var xx = self.location.toString();
   if(document.all) {
   // if (xx.substr(-9,9) == "nav_0.php") {
   //    self.scrollTop;
   // }else{
         self.scrollTop = self.scrollHeight;
   // }
   }else{
   // if (xx.substr(-9,9) == "nav_0.php") {
   //    self.scrollTo(0,0);
   // }else{
         var maxY = window.scrollMaxY;
         self.scrollTo(0,maxY); // Scroll to the bottom of the page
   // }
   }
}

function scrollDown(i) {
   var j = 'point' + i.toString();
   var thepoint = document.getElementById(j).offsetTop;
   document.getElementById('preview').scrollTop = thepoint;
}
function scrolldiv() {
   var x = document.getElementById( "preview" );
   alert (x);
   x.scrollBy( 10, 10 ) ;
   alert("ok");
}
/* ----------------------------------------------------------------------------------- */
/* dal sito http://www.constile.org                                                    */
/* ----------------------------------------------------------------------------------- */
function createCookie(name,value,days,path) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = '; expires='+date.toGMTString();
  }
  else expires = '';
  //document.cookie = name+'='+value+expires+'; path=/~sacchim/uicicr/php/'; // casa
  //document.cookie = name+'='+value+expires+'; path=/uicicr/php/'; // ufficio
  document.cookie = name + '=' + value+expires + '; path=/'; // . path;
}

function readCookie(name) {
  var nameEQ = name + '=';
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}
function setCSS(nome_file_css,path) {
   createCookie('STYLE',nome_file_css,365,path);
   location.reload();
}
function setCSShref(nome_file_css) {
   var link_ = document.getElementsByTagName("link");
   for ($i=0;$i<link_.length;$i++)
      if(link_[$i].media=="screen") link_[$i].href=nome_file_css+".css";
}
/*
window.onload = function() {
   nome_file_css = readCookie('skinUtente');
   if(nome_file_css) setCSShref(nome_file_css);
}
*/
function e_mail(who, what, body) {
   parent.location.href='mailto:' + who +
                        '?cc='    + '' +
                        '&bcc='   + '' +
                        '&subject=Rif. ' + what +
                        '&body='  + body;
}


