// Please note this script uses PHP as well as Javascript to work. Using this source is not the full way to get the toast working.
// This script belongs to msgstuff.com and was orginally coded by -dt-.
// You may not use this script without permission.

//millisecs to go up in
var timeupInLots = '1';
//px to go up by (best to keep even number)
var pxtogoup = 2;
//amount of time for it to stay not moving after coming up
var wait = '10000';

var msnPopup,timeleft = 0,total = 0;
var dir = 'up';
window.addEventListener('load',msnPopup_start,false);

function msnPopup_start()
{
	msnPopup = document.getElementById('msnpopup');
	msnPopup.style.display = 'block';
	msnPopup.addEventListener('contextmenu',msnPopup_ClickHandler,false);
	msnPopup.addEventListener('click',msnPopup_ClickHandler,false);
	msnPopup_controller();
}

function msnPopup_controller()
{
	var bottom = parseInt(msnPopup.style.bottom);
	
	if (bottom<-120&dir=='down')
	{
		msnPopup_close();
		return;
	}
	
	if (dir=='up')
	{
		if (bottom-bottom-bottom>pxtogoup)
		{
			msnPopup_slide('up',pxtogoup);
			setTimeout("msnPopup_controller();",timeupInLots);
		}
	
		else
		{
			msnPopup_slide('up',bottom-bottom-bottom);
			dir = 'down';
			setTimeout("msnPopup_controller();",wait);
		}
	}
	
	else
	{
		msnPopup_slide('down',pxtogoup);
		setTimeout("msnPopup_controller();",timeupInLots);
	}

	if (dir=='stop')return;
}


function msnPopup_slide(way,by)
{
	if (way == "up")
	{
		msnPopup.style.bottom =	parseInt(msnPopup.style.bottom) + by +'px';
	}

	else if (way == "down")
	{
		msnPopup.style.bottom =	parseInt(msnPopup.style.bottom) - by +'px';
	}
}

function msnPopup_close()
{
	msnPopup.style.display = 'none';
	msnPopup.removeEventListener('contextmenu',msnPopup_ClickHandler,false);
	msnPopup.removeEventListener('click',msnPopup_ClickHandler,false);
}

function msnPopup_ClickHandler(e)
{
	msnPopup_close();
	if(e.button==2)e.preventDefault();
}

function toast_confirm()
{
	var name = 'toast';
	var value = '1';
	var days = '7';
		
	var date = new Date();
	date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
	var expires = "; expires=" + date.toGMTString();
		
	document.cookie = name + "=" + value+expires+"; path=/";
}