// Initializes the layout.
//
function initLayout() {

	initRotatingPhotos();

} // End initLayout().

// Initializes the rotating photos.
//
function initRotatingPhotos() {

	var rotatingPhotos = $( 'rotatingPhotos' );
	var xmlDoc;

	if ( rotatingPhotos == null ) {
		return;
	} else if ( rotatingPhotos.hasClassName( 'secondary_about' ) ) {
		xmlDoc = '/xml/about/secondaryPhotos.xml';
	} else if ( rotatingPhotos.hasClassName( 'secondary_donors' ) ) {
		xmlDoc = '/xml/about/secondaryPhotos.xml';
	} else if ( rotatingPhotos.hasClassName( 'secondary_general' ) ) {
		xmlDoc = '/xml/about/secondaryPhotos.xml';
	} else if ( rotatingPhotos.hasClassName( 'secondary_training' ) ) {
		xmlDoc = '/xml/training/secondaryPhotos.xml';
	} else if ( rotatingPhotos.hasClassName( 'secondary_innovation' ) ) {
		xmlDoc = '/xml/innovation/secondaryPhotos.xml';
	} else if ( rotatingPhotos.hasClassName( 'secondary_research' ) ) {
		xmlDoc = '/xml/research/secondaryPhotos.xml';
	} else {
		return;
	} // End if.

	var flashvars = {
		xml: xmlDoc
	};
	var params = {
		menu: 'false',
		wmode: 'transparent'
	};
	var attributes = {
	};

	swfobject.embedSWF( '/flash/global/rotatingPhotos.swf', 'rotatingPhotos', '222', '241', '7.0.0', null, flashvars, params, attributes );

} // End initRotatingPhotos().

// Sets CSS rules to a specified CSS tree.
//
function setStyleSheetRule( cssId, selectorName, styleName, styleValue ) {

	// Get the stylesheet.
	var cssObj = $( cssId );
	if ( cssObj == null ) return false;

	// Get the stylesheet's rules.
	var cssRules;
	if( cssObj[ 'styleSheet' ] ) {
		cssRules = cssObj.styleSheet.rules;
	} else if( cssObj["sheet"] ) {
		cssRules = cssObj.sheet.cssRules;
	} else {
		return false;
	} // End if.

	// Modify the specified stylesheet rule.
	for( var i = 0; i < cssRules.length; i++ ) {
		var rule = cssRules[ i ];
		if( rule.selectorText.toUpperCase() == selectorName.toUpperCase() ) {
			rule.style[ styleName ] = styleValue;
			return true;
		} // End if.
	} // End for.

	return false;

} // End setStyleSheetRule().

Event.observe( window, 'load', initLayout, false );

