// hmpg.js
// Ken Ficara
// Copyright (C) 2009 Harmonica, LLC
//
// Specific home page functions for text display.
//
// $Id: nav.js 94 2010-02-01 04:21:07Z ficara $
//-------------------------------------------------------------------


// Globals

var kf;

if (!kf) kf = {};
else if (typeof (kf) != 'object') 
        throw new error ('kf is not an object');
        
kf.sections = new Array ('home', 'music', 'words', 'images');

// Preload images

var bw_icons = new Array;
var color_icons = new Array;

function highlight(item)
{
	
	if (kf.current=='home')
	{
		var graf = document.getElementById(item+'-graf');
	
		if (graf)
		{
			graf.style.color='#CC6600';
			graf.style.display='block';
		}
		

	}
		
	apply (item, true);
	
	if (document.body.id == 'home' && kf.current != 'home')
	{
		apply (kf.current, true);
	}
	
	return(true);
}

function dim(item)
{
	if (kf.current=='home')
	{		var graf = document.getElementById(item+'-graf')

		
		if (graf)
		{
			graf.style.color='white';
			if (item != 'home')
			{
				document.getElementById(item+'-graf').style.display='none';
			}
		}
	}
	
	if (document.body.id == 'home')
	{
		if (item != kf.current || item == 'home')
		{
			apply (item, false);
		}
	}
	else
	{
		apply (item, false);
	}
	return(true);
}

function show(item)
{
	if (document.body.id == 'home')
	{ 
		var old = kf.current;
		
		kf.current = item;

		$('.news-'+old).hide();
		$('p#'+old+'-graf').hide();
		$('p#'+item+'-graf').show();
		$('p#'+item+'-graf').css('color','#C60');
		
		if (item == 'home')
		{
			$('div#topnews').show();
		
		}
		else
		{
			$('.news-'+item).show();
			$('div#topnews').hide();

		}
		
		apply (old, false);
		apply (item, true);
	}
	else
	{
		window.location = '/home.php';
	}
}
	


$(function()
{

kf.current = document.body.id;

kf.bw_icons = new Array;
kf.color_icons = new Array;

for (i in kf.sections)
{
	var section = kf.sections[i];

	kf.bw_icons[section] = new Image(100,100);
	kf.bw_icons[section].src ='/media/'+section+'-bw.jpg';

	kf.color_icons[section] = new Image(100,100);
	kf.color_icons[section].src = '/media/'+section+'-c.jpg';
}

// Nav rollovers are done with direct JS because jquery is for some 
// reason very slow. This rollover is for the overall nav block,
// to show or hide the default home page text.


$('div#nav').hover(
function()
{
	if (kf.current == 'home')
	{
		$('p#home-graf').hide();
	}
},

function()
{
	if (kf.current == 'home')
	{
		$('p#home-graf').show();
	}
})

$('div[class*=news]').hide();

$('div#topnews').show();

});