// JavaScript Document
$(function(){
	var path = location.pathname.substring(location.pathname.lastIndexOf('/')+1);
	if ( path )
		$('.subnav > li a[href$="' + path + '"]').attr('class', 'active');
});

function updateMainContent(section) {
	var content = document.getElementById('topmaincontent');
	var newContent;
	var newClass;
	var newTitle;
	if (section == 1) {
		newContent = '<a href="#" onclick=\'window.open("solutions/it/side-it-cs1.html","itwindow","location=0,menubar=0,resizable=0,scrollbars=1,width=579,height=700");\'><img src="./images/pixel.png" width="30" height="30" style="position:absolute; border:0px dotted red; z-index:10; top:100px; left:800px;"></a>';
		newClass = 'it';
		newTitle = 'Kratos Information Technology Solutions operates and hosts facility to develop eTools, supporting DCMA mission.';
	} else if (section == 2) {
		newContent = '<a href="#" onclick=\'window.open("solutions/pss/side-pss-cs.html","pswindow","location=0,menubar=0,resizable=0,scrollbars=1,width=579,height=700");\'><img src="./images/pixel.png" width="30" height="30" style="position:absolute; border:0px dotted red; z-index:10; top:100px; left:790px;"></a>';
		newClass = 'pss';
		newTitle = 'Kratos Public Safety & Security develops fire alarm network for the world\'s busiest passenger airport.';
	} else if (section == 3) {
		newContent = '<a href="#" onclick=\'window.open("solutions/de/side-de-cs1.html","dewindow","location=0,menubar=0,resizable=0,scrollbars=1,width=579,height=700");\'><img src="./images/pixel.png" width="30" height="30" style="position:absolute; border:0px dotted red; z-index:10; top:100px; left:825px;"></a>';
		newClass = 'de';
		newTitle = 'Kratos engineers install the latest C4I systems on U.S. Pacific Fleet submarines.';
	} else if (section == 4) {
		newContent = '';
		newClass = 'wss';
		newTitle = 'Kratos is a world-class provider of Weapons System Support services. Our highly-trained and specialized staff have years of experience in logistics, engineering, and target operations support, as well as international programs, technology initiatives, and advanced weapon system research and engineering.';
	} 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/it_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/it_active.jpg') {
			it.src = docroot + 'images/it_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+"')", 30000);
}

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);
}
