<?php
$page_name = "Home";
$menu_type = "ignore";
$menu_name = "Home";
$blog_num = 0;
$page_rate = 9;
$page_tags = array();
include_once("./files/head.php");

echo "<p>Welcome to my blog...Like every other blog out there, this is where I tell the world about what interests me at any current moment.  What's different is that I have a pretty eclectic collection of hobbies and interests.  Or my attention wanders a lot...Anyways, Enjoy!</p>\n";

echo "<p>Oh yeah, don't expect to see anything about friends, family, or work...Those will just get me in trouble :P</p>\n";

//include_once("./files/countdown_timer.php");

$news_items = file("./files/news.php");
$in_list = 0;
$hide_old_news = 0;
foreach ($news_items as $key => $item) {
  $item = trim($item);
  $item_start = substr($item, 0, 5); //first 5 letters of each line
  $item_body = substr($item, 6); //the rest of the line
  
  if ($item_start == "DATE:"){
    $item_date = date("Y", strtotime($item_body)) . str_pad(date("z", strtotime($item_body)), 3, 0, STR_PAD_LEFT); //convert date to yyyyddd (2011345)
    $temp = date("Y", time()) . str_pad(date("z", time()), 3, 0, STR_PAD_LEFT); //todays date as yyyyddd (2011322)
    $is_old = substr($temp, 0, 4) - substr($item_date, 0, 4); //look for previous years
  }

  //make a new hidden div for every year
  if ($hide_old_news == 1 && $how_old != $is_old){
    $hide_old_news = 0;
    echo "</div>\n";
  }

  //hide all news from previous years
  if ($is_old > 0 && $hide_old_news == 0){
    echo "<br /><a href=\"javascript:toggle('" . $is_old . "old_news', '" . $is_old . "old_news_pica', '" . $is_old . "old_news_picb');\">";
	echo "<img src=\"./images/plus.gif\" id=\"" . $is_old . "old_news_pica\" width=15 height=15 style=\"display: inline;\" >";
	echo "<img src=\"./images/minus.gif\" id=\"" . $is_old . "old_news_picb\" width=15 height=15 style=\"display: none;\" >";
	echo substr($temp, 0, 4) - $is_old . " news</a>\n";
	echo "<div id=\"" . $is_old . "old_news\" style=\"display: none;\">";
    $hide_old_news = 1;
    $how_old = $is_old;
  }

  $item_skip = ($item_date <= $temp) ? 0 : 1; //if item date > todays date, set item_skip bit (2011345 > 2011322 = do not show)
  if ($item_skip != 1) {
    if ($item_start == "DATE:") {
      //start entry
      echo "<br />\n<br />\n<h4 class=\"pink no_space\">";
      echo date("F j, Y", strtotime($item_body));
      echo "</h4>";
    } else if ($item_start == "TEXT:" && $in_list == 0) {
      //text
      echo "<p class=\"no_space\">&nbsp;&nbsp;&nbsp;";
      echo $item_body;
      echo "</p>\n";
    } else if ($item_start != "-----" && $in_list == 1) {
      //list item
      echo "<li>";
      echo $item;
      echo "</li>\n";
    } else if ($item_start == "-----" && $in_list == 0) {
      //start list
      $in_list = 1;
      echo "<ul>\n";
    } else if ($item_start == "-----" && $in_list == 1) {
      //end list
      $in_list = 0;
      echo "</ul>\n";
    }
  }
}

if ($hide_old_news == 1){
  echo "</div>\n";
}

include_once("./files/close.php");

?>