
// ***  LOGIN FORM  *** //

var statusLoginForm = false;
var intervalStarted = false;
var tTimer;
var secondsShow = 5;
var oObject;

document.onclick = function test(e){
    var browser=navigator.appName;
    if (browser=="Microsoft Internet Explorer"){
        oObject = window.event.srcElement;
    }else{
        oObject = e.target;
    }
    setIntervalHideLoginForm();
}

function setIntervalHideLoginForm(){
    if (statusLoginForm==true){
        if (oObject.id =="loginContainer" || oObject.id =="loginClient" || oObject.id =="loginForm" || oObject.id =="loginRegister" || oObject.id =="loginRegisterLink" || oObject.id =="loginControls" || oObject.id =="loginProfileControls" || oObject.id =="ctl00_LoginControl1_txtLoginUsername" || oObject.id =="ctl00_LoginControl1_txtLoginPassword" || oObject.id =="ctl00_LoginControl1_btnLogin" || oObject.id =="ctl00_LoginControl1_lblClientLogin" || oObject.id =="ctl00_LoginControl1_pnlLoggedIn" || oObject.id =="ctl00_LoginControl1_pnlLoggedOut" || oObject.id =="ctl00_LoginControl1_lbtnLogoutLink" || oObject.id =="logout" ){
	        if (intervalStarted==true){
	            window.clearInterval(tTimer);
	            intervalStarted = false;
	        }
	        secondsShow = 5;
	    }else{
	        if (intervalStarted === false){
	            tTimer = window.setInterval("timerHideLoginForm()", 100);
	            intervalStarted = true;
	        }
	    }
    }
}

function timerHideLoginForm(){
    if (secondsShow>0){
     secondsShow -=1;
    }else{
        window.clearInterval(tTimer);
	    intervalStarted = false;
	    secondsShow = 5;
	    hideLoginForm(oObject);
    }
}

function hideLoginForm(oObject){
    statusLoginForm = false;
	var oLoginFormStyle = document.getElementById('loginForm').style
	loginFormTween = new Tween(oLoginFormStyle, 'top', Tween.elasticEaseOut, -15, -55,0.5,'px');
	loginFormTween.start();
}
function showLoginForm(){
	var oLoginFormStyle = document.getElementById('loginForm').style
	if (statusLoginForm==false){
		loginFormTween = new Tween(oLoginFormStyle, 'top', Tween.elasticEaseOut, -55, -15,1,'px');
		statusLoginForm = true;
		loginFormTween.start();
	}	
}

function clearTextField(txtField, txtValue, cColor, isPassword){
    if (txtField.value == txtValue){
        txtField.value = '';
        if (isPassword == 'yes'){
            var np = txtField.cloneNode(true);
            np.type='password';
            txtField.parentNode.replaceChild(np, txtField);
        }
    }
    txtField.style.color = cColor;
}

function setTextField(txtField, txtValue, cColor){
    if (txtField.value == '' || txtField.value == txtValue){
        txtField.value = txtValue;
        txtField.style.color = cColor;
        txtField.type = 'text';
    }
}
