function addbookmark()
{
  var title = "trixmoto"
  var url = "http://trixmoto.net/index.php"
  if (window.sidebar) 
    window.sidebar.addPanel(title,url,"") 
  else if( document.all ) 
    window.external.AddFavorite(url,title) 
  else if( window.opera && window.print ) 
    return true;
}

function showmail()
{
  document.getElementById("mail").style.display = "block";
}

function hidemail()
{
  document.getElementById("mail").style.display = "none";
}

function sendmail()
{
  var from = document.getElementById("from").value;
  var mess = document.getElementById("mess").value;
  if(from=="" || mess=="") {
    message("You must specify both from address and your message.",3);
  }
  else {
    hidemail();
    var a = new XMLHttpRequest();
    if(!a) {
      a = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if(!a) {
      message("Sorry, email could not be sent.",3);    
    }
    else {      
      document.getElementById("mess").value = "";
      mess = mess.replace(/&/,"%26");
      a.open("get","run.php?do=email&from="+from+"&mess="+mess);
      a.onreadystatechange = function () {
        if (a.readyState == 4) message(a.responseText,2);
      }  
      a.send(null);
      message("Sending...",10);
    }
  }
}      

var dx, xp, yp;
var am, stx, sty;
var i, doc_width = 800, doc_height = 600;
var dosnow = 0, snowcount = 50;

function initSnow()
{
  dosnow = 1;
  setSize();
  dx = new Array();
  xp = new Array();
  yp = new Array();
  am = new Array();
  stx = new Array();
  sty = new Array();

  for (i = 0; i < snowcount; ++ i) 
  {
    dx[i] = 0;  
    xp[i] = Math.random()*(doc_width-50); 
    yp[i] = Math.random()*doc_height;
    am[i] = Math.random()*20;         
    stx[i] = 0.02 + Math.random()/10; 
    sty[i] = 0.7 + Math.random();     
    document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='gifs/snow.gif' border=\"0\"></div>");
  }
  moveSnow();
}

function setSize()
{
  if (document.all) 
  {
    doc_width = document.body.clientWidth;
    doc_height = document.body.clientHeight;
  }
  else
  {
    doc_width = self.innerWidth;
    doc_height = self.innerHeight;
  }
}

function moveSnow() 
{
  setSize();
  for (i = 0; i < snowcount; ++ i)
  {
    yp[i] += sty[i];
    if (yp[i] > doc_height-50) 
    {
      xp[i] = Math.random()*(doc_width-am[i]-30);
      yp[i] = 0;
      stx[i] = 0.02 + Math.random()/10;
      sty[i] = 0.7 + Math.random();
    }
    dx[i] += stx[i];
    document.getElementById("dot"+i).style.top = yp[i];
    document.getElementById("dot"+i).style.left = xp[i] + am[i]*Math.sin(dx[i]);
  }
  if (dosnow == 1) setTimeout("moveSnow()", 10);
}

function stopSnow()
{
  if (dosnow == 1)
  {
    dosnow = 0;
    for (i = 0; i < snowcount; ++ i)
    {
      document.getElementById("dot"+i).style.visibility = "hidden";
    }
  }
  else
  {
    dosnow = 1;
    for (i = 0; i < snowcount; ++ i)
    {   
      document.getElementById("dot"+i).style.visibility = "visible";
    }   
    setTimeout("moveSnow()", 10);
  }     
}

function message(text,secs)
{
  setSize();
  var note = document.getElementById("notice");
  note.innerHTML = text;
  note.style.left = doc_width/2-note.offsetWidth/2;
  note.style.top = doc_height/2-note.offsetHeight/2;
  note.style.visibility = "visible";
  setTimeout("hidemess()",secs*1000);
}

function hidemess()
{
  document.getElementById("notice").style.visibility = "hidden";
  return true;
}