// script stuff

function toogleLogin() {
	$("#passwordfield").removeClass("fieldfail");
	$("#loginPopup").toggle();
	if ($("#login_form input[name=login_username]").val()) {
		$("#login_form input[name=login_password]").focus();	
	} else {
		$("#login_form input[name=login_username]").focus();	
	}
}

// TopMenu scripts
var tin = new Array();
var tout = new Array();

function wait_in(index) {
	var topMenu = $("#TMC" + index);
	if (topMenu != null) {
		$("#TMC" + index).css({ 'display': 'block' });
	}
	tin[index] = null;
}

function waitout(index) {
	var topMenu = $("#TMC" + index);
	if (topMenu != null) {
		$("#TMC" + index).css({ 'display': 'none' });
	}
	tout[index] = null;
	if (tin[index] != null) {
		clearTimeout(tin[index]);
		tin[index] = null;
	}
}

function showSC(index) {
	if (tout[index] != null) {
		clearTimeout(tout[index]);
		tout[index] = null;
	}
	var topMenu = $("#TMC" + index);
	if (topMenu != null) {
		if (tin[index] == null && topMenu.css('display') == 'none') {
			tin[index] = setTimeout('wait_in(' + index + ')', 150);
		}
	}
}

function hideSC(index) {
	if (tout[index] == null) {
		tout[index] = setTimeout('waitout(' + index + ')', 10);
	}
}

function actiSC(index, url) {
	var topMenu = $("#TMC" + index);
	if (topMenu != null) {
		if (tin[index] != null && topMenu.css('display') == 'none') {
			showSC(index);
		} else {
			window.location = url;	
		}
	}
}

$(function() {
	$("#feedbacktab").colorbox({href:"feedback.php"});		

	$("#login_form input[name=login_password]").keyup(function(event) {
		if (event.keyCode == 13) {
			$("#login_form").submit();
		}
	});		

	$(".nologin").bind('click', function(e) {
	    e.preventDefault();
	});
});

