// function to change box manually
function boxChange(nr) {
    stopRotation();
    wtObj.active = nr;
    changeBoxContent(wtObj.active);
}
// function to start rotation
function startRotation(startOnLoad) {
    setNextBoxStatus();
    if (!startOnLoad) {changeBoxContent(wtObj.active);}
    intervalID = setInterval(boxRotation, (wtObj.sleep * 1000));
    $(wtObj.idStart).css('display', 'none');
    $(wtObj.idStop).css('display', 'block');
}
// function to stop rotation
function stopRotation() {
    clearInterval(intervalID);
    $(wtObj.idStart).css('display', 'block');
    $(wtObj.idStop).css('display', 'none');
}
// function for rotation
function boxRotation() {
    setNextBoxStatus();
   	changeBoxContent(wtObj.active);
}
// ajax function to replace and fade next content
function changeBoxContent(){
    $(wtObj.idMain).fadeOut('fast', function(){
        $.get(wtObj.url + wtObj.active, function(data){
            $(wtObj.idMain).html(data).fadeIn('fast');
            $(wtObj.idRight).children('li').attr('class', wtObj.classNameStd);
            $(wtObj.idRightLi + wtObj.active).attr('class', wtObj.classNameAct);
        });
    });
}
// get box status to change box
function setNextBoxStatus(){
    if (wtObj.max <= wtObj.active) {
    	if (wtObj.replay == 1){
    		wtObj.active = 1;
    	} else {
    		stopRotation();
    	}
    }
    else {
    	wtObj.active = wtObj.active + 1;
    }
}

