var ua = navigator.userAgent.toLowerCase();	/* // Browser-versions in lower case */
var an = navigator.appName.toLowerCase();		/* // Browser-names in lower case */
var MAC = ua.indexOf("mac") != -1; 				/* // Macintosh-hardware */
var OLD = navigator.userAgent.substring(7+navigator.userAgent.indexOf("ozilla"),8+navigator.userAgent.indexOf("ozilla"))<="3";	/* // Mozilla lesser than version 4 */
var MSIE = ua.indexOf("msie")>-1;				/* // Microsoft Internet Explorer in general */
var NTSC = an.indexOf("netscape")>-1;			/* // Netscape in general */
var OPERA = ua.indexOf("opera")>-1;				/* // Opera in general */
var DOM = document.getElementById; 				/* // Browsers compatible to the dynamic object model */
var IE6 = ua.indexOf("msie 6")>-1;				/* // Internetexplorer version 6.x PC and MACintosh */
var IE5 = ua.indexOf("msie 5")>-1;				/* // Internetexplorer version 5.x PC and MACintosh */
var IE4 = ua.indexOf("msie 4")>-1;				/* // Internetexplorer version 4.x PC and MACintosh */
var N6_1 = ua.indexOf('netscape6/6.1')>-1;	/* // Netscape version 6.1 PC and MACintosh */
var N6x = ua.indexOf('netscape6')>-1 || ua.indexOf('netscape/7')>-1;	/* // Netscape version 6/7.x PC and MACintosh */
var N4 = navigator.userAgent.substring(7+navigator.userAgent.indexOf("ozilla"),8+navigator.userAgent.indexOf("ozilla"))<="4" && NTSC;	/* // Netscape version 4.x PC and MAC */
var OPERA5 = ua.indexOf('opera 5')>-1;			/* // Opera 5.x in MSIE 5 compatible mode */
var OPERA6 = ua.indexOf('opera 6')>-1;			/* // Opera 6.x in MSIE 5 compatible mode */
var OTHERS = !MSIE && !NTSC && !OPERA && !OLD; 	/* // All non-specified browsers version 4.x on all platforms */
var MACMSIE = MAC && MSIE;							/* // Microsoft Internet Explorer in general on MACintosh */
var MACIE51 = ua.indexOf("msie 5.1")>-1 && MAC;	/* // Internetexplorer version 5.1 on MACintosh */
var MACIE5 = IE5 && MAC;							/* // Internetexplorer version 5.x on MACintosh */
var MACIE4 = IE4 && MAC;							/* // Internetexplorer version 4.x on MACintosh */
var MACN6_1 = N6_1 && MAC;							/* // Netscape version 6.1 on MACintosh */
var MACN6x = N6x && MAC;							/* // Netscape version 6/7 on MACintosh */
var MACN4 = N4 && MAC;								/* // Netscape version 4.x PC and MACintosh */
var MACOTHERS = OTHERS && MAC; 					/* // MACintosh and all non-specified browsers version 4.x */
var IFRAMERS = (MSIE || DOM) && !OPERA;		/* // Browsers, which cope with iframes (Opera knows them, but is not really compatible to that technology) */
var isDOM = (document.getElementById ? true : false);

function checkInput() {

	if(N4) {
		if((document.layers["loginFormLayer"].document.forms[0].j_username.value.charAt(0) == " ")||(document.layers["loginFormLayer"].document.forms[0].j_username.value == "")) {
			alert("Please insert a valid username");
			return false;
		}
	} else {
		if((document.loginForm.j_username.value.charAt(0) == " ")||(document.loginForm.j_username.value == "")) {
			alert("Please insert a valid username");
			return false;
		}
	}

	if(N4) {
		if((document.layers["loginFormLayer"].document.forms[0].j_password.value.charAt(0) == " ")||(document.layers["loginFormLayer"].document.forms[0].j_password.value == "")) {
			alert("Please insert a valid password");
			return false;
		}
	} else {
		if((document.loginForm.j_password.value.charAt(0) == " ")||(document.loginForm.j_password.value == "")) {
			alert("Please insert a valid password");
			return false;
		}
	}

}


var clickCounter = 0;
var showIt = 0;
var stopIt = 0;


function setClick(counter) {
	if(clickCounter == 1) {
		clickCounter = 0;
		showIt=0;
		stopIt = 1;
		eval(showLogin());
		setTimeout("stopIt=0",2000);
	} else {
		clickCounter = counter;
		showIt=1;
		eval(showLogin());
	}
}


function showLogin() {
	
	if(showIt == 1 && stopIt == 0) {

		if(DOM || MSIE || OPERA || N6x)	{
			document.getElementById("loginFormLayer").style.visibility = "visible";
		} else {
			document.loginFormLayer.visibility = "show";
		}

	} else {

		if(DOM || MSIE || OPERA || N6x)	{
			if(clickCounter == 0) {
				document.getElementById("loginFormLayer").style.visibility = "hidden";
			} else {
				document.getElementById("loginFormLayer").style.visibility = "visible";
			}
		} else {
			if(clickCounter == 0) {
				document.loginFormLayer.visibility = "hide";
			} else {
				document.loginFormLayer.visibility = "show";
			}
		}

	}
}