	//javascript to organize the fantasy archives page according to the
	// http://www.mlb.com/mlb/components/fantasy/fantasy_archives.xml file
	
	$(document).ready(function() {
		$("div [class^='place_']").each(function() {
			//$cfg being each div created by the xsl transform of the fantasy_archives.xml file
			var $cfg = $(this);
			var config_txt = jQuery.trim($cfg.text()).toUpperCase();
			config_txt = config_txt.replace(/\s/g,'');
			var config_id = $cfg.attr("id");		
			$("div .hlXs").each(function() {
				//$hed being each div created by the xsl transform of the cms-generated headline xml file
				var $hed = $(this);
				var value_txt = jQuery.trim($hed.text()).toUpperCase();
				value_txt = value_txt.replace(/\s/g,'');
				
				if ( value_txt.indexOf(config_txt) >= 0) {
					//move the classes and id's from the invisible config divs to 
					//the corresponding headline divs and their children
					var place_class = $cfg.attr("class");
					$hed.addClass(place_class);
					$hed.attr("id",config_id);
					$cfg.removeAttr("id");
					$hed.children().addClass(place_class);
				}
			});
			//remove the config divs from the DOM
			$cfg.remove();
			//add the headline divs to the appropriate location on the page
			$(".place_left").each(function() {
				$("div#archive_left").append($(this));
			});
			$(".place_right").each(function() {
				$("div#archive_right").append($(this));
			});
		});
		//hide any divs that do not have a corresponding entry in the config file
		$("div .hlXs").each(function() {
			if(!($(this).hasClass("place_left") || $(this).hasClass("place_right") )) {
				$(this).hide();
			} else {
				$(this).show();
			}
		});
		
		$(".story").each(function() {
			if($(this).hasClass("place_left") || $(this).hasClass("place_right") ) {
				$(this).show();
			} 
		});
	});