<?php
	if ( !$settings->title ) {
		exit( 'Please, don\'t load this page directly. Thanks.' );
	}
?>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title><?php echo $settings->title; ?></title>
		<?php if ( $settings->slideshow ) { ?>
			<link rel="stylesheet" href="css/jd.gallery.css" type="text/css" media="screen" charset="utf-8" />
			<script src="scripts/mootools-1.2.1-core-yc.js" type="text/javascript"></script>
			<script src="scripts/mootools-1.2-more.js" type="text/javascript"></script>
			<script src="scripts/jd.gallery.js" type="text/javascript"></script>
			<?php if ( $settings->gallery_sets ) { ?>
				<script src="scripts/jd.gallery.set.js" type="text/javascript"></script>
			<?php } ?>
		<?php } ?>
		<link rel="stylesheet" href="style.css" type="text/css" media="all">
		<link href='http://fonts.googleapis.com/css?family=Orbitron' rel='stylesheet' type='text/css'>
		<script type="text/javascript">
			function setOpacity( element, value ) {
			 element.style.opacity = value/100; 
			 element.style.MozOpacity =  value/100; 
			 element.style.KhtmlOpacity =  value/100; 
			 element.style.filter=" alpha(opacity ="+value+")";
			}
		</script>
	</head>

	<body>
		<div id="logo">
			<img id="left-pop-out" src="images/omicron.png">
			<img id="right-pop-out" src="images/destroyer.png">
			<a title="" href="/"><img id="nova" src="images/logo-nova.png"></a>
		</div>

		<div id="ticker">
			<strong>news:</strong><div id="ticker-content"></div>
		</div>
		<script type="text/javascript">
			var newsCount = 0;
			var newsTimer = 0;
			var newsHeadlines = new Array();
			<?php
				$news = load_feed( 'http://www.freeallegiance.org/forums/index.php?act=rssout&id=1' );
				$i = 0;
				foreach ( $news as $headline ) {
					if ( strlen( $headline[ 'title' ] ) > 45 ) { $headline[ 'title' ] = substr( $headline[ 'title' ], 0, 45 ) . '…'; }
					$headline[ 'title' ] = '<small>' . date( 'd M Y', strtotime( $headline[ 'date' ] ) ) . '</small>  ' . $headline[ 'title' ];
					echo 'newsHeadlines[', $i, ']="<a href=" + \'"\' + "', htmlentities( $headline[ 'link' ] ), '" + \'"\' + ">', $headline[ 'title' ], '</a>";', "\n";
					$i++;
				}
			?>
			function tickerState() {
				newsTimer = newsTimer + 1;
				if ( newsTimer == 501) { newsTimer = 1; }
				if ( newsTimer < 51 ) {
					setOpacity( document.getElementById( "ticker-content" ), newsTimer * 2 );
				}
				if ( newsTimer > 449 && newsTimer < 500 ) {
					setOpacity( document.getElementById( "ticker-content" ), (500 - newsTimer) * 2 );
				}
				if ( newsTimer == 500 ) {
					newsTicker();
				}				
			}
			function newsTicker() {
				document.getElementById( "ticker" ).innerHTML = "<strong>news:</strong> <div id='ticker-content'  style='filter:alpha(opacity=0);opacity:0;'>" + newsHeadlines[ newsCount ] + "</div>";
				newsCount = newsCount + 1;
				if ( newsCount == 4 ) { newsCount = 0; }
			}
			newsTicker();
			timer = setInterval( "tickerState()", 10 );
		</script>