// chenghsin-0.1.js
// basic utils for the cheng hsin site
// dependencies
// yui
// jquery
// 2011-0828 cda - changed order. moved scheduled events to be the first item under Study with Us
// 2011-0830 cda - added section Schedule and Registration, to contain Schedule, Sign Yourself up and the all x lists

// correctly handle PNG transparency in Win IE 5.5 & 6.
function fnCorrectPNG() {
   var arVersion = navigator.appVersion.split("MSIE");
   var version = parseFloat(arVersion[1]);
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i];
         var imgName = img.src.toUpperCase();
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : "";
            var imgClass = (img.className) ? "class='" + img.className + "' " : "";
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
            var imgStyle = "display:inline-block;" + img.style.cssText ;
			
            if (img.align == "left") {imgStyle = "float:left;" + imgStyle;}
            if (img.align == "right") {imgStyle = "float:right;" + imgStyle;}
            if (img.parentElement.href) {imgStyle = "cursor:hand;" + imgStyle;}
            
			var strNewHTML = 
			"<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"  + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"  ;
			
            img.outerHTML = strNewHTML;
            i = i-1;
         }
      }
   }  
}
/*
function alertSize() {
  var myWidth = 0, myHeight = 0;
  
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
	return[myWidth,myHeight] ;
	
}
*/
var orientation_items = 	
	[	
		{text: "What is Cheng Hsin?", 	url: "orientation-what-is-chenghsin.html" },
		{text: "Cornerstone Principles", url: "orientation-the-cornerstone-principles.html" },
		{text: "Spirit and Essence",	url:"orientation-spirit-of-chenghsin.html" },			
		{text: "Pursuits and Goals",	url:"orientation-chenghsin-pursuits-and-goals.html" }
	];
	
var whois_items = 
		[ 
		{url: "founder-whoispeterralston.html"    		, text: "Who is Peter Ralston?"},
		{url: "founder-peterralstoninterview1978.html"  , text: "Origins Interview, 1978"},  
		{url: "founder-faqs.html"    					, text: "Frequent Questions"		},	
		{url: "founder-newsletter.html"    				, text: "Founder's Newsletter" },
		{url: "interact-request-newsletter.html"   		, text: "Subscribe to the Newsletter"} 
	];

var arts_items =
	[
		{url: "art-of-effortless-power.html"    		, text: "The Art of Effortless Power"}, 
		{url: "art-of-being-a-body.html"    			, text: "Zen Body-Being" },
		{url: "art-of-consciousness.html"  			  	, text: "Consciousness" , 
        	submenu: { 
				id: 	"consciousness-submenu",  
	        	itemdata: [ //group 2, item 2, submenu item 0
	        		{text: "Art of Contemplation",	url:"art-of-contemplation.html" },
		        	{text: "Art of Experiential Inquiry",	url:"art-of-inquiry.html" }
			    ]
			}
		},
		{url: "art-of-personal-transformation.html"    	, text: "Personal Transformation" },
		{url: "cliplist.html",			text: "Watch some clips" ,
			submenu: { 	
				id: "clips-submenu"	,  
				itemdata: [ //4,1,0
					{url: "dvd-intro.html"    					, text: "Introduction to Cheng Hsin Arts" },
					{url: "dvd-interview.html"    				, text: "Discovery Interview, 2006" },
					{url: "dvd-taichi.html" 	   				, text: "Tai Chi Instruction, 2008" },
					{url: "dvd-fightplaydemo.html"    			, text: "Fight Play Demo, 2007"     },
					{url: "dvd-instructionals.html"    			, text: "Art of Effortless Power Instructional DVDs, 2009"     },
					{url: "dvd-experiencing-the-nature-of-being-course.html"   , text: "Experiencing the Nature of Being DVD Course, 2010"     }

				]
	 		}
		} 				
	];
var study_items = 
	[
	//	{url: "workshoplist.html"    	, text: "Workshops at The Center" },
/* moved to new schedule_items section
		{url: "workshoplist-schedule.html", text: "Schedule of All Events"},
*/
		{url: "workshop-chenghsin-retreat.html" 		, text: "The Spring Retreat" ,
			submenu: {	
				id: "chenghsin-retreat-workshops-submenu" ,  
				itemdata: [ //3,2,0..1
					{url:  "workshop-experiencing-the-nature-of-being.html"  , text: "Experiencing the Nature of Being" }, 
					{url:  "workshop-art-of-effortless-power.html",				text: "The Art of Effortless Power" ,
						submenu: { 	
							id: "retreat-topic-submenu" ,  
							itemdata: [ //3,2,1,0..4 
								{url:  "workshop-topic-principlesofbodybeing.html" 	, text: "The Principles of Effortlessly Effective Body-Being" },
								{url:  "workshop-topic-principlesofeffectiveinteraction.html"  , text: "The Principles of Effective Interaction" },
								{url:  "workshop-topic-taichiset.html"    			, text: "Tai Chi set"  },
								{url:  "workshop-topic-sanshouset.html"    			, text: "San Shou set" }, 
								{url:  "workshop-topic-swordset.html"    			, text: "Sword Play" }
							]
						}										
					}
				]	
			}
		},

		{url: "workshop-fall-series.html"    	, text: "The Fall Workshop Series" ,
			submenu: {	
				id: "fall-series-workshops-submenu" ,  
	           	itemdata: [ //3,3,0
					{url: "workshop-effortless-power-training-camp.html"    	, text: "Effortless Power Training Camp"},
					{url:  "workshop-experiencing-the-nature-of-being.html"  , text: "Experiencing the Nature of Being" },
					{url: "workshop-consciousness-training-camp.html"    	, text: "Consciousness Training Camp"},
					{url: "workshop-contemplation-intensive.html"    		, text: "Contemplation Intensive" }
		       	]
	       	}
		},		
		
		{url: "apprentice-program.html"    	, text: "The Apprentice Programs",
			submenu: {	
				id: "apprentice-programs-submenu" ,  
				itemdata: [ 
					{url: "apprentice-program-consciousness.html" , text: "Consciousness Apprenticeship" },
					{url: "apprentice-program-martial-arts.html" , text: "Martial Arts Apprenticeship" }
		       	]
	       	}
		}, 
		
		{url: "workshop-threemonthtraining.html", text: "Three Month Training Program" },
	
		{url: "ecourselist.html"    	, text: "Online eCourses" ,
	        submenu: {
				id:"ecourse-submenu" ,  
	            itemdata: [	 	// 3,1,0			
					{url: "ecourse-transcending-self.html"    	, text: "Transcending Self - a Mind Course"}, 
					{url: "ecourse-bodybeing.html"    			, text: "The Principles of Effortlessly Effective Body-Being" },
					{url: "ecourse-relationship.html"    		, text: "Transforming Your Experience of Relationship" },
					{url: "ecourse-effective-interaction.html" 	, text: "The Principles of Effective Interaction" },
					{url: "ecourse-powerofcontemplation.html"  	, text: "The Power of Contemplation" },
					{url: "ecourse-taichi-body-mind.html"  		,     text: "Tai Chi Body-Mind (short ecourse)" },
					{url: "ecourse-increasing-consciousness.html"  	, text: "Increasing Consciousness (short ecourse)" }
				]
	       	}
		},

		{url: "home-study-list.html",	 text: "Home Study Courses" ,
			submenu: {
				id: "home-study-submenu" ,  
	          	itemdata: [ 
					{url: "home-study-experiencing-the-nature-of-being-course.html" , text: "Experiencing the Nature of Being DVD Course" },
					{url: "home-study-art-of-effortless-power-degree-instruction.html"  , text: "Art of Effortless Power Instructional DVDs" }
	        	]
	       	}
		},
	


/* moved to new schedule_items section
		{url: "studies-consciousness.html",	text: "All Consciousness Studies"},
		{url: "studies-martial-arts.html", 	text: "All Martial Arts Studies"},
		{url: "studies-body-being.html", 	text: "All Body-Being Studies" },
		{url: "workshop-registration.html", text: "Sign Yourself Up" }
*/

	];	

var schedule_items =
[
		{url: "workshoplist-schedule.html", text: "Schedule of All Events"},
		{url: "studies-consciousness.html",	text: "All Consciousness Studies"},
		{url: "studies-martial-arts.html", 	text: "All Martial Arts Studies"},
		{url: "studies-body-being.html", 	text: "All Body-Being Studies" },
		{url: "workshops-on-the-road.html", text: "Workshops Around the World" 	},
		{url: "workshoplist.html", text: "Sign Yourself Up" }
];

var study_materials = 
[

		{url: "book-list.html",		text: "Books" ,
			submenu: {	
				id: "books-submenu" ,  
	          	itemdata: [ 
					{url: "book-of-not-knowing.html"    	    , text: "Book of Not Knowing" },
					{url: "book-reflections-of-being.html"    	, text: "Reflections of Being" },
					{url: "book-principles.html"    			, text: "The Principles of Effortless Power" },
					{url: "book-art-of-effortless-power.html"   , text: "The Art of Effortless Power" },
					{url: "book-ancient-wisdom.html"   			, text: "Ancient Wisdom, New Spirit" },
					{url: "book-zenbb.html"    					, text: "Zen Body-Being" }
	        	]
	       	}
		},
		{url: "dvd-list.html",	text: "DVDs" ,
			submenu: {	
				id: "dvd-submenu",  
	           	itemdata: [ //4,1,0
					{url: "dvd-intro.html"    					, text: "Introduction to Cheng Hsin Arts" },
					{url: "dvd-interview.html"    				, text: "Discovery Interview, 2006" },
					{url: "dvd-taichi.html" 	   				, text: "Tai Chi Instruction, 2008" },
					{url: "dvd-fightplaydemo.html"    			, text: "Fight Play Demo, 2007"     },
					{url: "dvd-instructionals.html"    			, text: "Art of Effortless Power Instructional DVDs, 2009"     },
					
					{url: "dvd-san-shou-instruction.html"   , text: "San Shou Instruction, 2012"     },
					
					{url: "dvd-effortless-power-series.html"   , text: "Mastering Effortless Power Series, 2012"     },
					
					{url: "dvd-striking-arts-series.html"   , text: "The Striking Arts of Cheng Hsin, 2012"     },
					
					{url: "dvd-sword-instruction.html"   , text: "Cheng Hsin Sword Instruction, 2012"     },
					
					{url: "dvd-consciousness.html"   , text: "Introduction to Consciousness, 2012"     },
					
					{url: "dvd-contemplation.html"   , text: "The Skill of Contemplation, 2012"     }
					
				]
	       	}
		},
		{url: "chenghsin-degree-system.html" , text: "The Degree System"},
		{url: "chenghsin-archives.html",		text: "Archives", 
			submenu: {	
				id: "archives-contents-list-submenu" ,  
	    		itemdata: [ //4,3,0
					{url: "archives-article-chenghsin-handbook.html" 	, text: "Cheng Hsin Handbook" },
					{url: "archives-internal-dialog-anthology.html"  	, text: "Internal Dialog Anthology"   },           
				 	{url: "archives-articles.html",						text: "Articles" ,
						submenu: {	
							id: "archives-articles-submenu" ,  
		        	    	itemdata: [ // 4,3,2,0
								{url: 	"archives-article-creationofchenghsin.html"    		, text: "Creation of Cheng Hsin" },
								{url: 	"archives-article-discoveriesandinnovations.html"  	, text: "Discoveries and Innovations"}, 
								{url: 	"archives-article-experiencing-empowerment.html"  	, text: "Empowerment" }
				        	]	
			       		}
					},
					{url: "archives-newsletters.html" ,					text: "Newsletter Anthologies"},
					{url: "archives-newsletters.html" ,					text: "Newsletter Archives" ,
						submenu: { 	
							id: "newsletters-submenu",  
			           		itemdata: 	[  	//4,4,3,0			
								{url: "archives-newsletters-1998.html"    , text: "1998" },
								{url: "archives-newsletters-1999.html"    , text: "1999" },
								{url: "archives-newsletters-2000.html"    , text: "2000" },
								{url: "archives-newsletters-2001.html"    , text: "2001" },
								{url: "archives-newsletters-2002.html"    , text: "2002" },
								{url: "archives-newsletters-2003.html"    , text: "2003" },
								{url: "archives-newsletters-2004.html"    , text: "2004" },
								{url: "archives-newsletters-2005.html"    , text: "2005" }	
			        		]
				       	}
					}	        		
				]
	       	}
		}
		//	, 
		//	{url: "chenghsin-sales.html"		, text: "buy stuff"}  
	];
var joinus_items = 
	[
		{url: "interact-upcoming-events.html"    		, text: "Calendar of Events" },
		{url: "interact-request-newsletter.html"    	, text: "Get the Newsletter" },
		{url: "interact-chenghsin-aroundtheworld.html"	, text: "Sites Around the World" },
		{url: "interact-trainersandteachers.html"   	, text: "Teachers and Trainers"}, 
		{url: "interact-what-others-are-saying.html"	, text: "Participant Feedback"}, 
		{url: "workshoppix-2000.html",					text: "Past Participants Pix" ,
			submenu: { 	
				id: "workshop-pictures-submenu",  
				itemdata: [  //5,4,0
					{url: "workshoppix-2000.html"    		, text: "Workshops 2000"  },
					{url: "workshoppix-2002.html"    		, text: "Workshops 2002" },
					{url: "apprentices-2004.html"    		, text: "Apprentices 2004"}, 
					{url: "apprentices-2006.html" 			, text: "Apprentices 2006" },
					{url: "apprentices-2008.html" 			, text: "Apprentices 2008" }
				]
			}
		},
		{url: "interact-sponsor-a-workshop.html" 	, text: "Sponsor a Workshop"},  
		{url: "interact-contactpeter.html"    		, text: "Contact Peter Ralston"} 
	];
var about_items = 
	[
		{url: "about-chenghsin-center.html" 			, text: "The Cheng Hsin Center" },
		{url: "about-this-site.html"    				, text: "The Cheng Hsin Site" }  
	];
	
var the_sidebarMenuItems = 
	[
		orientation_items,
		whois_items,
		arts_items,
		study_items,
		schedule_items,
		study_materials,
		joinus_items,
		about_items
	];  // end sidebarmenuitems

// define the menu item group headings
var groupHeadings = [
		{groupindex: 0 , groupTitle: "Orientation" , 	subnavid: "orientation_subnav"},
		{groupindex: 1 , groupTitle: "The Founder", 	subnavid: "founder_subnav"},
		{groupindex: 2 , groupTitle: "The Arts of Cheng Hsin", subnavid: "arts_subnav"},
		{groupindex: 3 , groupTitle: "Study With Us", 	subnavid: "study_subnav"},
		{groupindex: 4 , groupTitle: "Schedule and Registration", 	subnavid: "study_subnav"},
		{groupindex: 5 , groupTitle: "Helpful Materials", 	subnavid: "materials_subnav"},
		{groupindex: 6 , groupTitle: "Join In", 		subnavid: "join_subnav"},
		{groupindex: 7 , groupTitle: "About", 			subnavid: "about_subnav"}
	];

var standardPageHeadings= {
	"Orientation"			:{ heading: "Orientation", 				nav: "orientation_subnav" },
	"The Founder"			:{ heading: "The Founder", 				nav: "founder_subnav" },
	"The Arts of Cheng Hsin":{ heading: "The Arts of Cheng Hsin", 	nav: "arts_subnav" },
	"Study With Us"			:{ heading: "Study With Us", 			nav: "study_subnav" },
	"Schedule and Registration":{ heading: "Schedule and Registration", 			nav: "study_subnav" },
	"Helpful Materials"		:{ heading: "Helpful Materials",		nav: "materials_subnav" },
	"Join In"				:{ heading: "Join In", 					nav: "join_subnav" },
	"About"					:{ heading: "About", 					nav: "about_subnav" }
};

var specialPageHeadings = { 
	"default"									:{heading: "An Open Invitation", 	nav: "orientation_subnav" },
	"Home Study Courses"						:{heading: "Home Study Courses", 	nav: "home-study_subnav" },
	"Tai Chi Body-Mind (short ecourse)"			:{heading: "mini-eCourses",			nav: "mini-ecourses_subnav"},
	"Increasing Consciousness (short ecourse)"	:{heading: "mini-eCourses",			nav: "mini-ecourses_subnav"},
	"Online eCourses"							:{heading: "eCourses",				nav: "ecourses_subnav"},
	"The Apprentice Programs"					:{heading: "The Apprentice Programs",	nav: "apprentice_programs_subnav"},
	"Consciousness"								:{heading: "Consciousness",			nav: "consciousness_subnav"},
	"Cheng Hsin Pursuits and Goals"				:{heading: "Cheng Hsin Pursuits and Goals",	nav: "essentials_subnav"},
	"The Spirit of Cheng Hsin"					:{heading: "The Spirit of Cheng Hsin",	nav: "essentials_subnav"},
	"The Essence of Cheng Hsin"					:{heading: "The Essence of Cheng Hsin",	nav: "essentials_subnav"},
	"The Spring Retreat"						:{heading: "The Spring Retreat",		nav: "retreat_subnav"},
	"The Fall Workshop Series"					:{heading: "The Fall Workshop Series",	nav: "fallseries_subnav"},
	
	"Experiencing the Nature of Being"			:{heading: "Experience Being",	nav: "study-of-being_subnav"}
	};


//
// need to get the subheading title and the subhead nav
// that's it?

function on_mainpage() {	// returns true if current page is index.html or one of its variants 
	// get my url path. split it into an array of its parts
	var pathname_array = [];
		pathname_array = (location.pathname).split("/");
	
		if ( (location.pathname).charAt((location.pathname).length - 1) === "/" 
			 || pathname_array[1] === "" 
			 || pathname_array[1] === "index.html" 
			 || pathname_array[2] === "index.html"
			) { return (true);		};

		return(false)
		}
		
function getPageUrl() {
	
	if ( on_mainpage() ) 
		{ 
			return("index.html")
		}
	else 
		{
		var pathname_array = (location.pathname).split("/");
		return (pathname_array[ (pathname_array.length)-1 ] );
	}
}
	
		
var pageUrl = getPageUrl();		
 
// Instantiate the main sidebar menu 
var oMenu = null;
var onSidebarMenuReady = function(p_oEvent) {
	
	// no menu on the splash page
	if ( !on_mainpage() ) {	
	
		oMenu = new YAHOO.widget.Menu("ChengHsinSidebarMenu",{ position:"static",  hidedelay:750, lazyload:true });

		// add the items to the menu
		oMenu.addItems(the_sidebarMenuItems);    
		
		// set the group headings
		for ( i=0; i< groupHeadings.length; i++) { oMenu.setItemGroupTitle(groupHeadings[i].groupTitle, i); }
			
		// render and show
		oMenu.render("rendertarget");
		oMenu.show();
	};		

	// helpful positioning locators
	var current_group = null;
	var current_item = null;
	var current_submenu_item = null;
	var current_sub_submenu_item = null;
		
	var xresult = { 
				_subnav: 		{id:"orientation_subnav"},
				_group:			{index:0, 		heading:"An Open Invitation"},
				_item:			{index:null,  	text:null, 	_url:null},
				_submenu_item:	{index:null,  	text:null, 	_url:null },
				_subsubmenu_item:{index:null,  	text:null, 	_url:null }
			 };

	 // returns the current page's coordinates - its position in the menu	
	function get_c_p( page_name ) {
		// group, item, sub, sub-sub
		current_group = null;
		current_item = null;
		current_submenu_item = null;
		current_sub_submenu_item = null;
		
		var result = { 
				_subnav: 		{id:"orientation_subnav"},
				_group:			{index:0, 		heading:"An Open Invitation"},
				_item:			{index:null,  	text:null, 	_url:null},
				_submenu_item:	{index:null,  	text:null, 	_url:null },
				_subsubmenu_item:{index:null,  	text:null, 	_url:null }
			 };
			 
		 var ndx_g = 0;
		 var ndx_i = 0;
		 var ndx_si = 0;
		 var ndx_ssi = 0;
			 
		// search array of menu item groups
		for (ndx_g = 0; ndx_g < the_sidebarMenuItems.length; ndx_g++)
		{	    
			current_group = the_sidebarMenuItems[[ndx_g]];
			
			// search array of menu items
			for (ndx_i = 0; ndx_i < current_group.length; ndx_i++)
			{          
				current_item = current_group[ndx_i];	

				// match?
				if (page_name == current_item.url)
					{
						result._subnav.id		=groupHeadings[ndx_g].subnavid;
						
						result._group.index		=ndx_g;
						result._group.heading 	=groupHeadings[ndx_g].groupTitle;
						
						result._item.index		=ndx_i;
						result._item.text		=current_item.text;
						result._item._url		=current_item.url;
						
						return result;	}
						
				// submenu ??
				if (current_item.submenu) { 
					
					// search array of submenu items     
					for (ndx_si=0; ndx_si<current_item.submenu.itemdata.length; ndx_si++)
						{
		
							current_submenu_item = current_item.submenu.itemdata[ndx_si];
							// match??
							if (page_name == current_submenu_item.url) 	{
								
									//result._group.heading=groupHeadings[ndx_g].groupTitle;
									
									// use the submenu parent for the heading
									result._subnav.id		=groupHeadings[ndx_g].subnavid;				
									
									result._group.heading	=current_item.text;
									result._group.index		=ndx_g;
									
									result._item.index		=ndx_i;
									result._item.text		=current_item.text;
									result._item._url		=current_item.url;
									
									result._submenu_item.index	=ndx_si;
									result._submenu_item.text	=current_submenu_item.text;
									result._submenu_item._url	=current_submenu_item.url;
						
									return result;     
								}
							// submenu??
							if (current_submenu_item.submenu) {
								for (ndx_ssi = 0;    ndx_ssi < current_submenu_item.submenu.itemdata.length; ndx_ssi++)
								{
									current_sub_submenu_item = current_submenu_item.submenu.itemdata[ndx_ssi];
									
									if (page_name == current_sub_submenu_item.url)								{
									
									// we matched a sub-sub menu item
									// use its parent sub-menu item for the group heading
									// use its siblings for the navbar
									
									result._subnav.id		=groupHeadings[ndx_g].subnavid;
									
									result._group.heading	=current_item.text;
									result._group.index		=ndx_g;
									
									result._item.index	=ndx_i;
									result._item.text	=current_item.text;
									result._item._url	=current_item.url;
									
									result._submenu_item.index	=ndx_si;
									result._submenu_item.text	=current_submenu_item.text;
									result._submenu_item._url	=current_submenu_item.url;

									result._subsubmenu_item.index	=ndx_ssi;
									result._subsubmenu_item.text	=current_sub_submenu_item.text;
									result._subsubmenu_item._url	=current_sub_submenu_item.url;
						
									return result;     
									}
								}
							}
							 // if we get here we are done searching this item and all its submenus and have not found a match	
						}
				}
				 // if we get here we are done searching this item and all its submenus and have not found a match	      
			}
		}
		return result;
	}

	//
	// get the current position in page coordinates 
	//
	var c_p = null;
	c_p = get_c_p(pageUrl);

	//
	//   use the current position to set up the banner subheading and its navbar items  
	//
	var subnavid = c_p._subnav.id;

	//	
	// make any adjustments to heading and navbar for special cases
	//
	if ( c_p._submenu_item.text == "Cheng Hsin Pursuits and Goals" 
		|| c_p._submenu_item.text == "The Spirit of Cheng Hsin" 
		|| c_p._submenu_item.text == "The Essence of Cheng Hsin" )
		{ 
			c_p._group.heading = c_p._item.text;
			subnavid="essentials_subnav";
		}
	if (c_p._item.text== "Consciousness"){
			c_p._group.heading = c_p._item.text;
			subnavid="consciousness_subnav";
		}
	if (c_p._item.text== "The Spring Retreat"){
			c_p._group.heading = c_p._item.text;
			subnavid="retreat_subnav";
		}
	if (c_p._item.text== "The Fall Workshop Series"){
			c_p._group.heading = c_p._item.text;
			subnavid="fallseries_subnav";
		}
	if (c_p._item.text== "The Apprentice Programs"){
			c_p._group.heading = c_p._item.text;
			subnavid="apprentice_programs_subnav";
		}
	if (c_p._item.text== "Online eCourses"){
			c_p._group.heading = "eCourses";
			subnavid="ecourses_subnav";
		}	
	if ( c_p._submenu_item.text == "Tai Chi Body-Mind (short ecourse)"	
		|| c_p._submenu_item.text == "Increasing Consciousness (short ecourse)" 
		){ 
			c_p._group.heading = "mini-eCourses";
			subnavid="mini-ecourses_subnav";
		}

	if (c_p._item.text== "Home Study Courses"){
			c_p._group.heading = c_p._item.text;
			subnavid="home-study_subnav";
		}
		
	if (c_p._item.text== "Watch some clips"){
			c_p._group.heading = "DVDs and Clips";
			subnavid="dvds_subnav";
		}
		
	if (c_p._submenu_item.text== "Experiencing the Nature of Being"){
			c_p._group.heading = "Experience Being";
			subnavid="study-of-being_subnav";
		}
		
		//
	//	set up the banner subheading
	//
	$("div.section-heading").html(c_p._group.heading);
	
	//
	// use to subnavid and jquery to load the html snippet. 
	// load the element where subnavid == html element id
	//
		
	// do not display the banner submenu on the index page 	
	if ( on_mainpage() )
		{		
			$("#snavlist").hide ;
		}
	else 
		{	
			$("#snavcontainer").load( "_codesnip_subhead_navbar2.html #".concat(subnavid));
			$("#snavlist").show ;	
		}
 };

/*
function dumpmenuitems (){
	var ndx_g =0;
	var ndx_i =0;
	var ndx_si = 0;
	
	for (ndx_g = 0; ndx_g < the_sidebarMenuItems.length; ndx_g++){
	    
	    current_group = the_sidebarMenuItems[[ndx_g]];
	    
	    console.log(
	    		ndx_g, 
	    		" current_group is ", current_group);
	
	    for (ndx_i = 0; ndx_i < current_group.length; ndx_i++){
	           
	        current_item = current_group[ndx_i];
	        
	        console.log(
	      		ndx_g,
	        	ndx_i,
	        	current_item.text,
	        	current_item.url
	  			);
	
	        if (current_item.submenu) { 
	          
	          	console.log(current_item.submenu.id);
	
	            for (ndx_si=0; ndx_si<current_item.submenu.itemdata.length; ndx_si++)
	                {
	                	
	                current_submenu_item = current_item.submenu.itemdata[ndx_si];
	                
	                console.log(
	                	ndx_g,
	                	ndx_i,
	                	ndx_si,
	                	current_submenu_item.text,
	                	current_submenu_item.url
	                	);
	            }
	        }
	    }
	}
}
*/

/* 
no longer used. moved all code snippets inline..
moved dvd pricing to that dvds page.
 
// setup for load
var whichDVD 					= ""; 		
var	usBuyNowPrice 			= ""; 
var	internationalBuyNowPrice 	= ""; 
var	mailInACheckPrice 			= ""; 

function setupDVD(){

		var spath = window.location.pathname;
		var sfilename = spath.substring(spath.lastIndexOf('/') + 1);
		var spagename = sfilename.split('.')[0];

	whichDVD = spagename;
		
	if (whichDVD == "dvd-interview")
	{
		usBuyNowPrice 			= "for $25.00" ;		
		internationalBuyNowPrice = "for $30.00";
		mailInACheckPrice 			= "&nbsp;or mail a check for $24.00" ;
		
	}
	else if (whichDVD == "dvd-experiencing-the-nature-of-being-course")
	{	
		usBuyNowPrice 			= "for $1295" ;		
		internationalBuyNowPrice = "for $1295";
		mailInACheckPrice 			= "&nbsp;" ;
	}
	else
	{
		usBuyNowPrice 			= "for $35.00" ;		
		internationalBuyNowPrice = "for $40.00";
		mailInACheckPrice 			= "&nbsp;or mail a check for $34.00" ;
	};
}

function setUSPrices(){
		$("#us_price").html(usBuyNowPrice);
		$("#mail_check_price").html(mailInACheckPrice);
	} 
function setInternationalPrices(){
		$("#international_price").html(internationalBuyNowPrice);
	}
function loadBuyNowForms() {
	
		// loads the buy now related forms for a specific dvd.
		// after loading, sets the US and international prices for that dvd
		$("#insert_buynow_us_form").load( (whichDVD).concat("-buynow-us.html"), setUSPrices	);
			
		$("#insert_buynow_international_form").load( (whichDVD).concat("-buynow-int.html"), setInternationalPrices 	);
	}
	*/
	
// makes height of matching classnames the same
// used to create equal height columns

function equalHeight(group) {
	var tallest = 0;
	var thisHeight=0;
	
	group.each(function() {
		var thisHeight = $(this).height();
	
		if(thisHeight > tallest) {tallest = thisHeight;}
	});
	group.height(tallest);
	
}

