/**
*	Author: Jarrett M. Barnett
*	E-mail: jarrett@mc2design.com
*	Company: MC2 Design Group, Inc.
*	Copyright (c) 2009
*	Last Modified: 2009-09-28
*/

/**
*	Notes:
*		Built using jQuery library. 
*			Confirmed to work with jQuery v1.3.2.
*/
function carousel(){
	var $active = $('#slideshow img.active');
	if ( $active.length == 0 ) $active = $('#slideshow img:last');
	var $next =  $active.next().length ? $active.next()
		: $('#slideshow img:first');
	$active.addClass('last-active');

	$next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 1000, function() {
			$active.removeClass('active last-active');
	});
		$active.animate({opacity: 0.0}, 1000);
}

$(function() {
		$('.showhide').hover(function() {
				clearInterval(mycarousel);
				$('#slideshow img').removeClass('active').removeClass('last-active').animate({opacity: 0}, 0),
				$('#slideshow img.' + $(this).attr('rel')).addClass('active').animate({opacity: 1.0}, 500);
		 }).mouseout(function() {
			 mycarousel = setInterval("carousel()", 4000);
		 });
	var mycarousel = setInterval("carousel()", 4000);
	
	$('#qm0').css('z-index', '2000');
	
	
	/** Scroll Slideshow Into View *//*
		var name = "#slideshow"; // element to scroll
        var menuYloc = null;
        var topoffset = 110; // dont scroll until top offset exceeded
        var bottomoffset = 200; // dont scroll when bottom offset exceeded

        menuYloc = parseInt($(name).css("top").substring(0,$(name).css("top").indexOf("px")))

        // execute on scroll action
        $(window).scroll(function () {
            contentheight = $("#content").height();
            dontexceed = contentheight-bottomoffset;

            if ($(document).scrollTop() < topoffset) { // ensure scroll resets to top when under topoffset
                offset = 0;
            } else if ($(document).scrollTop() > dontexceed && dontexceed > topoffset) { // dont scroll down too low
                offset = dontexceed-bottomoffset;
            } else if ($(document).scrollTop() > topoffset) { // dont scroll until topoffset is offscreen  (i.e. header)
                offset = menuYloc+$(document).scrollTop()-topoffset;
            } else { // scroll the menu
                offset = menuYloc+$(document).scrollTop();
            }

            $(name).animate({top:offset+"px"},{duration:500,queue:false});
        });
	
	*/
	
	
});