var CMS = {
    showObj: function(objID) {
        $(objID).setStyle({
            'visibility': 'visible',
            'margin-top': '0px'
        });
    },
    hideObj: function(objID) {
        $(objID).setStyle({
            'visibility': 'hidden',
            'margin-top': '0px'
        });
    },
    linkAnimate: function(linkID) {
		new Effect.Move('linkAnimation', {
			x: ((linkID - 1) * 112),
			y: 50,
			mode: 'absolute',
			transition: Effect.Transitions.spring
		});
    },
    fixMarginIssue: function(which) {
        var styleToSet = {};
        switch(which) {
            case 0:
                styleToSet = {
                    'height': '40px'
                };
                break;
            case 1:
                styleToSet = {
                    'height': '60px'
                };
                break;
        }
        $('linksContainer').setStyle(styleToSet);
    },
	links: null,
	linkContainer: null
}

/* Various variables for usage */
infoBoxes = ['news', 'twitter', 'blog'];
infoBox = null;
currentInfoBox = -1;
req = null;

function swapOut() {
	try{
		currentInfoBox++;
		if (currentInfoBox === infoBoxes.length) currentInfoBox = 0;
		req = new Ajax.Request("/infoBox_" + infoBoxes[currentInfoBox] + ".htm", {
			method: 'get',
			onSuccess: function(resp) {
				infoBox = document.getElementById("infoBox");
				infoBox.innerHTML = resp.responseText;
				setTimeout("swapOut()", 60000);
			}.bind(this),
			onFailure: function(resp) {
				//alert("Failed...\n" + resp.status + ": " + resp.statusText);
			}.bind(this),
			on0: function() {}
		});
	} catch(e) {}
}

window.onload = function() {
	swapOut();
	CMS.links = document.getElementById('linksContainer').getElementsByTagName('a');
}
