var menuItems = new Array();

addLoadEvent(function(){
	setupQL();
	setupFormRollover();
	setupPopups();
});

function setupQL()
{
	var roles ;
	roles = getElementsByTagAndClassName(null, 'qlParent', 'flQuickLinks');
	for (i = 0; i < roles.length; i++)
	{
		var a;
		var ul;

		a = getFirstElementByTagAndClassName('a', null, roles[i]);
		ul = getFirstElementByTagAndClassName('ul', 'qlInner', roles[i]);

		menuItems[i] = {
			state : 'hidden',
			link : a,
			ulToShow : ul,
			toggle : function(e)
			{
				var lis;
				li = getElementsByTagAndClassName('li', null, this.ulToShow);
				for (var j = 0; j < li.length; j++)
				{
					if (this.state == 'hidden')
					{
						showElement(li[j]);
					}else{
						hideElement(li[j]);
					}
				}
				if (this.state == 'hidden')
				{
					this.state = 'shown';
				}else{
					this.state = 'hidden';
				}
				return false;
			}
		};

		connect(a, 'onclick', menuItems[i], 'toggle');

	}
}

function setupFormRollover()
{
	if ($('btnFormSubmit'))
	{
		connect('btnFormSubmit', 'onmouseover', function(){
			setNodeAttribute('btnFormSubmit', 'src', base_url + 'assets/images/submit_down.gif');
		});

		connect('btnFormSubmit', 'onmouseout', function(){
			setNodeAttribute('btnFormSubmit', 'src', base_url + 'assets/images/submit_up.gif');
		});
	}
}

function setupPopups()
{
	var els = getElementsByTagAndClassName('a', 'popup');
	for (var i = 0; i < els.length; i++)
	{
		connect(els[i], 'onclick', function(e){
			e.preventDefault();
			var w = window.open(getNodeAttribute(this, 'href'), this.target);
		});
	}
}
