function frontpageEvents(id) {
	$('#frontpageEvents').html('<img src="/images/system/loading.gif" alt="" />');
	$('#frontpageEvents').load('/ajax/frontpageEvents/'+id);
	$("#node1").addClass("pageInactive").removeClass("pageActive");
	$("#node2").addClass("pageInactive").removeClass("pageActive");
	$("#node3").addClass("pageInactive").removeClass("pageActive");
	$("#node4").addClass("pageInactive").removeClass("pageActive");
	$("#node5").addClass("pageInactive").removeClass("pageActive");
	$('#node'+id).addClass("pageActive").removeClass("pageInactive");
}

function frontpageLoadEvent(id,node) {
	$('#frontpageLoadEvent').load('/ajax/frontpageLoadEvent/'+id+'/');
	$("#sub1").removeClass("active");
	$("#sub2").removeClass("active");
	$("#sub3").removeClass("active");
	$("#sub4").removeClass("active");
	$("#sub5").removeClass("active");
	$("#sub6").removeClass("active");
	$('#sub'+node).addClass("active");
}

function frontpageForum(selectObj) {
	// get the index of the selected option
	var idx = selectObj.selectedIndex;
	// get the value of the selected option
	var which = selectObj.options[idx].value;
	$('#frontpageForum').html('<img src="/images/system/loading.gif" alt="" />');
	$('#frontpageForum').load('/ajax/frontpageForum/'+which);
}

$(document).ready(function() { 
	$("#ddp").html('<img src="/images/system/loading.gif" alt="" />');
	$("#ddp").load('/ajax/frontpageDDP/');
});

function slideSwitch() {
    var $active = $('#ddp div.active');

    if ( $active.length == 0 ) $active = $('#ddp div:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#ddp div:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

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

$(function() {
    setInterval( "slideSwitch()", 7000 );
});
