var Section = {
    previous : function (id) {
        if (parseInt($(id).style.left) < 0) {
            if (parseInt($(id).style.left) < -614) {
                new Effect.Move(id, {x: Number(208 * 3), y: 0, duration: 0.5});
            } else {
                new Effect.Move(id, {x: Number(parseInt($(id).style.left.substring(1))), y: 0, duration: 0.5});
            }
        }
    },
    
    next : function (id, rows) {
        if (!$(id).style.width) {
            $(id).style.width = 0;
        }
        
        if (!$(id).style.left) {
            $(id).style.left = 0;
        }
        
        if ((parseInt($(id).style.width) + parseInt($(id).style.left) - Number(3 * 208) >= 614)) {
            new Effect.Move(id, {x: -Number(208 * 3), y: 0, queue: {position: 'end', scope: 'sectionscope', limit: 1}, duration: 0.5});
        } else if (parseInt($(id).style.width) + parseInt($(id).style.left) - Number(3 * 208) >= 406) {
            new Effect.Move(id, {x: -Number(208 * 2), y: 0, queue: {position: 'end', scope: 'sectionscope', limit: 1}, duration: 0.5});
        } else if (parseInt($(id).style.width) + parseInt($(id).style.left) - Number(3 * 208) >= 198) {
            new Effect.Move(id, {x: -208, y: 0, queue: {position: 'end', scope: 'sectionscope', limit: 1}, duration: 0.5});
        } else {
            new Effect.Move(id, {x: (parseInt($(id).style.width) - parseInt($(id).style.left) - (208 * rows) + 10), y: 0, queue: {position: 'end', scope: 'sectionscope', limit: 1}, duration: 0.5});
        }
    }
}

var Category = {
    previous : function (id) {
        if (parseInt($(id).style.left) < 0) {
            new Effect.Move(id, {x: 548, y: 0, duration: 0.5});
        }
    },
    
    next : function (id) {
        if (!$(id).style.width) {
            $(id).style.width = 0;
        }
        
        if (!$(id).style.left) {
            $(id).style.left = 0;
        }
        
        if ((parseInt($(id).style.width) + parseInt($(id).style.left) - 548 > 547)) {
            new Effect.Move(id, {x: -548, y: 0, queue: {position: 'end', scope: 'categoryscope', limit: 1}, duration: 0.5});
        } else {
            new Effect.Move(id, {x: (parseInt($(id).style.width) - 548), y: 0, queue: {position: 'end', scope: 'categoryscope', limit: 1}, duration: 0.5});
        }
    }
}

var Article = {
    previous : function (id) {
        if (parseInt($(id).style.left) < 0) {
            new Effect.Move(id, {x: 548, y: 0});
        }
    },
    
    next : function (id) {
        if (!$(id).style.width) {
            $(id).style.width = 0;
        }
        
        if (!$(id).style.left) {
            $(id).style.left = 0;
        }
        
        if ((parseInt($(id).style.width) + parseInt($(id).style.left) - 548 > 547)) {
            new Effect.Move(id, {x: -548, y: 0, queue: {position: 'end', scope: 'articlescope', limit: 1}, duration: 0.5});
        } else {
            new Effect.Move(id, {x: (parseInt($(id).style.width) - 548), y: 0, queue: {position: 'end', scope: 'articlescope', limit: 1}, duration: 0.5});
        }
    }
}

function showTooltip(el) {
    var top = Number($(el).cumulativeOffset().top - 140);
    var left = Number($(el).cumulativeOffset().left);
    $('kmalu').setStyle({'top': top + 'px', 'left': left + 'px'});
    new Effect.Appear($('kmalu'));
    
	new PeriodicalExecuter(function(pe) {
		new Effect.Fade('kmalu');
		pe.stop();
	}, 4);
}
