/*************************************************************************

  Implements utility functions and objects for the BC website.

  Original Author:  Brian Stucky, February 16, 2007

  Copyright(c) Bethel College, 2006

**************************************************************************/

function toggleDisplay(element) {
	element = document.getElementById(element);

	if (!(element.style.display) || (element.style.display == 'none'))
		element.style.display = 'block';
	else
		element.style.display = 'none';
}

function showPanorama(URL, name) {
	window.open(URL, name, 'resizable=true,width=380,height=250');
	return false;
}
function popit(url) {
	var newwindow;
	newwindow = window.open(url,'name','height=800,width=600');
	if (window.focus) {
		newwindow.focus()
	}
}

function fadeinout() {          
  $(".seek").delay(2000).fadeIn(750, function() {
    $(".seek").fadeOut(1000, function() {
      $(".serve").fadeIn(750, function() {
        $(".serve").fadeOut(1000, function() {
          $(".grow").fadeIn(750, function() {
            $(".grow").fadeOut(1000, function() {
              $(".seek").fadeIn(750, function() {
                $(".serve").fadeIn(750, function() {
                  $(".grow").fadeIn(750);
                });
              });
            });
          });
        });
      });
    });
  });
}

$(document).ready(function() {
  if ($('.ssg').get(0)) {
    fadeinout();
  }

  if ($('#highlightbox').get(0)) {
    calpopup = new PopupElement(400, 80, 4, 2);
    hlcontroller = new HlController('highlightbox', 10);

    hlcontroller.startAutoPlay();

    $('#hlPrev').click(function() {
      hlcontroller.rotateContent(1);
    });
    $('#hlNext').click(function() {
      hlcontroller.rotateContent(0);
    });
    $('#hlcontrolpause').click(function() {
      hlcontroller.pauseHandler();
    });
  }

  if ($('#upcomingEvents').get(0)) {
    $('#upcomingEvents li').hover(
      function() {
        $(this).children('.desc').fadeIn();
      },
      function() {
        $(this).children('.desc').fadeOut();
      }
    );

    $('#newsItems li').hover(
      function() {
        $(this).children('.desc').fadeIn();
      },
      function() {
        $(this).children('.desc').fadeOut();
      }
    );
  }
});

