/**
 * Extend the DOM with get element by classname
 */
function getElementsByClass( searchClass, domNode, tagName) {
	if (domNode == null) domNode = document;
	if (tagName == null) tagName = '*';
	var el = new Array();
	var tags = domNode.getElementsByTagName(tagName);
	var tcl = " "+searchClass+" ";
	for(i=0,j=0; i<tags.length; i++) 
	{
		var test = " " + tags[i].className + " ";
		if (test.indexOf(tcl) != -1)
			el[j++] = tags[i];
	}
	return el;
}
/**
 * Function to show/hide the loginbox
 */
function showHideLogin() {
	var loginBox = getElementsByClass('tx-felogin-pi1');
	loginBox = loginBox[0];
	if (loginBox == '[object HTMLDivElement]' || loginBox == '[object]') {
		if (loginBox.style.display == 'none') {
			loginBox.style.width = '207px';
			loginBox.style.display = 'block';
		} else {
			loginBox.style.display = 'none';
			loginBox.style.width = '1px';
		}
	}
}

/**
 * Checks if there is any errors in the login, if so displays the box 
 */
function checkLogin() {
	var status = document.getElementById('loginstatus');
	if (status == '[object HTMLInputElement]' || loginBox == '[object]') {
		if (status.value == 'error' || status.value == 'forgot' || status.value == 'change') {
			showHideLogin();
		} else if (status.value == 'logout' || status.value == 'success') {
			//showHideLogin();
			//setTimeout("showHideLogin()", 500);
		}
	}	
}
