// Init Navigation
function initNavigation() {
	if (location.href.split('#')[1] != null)
		highlightMenu('mi-'+location.href.split('#')[1]);
}

function changeColor(obj,state) {
	if (state == "on")
		obj.style.color='#e16d26'
	else
		obj.style.color='#122959'
}

// Highlight Navigation Menu
function highlightMenu(menuSelection) 
{
  var menu = document.getElementById('header');
	var menuItem = menu.getElementsByTagName('a');
   //reset all menu item color
   for ( var t = 0; t < menuItem.length; ++t ) {
		if (menuItem[t].id != "mi-homepage") {
			menuItem[t].style.color = "#555555";
			menuItem[t].style.fontSize = "13px";
			menuItem[t].style.borderTop = "0px solid #353b43";
			menuItem[t].style.fontWeight = "bold";
			menuItem[t].style.background = "";
		}
	}
	var selectedItem = document.getElementById(menuSelection);
	if (menuSelection != "mi-homepage") {
		selectedItem.style.color = "#df6325";
		selectedItem.style.fontSize = "13px";
		selectedItem.style.borderTop = "0px solid #df6325";
		selectedItem.style.fontWeight = "bold";
		selectedItem.style.background = "url('images/bgMenuItem.png') no-repeat";
	}
}

// Rotate logos
$(function() {
	$(".logoCarousel").jCarouselLite({
		btnNext: ".logoNext",
		btnPrev: ".logoPrev",
		mouseWheel: true,
		auto: 2000,
		visible: 1,
		//vertical: true,
		//circular: false,
		easing: "backout",
		scroll: 1, //scrolling more than 1 item at a time
		speed: 500
	});
	
	// Rotate testimonials
	$(".testimonialsCarousel").jCarouselLite({
		btnNext: ".testimonialsNext",
		btnPrev: ".testimonialsPrev",
		mouseWheel: true,
		//auto: 25000,
		visible: 1,
		vertical: true,
		//circular: false,
		//easing: "backout",
		scroll: 1, //scrolling more than 1 item at a time
		speed: 1500
	});
});

// Slide Panel: http://www.ultramegatech.com/blog/2009/06/create-a-slide-in-panel-jquery/
	var sipPos = 0;
	$(document).ready(function() {
		$("#sitemapPanelHandle").click(function() {
			$("#sitemapPanel").animate({ left: sipPos }, 800, 'linear', function() {
			if(sipPos == 0) { sipPos = -273; }
			else { sipPos = 0; }
		});
	});
	
	// Show Menu
	// http://wkamwai.googlepages.com/
	// http://wkamwai.googlepages.com/test.html
	$("#mainmenu li:nth-child(even)").hide();
	$("#mainmenu li:nth-child(odd)").click(
		function(){
		if($(this).next().css("display")=="none" ){
			$(this).parent().find("li:nth-child(even)").slideUp("fast");
			$(this).parent().find("li:nth-child(odd)").removeClass("selected");
			$(this).addClass("selected").next().slideDown("fast");
			}else{
			$(this).next().slideUp("fast");
			} 
		}
	);
});
