var elmDsp = new Array();
/*function hideshow(id)
{
	if(!(elm = document.getElementById(id)))
	{
		return false;
	}

	if(elm.style.display != 'block')
	{
		elm.style.display = 'block';
	}
	else
	{
		elm.style.display = 'none';
	}
	
	return true;
}*/

var animating = false;
function hideshow(id)
{
	if(!(elm = document.getElementById(id)))
	{
		return false;
	}
	
	if(!animating)
	{
		if(elm.style.display == 'none')
		{
			animating = true;
			Effect.BlindDown(id, {afterFinish:function(){animating = false;}});
		}
		else
		{
			animating = true;
			Effect.BlindUp(id, {afterFinish:function(){animating = false;}});
		}
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name, clear) {
	var ca = document.cookie.split(';');
	var out = new Array();
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.split('=')[0].match(name) != null)
		{		
			out[out.length] = c.split('=')[1];
			if(clear) eraseCookie(c.split('=')[0]);
		} 
	}
	if(out.length == 0)
		return null;
	else
		return out;
}


function eraseCookie(name) {
	createCookie(name,"",-1);
}

function notices()
{
	if((n = readCookie('hungryhank\\[notice\\]', true)) != null)
	{
		for(var i = 0;i<n.length;i++)
		{
			notice = n[i];
			message = unescape(notice.split('%7E')[0]).replace(/\+/g, ' ');
			type = notice.split('%7E')[1].replace(/[^a-z]/g, '');
			if($('notices'))
			{
				$('notices').innerHTML += '<div class="'+type+'" onclick="Effect.Fade($(this))">'+message+'</div>';
			}
		}
	}
	setTimeout("fadeNotices()", 5000);
	$('notices').style.display = 'block';
}

function fadeNotices()
{
	var noticeBlocks = $('notices').getElementsByTagName('div');
	var num = noticeBlocks.length;
	for(var i = 0; i < num; i++)
	{
		if(noticeBlocks[i].style.display != 'none')
		{
			Effect.Fade(noticeBlocks[i]);
			break;
		}
	}
	if(i < num)
	{
		setTimeout("fadeNotices()", 500);
	}
}

function selectOption(id, value)
{
	if(!(elm = $(id)))
	{
		return false;
	}
	options = elm.getElementsByTagName('option');
	var found = false;
	for(var i=0;i<options.length;i++)
	{
		if(options[i].value == value)
		{
			options[i].selected = 'selected';
			found = true;
		}
		else
		{
			options[i].selected = '';
		}
	}
	return found;
}

function addOnLoad(myFunction)
{
	var oldOnload = window.onload;
    window.onload = function () {
		if(myFunction != null && typeof(myFunction) == 'function')
		{
			myFunction();
		}
        if(oldOnload != null && typeof(oldOnload) == 'function')
		{
            oldOnload();
        }
    }
}