
var $j = jQuery.noConflict();
var MC = {}; //namespace for dotcom
MC.timeSlider = false; 

//document ready
$j(function() {
	/*This function controlls the hover state of the global nav. It adds a slow delay ~1000 ms and sets the background color of the hovered element accordingly*/
    hiConfig = {
        sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)
        interval: 100, // number = milliseconds for onMouseOver polling interval
        timeout: 0, // number = milliseconds delay before onMouseOut
        over: function() {
            $j(this).children('.flyout-container').fadeIn('fast');
			$j(this).children('.parent').css('backgroundColor','#00adef');
        }, // function = onMouseOver callback (REQUIRED)
        out: function() { 
			$j(this).children('.flyout-container').hide();
			$j(this).children('.parent').css('backgroundColor','');
		}
    }
	
   $j("#nav li").hoverIntent(hiConfig);
   
   	//fix for the bouncing of the contact us footer in IE
	$j(".contactUsFooter").hover(
		function(){
			$j(".arrowRightFooter").css('backgroundPosition','-127px -152px');
		},function(){
			$j(".arrowRightFooter").css('backgroundPosition','-157px -152px');
		}
	);	

	/*fix for IE for the z-index state uppon hovering the share moudle the download widget
	is still showing on top*/
	$j(".downloadWidget>ul>li.dd").hover(
		function () {
		    $j(this).css('position','relative');
		  }, 
		  function () {
		    $j(this).css('position','');
		  }
	);

	//contact us form message toggle on checkbox click event

	$j(".dotComFormOpt").click(function(){
		var toShow = $j(this).attr('data');
		$j(".radioShowMsg").children('div').hide();
		$j(".radioShowMsg").find("#"+toShow).toggle();
		
	});

	
	
	//fix for the last bottom border in the recommended results in searchresults

	$j('.recRes:last-child').addClass("noBotBorder");
	
	
    $j("#form-search-inner").keypress(function(e) {

		var code = (e.keyCode ? e.keyCode : e.which);
		 if(code == 13) { //Enter keycode
		   var focusE = $j(document.activeElement);
			if($j(focusE).attr('id')=='TextBoxSearch'){
				$j(".mck_formRow").each(function(){
					$j(this).children('select').removeAttr('required');
					$j(this).children('input').removeAttr('required');
					$j(this).children('textarea').removeAttr('required');
				});
			}
		 }
	
	});	

		// Login Container
		
		$j(".loginClick").click(function(){
			$j(this).siblings(".loginBox").toggle();
		});

		$j(".goTo123").click(function(){
			var usr = $j("#login").val();
			var psw = $j("#password").val();
			var checkReg = usr;
			checkReg = checkReg.match(/[@|'|^|*|?|<|>|=|#|%|{|}|\[|\]|\:|\;|(|)|$\/]/g);
			if(checkReg==null){
				checkReg="";
			}
			if(usr.length === 0 || psw.length===0 || checkReg.length !==0){
				$j(".error").show();
			}

			//do reg
			alert("userName "+usr+" password "+psw);
		});
		$j("#login, #password").keyup(function(){
			$j(".error").fadeOut("slow");
		});


		
	$j("#ImageButtonSearch").click(function(){
		var focusE = $j(document.activeElement);
		$j(".mck_formRow").each(function(){
			$j(this).children('select').removeAttr('required');
			$j(this).children('input').removeAttr('required');
			$j(this).children('textarea').removeAttr('required');
		});
		
	});
	
	//search for the input box on the global nav when
	//the magnifying glass is clicked
	$j(".magniGlass").click(function(){
		var str = $j("#TextBoxSearch").val();
		str = str.replace(/[@|'|^|*|?|<|>|=|#|%|{|}|\[|\]|\:|\;|(|)|$\/]/g,"");
		str = str.replace(/&/g,"%26");
		
		if (str !== '') {
			window.location = "/Search.aspx?q=" + str;
		}else{
		}
		
	});	
	
	//search for the input box in the globa nav
	//when the user left clicks
	$j("#TextBoxSearch").click(function(){
		var searchFor = $j(this).val();
		if(searchFor ==="Search"){
			
			$j(this).val('');
		}
	});
	
	//search for the input box on the global nav when
	//the magnifying glass is clicked
	$j(".magGlass").click(function(){
		var str = $j("#MGITextBoxSearch").val();
		str = str.replace(/[@|'|^|*|?|<|>|=|#|%|{|}|\[|\]|\:|\;|(|)|$\/]/g,"");
		str = str.replace(/&/g,"%26");
		
		if (str !== '') {
			window.location = "/Search.aspx?q=" + str + "&collection=Knowledge";
		}else{
		}		
	});	
	
	//search for the input box in the globa nav
	//when the user left clicks
	$j("#MGITextBoxSearch").click(function(){
		var searchFor = $j(this).val();
		if(searchFor ==="Search the knowledge center"){
			$j(this).val('');
		}
	});	

	$j("#TextBoxSearch").keypress(function(e){
		var str = $j(this).val();
		if(str.length !==0){
			if(e.keyCode==13){
				
				if(str==''){
					return false;
				}else{
					str = str.replace(/[@|'|^|*|?|<|>|=|#|%|{|}|\[|\]|\:|\;|(|)|$\/]/g,"");
					str = str.replace(/&/g,"%26");
					str = str.replace(/ /g,"%20");
					window.location = "/Search.aspx?q=" + str;
					return false;
				}
				
			}
		}
	});

	$j("#MGITextBoxSearch").keypress(function(e){
		var str = $j(this).val();
		if(str.length !==0){
			if(e.keyCode==13){
				
				if(str==''){
					return false;
				}else{
					str = str.replace(/[@|'|^|*|?|<|>|=|#|%|{|}|\[|\]|\:|\;|(|)|$\/]/g,"");
					str = str.replace(/&/g,"%26");
					str = str.replace(/ /g,"%20");
					window.location = "/Search.aspx?q=" + str + "&collection=Knowledge";
					return false;
				}
				
			}
		}
	});


	//stay connected module
	$j(".stayConnectedList>li>a[title]").click(function(){
	
		var path = $j(this).attr('title');
		
		window.open(path,'_blank');
		
	})

   /////////////////////////////////////
   ////////////////////////////////////////
   ///////////// CAREERS CODE //////////////
   ///////////////////////////////////////
   /////////////////////////////////////
   
   
   
   
   //click event for the tabs in the hero timeline image
   
	//check the timeslider tab to sere how many elements it has
		MC.timeSlideE = 0;
		MC.timeSlideCont = 0;
		MC.timeSlieDesc = 0;
		MC.timeSlideContSib = 0;
		MC.timeSlideOpen = 0;
		MC.timeSlideLeftMar = 0;
		$j(".timeSliderTab").each(function(){
			MC.timeSlideE++;
		});
		
	//fix the layout of the timeline
		function fixTimeLine(count){
			switch (count)
			{
			case 5:
			  MC.timeSlideCont = 71;
			  MC.timeSlideContSib = 255;
			  MC.timeSlideOpen = 258;
			  MC.timeSlideLeftMar = 171.5;
			  break;
			case 4:
			  MC.timeSlideCont = 71;
			  MC.timeSlideContSib = 285;
			  MC.timeSlideOpen = 361;
			  MC.timeSlideLeftMar = 270.5;
			  break;
			case 3:
			  MC.timeSlideCont = 71;
			  MC.timeSlideContSib = 285;
			  MC.timeSlideOpen = 455;
			  MC.timeSlideLeftMar = 370;
			  break;
			case 2:
			  MC.timeSlideCont = 71;
			  MC.timeSlideContSib = 285;
			  MC.timeSlideOpen = 565;
			  MC.timeSlideLeftMar = 480;
			  break;
			case 1:
			  //document.write("Sleepy Sunday");
			  break;
			default:
			  //document.write("I'm looking forward to this weekend!");
			}
			
			if(count<5 && count>0){
				$j(".timeSliderTab").each(function(){
					if ($j(this).hasClass('noBgImg')) {
						$j(this).children(".timeSliderCont").css('width',MC.timeSlideOpen+'px');
					}
					else {
						//$j(this).addClass("timeSliderTabOver");
						if ($j(this).find(".descTitle").hasClass("black")) {
						
						}
						else {
							$j(this).find(".descTitle").css('width', '71px');
						}
					}
				});
			}
		}
		

		
		fixTimeLine(MC.timeSlideE);


	  $j(".timeSliderTab").click(function(){
	   		if(MC.timeSlider == false){
				MC.timeSlider = true; //st the timeslider var to true in order to prevent other clickng events on the timeframe
				
				//we need to first move the siblings in order
				//to make space for the clicked element
				$j(this).siblings().animate({
					marginLeft:0
				}).removeClass("noBgImg");
				
				$j(this).siblings().children(".timeSliderCont").each(function(){
					$j(this).animate({
						marginLeft:10,
						paddingLeft:0,
						width:MC.timeSlideCont
					});
					$j(this).children(".descTitle").removeClass("black").siblings(".desc").hide();
				});
				
				
				
				//then we take care of the clicked element
				
				$j(this).animate({
					marginLeft:MC.timeSlideLeftMar
			   	}).addClass("noBgImg");
				$j(this).find(".descTitle").css('width','auto');

				$j(this).children(".timeSliderCont").animate({
					marginLeft:MC.timeSlideLeftMar*-1,
					width:MC.timeSlideContSib,
					paddingLeft:10,
					width:MC.timeSlideOpen
				},function(){
					$j(this).children(".desc").fadeIn('slow');
					MC.timeSlider = false;
				}).children(".descTitle").addClass("black");
				
				
			}
	   });
	   
	   //hover event for the timeslider tab
	   
	   $j(".timeSliderTab").hover(
	   		function(){
				$j(this).addClass("timeSliderTabOver");
			},function(){
				$j(this).removeClass("timeSliderTabOver");
		});
	   
   
   
   //FAQ EVENTS
   $j(".questionCont").click(function(){
   		$j(this).children(".faqAnswer").slideToggle("slow");
		if($j(this).children(".expandQuest").size()!==0){
			$j(this).find(".expandQuest").removeClass("expandQuest").addClass("hideQuest");
			$j(this).addClass("selAnswer");
			$j(this).find(".blueQuestion").addClass("blackQuestion");
		}else{
			$j(this).find(".hideQuest").removeClass("hideQuest").addClass("expandQuest");
			$j(this).removeClass("selAnswer");
			$j(this).find(".blueQuestion").removeClass("blackQuestion");
		}
		
		
   });
   
   $j(".questionCont").hover(
	function(){
		$j(this).addClass("overAnswer");
	},function(){
		$j(this).removeClass("overAnswer");
	})
	
	$j(".showAllAnsw").click(function(){
		var currentTxt = $j(this).find(".txtLg");
		//if we want to show
		if($j(currentTxt).text()=="Show all answers"){
			$j(currentTxt).text("Hide all answers");
			$j(currentTxt).prev().addClass("arrowUpIco");
			$j(this).siblings('.qMainCont').children('div').each(function(){
				$j(this).addClass("selAnswer");
				$j(this).find(".faqAnswer").slideDown("slow");
				$j(this).find(".expandQuest").removeClass("expandQuest").addClass("hideQuest");	
				$j(this).find(".blueQuestion").addClass("blackQuestion");
							
			});
		}else{
			//if we want to hide
			$j(currentTxt).text("Show all answers");
			$j(currentTxt).prev().removeClass("arrowUpIco");
			$j(this).siblings('.qMainCont').children('div').each(function(){
				$j(this).removeClass("selAnswer");
				$j(this).find(".faqAnswer").slideUp("slow");
				$j(this).find(".hideQuest").removeClass("hideQuest").addClass("expandQuest");	
				$j(this).find(".blueQuestion").removeClass("blackQuestion");
							
			});
		}
		
		
	});
	
	
	
	//school finder clear input on click
	$j(".schFindInp").click(function(){
		var e = $j(this).val();
		if(e=='Find your school'){
			$j(this).val('').css('color','#000');
		}
		
	})
	
	//video click event that maximizes "video"
	$j(".videoThumb").click(function(){
		var pathToVid = $j(this).parent().siblings('a').attr('href');
		$j(this).parent().siblings('div').remove();
		var toAppend ='<embed width="510" height="395" src="/global_resources/dotcom/js/video/player.swf"';
			toAppend+='type="application/x-shockwave-flash" allowfullscreen="false" name="player"';
			toAppend+='allowscriptaccess="always" id="" flashvars="file='+pathToVid+'&amp;autostart=true&amp;';
			toAppend+='skin=/global_resources/dotcom/js/video/glow.zip&amp;image=/~/media/McKinsey/dotcom/Careers/keydrivers_150x84.ashx&amp;';
			toAppend+='stretching=fill&amp;controlbar.position=over&amp;plugins=gapro-1&amp;gapro.accountid=UA-20614377-1&amp;';
			toAppend+='gapro.trackstarts=true&amp;gapro.trackpercentage=true&amp;gapro.tracktime=true&amp;';
			toAppend+='gapro.idstring=Video: Spending in the right places to reach more priority customers" wmode="opaque">';
		var putIn = $j(this).parent().parent();

		$j(this).animate({
			width:510,
			height:287
		},function(){
			$j(this).fadeOut("slow",function(){
				$j(putIn).append(toAppend);
			});
			
		});
		$j(this).parents('td').next('td').children('p').css('width','510px');
		$j(this).css('cursor','default');
		var content = $j(this).parents('td').next('td').html();
		
		$j(this).parents('td').next('td').children().remove();
		$j(this).parents('tbody').append('<tr><td><div style="padding:10px 0">'+content+'</div></td></tr>');
		
	});
	
	//video click event that maximizes "video" but for the fake play button click
	$j(".fakePlay").click(function(){
		$j(this).css('visibility','hidden');
		var pathToVid = $j(this).next('a').attr('href');
		var toSend = makeFla(pathToVid);
		
		var putIn = $j(this).parent('td');
		
		$j(putIn).find('img').animate({
			width:510,
			height:287
		},function(){
			$j(this).fadeOut("slow",function(){
				$j(putIn).append(toSend);
			});
		});
		
		$j(this).parents('td').next('td').children('p').css('width','510px');
		$j(this).css('cursor','default');
		var content = $j(this).parents('td').next('td').html();
		
		$j(this).parents('td').next('td').children().remove();
		$j(this).parents('tbody').append('<tr><td><div style="padding:10px 0">'+content+'</div></td></tr>');
		
		
	});
	
	//Inline Video (IVI) click event to show the video
	$j(".playIvi").click(function(){
		$j(this).siblings('.fakePlayCircleContainer').children('.fakePlayCircle').remove();
		var pathToVid = $j(this).siblings('a').attr('href');
		var toSend = makeFla(pathToVid);

		
		$j(this).parent(".floatVidleft").css({
			'borderBottom':'0',
			'float':'none',
			'marginBottom':'25px'
		});
		$j('.floatVidleft #descriptionDiv, .floatVidleft .descriptionDiv').css('paddingBottom','20px');
		$j(this).animate({
			width:500
		},function(){
			$j(this).fadeOut("slow",function(){
				$j(this).after(toSend);
			});
			
		});
		
		$j(this).siblings('h4, div, h3').css('width','510px');		
		$j(this).siblings('.descriptionDiv').css('borderBottom','1px dotted #ebebeb');
		$j(this).siblings('div.clear').css('borderBottom','none');
		$j(this).siblings('ul').remove();
		
	});
	
	//Inline Video (IVI) click event to show the video but click on the fake video player button
	//$j(".fakePlayCircle").click(function(){
	//	$j(this).hide();
	//	var pathToVid = $j(this).parent().siblings('a').attr('href');
	//	var theImg = $j(this).parent().prev('img');
	//	var toSend = makeFla(pathToVid);
    //
	//	
	//	$j(theImg).parent(".floatVidleft").css({
	//		'borderBottom':'0',
	//		'float':'none',
	//		'marginBottom':'25px'
	//	});
	//	$j('.floatVidleft #descriptionDiv, .floatVidleft .descriptionDiv').css('paddingBottom','20px');
	//	$j(theImg).animate({
	//		width:500
	//	},function(){
	//		$j(theImg).fadeOut("slow",function(){
	//			$j(theImg).after(toSend);
	//		});
	//		
	//	});
		
		
	//	$j(this).parent().prev('img').siblings('h4, div, h3').css('width','510px');
	//	$j(this).parent().siblings('div').css('borderBottom','1px dotted #ebebeb');
	//	$j(this).parent().siblings('div.clear').css('borderBottom','none');
	//	$j(this).parent().prev('img').siblings('ul').remove();
		
	//});
	
	$j(".fakePlayCircleContainer").click(function() {    
	    if (! $j(this).hasClass('fakePlayCircle')) {
	        $j(this, '.fakePlayCircle').hide();
	        var pathToVid = $j(this).siblings('a').attr('href');
	        var theImg = $j(this).prev('img');
	        var toSend = makeFla(pathToVid);
	        $j(theImg).parent(".floatVidleft").css({
			    'borderBottom':'0',
			    'float':'none',
			    'marginBottom':'25px'
		    });
		    $j('.floatVidleft #descriptionDiv, .floatVidleft .descriptionDiv').css('paddingBottom','20px');
		    $j(theImg).animate({
			    width:500
		    },function(){
			    $j(theImg).fadeOut("slow",function(){
				    $j(theImg).after(toSend);
			    });
			});    
			$j(this).siblings('h4, div, h3').css('width','510px');
		    $j(this).siblings('div.descriptionDiv').css('borderBottom','1px dotted #ebebeb');
		    $j(this).siblings('div.clear').css('borderBottom','none');
		    $j(this).siblings('ul').remove();
	    }		
	});
	
	//inline video (IVI) click event frmo the link in the raquo
	$j(".playVidIviLink").click(function(e){
	    e.preventDefault();
	    var pathToVid = $j(this).parents('ul').siblings('a').attr('href');
		var theImg = $j(this).parents('ul').siblings('img');
		$j(theImg).next('.fakePlayCircle').hide();
		$j(theImg).siblings('.fakePlayCircleContainer').hide();
		$j(theImg).siblings('h3').css('width','500px');
		$j(this).fadeOut("slow");
		var toSend = makeFla(pathToVid);

		
		$j(theImg).parent(".floatVidleft").css({
			'borderBottom':'0',
			'float':'none',
			'marginBottom':'25px'
		});
		$j('.floatVidleft #descriptionDiv, .floatVidleft .descriptionDiv').css('paddingBottom','20px');
		$j(theImg).animate({
			width:500
		},function(){
			$j(theImg).fadeOut("slow",function(){
				$j(theImg).after(toSend);
			}); 	
			
		});
		
		
		$j(this).parents('ul').siblings('h4, h3, div').css('width','510px');
		$j(this).parents('ul').siblings('div').css('borderBottom','1px dotted #ebebeb');
		$j(this).parents('ul').siblings('div.clear').css('borderBottom','none');
		//$j(this).prev('img').siblings('ul').remove();
		$j(this).parents('ul').remove();
	});
	
	//hide the anchor tag used in the inline video
	$j(".iviHiddenAnchor").hide();
	

	//dobule Standard more link click
	$j(".dSMoreCont").click(function(){
		$j(this).prev().slideToggle('slow');
		$j(this).find('.sprite').toggleClass("arrowUpIco");
		var txt = $j(this).find('.sprite').next('span');
		if($j(txt).text()=='More'){
			$j(txt).text('Less');
		}else{
			$j(txt).text('More');
		}
		
	});
	
	//triger the function to check the filter story
	checkFilterStory();

	$j("#startApApplyCar").click(function(){
   		window.open('http://careers.mckinsey.com/app004/ressub.nsf/applynow?openform');
    });
   
   $j(".checkInputVal").click(function(){       
		var ddVal = $j(this).siblings(".appNowSel").attr('value');
		var goTo = "";
		
		if(ddVal=="Select a location"){
			$j(this).siblings(".roleSearError").show();
		}else{
			$j(".roleSearError").hide();
			if($j(this).context.id =="expert"){
				goTo = "http://recruiting.mckinsey.com/app004/position.nsf/SearchForm?ReadForm&Type=w&BA=Consulting&KA=All+Knowledge+Areas&Loc="+ddVal+"&Query=&Sort=title&start=1&count=10";
			}else{
				goTo = "http://recruiting.mckinsey.com/app004/position.nsf/SearchForm?ReadForm&Type=w&BA=Knowledge+Management+&+Research&KA=All+Knowledge+Areas&Loc="+ddVal+"&Query=&Sort=title&start=1&count=10";
			}
			window.open(goTo);
		}
   });
   
   //function that checks double inputs in careers for apply now
   $j("#checkDoubleInput").click(function(){
   		var roleVal = $j(this).siblings("#ddlRole").attr('value');
		var locationVal = $j(this).siblings("#ddlLocation").attr('value');
		if(roleVal=="Select a role" && locationVal == "Select a location"){
			
			$j(this).siblings(".roleSearError").show();			
			$j(this).siblings(".positionSearError").show();
			
		}else if(locationVal == "Select a location"){
			$j(this).siblings(".roleSearError").hide();	
			$j(this).siblings(".positionSearError").show();
		}else if(roleVal=="Select a role"){
			$j(this).siblings(".roleSearError").show();
			$j(this).siblings(".positionSearError").hide();
		}else{
			$j(this).siblings(".positionSearError, .roleSearError").hide();
			var goTo = 'http://recruiting.mckinsey.com/app004/position.nsf/SearchForm?ReadForm&Type=w&BA=' + roleVal + '&KA=All+Knowledge+Areas&Loc=' + locationVal + '&Query=&Sort=title&start=1&count=10';
			window.open(goTo);
		}
   });
	
	//filter story click events
	$j(".filterStoryContainer li").click(function(){
		
	});
   //END OF FAQ EVENTS
   
   
   //key up event from school finder in careers
   $j('.schFindInp').keyup(function(e) {	
	   	switch(e.keyCode)
		{
		case 8://backspace
			$j(".showingDropDown").children().remove();
			if($j(this).val()!=="" && $j(this).val().length >2){
				$j(".showingDropDown").children().remove();			
				var typed = $j(this).val();
				typed = typed.toLowerCase();
				getSchool(typed);	
			}else{
				$j(".showingDropDown").hide();
			}
			break;
		case 13://return
			var theDrop = $j(".schFindInp").val();
			
			if(theDrop.length!==0 && $j(".showingDropDown").children('div').size()!==0){
				var url = $j(".showingDropDown").find(".autoSugResSel").attr("togo");
				window.open(url,'_self');	
			}else{
				//go to the school not found page
				var url = schoolNotFoundUrl;	
				window.open(url,'_self');
			}
			break;
		case 38://arrow up
			var theDrop = $j(".showingDropDown");
			if($j(theDrop).css('display')=='block'){
				if($j(theDrop).find(".autoSugResSel").size()==1){
					//move the current position of 
					//selected element
					$j(".autoSugResSel").removeClass("autoSugResSel").prev().addClass("autoSugResSel");
				}else{
					//set the first element
					$j(theDrop).children("div:last-child").addClass('autoSugResSel');
				}
								
			}
			break;
		case 40://arrow down
			var theDrop = $j(".showingDropDown");
			if($j(theDrop).css('display')=='block'){
				if($j(theDrop).find(".autoSugResSel").size()==1){
					//move the current position of 
					//selected element
					$j(".autoSugResSel").removeClass("autoSugResSel").next().addClass("autoSugResSel");
				}else{
					//set the first element
					$j(theDrop).children("div:first-child").addClass('autoSugResSel');
				}
								
			}
			break;
		default:		
			if($j(this).val()!=="" && $j(this).val().length>2){
				if($j(".showingDropDown").css('display')=='none'){
					$j(".showingDropDown").css('display','block');
					
				}
				$j(".showingDropDown").children().remove();			
				var typed = $j(this).val();
				typed = typed.toLowerCase();
				getSchool(typed);
				$j(".showingDropDown").find(":first-child").addClass("autoSugResSel");	
			}
		}				  
	});	
	
	//hover event for school finder results in careers
	$j(".autoSugRes").live('hover',
        function (ev) {
            if (ev.type == 'mouseover') {
				$j(this).siblings("div").removeClass("autoSugResSel");
                $j(this).addClass("autoSugResSel");
            }

            if (ev.type == 'mouseout') {
                $j(this).removeClass("autoSugResSel");
            }
     });
	 
	 
	 //click event for school finder results in careers
	 $j(".autoSugRes").live('click',function(){
	 	var goTo = $j(this).attr('togo');
		$j(".showingDropDown").css('display','none');
		$j(".schFindInp").val('');
		window.open(goTo,'_self');
	 });
   
   
   ///////////////////////
   //// CODE FOR MGI  ////
   ///////////////////////
   
   $j(".whiteArrowBottomBGBlack").click(function(){				
		if($j(this).hasClass('whiteArrowBottomBGBlue')!==true)
		{
			$j(this).addClass('whiteArrowBottomBGBlue').removeClass('whiteArrowBottomBGBlack');
			$j(this).parent().addClass('textHeaderComboContainerBlue').removeClass('textHeaderComboContainerBlack');
			$j(this).parent().prev().addClass('headerComboContainerLeftBlue').removeClass('headerComboContainerLeftBlack');
			$j(this).parent().next().addClass('headerComboContainerRightBlue').removeClass('headerComboContainerRightBlack');
		}else{
			$j(this).addClass('whiteArrowBottomBGBlack').removeClass('whiteArrowBottomBGBlue');
			$j(this).parent().addClass('textHeaderComboContainerBlack').removeClass('textHeaderComboContainerBlue');
			$j(this).parent().prev().addClass('headerComboContainerLeftBlack').removeClass('headerComboContainerLeftBlue');
			$j(this).parent().next().addClass('headerComboContainerRightBlack').removeClass('headerComboContainerRightBlue');
		}
		
		$j(this).parent().parent().next().slideToggle('slow');
	});

    ///////////////////////
   //// CODE FOR I&P  ////
   ///////////////////////
   
	$j(".link-footnote").tooltip({position:'top center',offset:[10,8]});
});

//location finder in careers
function runLocationSearch(){
	var indusIntL = '';
	var officeLoc = '';
	var officeSize = '';
	$j(".IndustryOfInterestLeft").children('li').each(function(){
		if($j(this).children('input').is(':checked')){
			indusIntL+= $j(this).children('input').attr('itemid')+'|';
		}
	});
	
	
	
	$j(".IndustryOfInterestRight").children('li').each(function(){
		if($j(this).children('input').is(':checked')){
			indusIntL+= $j(this).children('input').attr('itemid')+'|';
		}
	});
	
	
	
	$j(".hdnIndustryOfInterests").val(indusIntL);
	
	
	$j(".OfficeLocation").children('li').each(function(){
		if($j(this).children('input').is(':checked')){
			officeLoc+= $j(this).children('input').attr('itemid')+'|';
		}
	});
	
	$j(".hdnOfficeLocations").val(officeLoc);
	
	
	$j(".OfficeSize").children('li').each(function(){
		if($j(this).children('input').is(':checked')){
			officeSize+= $j(this).children('input').attr('itemid')+'|';
		}
	});
	
	$j(".hdnOfficeSizes").val(officeSize);

}

function display(id, text){    
    if(text != "")
    {
        document.getElementById(id).innerHTML = text;
    }
    else
    {
        document.getElementById(id).innerHTML = '';
    }
}

function hide(id){
    document.getElementById(id).style.display = 'none';
}


//function for the school finder in careers
function getSchool(e){
	var searchFor = e;
	searchFor = searchFor.toLowerCase();

	$j.each(schoolCollection, function(key, value){
		var toAppend = $j('<div/>');
		var noRes = $j('<div/>');
		
		$j(toAppend).attr({
			'id': value.SchoolID,
			'toGo': value.SchoolUrl,
			'class': 'autoSugRes'
		});
		
		$j(noRes).attr({
			'id':'none',
			'class': 'autoSugRes'
		}).text('No suggestions');
		
		var keywords = value.Keywords;
		var toLoop = keywords.toString();
		var totKeyWords = toLoop.split(",");
		var schoolName = value.SchoolName;
		var schoolId = value.SchoolID;	
		var finalAdd ="";
		for (var i = 0, ii = totKeyWords.length; i<ii; i++){				
			if(totKeyWords[i].search(searchFor)!==-1){
				finalAdd+='<div id="'+value.SchoolID+'" toGo="'+value.SchoolUrl+'" class="autoSugRes">'+totKeyWords[i]+'</div>';
			}			
		}
		if ($j(".showingDropDown").children("#" + schoolId).size() == 0) {
			$j(".showingDropDown").append(finalAdd);
		
		}
			
	});
	
}

//function to detect if the filter story is selected and to add the span
function checkFilterStory(){
	var h = '';
	$j(".filterStoryContainer li").each(function(){
		h = $j(this).height();
		h+=13;
		if($j(this).hasClass("selected")){
			$j(this).prepend('<span><img src="/images/dotcom/global/navigation/testArrow.png" height="'+h+'px" class="fakeSelArrow"/></span>');			
			$j(this).prev('li').css('border-bottom','0');
			
		}
	});
}


//function that makes an embedded flash object, receivs the path and returns a strig with the flash object
function makeFla(e){
	var flash ='<embed width="510" height="395" src="/global_resources/dotcom/js/video/player.swf"';
			flash+='type="application/x-shockwave-flash" allowfullscreen="false" name="player"';
			flash+='allowscriptaccess="always" id="" flashvars="file='+e+'&amp;autostart=true&amp;';
			flash+='skin=/global_resources/dotcom/js/video/glow.zip&amp;image=/~/media/McKinsey/dotcom/Careers/keydrivers_150x84.ashx&amp;';
			flash+='stretching=fill&amp;controlbar.position=over&amp;plugins=gapro-1&amp;gapro.accountid=UA-20614377-1&amp;';
			flash+='gapro.trackstarts=true&amp;gapro.trackpercentage=true&amp;gapro.tracktime=true&amp;';
			flash+='gapro.idstring=Video: Spending in the right places to reach more priority customers" wmode="opaque">';

	return flash;
}

function unhide(divID,e) {
    var item = document.getElementById(divID);
    if (item) {
        item.className = (item.className == 'hidden') ? 'unhidden' : 'hidden';
    }
	var eClassName = e.className;
	if(eClassName=='more'){
		e.innerHTML='Close';
		e.className="closeMore";
	}else{
		if(e.className=='closeMore'){
			e.innerHTML='More';
			e.className="more";	
		}
	}

}
 


/*var textboxvalue*/
function doClear(obj) {
	obj.value = "";
}


function ImageButton_Click() {

	/*if (document.getElementById("<%=TextBoxSearch.ClientID%>").value == "" || document.getElementById("<%=TextBoxSearch.ClientID%>").value == "Search") {
		alert("Please enter one or more search terms");
		document.getElementById("<%=TextBoxSearch.ClientID%>").focus();
		return false;
	}*/
	//return true;
}

function checkForIEVersion(){
	var s = navigator.userAgent.toLowerCase();
	var isIE7 = /*@cc_on!@*/  false && (parseInt(s.match(/msie (\d+)/)[1]) >= 7); 
	if (isIE7 == true) {
		$j("#nav-footer").css('position','relative');
		$j("#nav-footer").css('position','absolute');
	}
}


function chekSpecCharSearch(e){
	$j(".specialCharMes").remove();
	var searchForClass = "."+e;
	
	var searchFor = $j(''+searchForClass+'').val();	
	var compareTo= new RegExp;
	compareTo=/[@|'|^|*|?|<|>|=|#|%|{|}|\[|\]|\:|\;|(|)|$\/]/g; // regex special chars
	var findSpec = searchFor.match(compareTo);
	//if ther is something to compare for
	
	if(searchFor!==''){	 
	  
		//check the regex
		if(findSpec != null ){		    
			$j("#rightframe_0_searchtermvalue").html('<h1 class="resultTextHeader">Sorry, your search included a disallowed character.</h1><br/>')			
			$j(".search_results_table").hide();
            $j(".horizSeparator").hide();			
			return false;
			
		}
		else
		{
		    
		}
	}else{
		
		//the user hasn't typed anything in		
		$j("#rightframe_0_searchtermvalue").html('<h1 class="resultTextHeader">Please enter one or more search terms.</h1>');		
		$j(".horizSeparator").hide();
		return false;
	}
}


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else {
     	var futdate = new Date()		//Get the current time and date
      	var expdate = futdate.getTime()  //Get the milliseconds since Jan 1, 1970
      	expdate += 3600*1000  //expires in 1 hour(milliseconds)
      	futdate.setTime(expdate)
      	var expires = "";
      	expires = "; expires=" + futdate.toGMTString()
	}
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


function ResetSliderCookie() {
	eraseCookie("slider");
}


/*Function to send an email to a particual address*/
function emailForm(sendTo){						
	win = window.open('mailto:'+sendTo,'emailWindow');
	if (win && win.open &&!win.closed) win.close();
}

