/**** Ind/ Cap Menus ****/	   
	$('#nav-ind,#nav-cap').hover( function(){ $(this).children('li').show()}, 
		function(){$(this).children('li:not(:first-child)').hide()});
	$('#nav-ind > li > ul').parent().children('a').append(' <span style="float:right">&raquo;</span>');
	
	$('#nav-ind:first-child,#nav-cap:first-child').toggle( function(){ $(this).children('li').show()}, 
		function(){$(this).children('li:not(:first-child)').hide()});
	$('#nav-ind > li > ul').parent().children('a').append(' <span style="float:right">&raquo;</span>');
	
	/** If IE 7 or less **/ 

/**** Slider ****/
	if ($('#slider').length){

	    function randOrd() { return(Math.round(Math.random())-0.5); }
			$("#largeSlider").children("ul").each(function() {
				var $this = $(this);
				var $children = $this.children();
				var childCount = $children.length;
 
				if (childCount > 1) {
					$children.remove();
					var indices = new Array();
					for (i=0;i<childCount;i++) { indices[indices.length] = i; }
					indices = indices.sort(randOrd);
					$.each(indices,function(j,k) { $this.append($children.eq(k)); });
				}
		});
		$('#slider').show().anythingSlider(); 
		$('#largeSlider, #smallSlider').removeClass('visuallyhidden');
	}
/**** Main Section ****/	
	if($('#main > h4 > a').length){
		$('#main > h4 > a').append('<div class="arrow-blue"></div>')	
	}
	
	if($('.industryItem > h4 > a').length){
		$('.industryItem > h4 > a').append('<div class="arrow-blue"></div>')	
	}
/*** Sidebar1 ****/
	if ($('.insight_button').length){
		$('.insight_button').append('<div class="arrow-white"></div>')
	}

/**** Sidebar2 collapsible Menus ****/
	if ($('#aside2').length){
		/* Adds arrows */
		if($(".sidebar-section-insights > ul >li:nthchild(2):visible")){
			$(".sidebar-section-insights > ul >li:first-child > .arrow-white").addClass("arrow-white-down");
		}
		$('.sidebar-section, .sidebar-section-insights').click(
			function(){
				$(this).children("ul").children("li:not(:first-child)").toggle(0);
				$(this).children("ul").children("li").children(".arrow-white").toggleClass("arrow-white-down");
			}
		);
		/* Zebra striping*/
		$(".sidebar-section > ul > li:odd, .sidebar-section-insights > ul > li:odd").addClass("even");
		if($('.aside-textbox').length){
			$(".aside-textbox > p:odd").addClass("even");
		}
	}
	
/**** Home sections ****/	
if($('.section').length){
	$('.section').hover(
	  function () {
		$(this).children('.home-slideout').filter(':not(:animated)').animate({
			left: 310
		},300);
		$(this).children('.home-content').children('p').addClass('home-slideout-text');
		$(this).children('.home-content').children('h2').addClass('home-slideout-text');		
	  },
	  function () {
		$(this).children('.home-slideout').animate({
			left: 0
		},
		600,
		function(){
			$(this).parent().children('.home-content').children('p').removeClass('home-slideout-text')
			$(this).parent().children('.home-content').children('h2').removeClass('home-slideout-text')
		});	

		
	  }
	);
}
/**** Search ****/

$('#search').keyup(function(e) {
    if(e.keyCode == 13) {
    	window.location = "http://www.oliverwyman.de/search.htm?q=" + escape($("#search").val());
    }
});
$("#search-submit").click(function () {
	window.location = "http://www.oliverwyman.de/search.htm?q=" + escape($("#search").val());								
});


/**** Insights Search ****/
if ($('#InsightsForm').length){
	ind = $('#insight-filter-ind').val();
	cap = $('#insight-filter-cap').val();
	q = $('#search-ins').val();
	ic = $('#search-ic').val();
	
	if (ind != ""){
		$('#insightsFrame').load('insightSearch.xml?ind='+ind+'').fadeIn();
	}	
	if (cap != ""){
		$('#insightsFrame').load('insightSearch.xml?cap='+cap+'').fadeIn();
	}	
	if (q != ""){
		$('#insightsFrame').load('insightSearch.xml?q='+q+'').fadeIn();
		$('#search-ins').val(q);
	}
	
	if (ind == "" && cap =="" && ic != ""){
		if (ic == "Industrial Products"){ ic ="Industrial Products & Services"}
		if (ic == "Business & Organization Transformation" || ic == "CEO Effectiveness"	){
				ic = "Delta"}
		if (ic == "Corporate Finance & Restructuring"){ ic ="Corporate Finance"}		
		$('#insightsFrame').load('insightSearch.xml?ic='+ encodeURI(ic).replace("&","%26") + '').fadeIn();
		$('#search-ic').val(encodeURI(ic.replace("&amp;","%26")));
	}
	
	$('#insight-filter-ind').change(
		function(){
			$('#insightsFrame').fadeOut();
			ind = $('#insight-filter-ind').val();	
			$('#insightsFrame').load('insightSearch.xml?ind='+ind+'').fadeIn();	
			$('#insight-filter-cap').val("");
		}
	)
	$('#insight-filter-cap').change(
		function(){
			$('#insightsFrame').fadeOut();
			cap = $('#insight-filter-cap').val();
			if (cap == "Business%20%26%20Organizational%20Transformation" || cap == "CEO%20Effectiveness"	){
				cap="Delta"
			}
			$('#insightsFrame').load('insightSearch.xml?cap='+cap+'').fadeIn();	
			$('#insight-filter-ind').val("");
		}
	)
	
	$('#search-ins-go').click(function(){
			$('#insightsFrame').fadeOut();
			q = $('#search-ins').val();
			if( q != ""){				
				$('#insightsFrame').load('insightSearch.xml?q='+q+'').fadeIn();
			}
			else{
				$('#insightsFrame').load('insightSearch.xml?ins=all').fadeIn();
			}
	});
	
	$('#search-ins').keyup(function(e) {
    	if(e.keyCode == 13) {   
    		$('#insightsFrame').fadeOut();
			q = $('#search-ins').val();
			if( q != ""){				
				$('#insightsFrame').load('insightSearch.xml?q='+q+'').fadeIn();
			}
			else{
				$('#insightsFrame').load('insightSearch.xml?ins=all').fadeIn();
			}
    	}
	});
}


/* Maps Columns */

if ($('#office_list').length){

	if ($('#office_list > ul >li').length > 10){
		$('#office_list').columnize({ columns: 3 });
	}	
}

