
$(document).ready(function() {
		
		
// Add wrapper around 960 wrapper 
$("#main-wrapper").wrap('<div id="wide-wrapper"></div>');
// Dynamically create two divs stacked on top of each other: #left-stripe holds the left stripe of blue dots & #left-fill fills in the white behind #left-stripe.
$("#wide-wrapper").prepend("<div id='left-stripe'><div></div><div id='left-fill'></div>");



/* Includes
---------------------------*/
// Rotator
$("#hospital-stories").load("/includes/html/hospital_stories.html", tabIt);
$("#lunenfeld-stories").load("/includes/html/lunenfeld_stories.html", tabIt);

$("#foundation-stories").load("/includes/html/foundation_stories.html", tabIt);
$("#stories-landing").load("/includes/html/patient_stories.html", tabIt2);

// Lists
$("#donors-list").load("/includes/html/donors-list.html", donorsSideNav);
$("#hospital-stories-list").load("/includes/html/hospital_docs.html", hospitalStoriesSubNav);
$("#lunenfeld-stories-list").load("/includes/html/lunenfeld_docs.html", lunenfeldStoriesSubNav);
$("#foundation-stories-list").load("/includes/html/foundation_docs.html", foundationStoriesSubNav);
$("#patient-stories-list").load("/includes/html/patient_docs.html", patientStoriesSubNav);

// Summary grid
$("#hospital-story-summaries").load("/includes/html/hospital_summary.html");
$("#lunenfeld-story-summaries").load("/includes/html/lunenfeld_summary.html");
$("#foundation-story-summaries").load("/includes/html/foundation_summary.html");
$("#patient-story-summaries").load("/includes/html/patient_summary.html");

//Sub nav
$("#foundation-nav").load("/includes/html/nav/foundation_nav.html", foundationSubNav);
$("#about-nav").load("/includes/html/nav/about_nav.html", aboutSubNav);
$("#lunefeld-nav").load("/includes/html/nav/lunenfeld_nav.html", luneSubNav);
$("#_stories-nav").load("/includes/html/nav/stories_nav.html", storiesSubNav);
$("#numbers-nav").load("/includes/html/nav/numbers_nav.html", numbersSubNav);
$("#financials-nav").load("/includes/html/nav/financials_nav.html", financialsSubNav);

$("#top-nav").load("/includes/html/nav/nav.html", topNav);
$("footer").load("/includes/html/footer.html");

/* Donors List Aside Nav
---------------------------*/

function topNav() {
	if ( $("body").hasClass("mn-foundation") ) {
		$("#top-nav a:nth-child(4)").addClass("active");
	}
	else if ( $("body").hasClass("mn-hospital") ) {
		$("#top-nav a:nth-child(2)").addClass("active");
	}
	else if ( $("body").hasClass("mn-lunenfeld") ) {
		$("#top-nav a:nth-child(3)").addClass("active");
	}
	else if ( $("body").hasClass("mn-highlights") ) {
		$("#top-nav a:nth-child(5)").addClass("active");
	}
	else if ( $("body").hasClass("mn-stories") ) {
		$("#top-nav a:nth-child(8)").addClass("active");
	}
	else if ( $("body").hasClass("mn-numbers") ) {
		$("#top-nav a:nth-child(6)").addClass("active");
	}
	else if ( $("body").hasClass("mn-financials") ) {
		$("#top-nav a:nth-child(7)").addClass("active");
	}
	else if ( $("body").hasClass("mn-homepage") ) {
		$("#top-nav a:nth-child(1)").addClass("active");
	}
}

function financialsSubNav() {
	
	if ( $("body").hasClass("sb-hos-financials") ) {
		$("#sub-nav a:nth-child(1)").addClass("active");
	}
	else if ( $("body").hasClass("sb-found-financials") ) {
		$("#sub-nav a:nth-child(3)").addClass("active");
	}
	else if ( $("body").hasClass("sb-lune-financials") ) {
		$("#sub-nav a:nth-child(2)").addClass("active");
	}

}

function numbersSubNav() {
	if ( $("body").hasClass("sb-hospital-numbers") ) {
		$("#sub-nav a:nth-child(1)").addClass("active");
	}
	else if ( $("body").hasClass("sb-lunenfeld-numbers") ) {
		$("#sub-nav a:last-child").addClass("active");
	}

}

function storiesSubNav() {
	
if ( $("body").hasClass("sb-hospital-stories") ) {
		$("#sub-nav a:nth-child(1)").addClass("active");
	}
else if ( $("body").hasClass("sb-lunenfeld-stories") ) {
		$("#sub-nav a:nth-child(2)").addClass("active");
	}
else if ( $("body").hasClass("sb-foundation-stories") ) {
		$("#sub-nav a:nth-child(3)").addClass("active");
	}
	else if ( $("body").hasClass("sb-patient-stories") ) {
		$("#sub-nav a:nth-child(4)").addClass("active");
	}
}

function luneSubNav() {
	if ( $("body").hasClass("sb-letter") ) {
		$("#sub-nav a:nth-child(2)").addClass("active");
	}
	else if ( $("body").hasClass("sb-about") ) {
		$("#sub-nav a:nth-child(1)").addClass("active");
	}
	else if ( $("body").hasClass("sb-25") ) {
		$("#sub-nav a:nth-child(3)").addClass("active");
	}
	/*else if ( $("body").hasClass("mn-stories") ) {
		$("#sub-nav a:nth-child(4)").addClass("active");
	}*/
	else if ( $("body").hasClass("sb-stories") ) {
		$("#sub-nav a:nth-child(4)").addClass("active");
	}
	else if ( $("body").hasClass("sb-highlights") ) {
		$("#sub-nav a:nth-child(5)").addClass("active");
	}
	else if ( $("body").hasClass("sb-financials") ) {
		$("#sub-nav a:nth-child(6)").addClass("active");
	}
	else if ( $("body").hasClass("sb-numbers") ) {
		$("#sub-nav a:nth-child(7)").addClass("active");
	}
	else if ( $("body").hasClass("sb-research") ) {
		$("#sub-nav a:nth-child(8)").addClass("active");
	}
}
function aboutSubNav() {
		if ( $("body").hasClass("sb-about") ) {
		$("#sub-nav a:nth-child(1)").addClass("active");
	}
	else if ( $("body").hasClass("sb-letter") ) {
		$("#sub-nav a:nth-child(2)").addClass("active");
	}
	else if ( $("body").hasClass("sb-stories") ) {
		$("#sub-nav a:nth-child(3)").addClass("active");
	}
	else if ( $("body").hasClass("sb-financials") ) {
		$("#sub-nav a:nth-child(4)").addClass("active");
	}
	else if ( $("body").hasClass("sb-numbers") ) {
		$("#sub-nav a:nth-child(5)").addClass("active");
	}
	else if ( $("body").hasClass("sb-members") ) {
		$("#sub-nav a:last-child").addClass("active");
	}
}

function foundationSubNav() {
	if ( $("body").hasClass("sb-donors") ) {
		$("#sub-nav a:nth-child(4)").addClass("active");
	}
	else if ( $("body").hasClass("sb-letter") ) {
		$("#sub-nav a:nth-child(2)").addClass("active");
	}
	else if ( $("body").hasClass("sb-events") ) {
		$("#sub-nav a:nth-child(5)").addClass("active");
	}
	else if ( $("body").hasClass("sb-financials") ) {
		$("#sub-nav a:nth-child(6)").addClass("active");
	}
	else if ( $("body").hasClass("sb-directors") ) {
		$("#sub-nav a:nth-child(7)").addClass("active");
	}
	else if ( $("body").hasClass("sb-about") ) {
		$("#sub-nav a:nth-child(1)").addClass("active");
	}
	else if ( $("body").hasClass("sb-stories") ) {
		$("#sub-nav a:nth-child(3)").addClass("active");
	}
}
function donorsSideNav() {
	 if ( $("body").hasClass("as-1995") ) {
		$("#donors-list ul li:nth-child(1) a").addClass("active");
	}
	else if ( $("body").hasClass("as-2009") ) {
		$("#donors-list ul li:nth-child(2) a").addClass("active");
	}
	else if ( $("body").hasClass("as-venture") ) {
		$("#donors-list ul li:nth-child(3) a").addClass("active");
	}
	else if ( $("body").hasClass("as-founders") ) {
		$("#donors-list ul li:nth-child(4) a").addClass("active");
	}
	else if ( $("body").hasClass("as-leadership-sinai") ) {
		$("#donors-list ul li:nth-child(5) a").addClass("active");
	}
	else if ( $("body").hasClass("as-legacy-sinai") ) {
		$("#donors-list ul li:nth-child(6) a").addClass("active");
	}
	else if ( $("body").hasClass("as-events") ) {
		$("#donors-list ul li:nth-child(7) a").addClass("active");
	}
	else if ( $("body").hasClass("as-endowment-funds") ) {
		$("#donors-list ul li:nth-child(8) a").addClass("active");
	}
	else if ( $("body").hasClass("as-chairs") ) {
		$("#donors-list ul li:nth-child(9) a").addClass("active");
	}
	else if ( $("body").hasClass("as-programs") ) {
		$("#donors-list ul li:nth-child(10) a").addClass("active");
	}
	
}

function hospitalStoriesSubNav() {
	if ( $("body").hasClass("ryan") ) {
		$("#hospital-stories-list ul li:nth-child(1) a").addClass("active");
	}
	else if ( $("body").hasClass("shah") ) {
		$("#hospital-stories-list ul li:nth-child(2) a").addClass("active");
	}
	else if ( $("body").hasClass("morris") ) {
		$("#hospital-stories-list ul li:nth-child(3) a").addClass("active");
	}
	else if ( $("body").hasClass("ferguson") ) {
		$("#hospital-stories-list ul li:nth-child(4) a").addClass("active");
	}
	else if ( $("body").hasClass("emeds") ) {
		$("#hospital-stories-list ul li:nth-child(5) a").addClass("active");
	}
	else if ( $("body").hasClass("greenblatt") ) {
		$("#hospital-stories-list ul li:nth-child(6) a").addClass("active");
	}
	else if ( $("body").hasClass("maunder") ) {
		$("#hospital-stories-list ul li:nth-child(7) a").addClass("active");
	}
	else if ( $("body").hasClass("shandling") ) {
		$("#hospital-stories-list ul li:nth-child(8) a").addClass("active");
	}
	else if ( $("body").hasClass("lee") ) {
		$("#hospital-stories-list ul li:nth-child(9) a").addClass("active");
	}
	else if ( $("body").hasClass("beduz") ) {
		$("#hospital-stories-list ul li:nth-child(10) a").addClass("active");
	}
	else if ( $("body").hasClass("walfish") ) {
		$("#hospital-stories-list ul li:nth-child(11) a").addClass("active");
	}
	else if ( $("body").hasClass("zlotta") ) {
		$("#hospital-stories-list ul li:nth-child(12) a").addClass("active");
	}
	else if ( $("body").hasClass("awards") ) {
		$("#hospital-stories-list ul li:nth-child(13) a").addClass("active");
	}
}

function lunenfeldStoriesSubNav() {
	if ( $("body").hasClass("siminovitch") ) {
		$("#lunenfeld-stories-list ul li:nth-child(1) a").addClass("active");
	}
	else if ( $("body").hasClass("casper") ) {
		$("#lunenfeld-stories-list ul li:nth-child(2) a").addClass("active");
	}
	else if ( $("body").hasClass("roder") ) {
		$("#lunenfeld-stories-list ul li:nth-child(3) a").addClass("active");
	}
	else if ( $("body").hasClass("durocher") ) {
		$("#lunenfeld-stories-list ul li:nth-child(4) a").addClass("active");
	}
}

function foundationStoriesSubNav() {
	if ( $("body").hasClass("renew") ) {
		$("#foundation-stories-list ul li:nth-child(3) a").addClass("active");
	}
	else if ( $("body").hasClass("mandarin") ) {
		$("#foundation-stories-list ul li:nth-child(7) a").addClass("active");
	}
	else if ( $("body").hasClass("daniels") ) {
		$("#foundation-stories-list ul li:nth-child(2) a").addClass("active");
	}
	else if ( $("body").hasClass("mccleary") ) {
		$("#foundation-stories-list ul li:nth-child(5) a").addClass("active");
	}
	else if ( $("body").hasClass("frankfort") ) {
		$("#foundation-stories-list ul li:nth-child(4) a").addClass("active");
	}
	else if ( $("body").hasClass("hoffman") ) {
		$("#foundation-stories-list ul li:nth-child(6) a").addClass("active");
	}
	else if ( $("body").hasClass("slaight") ) {
		$("#foundation-stories-list ul li:nth-child(1) a").addClass("active");
	}

}

function patientStoriesSubNav() {
	if ( $("body").hasClass("tang") ) {
		$("#patient-stories-list ul li:nth-child(1) a").addClass("active");
	}
	else if ( $("body").hasClass("cohon") ) {
		$("#patient-stories-list ul li:nth-child(2) a").addClass("active");
	}
	else if ( $("body").hasClass("miller") ) {
		$("#patient-stories-list ul li:nth-child(3) a").addClass("active");
	}
	else if ( $("body").hasClass("smith") ) {
		$("#patient-stories-list ul li:nth-child(4) a").addClass("active");
	}
}




// This code initializes the Tabs functionality of callout4
function tabIt() {
	
	var $tabs = $('#tabs').tabs();
	
		
	$(".ui-tabs-panel").each(function(i){
	
	  var totalSize = $(".ui-tabs-panel").size() - 1;
	
	  if (i != totalSize) {
		 var next = i + 2;
		  $(this).prepend("<a href='#' class='next-tab mover' rel='" + next + "'>Next&#187;</a>");
	  }
	
	  if (i != 0) {
		 var prev = i;
		  $(this).prepend("<a href='#' class='prev-tab mover' rel='" + prev + "'>&#171; Prev</a>");
	  }
	
	});
	
	$('.next-tab, .prev-tab').click(function() { 
		   $tabs.tabs('select', $(this).attr("rel"));
		   return false;
	   });
	   
	 // NOTE: if 'Next' is clicked when panel 5 is visible, load in 6-10
	 $("#fragment-5 a.next-tab").click(function() {
		
		$("#tabSet1 li:lt(5)").addClass("displayNone");
		
		})
		
	// NOTE: if 'Prev' is clicked when panel 6 is visible, load in 1-5 
	 $("#fragment-6 a.prev-tab").click(function() {
		
		$("#tabSet1 li:lt(5)").removeClass("displayNone");
		
		})
	
	
		$("#tabs div:last-child a.next-tab").css("display","none");
				
			
			//$('#tabs').clone(true).addClass('tabClone').insertAfter('#tabs');
			//$('a.prev-tab').clone(true).appendTo('.tabClone');
	
	        //alert($(".ui-tabs-panel").size());
		
	}
	
function tabIt2() {
	
	var $tabs = $('#tabs').tabs();
	
		
	$(".ui-tabs-panel").each(function(i){
	
	  var totalSize = $(".ui-tabs-panel").size() - 1;
	
	  if (i != totalSize) {
		 var next = i + 2;
		  $(this).prepend("<a href='#' class='next-tab mover' rel='" + next + "'>Next&#187;</a>");
	  }
	
	  if (i != 0) {
		 var prev = i;
		  $(this).prepend("<a href='#' class='prev-tab mover' rel='" + prev + "'>&#171; Prev</a>");
	  }
	
	});
	
	$('.next-tab, .prev-tab').click(function() { 
		   $tabs.tabs('select', $(this).attr("rel"));
		   return false;
	   });
	   
	 // NOTE: if 'Next' is clicked when panel 5 is visible, load in 6-10
	 $("#fragment-5 a.next-tab").click(function() {
		
		$("#tabSet1 li:lt(5)").addClass("displayNone");
		
		})
		
	// NOTE: if 'Prev' is clicked when panel 6 is visible, load in 1-5 
	 $("#fragment-6 a.prev-tab").click(function() {
		
		$("#tabSet1 li:lt(5)").removeClass("displayNone");
		
		})
	
	
		$("#tabs div:last-child a.next-tab").css("display","none");
				
			
			//$('#tabs').clone(true).addClass('tabClone').insertAfter('#tabs');
			//$('a.prev-tab').clone(true).appendTo('.tabClone');
	
	        //alert($(".ui-tabs-panel").size());
		
	}
	
	
	
	function tabIt2() {
	
	var $tabs = $('#tabs').tabs();


	$(".ui-tabs-panel-landing").each(function(i) {

	var totalSize = $(".ui-tabs-panel-landing").size() - 1;
	
	  if (i != totalSize) {
		 var next = i + 2;
		  $(this).prepend("<a href='#' class='next-tab2 mover' rel='" + next + "'>Next&#187;</a>");
	  }
	
	  if (i != 0) {
		 var prev = i;
		  $(this).prepend("<a href='#' class='prev-tab2 mover' rel='" + prev + "'>&#171; Prev</a>");
	  }
	
	});
	
	$('.next-tab2, .prev-tab2').click(function() { 
		   $tabs.tabs('select', $(this).attr("rel"));
		   return false;
	   });
	   
	 // NOTE: if 'Next' is clicked when panel 5 is visible, load in 6-10
	 $("#Lfragment-4 a.next-tab2").click(function() {
		
		$("#LtabSet1 li:lt(3)").addClass("displayNone");
		
		})
		
	// NOTE: if 'Prev' is clicked when panel 6 is visible, load in 1-5 
	 $("#Lfragment-6 a.prev-tab2").click(function() {
		
		$("#LtabSet1 li:lt(5)").removeClass("displayNone");
		
		})
	
	
		$("#tabs2 div:last-child a.next-tab2").css("display","none");
				
			
			//$('#tabs').clone(true).addClass('tabClone').insertAfter('#tabs');
			//$('a.prev-tab').clone(true).appendTo('.tabClone');
	
	        //alert($(".ui-tabs-panel").size());
		
	}





})





 /*$.get('/includes/xml/stories.xml', function(data){
			
				$(data).find('story').each(function(i){
			
					var num = i + 1;
					
					var $name = $(this).attr("name");
					var $title = $(this).attr("title");
					var $img = $(this).attr("image");
					var $link = $(this).attr("link");
					var $copy = $(this).text();
					
					//var tabs = "<li><a href='#fragment-" + num + "'>" + num + "</a></li>";
					
					var html = "<div class='ui-tabs-panel' id='fragment-" + num + "'> <img src='" + $img + "'/><br />";
					html += "<h4>" + $name + "</h4><br />";
					html += "<h5>" + $title + "</h5><br/>";
					html += "<p>" + $copy + "</p>";
					html += "<a href='" + $link + "'>Read more &gt;</a>"
					html += "</div>";
					
					
					
					
					$('#tabs').append( $(html) );
					//alert(num);
					
				});
				
			});*/	



			
			
				
