var shown_elem = null;
var lited_elem = null;

function ShowMain(el) {
	$(el).css('left', 'auto');
}
function HideMain(el) {
	$(el).css('left', '-999em');
}

function HoverMain(el) {
	$(el).parent().addClass('hover');
	shown_elem = el;
}
function UnhoverMain(el) {
	$(el).parent().removeClass('hover');
	shown_elem = null;
}

function LiteElem(el) {
	$(el).css('background-color', '#DB3410');
	lited_elem = el;
}
function UnliteElem(el) {
	$(el).css('background-color', '');
	lited_elem = null;
}

function MainFocus(e) {
	if (!e) var e = window.event;
	elem = e.target;
	//ShowMain($(elem).parent().children().eq(1));
	HoverMain($(elem).parent().children().eq(1));
	LiteElem($(elem));
}
function MainBlur(e) {
	if (!e) var e = window.event;
	elem = e.target;
	//HideMain($(elem).parent().children().eq(1));
	UnhoverMain($(elem).parent().children().eq(1));
	UnliteElem($(elem));
}
function SubFocus(e) {
	if (!e) var e = window.event;
	elem = e.target;
	//ShowMain($(elem).parent().parent().parent().children().eq(1));
	HoverMain($(elem).parent().parent().parent().children().eq(1));
	LiteElem($(elem));
}
function SubBlur(e) {
	if (!e) var e = window.event;
	elem = e.target;
	//HideMain($(elem).parent().parent().parent().children().eq(1));
	UnhoverMain($(elem).parent().parent().parent().children().eq(1));
	UnliteElem($(elem));
}
function MouseOverReset() {
	if (shown_elem != null) {
		UnhoverMain(shown_elem);
	}
	if (lited_elem != null) {
		UnliteElem(lited_elem);
	}
}
function HookUp() {
	//main
	$("a.mainlevel-son-of-suckerfish-horizontal").focus(MainFocus);
	$("a.mainlevel-son-of-suckerfish-horizontal").blur(MainBlur);
	//main active
	$("a.mainlevel_active-son-of-suckerfish-horizontal").focus(MainFocus);
	$("a.mainlevel_active-son-of-suckerfish-horizontal").blur(MainBlur);
	//sub
	$("a.sublevel-son-of-suckerfish-horizontal").focus(SubFocus);
	$("a.sublevel-son-of-suckerfish-horizontal").blur(SubBlur);
	//sub active
	$("a.sublevel_current-son-of-suckerfish-horizontal").focus(SubFocus);
	$("a.sublevel_current-son-of-suckerfish-horizontal").blur(SubBlur);
	
	//mouseover reset
	$("a.mainlevel-son-of-suckerfish-horizontal").mouseover(MouseOverReset);
	$("a.mainlevel_active-son-of-suckerfish-horizontal").mouseover(MouseOverReset);
	$("a.sublevel-son-of-suckerfish-horizontal").mouseover(MouseOverReset);
	$("a.sublevel_current-son-of-suckerfish-horizontal").mouseover(MouseOverReset);
}
$(document).ready(HookUp);
