var ie = document.all;
var nn6 = document.getElementById&&!document.all;

function init()
{
	menuSetup();

	// "More" toggle on Resources page.
  $('#tog-pres_more').click(
    function() {
      if ($(this).html() == 'More &gt;' || $(this).html() == 'More >') {
        $(this).text('< Less');
        $('#pres_more').show('400');
      }
      else {
        $(this).text('More >');
        $('#pres_more').hide('400');
      }
    }
  );
  
  // Portfolio - logo events.
	$('.scroll_content').children('li').click(
    function() {
      $('#textholder').children('div').each(
        function() {
          $(this).hide();
        }
      );
      var spl = $(this).attr('id').split('-');
      if (spl[1]) {
        $('#pf_text-' + spl[1]).show();
      }
    }
  );

}

function menuSetup() {
  // Main menu styles.
  $('#menu_bar ul li a').each(
    function() {
      var spl = $(this).attr('id').split('-');
      if (spl[1] && section) {
        $(this).removeClass('on');
        if (spl[1] == section) {
          $(this).addClass('on');
        }
      }
    }
  );
  $('#menu_bar ul li a').hover(
    function() {
      var spl = $(this).attr('id').split('-');
      if (spl[1] && section) {
        var is_page = spl[1] == section;
      }
      if (!is_page) {
        $(this).toggleClass('on');
      }
    }
  );
  
  // Submenu styles.
  $('#submenu_bar ul li a').each(
    function() {
      var spl = $(this).attr('id').split('-');
      if (spl[1] && page) {
        $(this).removeClass('on');
        if (spl[1] == page) {
          $(this).addClass('on');
        }
      }
    }
  );
  $('#submenu_bar ul li a').hover(
    function() {
      var spl = $(this).attr('id').split('-');
      if (spl[1] && page) {
        var is_page = spl[1] == page;
      }
      if (!is_page) {
        $(this).toggleClass('on');
      }
    }
  );
}

_scrollbar_id = 1;

function setupScroll(num)
{
	var scrollbar = document.getElementById('scrollbar' + num);
	var content = document.getElementById('content' + num);
	var up = document.getElementById('up' + num);
	var down = document.getElementById('down' + num);
	
	up.onclick = function() { dw_scrollObj.initScroll('wn' + this.id.substring((this.id.length-1), this.id.length),'up'); };
	up.onmouseover = function() { dw_scrollObj.initScroll('wn' + this.id.substring((this.id.length-1), this.id.length),'up'); };
	up.onmouseout = function() { dw_scrollObj.stopScroll('wn' + this.id.substring((this.id.length-1), this.id.length)); };
	up.onmousedown = function() { dw_scrollObj.doubleSpeed('wn' + this.id.substring((this.id.length-1), this.id.length)); };
	up.onmouseup = function() { dw_scrollObj.resetSpeed('wn' + this.id.substring((this.id.length-1), this.id.length)); };

	down.onclick = function() { dw_scrollObj.initScroll('wn' + this.id.substring((this.id.length-1), this.id.length),'down'); };
	down.onmouseover = function() { dw_scrollObj.initScroll('wn' + this.id.substring((this.id.length-1), this.id.length),'down'); };
	down.onmouseout = function() { dw_scrollObj.stopScroll('wn' + this.id.substring((this.id.length-1), this.id.length)); };
	down.onmousedown = function() { dw_scrollObj.doubleSpeed('wn' + this.id.substring((this.id.length-1), this.id.length)); };
	down.onmouseup = function() { dw_scrollObj.resetSpeed('wn' + this.id.substring((this.id.length-1), this.id.length)); };
	
	var j = 0;
	for (var i=0; i < content.childNodes.length; i++)
	{
		if (content.childNodes[i].tagName == 'LI')
		{
			content.childNodes[i].id = 'pflist-' + j;
			if (j % 2)
			{
				// do odd stuff
				content.childNodes[i].className = 'right';
			}
			else
			{
				// do even stuff
				content.childNodes[i].className = 'left';
			}
			j++;
		}
	}
	content.style.visibility = 'visible';
	scrollbar.style.visibility = 'visible';
}

