/**** 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){
		$('#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();
				$(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.com/search.htm?q=" + escape($("#search").val());
    }
});
$("#search-submit").click(function () {
	window.location = "http://www.oliverwyman.com/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();	
			$('#Insights-search-frame').removeClass('error');
			$('#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();
			$('#Insights-search-frame').removeClass('error');
			$('#insight-filter-ind').val("");
		}
	)
	
	$('#search-ins-go').click(function(){
		q = $('#search-ins').val();							    
		if(q == ""){
			$('#Insights-search-frame').addClass('error');
		}
		else{
			$('#insightsFrame').fadeOut();
			$('#insightsFrame').load('insightSearch.xml?q='+escape(q)+'').fadeIn();
			$('#Insights-search-frame').removeClass('error');
                  console.log(q);  
		}
	});
	
	$('#search-ins').keyup(function(e) {
    		if(e.keyCode == 13) {   
			q = $('#search-ins').val();
			if(q == ""){
				$('#Insights-search-frame').addClass('error');
			}
			else{
				$('#insightsFrame').fadeOut();
				$('#insightsFrame').load('insightSearch.xml?q='+ escape(q) +'').fadeIn();
				$('#Insights-search-frame').removeClass('error');
			}
    		}
	});
}


/* Maps Columns */

if ($('#office_list').length){

	if ($('#office_list > ul >li').length > 10){
		$('#office_list').columnize({ columns: 3 });
	}	
}

/* */
if ($('.contact_form_link').length){
	$('.contact_form_link').fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',							 
		'width': 500,
		'height': 800
	});	
}

