/**
 * Collecting helper code for OAS JavaScript that resides in theme html files.
 *
 * @author Alex Wohlhueter <alex@clockwork.net>
*/


/* configure */

// sponsored section list - top-level dir names
var oas_active_sections  =  ['business','businessagenda','politics','arts','dailyglean'];

/* initialize */

// extra positions to request (comma-prefixed)
var oas_listpos_extras  =  '';

// empty or becomes e.g. '/business'
var oas_section_sitepage_prefix = '';

/* functions */

/* */
function oas_var_tag_matches_active_section ( section_var_tag ) {

	if ( section_var_tag == '' ) {
		return false;
	}
	else {
		if ( typeof( oas_active_sections ) == 'undefined' ) {
			return false;
		}
		// check that it's in_array of active sections
		var section_is_active  =  false;
		for ( var i = 0; i < oas_active_sections.length; i++ ) {
			if ( oas_active_sections[i] === section_var_tag ) {
				section_is_active  =  true;
			}
		}
		return section_is_active;
	}
}

/* match each section against current url */
function location_matches_oas_active_sections ( ) {
	var match  =  false;
	for ( var i = 0; i < oas_active_sections.length; i++ ) {
		var section_dir  =  '/' + oas_active_sections[i] + '/';
		if ( window.location.pathname.indexOf(section_dir) == 0 ) {
			match  =  true;
		}
	}
	return match;
}

/* Add the position name, reveal ad and hide competing content via CSS */
function show_oas_section_badge ( ) {
	// add our special position name
	oas_listpos_extras  =  oas_listpos_extras + ',TopLeft';
	// write style to show/hide affected content 
	document.write( '<style type="text/css">.hide-if-section-sponsor{ display: none; } ' + 
					'div.reveal-if-section-sponsor{ display: block; }</style>' );
}


// Show TopLet, but do not rely on section_var_tag --kpc

	pathArray = window.location.pathname.split( '/' );
	//	for ( i = 0; i pathArray.length; i++ ) {
	// ...
	//	}
	if ( pathArray[1] == 'dailyglean' ) {
		show_oas_section_badge( );
	}


