/**
 * @author Alex
 */
// Input todays date in dateTopLeft div
//////////////////////////////////////////////////////////////////////////////////////
//<script type="text/javascript" src="jquery.js"></script>

$(document).ready(function(){
  includeDate();	
  makeListCollapsible();
  
   // Make nav divs into links (not just the <a> that they contain)
  if(document.getElementById('navHome')){document.getElementById('navHome').onclick = function(){self.location = "index.php";};}  
  if(document.getElementById('navInfo')){document.getElementById('navInfo').onclick = function(){self.location = "info.php";};}  
  if(document.getElementById('navBlog')){document.getElementById('navBlog').onclick = function(){self.location = "blog.php";};}  
  if(document.getElementById('navPhotos')){document.getElementById('navPhotos').onclick = function(){self.location = "profile.php";};}  
  if(document.getElementById('navLegacy')){document.getElementById('navLegacy').onclick = function(){self.location = "legacy.php";};}  
  if(document.getElementById('navLinks')){document.getElementById('navLinks').onclick = function(){self.location = "links.php";};}      
  if(document.getElementById('sideBarInfo')){document.getElementById('sideBarInfo').onclick = function(){self.location = "info.php";};}  
  if(document.getElementById('sideBarBlog')){document.getElementById('sideBarBlog').onclick = function(){self.location = "blog.php";};} 
});

function makeListCollapsible(){
	
	$('.collapsibleList > ul > li').each(function(){	  	
	  if($(this).children().size() > 1){ // This li contains another list. Need to add listToggle div 
		$(this).prepend('<div class="listToggle">- </div>');	
	  }else{ // This li doesn't contain another list. Need to add listSpacing div to compensate for adding listToggle to other li's
		$(this).prepend('<div class="listSpacing">&nbsp;&nbsp;&nbsp;</div>');	
	  }	
	});	
	
	$('.listToggle').css('display','inline');
	$('.listToggle').css('cursor','pointer');	
	$('.listSpacing').css('display','inline');	
	$('.collapsibleList > ul').css('list-style-type','none');	

    
  $('.listToggle').hover(function(){
    $(this).css('color', '#5a91af');
  }, function(){
    $(this).css('color', '');
  });  
  
  $('.listToggle').click(function(){   	
    $(this).siblings().children().toggle();		
    if($(this).html() == "+ "){
      $(this).html("- ");
	}else{
      $(this).html("+ ");
	}
  });	
  
  //$('.listToggle').click(); // Make lists collapsed by default
  
}

function includeDate()
{
  var dateTopLeft = document.getElementById('dateTopLeft');   
  var dateString;
  var d = new Date();  
  var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
  var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December");  
  dateTopLeft.innerHTML = weekday[d.getDay()] + ', ' + monthname[d.getMonth()] + ' ' + d.getDate() + ', ' + d.getFullYear();  
}




