var madd = 'teeg@houseofteeg.com';

var quote = new Array();
var author = new Array();
var illust = new Array();
var illustTitle = new Array();

//quotes
quote[0] = "Your DNA may be destined to mingle with mine. Salutations!";
author[0] = "Richard Dawkins";
quote[1] = "It is a mistake to think you can solve any major problems just with potatoes";
author[1] = "Douglas Adams";
quote[2] = "The most incomprehensible thing about the world is that it is comprehensible";
author[2] = "Albert Einstein";
quote[3] = "Everything should be made as simple as possible, but no simpler";
author[3] = "Albert Einstein";
quote[4] = "Trying is the first step towards failure";
author[4] = "Homer Simpson";
quote[5] = "I reject your reality, and substitute my own";
author[5] = "Adam Savage";
quote[6] = "If you don't know where you are going, any road will take you there";
author[6] = "Lewis Carroll";
quote[7] = "All great truths begin as blasphemies";
author[7] = "George Bernard Shaw";
quote[8] = "You can't trample infidels when you're a tortoise";
author[8] = "Terry Pratchett";
quote[9] = "Geography is just physics slowed down, with a couple of trees stuck in it";
author[9] = "Terry Pratchett";


/*
quote[2] = "Great spirits have always encountered violent opposition from mediocre minds";
author[2] = "Albert Einstein";
quote[4] = "An appeaser is one who feeds a crocodile&mdash;hoping it will eat him last";
author[4] = "Winston Churchill";
quote[10] = "It is almost impossible to think of something no one has thought of before,<br>but it is always possible to add different frills";
author[10] = "Isaac Asimov";
quote[13] = "The trouble with having an open mind, of course, is that people will<br>insist on coming along and trying to put things in it";
author[13] = "Terry Pratchett";
*/

//end of quotes

//illustrations
illust[0] = "dragon";
illustTitle[0] = "Sleepy Dragon";
illust[1] = "bakumatsu";
illustTitle[1] = "Bakumatsuperhero";
illust[2] = "cutebot";
illustTitle[2] = "I, Cutebot";
//end of illustrations

function getNumber(){
	//return 12;
	return Math.floor(quote.length*Math.random());
}

function getIllustNumber(){
	//return 12;
	return Math.floor(illust.length*Math.random());
}

function getQuote(n){
	return quote[n];
}

function getAuthor(n){
	return author[n];
}

function getIllust(n){
	return illust[n];
}

function getIllustTitle(n){
	return illustTitle[n];
}

function getAddressen(obj, curLoc){
	document.getElementById("enLink").href=	curLoc.replace("/ja/","/en/");
}

function getAddressja(obj, curLoc){
	document.getElementById("jaLink").href=	curLoc.replace("/en/","/ja/");
}

//Functions and vars for fading:

var showTimer = 0;
var hideTimer = 0;
var fadeInTimer = 0;
var fadeOutTimer =  0;

function fadeIn(id, time) {
  clearTimeout(fadeOutTimer);

  //amount to step opacity   
  var step = 0.05;
  var t = (time * step);

  var object = document.getElementById(id).style;
  showItem(id); 
  if(Number(object.opacity) < 1){
    var newOpac = ((Number(object.opacity) + step)*100);
    changeOpac(newOpac, id);
    fadeInTimer = setTimeout('fadeIn("'+id+'",'+time+')', t);
  }else{
    changeOpac(100, id);
  }
  
}

function fadeOut(id, time) {
  clearTimeout(fadeInTimer);

  //amount to step opacity   
  var step = 0.05;
  var t = (time * step);

  var object = document.getElementById(id).style;
  if(Number(object.opacity) > 0){
    var newOpac = ((Number(object.opacity) - step)*100);
    changeOpac(newOpac, id);
    fadeOutTimer = setTimeout('fadeOut("'+id+'",'+time+')', t);
  }else{
    changeOpac(0, id);
    hideItem(id);
  }
  
}

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}

function waitShow(id, time){
  clearTimeout(hideTimer);
  showTimer = setInterval('fadeIn("'+id+'",1000)', time);
}

function waitHide(id, time){
  clearTimeout(showTimer);
  hideTimer = setInterval('fadeOut("'+id+'",1000)', time);
}

function showItem(id){
  document.getElementById(id).style.visibility='visible';
}

function hideItem(id){
  document.getElementById(id).style.visibility='hidden';
}