		Event.observe(document, 'dom:loaded', function(){
			if ($('course-index')) {										   
				$$('#course-index .categorylist', '#course-index .categorybox h2').invoke('hide');
				
				
				$$('#course-index .toggle-fulltext', '#course-index a.course-name').invoke('observe', 'click', function(e){
					Event.stop(e);
					x = Event.element(e).up('tr').next('tr');
					
					x.toggle();
					
					if (x.visible()) {
						x.previous('tr').down('.enroll .toggle-fulltext').innerHTML = ' Hide';
					}
					else {
						x.previous('tr').down('.enroll .toggle-fulltext').innerHTML = ' View';
					}
								
					Event.stop(e);
				});
				
				
				
				
				podcastHeading = '<h2 class="main podcasts"><span>Options Podcasts</span>&nbsp;</h2>';
				webcastHeading = '<h2 class="main webcasts"><span>Options Webcasts</span>&nbsp;</h2>';
				categoryBox = $$('#course-index .categorybox')[0];
				
				//$$('#course-index .categorybox')[0].insert(podcastHeading, {'before': $('webcast-heading')})
				
				categoryBox.insert(podcastHeading);
				
				
				$$('#course-index .categorylist.podcasts').each(function(x) {
					
					categoryBox.insert(x);
					
				});
				categoryBox.insert(webcastHeading);
				$$('#course-index .categorylist.webcasts').each(function(x) {
					
					categoryBox.insert(x);;
					
				});

				var rowCount = 0;
				$$('#course-index .categorybox .course-brief').each(function(x) {
					
					rowCount++;
					if (rowCount % 2 == 0)
						x.addClassName('row-even');
		
				});
				
				
				queryString = window.location.href.toQueryParams();
				
				if (queryString.podcasts && queryString.webcasts) {
					
					$$('#course-index .mycourses-tabs ul li a').invoke('removeClassName', 'active');
					
					$('tab-8').addClassName('active');
					$('tab-9').addClassName('active');
					
					$$('.categorylist').invoke('hide');
					$$('#course-index .categorybox h2').invoke('hide');
					$$('#course-index .categorybox h2.podcasts').invoke('show');
					$$('#course-index .categorylist.podcasts').invoke('show');
					$$('#course-index .categorybox h2.webcasts').invoke('show');
					$$('#course-index .categorylist.webcasts').invoke('show');
				}
				else if (queryString.podcasts) {
					
					$$('#course-index .mycourses-tabs ul li a').invoke('removeClassName', 'active');
					$('tab-8').addClassName('active');
					$$('.categorylist').invoke('hide');
					$$('#course-index .categorybox h2').invoke('hide');
					//$$('#course-index .categorybox h2.podcasts').invoke('show');
					
					$$('h2.podcast-cat-header').each(function(x) {
						cat = x.id.substring(10);
						categoryBox = $('category-'+cat);
						
						if (!categoryBox.empty()) {
							x.show();
							categoryBox.insert({before: x});
						}
					});
					
					$$('#course-index .categorylist.podcasts').invoke('show');
				}
				else if (queryString.webcasts) {
					
					$$('#course-index .mycourses-tabs ul li a').invoke('removeClassName', 'active');
					$('tab-9').addClassName('active');
					$$('.categorylist').invoke('hide');
					$$('#course-index .categorybox h2').invoke('hide');
					//$$('#course-index .categorybox h2.webcasts').invoke('show');
					
					$$('h2.webcast-cat-header').each(function(x) {
						cat = x.id.substring(10);
						categoryBox = $('category-'+cat);
						
						if (!categoryBox.empty()) {
							x.show();
							categoryBox.insert({before: x});
						}
					});
					
					$$('#course-index .categorylist.webcasts').invoke('show');
				}
				else if (queryString.id) {
					catID = queryString.id;

					$$('#course-index .mycourses-tabs ul li a').invoke('removeClassName', 'active');
					$('tab-'+catID).addClassName('active');
					
					$$('.categorylist').without($('category-'+catID)).invoke('hide');
					$$('#course-index .categorybox [parentID = '+catID+']').invoke('show');
					$('category-'+catID).show();
					$$('#course-index h2.main')[0].show();
				}
				else {
					$$('.categorylist', '#course-index .categorybox h2').invoke('show');
					$$('#course-index .categorybox h2.podcast-cat-header', '#course-index .categorybox h2.webcast-cat-header').invoke('hide');
				}
				
				
				
				$$('#course-index .mycourses-tabs ul li a').each(function(x){ 
					
					x.observe('click', function(e) {
						
						Event.stop(e);
						
						
						tab = Event.element(e);
						
						
						$$('#course-index .mycourses-tabs ul li a').invoke('removeClassName', 'active');
						tab.addClassName('active');
						
						catID = tab.id.substr(4);
						
						
						
						if (catID == 1) {
						
							$$('.categorylist', '#course-index .categorybox h2').invoke('show');
							$$('#course-index .categorybox h2.podcast-cat-header', '#course-index .categorybox h2.webcast-cat-header').invoke('hide');
							
						}
						else if (catID <= 0) {
						
						}
						else {
							
							$$('.categorylist').without($('category-'+catID)).invoke('hide');
							
							
													
							if (catID == 8) {
							
											
								$$('#course-index .categorybox h2').invoke('hide');
								//$$('#course-index .categorybox h2.podcasts').invoke('show');
								
								$$('h2.podcast-cat-header').each(function(x) {
									cat = x.id.substring(10);
									categoryBox = $('category-'+cat);
									
									if (!categoryBox.empty()) {
										x.show();
										categoryBox.insert({before: x});
									}
								});
								
								$$('#course-index .categorylist.podcasts').invoke('show');
								
								
							}
							else if (catID == 9) {
							
								//$('category-'+catID).show()					
								//$$('#course-index .categorybox h2').invoke('hide');
								//$$('#course-index .categorybox h2.webcasts').invoke('show');
								
								$$('#course-index .categorybox h2').invoke('hide');
								//$$('#course-index .categorybox h2.webcasts').invoke('show');
								$$('h2.webcast-cat-header').each(function(x) {
									cat = x.id.substring(10);
									categoryBox = $('category-'+cat);
									
									if (!categoryBox.empty()) {
										x.show();
										categoryBox.insert({before: x});
									}
								});
								
								$$('#course-index .categorylist.webcasts').invoke('show');
								
								
							}
							else {
								$('category-'+catID).show()
								$$('#course-index .categorybox h2.main').invoke('show');
								
								$$('#course-index .categorybox h2.podcast-cat-header', '#course-index .categorybox h2.webcast-cat-header').invoke('hide');
								
								$$('#course-index .categorybox [parentID = '+catID+']').invoke('show');
								
							}
							
						}
						
					
					});

					
					
				
				});
			}
		});

