// add function createTabs() to loadJS() in global_vars.js

/*
Elements to style and position:
#tab_content
*/

 //id of element to recieve content
var fsTabbedTarget = "tab_content";

//list the id's of the tab graphics
var fsTabbedButtons = new Array(
	"news_tab",
	"cal_tab"
);

// list the module class names which contain the content in the order of the tabs
var fsTabbedContainers = new Array(
	"news_list",
	"cal_list"
);

// list the module class names which contain the more links
var fsTabbedLinks = new Array(
	"more_news",
	"more_cal"
);

var fsTabbedBlocks = new Array();

function createTabs(){

	divs = document.getElementsByTagName('div');
	
	for(i=0;i<divs.length;i++){
		for(j=0;j<fsTabbedContainers.length;j++){
			if(divs[i].className == fsTabbedContainers[j]){
				fsTabbedBlocks[j] = divs[i].innerHTML;
			}
		}

		for(k=0;k<fsTabbedLinks.length;k++){
			if(divs[i].className == fsTabbedLinks[k]){
				document.getElementById(fsTabbedButtons[k]).moreLink = divs[i];
			}
		}


	}

	for(i=0;i<fsTabbedButtons.length;i++){
		document.getElementById(fsTabbedButtons[i]).offSrc = document.getElementById(fsTabbedButtons[i]).src;
		document.getElementById(fsTabbedButtons[i]).onSrc = document.getElementById(fsTabbedButtons[i]).src.replace(/\.(gif|jpg)/,"_on.$1");
	}

	fsTabbedBlocks[1] = '<iframe name="DCWebToolBox" width="260" height="140" target="_self" frameborder="0" src="http://www.dynacal.com/francisparker/WebToolBox_IFrameCal.asp?BG=%23ead8be&amp;BBG=%23330000&amp;BT=%23FFFFFF&amp;NT=%23FFFFFF&amp;NB=%23996600&amp;T=%23000000&amp;DIV=1&amp;CID=7174&amp;LAY=B"></iframe>';

	swapTab(0);

}


function swapTab(n){
	for(i=0;i<fsTabbedButtons.length;i++){
			document.getElementById(fsTabbedButtons[i]).src = document.getElementById(fsTabbedButtons[i]).offSrc;
			document.getElementById(fsTabbedButtons[i]).moreLink.style.display = 'none';
	}

	if(n){
		document.getElementById(fsTabbedButtons[n]).src = document.getElementById(fsTabbedButtons[n]).onSrc;
		document.getElementById(fsTabbedTarget).innerHTML = fsTabbedBlocks[n];
			document.getElementById(fsTabbedButtons[n]).moreLink.style.display = 'block';
	}else{
		document.getElementById(fsTabbedButtons[0]).src = document.getElementById(fsTabbedButtons[0]).onSrc;
		document.getElementById(fsTabbedTarget).innerHTML = fsTabbedBlocks[0];
		document.getElementById(fsTabbedButtons[0]).moreLink.style.display = 'block';
	}
}
