// JavaScript Document
function updateMainContent(section) {
	var content = document.getElementById('topmaincontent');
	var newContent;
	var newClass;
	var newTitle;
	if (section == 1) {
		newContent = 'This is content #1';
		newClass = 'it';
		newTitle = '';
	} else if (section == 2) {
		newContent = '';
		newClass = 'pss';
		newTitle = 'Kratos has specialized expertise in Physical Integrated Security and Surveillance Solutions. As a top security systems integrator in the US, we help protect sensitive government assets, as well as high-profile civilian assets.';
	} else if (section == 3) {
		newContent = 'This is <a href="#">content #3</a>';
		newClass = 'de';
		newTitle = '';
	} else if (section == 4) {
		newContent = 'This is <a href="#">content #4</a>';
		newClass = 'ws';
		newTitle = '';
	} else {
		newContent = '';
		newClass = 'default';
		newTitle = 'Kratos is a leading provider of Advanced Engineering, Security and Surveillance, IT Services and War Fighter Solutions for the federal government, and for state and local agencies. We leverage our intellectual and technical strengths to provide our customers with leading edge professional services and solutions for mission critical success.';
	}
	content.className = newClass;
	content.innerHTML = newContent;
	content.title = newTitle;
	fadeImages(section);
}
function fadeImages(section) {
	//preload images
	image1 = new Image();
	image1.src = docroot + 'images/tt_inactive.jpg';
	image2 = new Image();
	image2.src = docroot + 'images/pss_inactive.jpg';
	image3 = new Image();
	image3.src = docroot + 'images/de_inactive.jpg';
	image4 = new Image();
	image4.src = docroot + 'images/ws_inactive.jpg';
	
	var it = document.getElementById('imgIt');
	var pss = document.getElementById('imgPss');
	var de = document.getElementById('imgDe');
	var ws = document.getElementById('imgWs');
	
	if (section == 1) {
		//ensure active image is up
		if (it.src != docroot + 'images/tt_active.jpg') {
			it.src = docroot + 'images/tt_active.jpg'
		}
		//grey out other images
		pss.src=image2.src;
		de.src=image3.src;
		ws.src=image4.src;
	} else if (section == 2) {
	//ensure active image is up
		if (pss.src != docroot + 'images/pss_active.jpg') {
			pss.src = docroot + 'images/pss_active.jpg'
		}
		//grey out other images
		it.src=image1.src;
		de.src=image3.src;
		ws.src=image4.src;
	} else if (section == 3) {
	//ensure active image is up
		if (de.src != docroot + 'images/de_active.jpg') {
			de.src = docroot + 'images/de_active.jpg'
		}
		//grey out other images
		it.src=image1.src;
		pss.src=image2.src;
		ws.src=image4.src;
	} else if (section == 4) {
	//ensure active image is up
		if (ws.src != docroot + 'images/ws_active.jpg') {
			ws.src = docroot + 'images/ws_active.jpg'
		}
		//grey out other images
		it.src=image1.src;
		pss.src=image2.src;
		de.src=image3.src;
	}
}

//rotate content
function rotateContent(panelId) {
   setInterval("switchPanel('"+panelId+"')", 10000);
}

function switchPanel(panelId) {
   // (do something here)
   var panelArray = eval(panelId).getContentPanels();
	 var currIndex = eval(panelId).getCurrentTabIndex();
   var nextIndex = eval(panelId).getCurrentTabIndex() + 1;
   var numPanels = eval(panelId).getTabbedPanelCount();
	 var currPanelId = panelArray[currIndex].id
	 
   /*var effect = new Spry.Effect.Fade(currPanelId, { from: 100, to: 0, duration: 1000, toggle: true, finish:showNext(panelId, nextIndex), transition: Spry.sinusoidalTransition, fps: 60 });
   effect.start();
   */
	 
   if (nextIndex == numPanels) {
      nextIndex = 0;
   }

   eval(panelId).showPanel(nextIndex);
      
   //alert(contentPanelsArray.length);
}

function showNext(panelId, nextIndex){
	eval(panelId).showPanel(nextIndex);
}

