
var current = 1;
var total = 0;
var sliderInternal;

function StartSlider(interval) {
    sliderInternal = setInterval(MoveForward, interval * 1000);
}

function StopSlider() {
    clearInterval(sliderInternal);
}



//	 $(document).ready(function () {
//	 //load the newest blod as the first one
//		if(total > 0){
//			ShowPost(1);
//		}
//		StartSlider(@timeOut);
//	 });
//Move backwards thru the list of post
function MoveForward() {
    HidePost(current);
    if (current < total) {
        current++;
    } else {
        current = 1;
    }
    ShowPost(current);
};
//Move forward thru the list of post
function MoveBackward() {
    HidePost(current);
    if (current > 1) {
        current--;
    } else {
        current = total;
    }
    ShowPost(current);
}
//Show the current post and setup the display boxes
function ShowPost(postId) {
    $('#hero-' + postId).show();
    current = postId;
    var displayBoxes = '';
    for (var i = 1; i <= total; i++) {
        if (i == postId) {
            //make the current post box darker
            displayBoxes += '<a class="slideCountItemOn" ></a>';
        } else {
            //setup the onclick for the display boxes that aren't the current post
            displayBoxes += '<a class="slideCountItemOff"  onclick="SwitchSeenThis(' + postId + ',' + i + ');"></a>';
        }
    }
    $('.slideCounter').html(displayBoxes);
};
//hide the post
function HidePost(postId) {
    $('#hero-' + postId).hide();
}
//set the total amount of post that are used
function SetTotalSeenThisPost(count) {
    total = count;
    if (count < 2) {
        $('.hero-slider .slideNavigation').html('');
    }
}
//use the display boxes to switch
function SwitchSeenThis(currentPostId, newPostId) {
    HidePost(currentPostId);
    ShowPost(newPostId);
    current = newPostId;
}
	

