function InitializeContent()
{
	YAHOO.util.Dom.addClass('content-box', 'box-setup');
	
	if (navigator.platform.indexOf('Mac') != -1) {
    }
}

/**
 * Page scroller
 */
function PageScroller(id, pages, height, buttonText)
{
    var buttonTitles = buttonText.value.split('|');
	this.id = id;
	this.height = height;
	this.pages = [];
	this.current_page = 0;
	this.animation = null;
	this.timerHdl = 0;
    this.play = false;
    this.interval = 5000;
    
	// set up container
	this.container = document.getElementById(this.id);
	this.container.style.overflow = 'hidden';
	this.container.style.height = this.height + 'px';

	// set up prev link
	this.prev = document.createElement('a');
	this.prev.href = '#';
	YAHOO.util.Dom.addClass(this.prev, 'previous');
	this.prev.appendChild(document.createTextNode(buttonTitles[0]));
	YAHOO.util.Event.addListener(this.prev, 'click',
		function (e)
		{
			YAHOO.util.Event.preventDefault(e);
			this.prevPage();
		},
		this, true);

    // set up Play link
    this.playlink = document.createElement('a');
    this.playlink.href = '#';
    YAHOO.util.Dom.addClass(this.playlink, 'playlink');
    this.playlink.appendChild(document.createTextNode(buttonTitles[1]));
	YAHOO.util.Event.addListener(this.playlink, 'click',
		function (e)
		{
			YAHOO.util.Event.preventDefault(e);
			this.playSlideShow();
		},
		this, true);
		
     // set up Stop link
    this.stoplink = document.createElement('a');
    this.stoplink.href = '#';
    YAHOO.util.Dom.addClass(this.stoplink, 'stoplink');
    this.stoplink.appendChild(document.createTextNode(buttonTitles[2]));
	YAHOO.util.Event.addListener(this.stoplink, 'click',
		function (e)
		{
			YAHOO.util.Event.preventDefault(e);
			this.stopSlideShow();
		},
		this, true);
    
	// set up next link
	this.next = document.createElement('a');
	this.next.href = '#';
	YAHOO.util.Dom.addClass(this.next, 'next');
	this.next.appendChild(document.createTextNode(buttonTitles[3]));
	YAHOO.util.Event.addListener(this.next, 'click',
		function (e)
		{
			YAHOO.util.Event.preventDefault(e);
			this.nextPage();
		},
		this, true);

	// add pagination to page
	var divider = document.createElement('span');
	divider.appendChild(document.createTextNode('|'));
	YAHOO.util.Dom.addClass(divider, 'divider');
	var divider2 = document.createElement('span');
	divider2.appendChild(document.createTextNode('|'));
	YAHOO.util.Dom.addClass(divider2, 'divider');

	var pagination = document.getElementById('pagination');
	pagination.appendChild(this.prev);
	pagination.appendChild(divider);
	pagination.appendChild(this.playlink);
	pagination.appendChild(divider2);
	pagination.appendChild(this.next);

	// add pages
	for (var i = 0; i < pages.length; i++)
		this.addPage(new Page(pages[i]));

	// initialize to first page
	this.setPage(0);

    this.playSlideShow();
}

PageScroller.prototype.playSlideShow = function()
{
    if (!this.play) {
        if (this.playlink.parentNode) {
		        this.playlink.parentNode.replaceChild(
			        this.stoplink, this.playlink);
	    }
        
        this.timerHdl = window.setInterval("scroller.nextPage(true)", this.interval);
        this.play = true;
    }
}

PageScroller.prototype.stopSlideShow = function()
{
    if (this.play && this.stoplink.parentNode) {
		    this.stoplink.parentNode.replaceChild(
			    this.playlink, this.stoplink);
    }

    window.clearInterval(this.timerHdl);
    this.play = false;
}

PageScroller.prototype.addPage = function(page)
{
	var page_number = this.pages.length;
	page.setPageHeight(this.height);
	this.pages.push(page);

	if (page.nav) {
		YAHOO.util.Event.addListener(page.nav, 'click',
			function (e)
			{
				YAHOO.util.Event.preventDefault(e);
				this.setPage(page_number);
			},
			this, true);
	}
}

PageScroller.prototype.prevPage = function()
{
    this.stopSlideShow();
	this.setPage(this.current_page - 1);
}

PageScroller.prototype.nextPage = function(autoscroll)
{
    if (!autoscroll) {
        this.stopSlideShow();
    }
	this.setPage(this.current_page + 1);
}

PageScroller.prototype.setPage = function(page_number)
{
	// deselect current (old) page
	this.pages[this.current_page].setNavHighlight(false);

	// wrap page number
	if (page_number >= this.pages.length)
		this.current_page = 0;
	else if (page_number < 0)
		this.current_page = this.pages.length - 1;
	else
		this.current_page = page_number;
	
	// select current (new) page
	this.pages[this.current_page].setNavHighlight(true);

	// set prev link sensitivity
	//this.setPrevLinkSensitivity(this.current_page != 0);

	// set next link sensitivity
	//this.setNextLinkSensitivity(this.current_page != this.pages.length - 1);

	// scroll to the page
	this.scrollToCurrentPage();
}

PageScroller.prototype.scrollToCurrentPage = function()
{
    //if (this.timerHdl != 0)
    //    window.clearTimeout(this.timerHdl);
        
    //this.timerHdl = window.setTimeout("this.nextPage(), 10000);
    
	var old_scroll_pos = this.container.scrollTop;

	// works because all pages are the same height
	var new_scroll_pos = this.height * this.current_page;

	if (this.animation && this.animation.isAnimated())
		this.animation.stop();

	this.animation = new YAHOO.util.Scroll(this.container,
		{ scroll: { from: [0, old_scroll_pos], to: [0, new_scroll_pos] } },
		1.2, YAHOO.util.Easing.easeOut);

	this.animation.animate();
}

/**
 * Page
 */
function Page(id)
{
	this.id = id;

	this.nav = null;
	var nav_element = document.getElementById('nav-page-' + this.id);
	for (var i = 0; i < nav_element.childNodes.length; i++) {
		if (nav_element.childNodes[i].nodeName == 'A') {
			this.nav = nav_element.childNodes[i];
			break;
		}
	}

	this.page = document.getElementById('pc-page-' + this.id);
	this.page.style.overflow = 'hidden';
}

Page.prototype.setPageHeight = function(height)
{
	this.page.style.height = height + 'px';
}

Page.prototype.setNavHighlight = function(highlight)
{
	if (this.nav) {
		if (highlight)
			YAHOO.util.Dom.addClass(this.nav, 'current');
		else
			YAHOO.util.Dom.removeClass(this.nav, 'current');
	}
}
