/*ACCORDION PARAMETERS AND CONTROLS*/
$(document).ready(function () {
	$('#accordion').easyAccordion({ 
			autoStart: false,
			slideInterval: 1000,
			slideNum:true
	});
	
	buttonLeft = function() {
	  var curIndex = $('dl.easy-accordion dt.active').index('dt');
	  if(curIndex>0)
		$('dl.easy-accordion dt').eq($('dl.easy-accordion dt.active').index('dt')-1).trigger('click');	
	}
	buttonRight = function() {
		$('dl.easy-accordion dt').eq($('dl.easy-accordion dt.active').index('dt')+1).trigger('click');
	}
});
/**/

/*SHOW AND HIDE CONTENT*/
var curReveal = 'reveal0';
function showContent(boxid){
	var nextSlide = boxid.split("l",2);
	//$('#'+curReveal).fadeOut("slow");
	//$('#'+boxid).fadeIn("slow");
	//curReveal = boxid;
	$('dl.easy-accordion dt').eq(nextSlide[1]).trigger('click');
}

$(document).ready(function() {
	$('dl.easy-accordion dt').each(function() {
		$(this).click(function() {
			var slideNo = $(this).index('dt');
			$('#'+curReveal).fadeOut("slow");
			$('#reveal'+slideNo).fadeIn("slow");
			$('div#contentWrapper').animate({height: $('#reveal'+slideNo).height() + 50}); // push out the footer
			curReveal = 'reveal'+slideNo;
		});
	});
});

/**/

/* Home page fader and dots */
function fade_images() {
    $('div#home_images img').eq(2).fadeOut(1500).delay(5000).fadeOut(1500, function() {
        $(this).prependTo($('div#home_images')).show();
        setTimeout('fade_images();', 5000);
    })
};
function fade_dots(i) {
    var i = i || 1;
    // initially clone dots slide and set transparent
    if ($('div#dots > div.dots_slide').size() == 1) {
        $('div#dots div').clone().css({
            opacity: 0
        }).appendTo($('div#dots'));
    }
    // fade out visible slide
    $('div#dots div').eq(0).animate({
        opacity: 0
    }, 1000);
    //fade in next slide
    $('div#dots div').eq(1).css({
        backgroundPosition: '50% -'+(266*(i%4))+'px'
    }).animate({
        opacity: 1
    }, 1000, function() {
        // move this slide to the top
        $(this).prependTo($('div#dots'));
        setTimeout('fade_dots('+i+'+1);', 2000);
    });
}
$(document).ready(function() {
    setTimeout('fade_images();', 5000);
    //fade_dots(); they don't like our magic dots :(
});
