/*------------------------------------------------------------------------ //
   Microsoft / COSD Microsite
   -----------------------------------------------------------------------
   Description:  Custom JavaScript for the COSD microsite.
   Filename:     custom.js
   Requires:     jquery-1.2.6.pack.js
   ----------------------------------------------------------------------- */

/* ======================================================================= //
   AUTOLOAD:
   The following code is executed as soon as the DOM is ready.
   ======================================================================= */
$(function(){
	$(window).bind("load", function() {
		$.preloadImages("images/home/bg_p1.jpg",
					"images/home/popup_p1_copy.gif",
					"images/home/popup_p1.gif",
					"images/home/bg_p2.jpg",
					"images/home/popup_p2_copy.gif",
					"images/home/popup_p2.gif",
					"images/home/bg_p3.jpg",
					"images/home/popup_p3_copy.gif",
					"images/home/popup_p3.gif",
					"images/home/bg_p4.jpg",
					"images/home/popup_p4_copy.gif",
					"images/home/popup_p4.gif",
					"images/home/bg_p5.jpg",
					"images/home/popup_p5_copy.gif",
					"images/home/popup_p5.gif",
					"images/home/bg_p6.jpg",
					"images/home/popup_p6_copy.gif",
					"images/home/popup_p6.gif",
					"images/common/item_all_jobs.gif",
					"images/common/item_dev_jobs.gif",
					"images/common/item_prog_manag_jobs.gif",
					"images/common/item_test_jobs.gif",
					"images/common/item_operations_jobs.gif",
					"images/common/item_syst_engin_jobs.gif",
					"images/profile/bg_scroll.gif",
					"images/profile/bg_scrolltrack.gif",
					"images/profile/bg_profile_box.jpg",
					"images/profile/bg_tech_box.jpg");
	});
	
	$("#hsp1").bind("mouseenter",function() {
			
			$("#bg_p1").fadeIn("def").css({ zIndex:"400" });
			$("#bg_popup_p1").fadeIn("def").css({ zIndex:"405" });
			$("#hsp1").click(function() {
				location.href = "profile6.html";
			});
		}).bind("mouseleave",function() {
			$("#bg_p1").fadeOut("def");
			$("#bg_popup_p1").fadeOut("def");
	});
	
	$("#hsp2").bind("mouseenter",function() {
			$("#bg_p2").fadeIn("def").css({ zIndex:"400" });
			$("#bg_popup_p2").fadeIn("def").css({ zIndex:"405" });
			$("#hsp2").click(function() {
				location.href = "profile5.html";
			});
		}).bind("mouseleave",function() {
			$("#bg_p2").fadeOut("def");
			$("#bg_popup_p2").fadeOut("def");
	});
	
	$("#hsp3").bind("mouseenter",function() {
			$("#bg_p3").fadeIn("def").css({ zIndex:"400" });
			$("#bg_popup_p3").fadeIn("def").css({ zIndex:"405" });
			$("#hsp3").click(function() {
				location.href = "profile1.html";
			});
		}).bind("mouseleave",function() {
			$("#bg_p3").fadeOut("def");
			$("#bg_popup_p3").fadeOut("def");
	});
		
	$("#hsp4").bind("mouseenter",function() {
			$("#hsp5_5").css({ display:"block",zIndex:"415" });
			$("#bg_p4").fadeIn("def").css({zIndex:"400"});
			$("#bg_popup_p4").fadeIn("def").css({ zIndex:"405" });
			$("#hsp4").click(function() {
				location.href='profile2.html'
			});
		}).bind("mouseleave",function() {
			$("#bg_p4").fadeOut("def");
			$("#bg_popup_p4").fadeOut("def");
			$("#hsp5_5").css({display:"none"});
	});
	
	$("#hsp5").bind("mouseenter",function() {
			$("#bg_p5").fadeIn("def").css({ zIndex:"400" });
			$("#bg_popup_p5").fadeIn("def").css({ zIndex:"405" });
			$("#hsp5").click(function() {
				location.href = "profile3.html";
			});
		}).bind("mouseleave",function() {
			$("#bg_p5").fadeOut("def");
			$("#bg_popup_p5").fadeOut("def");
	});
		
	$("#hsp6").bind("mouseenter",function() {
			$("#bg_p6").fadeIn("def").css({ zIndex:"400" });
			$("#bg_popup_p6").fadeIn("def").css({ zIndex:"405" });
			$("#hsp6").click(function() {
				location.href = "profile4.html";
			});
		}).bind("mouseleave",function() {
			$("#bg_p6").fadeOut("def");
			$("#bg_popup_p6").fadeOut("def");
	});	
	
	if(jQuery.browser.version.charAt(0) == "6" && jQuery.browser.msie) {
		$("#menu").bind("mouseenter",function() {
			$("#menu ul").css({ display:"block",width:"157px",height:"71px" });
		}).bind("mouseleave",function() {
			$("#menu ul").css({ display:"none",width:"157px",height:"71px" });
	});}
		
	if(jQuery.browser.safari) {
		$("#bg_popup_p6_copy").css({marginLeft:"2px"})
	}
});

/* ======================================================================= //
   SHOWBOX:
   The following code displays and positions the small orange popup boxes
   in the profile box.
   ======================================================================= */
function showbox(id,id_div,state) {
	var offset = $(id).offset();
	var display;
	var y = 18;
	var x = 0;
	
	if(state)
		divdisplay = "block";
	else
		divdisplay = "none";

	$("#" + id_div).css({ top:(offset.top + y) + "px",left:(offset.left + x) + "px",display:divdisplay });
}

/* ======================================================================= //
   PRELOAD IMAGES:
   The following code preloads images.
   ======================================================================= */
jQuery.preloadImages = function() {
	for(var i = 0; i<arguments.length; i++)
		jQuery("<img>").attr("src", arguments[i]);
}

$(function(){ 
$("#video_1").click(function()
	{
		_mc_loadWindow()
	});
$("#video_2").click(function()
	{
		 window.open("http://on10.net/blogs/tina/Life-At-Microsoft/");
		
	});
$("#video_3").click(function()
	{
		window.open("http://www.fastcompany.tv/video/exclusive-first-look-worldwide-telescope");
	});
$("#video_4").click(function()
	{
		_mc_loadWindow()
	});
$("#video_5").click(function()
	{
		_mc_loadWindow()
	});
$("#video_emp_1").click(function()
	{
		_mc_loadWindow()
	});
$("#video_emp_2").click(function()
	{
		_mc_loadWindow()
	});
$("#video_emp_3").click(function()
	{
		_mc_loadWindow()
	});
$("#video_emp_4").click(function()
	{
		_mc_loadWindow()
	});
$("#video_emp_5").click(function()
	{
		_mc_loadWindow()
	});
$("#video_emp_6").click(function()
	{
		_mc_loadWindow()
	});
$("#video_emp_7").click(function()
	{
		_mc_loadWindow()
	});
$("#video_mic_1").click(function()
	{
		_mc_loadWindow()
	});
$("#video_mic_2").click(function()
	{
		_mc_loadWindow()
	});
$("#video_mic_3").click(function()
	{
		_mc_loadWindow()
	});
$("#video_cow_1").click(function()
	{
		_mc_loadWindow()
	});
$("#video_cow_2").click(function()
	{
		_mc_loadWindow()
	});
$("#video_cow_3").click(function()
	{
		_mc_loadWindow()
	});
$("#video_cow_4").click(function()
	{
		_mc_loadWindow()
	});
$("#video_cow_5").click(function()
	{
		_mc_loadWindow()
	});
$("#video_life_1").click(function()
	{
		window.open("http://on10.net/blogs/tina/Life-At-Microsoft/");
	});
$("#video_life_2").click(function()
	{
		window.open("http://www.fastcompany.tv/video/the-innovations-microsoft’s-new-research-building");
	});
$("#video_life_3").click(function()
	{
		window.open("http://on10.net/blogs/larry/Bills-Last-Day-CES-2008-Keynote-Video/Default.aspx");
	});
$("#video_life_4").click(function()
	{
		_mc_loadWindow()
	});
$("#video_life_5").click(function()
	{
		window.open("http://video.msn.com/video.aspx?mkt=en-us&vid=91fadae9-0715-4fa4-88de-995f6eafc526");
	});
$("#video_life_6").click(function()
	{
		window.open("http://video.msn.com/video.aspx?mkt=en-us&vid=b7bc0bde-5f9f-4851-9db1-efe944fe17c8");
	});
$("#video_life_7").click(function()
	{
		_mc_loadWindow()
	});
$("#video_life_8").click(function()
	{
		window.open("http://video.msn.com/video.aspx?mkt=en-us&vid=5c3821b9-1ce0-49ab-9792-07de28299ab4");
	});
$("#video_life_9").click(function()
	{
		_mc_loadWindow()
	});
$("#video_life_10").click(function()
	{
		_mc_loadWindow()
	});
$("#video_life_11").click(function()
	{
		_mc_loadWindow()
	});
$("#video_life_12").click(function()
	{
		_mc_loadWindow()
	});
$("#video_life_13").click(function()
	{
		_mc_loadWindow()
	});
$("#video_life_14").click(function()
	{
		window.open("http://video.msn.com/video.aspx?mkt=en-us&vid=e712f312-fa8a-46c6-bd11-24951018de94");
	});
$("#video_life_15").click(function()
	{
		window.open("http://video.msn.com/video.aspx?mkt=en-us&vid=b11aebcf-25ed-41ae-b43e-30e3ceb5f515");
	});
$("#video_life_16").click(function()
	{
		window.open("http://www.youtube.com/watch?v=zcuaHK1grrI");
	});
$("#video_life_17").click(function()
	{
		window.open("http://video.msn.com/video.aspx?mkt=en-us&tab=soapbox&vid=aa00da5a-427d-4a8d-855c-22ab4203e126");
	});
$("#video_life_18").click(function()
	{
		window.open("http://channel9.msdn.com/shows/WM_IN/Reads-Mini-Microsoft-and-Wears-Shorts-in-Winter-Lisa-Brummel-VP-of-HR/?CommentID=162680");
	});
$("#video_life_19").click(function()
	{
		window.open("http://on10.net/blogs/laura/Xbox-Careers/");
	});
$("#video_life_20").click(function()
	{
		window.open("http://video.msn.com/video.aspx?mkt=en-us&vid=30df5e92-13a2-4735-923f-0483e9fdc8b1");
	});
$("#video_life_21").click(function()
	{
		window.open("http://channel9.msdn.com/ShowPost.aspx?PostID=34526");
	});
$("#video_life_22").click(function()
	{
		window.open("http://video.msn.com/video.aspx?mkt=en-us&vid=17689642-ca2a-4613-9de7-d6ddd2808709");
	});
$("#video_def_1").click(function()
	{
		window.open("http://channel9.msdn.com/shows/Behind+The+Code/Life-and-Times-of-Anders-Hejlsberg/");
	});
$("#video_def_2").click(function()
	{
		window.open("http://channel9.msdn.com/ShowPost.aspx?PostID=333294");
	});
$("#video_def_3").click(function()
	{
		window.open("http://channel9.msdn.com/posts/Dan/Ray-Ozzie-Introducing-Live-Mesh/");
	});
$("#video_def_4").click(function()
	{
		window.open("http://channel9.msdn.com/posts/Dan/Mike-Klucher-XNA-Framework-games-running-on-Zune/");
	});
$("#video_def_5").click(function()
	{
		window.open("http://www.onten.net/blogs/nic/What-is-Microsoft-Media-Room/");
	});
$("#video_def_6").click(function()
	{
		window.open("http://channel9.msdn.com/shows/WM_IN/Shawn-Richardson-A-winding-road-to-Software-Security/");
	});
$("#video_def_7").click(function()
	{
		window.open("http://channel9.msdn.com/shows/Going+Deep/Dave-Campbell-SQL-Server-Data-Services-and-the-Future-of-Data-in-the-Cloud/");
	});
$("#video_def_8").click(function()
	{
		window.open("http://channel9.msdn.com/ShowPost.aspx?PostID=386824");
	});
$("#video_def_9").click(function()
	{
		window.open("http://edge.technet.com/Media/Introducing-Microsoft-Online-Services/");
	});
$("#video_def_10").click(function()
	{
		_mc_loadWindow()
	});
$("#video_def_11").click(function()
	{
		window.open("http://channel9.msdn.com/shows/WM_IN/Meghan-Perez-From-Software-Developer-to-Technical-Advisor/");
	});
$("#video_def_12").click(function()
	{
		window.open("http://edge.technet.com/Media/Bob-Muglia-Senior-VP-by-day-IT-Pro-by-night/");
	});
$("#video_def_13").click(function()
	{
		window.open("http://www.on10.net/Blogs/jesse/photosynth-and-seadragon-offer-a-glimpse-at-the-next-great-ui/");
	});
$("#video_def_14").click(function()
	{
		window.open("http://channel9.msdn.com/posts/Dan/Scott-Austin-GDC-Interesting-uses-of-Xbox-Live-Arcade/");
	});
$("#video_def_15").click(function()
	{
		window.open("http://channel9.msdn.com/posts/Charles/Microsoft-Robotics-Studio/");
	});
$("#video_def_16").click(function()
	{
		window.open("http://www.on10.net/Blogs/larry/first-look-microsoft-surfacing-computing/");
	});
$("#video_def_17").click(function()
	{
		window.open("http://channel9.msdn.com/posts/Charles/GDC08-James-Silva-XNA-XBOX-Arcade-Zune-Gaming-Renegade-Dishwasher-Samurai-Angst-and-Revenge/");
	});
$("#video_def_18").click(function()
	{
		window.open("http://channel9.msdn.com/posts/Charles/Mark-Light-and-Bohdan-Raciborski-Windows-XP-on-Flash-Based-Ultra-Low-Cost-PCs/");
	});
$("#video_def_19").click(function()
	{
		window.open("http://channel9.msdn.com/shows/Going+Deep/Mark-Russinovich-From-Winternals-to-Microsoft-On-Windows-Security-Windows-CoreArch/");
	});
$("#video_def_20").click(function()
	{
		window.open("http://www.microsoft.com/winme/0710/31052/current.htm");
	});
$("#video_def_21").click(function()
	{
		window.open("http://www.onten.net/blogs/nic/Robbie-Bach--CES-2008/Default.aspx");
	});
$("#video_top").click(function()
	{
		_mc_loadWindow()
	});
$("#video_top_mic").click(function()
	{
		_mc_loadWindow()
	});
$("#video_top_cow").click(function()
	{
		_mc_loadWindow()
	});
$("#video_top_life").click(function()
	{
		_mc_loadWindow()
	});
$("#video_top_def").click(function()
	{
		_mc_loadWindow()
	});

$("#navi_bttn_1").click(function(){ 
  //ID 'content' exist in maincontent.html      
  document.location.href = "blog.html";
  });
$("#navi_bttn_2").click(function(){ 
  //ID 'content' exist in maincontent.html      
  document.location.href = "blog_2.html";
  });
$("#navi_bttn_3").click(function(){ 
  //ID 'content' exist in maincontent.html      
  document.location.href = "blog_3.html";
  });
$("#navi_bttn_4").click(function(){ 
  //ID 'content' exist in maincontent.html      
  document.location.href = "blog_4.html";
  });
$("#navi_bttn_5").click(function(){ 
  //ID 'content' exist in maincontent.html      
  document.location.href = "blog_5.html";
  });
$("#navi_bttn_6").click(function(){ 
  //ID 'content' exist in maincontent.html      
  document.location.href = "blog_6.html";
  });
$(".blog_numb").mouseover(function(){ 
  //ID 'content' exist in maincontent.html      
  $(this).css({"color":"#f36f30"});
  }).mouseout(function(){ 
  //ID 'content' exist in maincontent.html
  if(!$(this).hasClass("active"))
	  $(this).css({"color":"#636A6A"});
  });
});


function _mc_loadWindow()
{
	state = $('#mc_opacity').css("display");
	if(state != "block") 
	{
		$.get('popup_1.html', function(newPage)
		{
			$('#newwindow').html(newPage);
			
			$('#popup_close').click(function()
			{
				_mc_loadWindow();
				return false;
			});
		}); 
		$('#mc_opacity').css({"display":"block"});
		$('#newwindow').css({"display":"block"});
	}
	else 
	{		
		$('#newwindow').html("");
		$('#mc_opacity').css({"display":"none"});
		$('#newwindow').css({"display":"none"});
	}
}