
var olddescription = '';
function showdescription(desc)
{
    olddescription = document.getElementById("description").innerHTML;
    document.getElementById("description").innerHTML = desc;
}

function nodescription()
{
    document.getElementById("description").innerHTML = olddescription;
}

function fadein(id,current,target)
{
    if (document && document.getElementById && document.getElementById(id).style)
    {
	document.getElementById(id).style.MozOpacity = current;
	if (current < target) {
	    if (current == 0)
		setTimeout( "fadein(\"" + id + "\", 0.1, " + target + ")", 100 );
	    else
		setTimeout( "fadein(\"" + id + "\", " + (current*1.1) + ", " + target + ")", 10 );
	}
    }
}

function show(id,x,y)
{
    thing = document.getElementById(id);
    thing.style.display = 'block';
    if (y+thing.height > window.innerHeight)
	y = window.innerHeight - thing.height;

    thing.style.top = y + "px";
    thing.style.left = x + "px";
}


function mouseover(e)
{
    var posx = 0;
    var posy = 0;
    if (!e)
	var e = window.event;
    if (e.pageX || e.pageY)
    {
	posx = e.pageX;
	posy = e.pageY;
    }
    else if (e.clientX || e.clientY)
    {
	posx = e.clientX + document.body.scrollLeft;
	posy = e.clientY + document.body.scrollTop;
    }
    posy = posy + 30;
    posx = posx - 40;

    if (posx > window.innerWidth/2)
    {
	var w = 0;
	if (document.getElementById(this.id+"_info").offsetWidth)
	    w = document.getElementById(this.id+"_info").offsetWidth;
	if (document.getElementById(this.id+"_info").style.pixelWidth)
	    w = document.getElementById(this.id+"_info").style.pixelWidth;
	if (w < 20) w = 210;
	w = w + 50;
	posx -= w;
    }
    if (posy > window.innerHeight/2)
    {
	var h = 0;
	if (document.getElementById(this.id+"_info").offsetHeight)
	    h = document.getElementById(this.id+"_info").offsetHeight;
	if (document.getElementById(this.id+"_info").style.pixelHeight)
	    h = document.getElementById(this.id+"_info").style.pixelHeight;
	if (h < 20) h = 150;
	h = h + 50;
	posy -=  h;
    }
    
    show(this.id+"_info",posx,posy)
}

function mouseout(e)
{
    document.getElementById(this.id+"_info").style.display = 'none';
}
   

function loaded()
{
    var menu = ['photos','weblog','tripreport','essays', 'activity','tripplan','toodrunk','activist',];

    for (var i=0; i < menu.length; i++)
    {
	if (document.getElementById(menu[i]))
	{
	    document.getElementById(menu[i]).onmousemove = mouseover;
	    document.getElementById(menu[i]).onmouseout = mouseout;
	}
    }

    document.getElementById('email').innerHTML = 'mike' + '@' + 'mike-warren.com';
    document.getElementById('email').href = 'mailto:mike' + '@' + 'mike-warren.com';
    document.getElementById('email').style.fontSize = '100%';
}
