/******************************************************************************
 *  TEXT ROTATOR WIDGET V1.0
 *  Copyright (C) 2004 Giovanni Glass <momendo at yahoo dot com>
 *  http://www.giovanniglass.com
 *
 *  This library is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation; either version 2.1 of the License, or
 *  (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 ******************************************************************************
 *
 *  Steps to execute:
 *  1. Define the text array and give it a unique name
 *  2. Create a DIV with a unique ID and place it where you want, style it too
 *  3. Instantiate the quoter object and follow the arguments given
 *  4. Stuff the body.onload event with the object's go() method to start it
 *  5. Stir and enjoy!
 *
 *****************************************************************************/

function quoter()
{
	this.divName = arguments[0];
	this.obj  = arguments[1];
	this.interval = arguments[2];
	this.text = arguments[3];
	this.index = 0; // this is our current index
	this.limit = this.text.length - 1; // determine our limit
	this.objInterval = new Object(); // assign an object for the interval so that we may later reference it

	this.go = function()
	{
		this.rotate(); // first time around, put text up immediately
		this.objInterval = setInterval(this.obj + ".rotate();", this.interval); // then start the timer
	}

	this.rotate = function()
	{
		document.getElementById(this.divName).innerHTML = this.text[this.index];

		if(this.index < this.limit) {
			this.index++;
		} else {
			this.index = 0;
		}

	}

	this.stop = function()
	{
		clearInterval(this.objInterval); // destroy the interval object
	}
}


/******************************************************************************
 *
 * Syntax:
 *
 * object = new quoter(string1, string2, integer, object)
 *
 *  - string1 is the name of the div
 *  - string2 is the name of the object instantiated (it's referencing itself)
 *  - integer is the number of cycles to wait
 *  - object is the reference to the text array
 *
 *****************************************************************************/

// Since we're object based, you can create as many tickers on a page as you need!
// test = new quoter("ticker", "test", 3000, text1);


/******************************************************************************
 *  QUOTE OF THE DAY V1.0
 *  Copyright (C) 2004 Giovanni Glass <momendo at yahoo dot com>
 *  http://www.giovanniglass.com
 *
 *  This library is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation; either version 2.1 of the License, or
 *  (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 ******************************************************************************
 *
 *  Steps to execute:
 *  1. Define the text array and give it a unique name
 *  2. Create a DIV with a unique ID and place it where you want, style it too
 *  3. Instantiate the quoter object and follow the arguments given
 *  4. Stuff the body.onload event with the object's go() method to start it
 *  5. Stir and enjoy!
 *
 *****************************************************************************/

function quoteOfTheDay()
{
	this.preText = "Rediscover the inner landscape of your heart, mind and soul through a year long journey of quotes and penetrating questions. <a href=\"guidedjournal.php\">Buy one for yourself and many for friends</a>.<br><br>";

	this.divName = arguments[0];
	this.obj  = arguments[1];
	this.text = arguments[2];
	this.epoch = arguments[3];

	this.index = 0; // this is our current index
	this.limit = this.text.length; // determine our limit

	this.today = new Date();
	this.one_day = 1000*60*60*24; // calculate milliseconds in a day

	this.go = function()
	{
		var getDaysPassed = Math.ceil((this.today.getTime() - this.epoch.getTime()) / this.one_day);

		var daysLimitIndex = getDaysPassed % this.limit; // this will get a steady 0 to # of quotes

		document.getElementById(this.divName).innerHTML = this.preText + this.text[daysLimitIndex];
	}
}


/******************************************************************************
 *
 * Syntax:
 *
 * object = new quoter(string1, string2, text object, date object)
 *
 *  - string1 is the name of the div
 *  - string2 is the name of the object instantiated (it's referencing itself)
 *  - text array object
 *  - object is from the date object as epoch
 *
 *****************************************************************************/

// Since we're object based, you can create as many tickers on a page as you need!
//test = new quoter("ticker", "test", text1, new Date(2000, 0, 1));

/******************************************************************************
 *  DIV SCROLL BOX V1.0
 *  Copyright (C) 2004 Giovanni Glass <momendo at yahoo dot com>
 *  http://www.giovanniglass.com
 *
 *  This library is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation; either version 2.1 of the License, or
 *  (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 ******************************************************************************
 *
 *  Steps to execute:
 *  1. Define the text array and give it a unique name
 *  2. Create a DIV with a unique ID and place it where you want, style it too
 *  3. Instantiate the scroller object and follow the arguments given
 *  4. Stuff the body.onload event with the object's go() method to start it
 *  5. Stir and enjoy!
 *
 *****************************************************************************/

function scroller(object, myName)
{
	this.state = false;
	this.interval = 50;
	this.who = myName;
	time1 = setTimeout("", 0); // empty timer
	
	this.up = function()
	{
		this.obj = document.getElementById(object);

		if(this.state) {
			// get initial position
			startY = this.obj.scrollTop;
			this.obj.scrollTop = startY - 5;
		}
		
		time1 = setTimeout(this.who + ".up()", this.interval);
	}

	this.down = function()
	{
		this.obj = document.getElementById(object);

		if (this.state) {
			// get initial position
			startY = this.obj.scrollTop;
			this.obj.scrollTop = startY + 5;
		} else {
			clearTimeout(time1);
		}
		
		time1 = setTimeout(this.who + ".down()", this.interval);
	}
	
	this.setState = function(x)
	{
		this.state = (x) ? true : false;
	}
	
	this.go = function(direction)
	{
		if (direction == "up") {
			this.setState(true); // ok to move
			clearTimeout(time1); // destroy the loop
			this.up();
		}
		
		if (direction == "down") {
			this.setState(true); // ok to move
			clearTimeout(time1); // destroy the loop
			this.down();
		}
		
		if (direction == "stop") {
			this.setState(false); // we've stopped
			clearTimeout(time1); // destroy the loop
		}
	}

}


/******************************************************************************
 *
 * Syntax:
 *
 * object = new scroller(string1, string2)
 *
 *  - string1 is the name of the div
 *  - string2 is the name of the object instantiated (it's referencing itself)
 *
 *****************************************************************************/
ss = new scroller("scroll1", "ss");