﻿var defaultEmailText = 'אימייל';

function ValidateLogin()
{
    var msg="";
    try
    {    
        if(document.getElementById("EmailTextBox").value=="" || document.getElementById("EmailTextBox").value==defaultEmailText)
        {
            msg="אימייל - שדה חובה";
            ShowMessage(msg, true);
            ReturnFocusOnMessageClose("EmailTextBox");
            return false;
        }
        
        if(!checkMail(document.getElementById("EmailTextBox").value))
        {
            msg="אימייל לא תקין.";
            ShowMessage(msg, true);
            ReturnFocusOnMessageClose("EmailTextBox");
            return false;
        }
        
        if(document.getElementById("PasswordTextBox").value=="")
        {
            msg="סיסמא - שדה חובה";
            ShowMessage(msg, true);            
            ReturnFocusOnMessageClose("PasswordLabelTextBox");
            return false;
        }
          
        if(document.getElementById("CheckLoginButton")!=null)
        {
            document.getElementById("CheckLoginButton").click();
        }        
    }
    catch(e)
    {
        alert(e.message)
    }
    return false;
    
}

function ForgetPassword()
{

    try
    {
        var msg="";
        
        if(document.getElementById("EmailTextBox").value=="" || document.getElementById("EmailTextBox").value==defaultEmailText)
        {
            msg="אימייל - שדה חובה";
            ShowMessage(msg, true);
            ReturnFocusOnMessageClose("EmailTextBox");
            return false;
        }
        
        if(!checkMail(document.getElementById("EmailTextBox").value))
        {
            msg="אימייל לא תקין.";
            ShowMessage(msg, true);
            ReturnFocusOnMessageClose("EmailTextBox");
            return false;
        }
        
        if(document.getElementById("ForgetPasswordButton")!=null)
        {
            document.getElementById("ForgetPasswordButton").click();
        }       
    }
    catch(e)
    {
        alert(e.message);
    }
    return false;
    
}

function TypePassword(focusIn)
{
    var passwordLabelTextBox = document.getElementById('PasswordLabelTextBox');
    var passwordTextBox = document.getElementById('PasswordTextBox');
     
    if (focusIn)
    {
        passwordLabelTextBox.style.visibilty = 'hidden';
        passwordLabelTextBox.style.display = 'none';
                
        passwordTextBox.style.visibility = 'visible';
        passwordTextBox.style.display = 'inline';
        passwordTextBox.focus();
    }
    else
    {
        if (passwordTextBox.value == '')
        {
            passwordTextBox.style.visibilty = 'hidden';
            passwordTextBox.style.display = 'none';            
                
            passwordLabelTextBox.style.visibility = 'visible';
            passwordLabelTextBox.style.display = 'inline';
        }    
    }
}

function TypeEmail(focusIn)
{    
    var emailTextBox = document.getElementById('EmailTextBox');    
    if (focusIn)
    {
        if (emailTextBox.value == '' || emailTextBox.value == defaultEmailText)
        {
            emailTextBox.value = '';
            emailTextBox.style.textAlign = 'left';
            emailTextBox.style.color = "black";
        }
    }
    else
    {
        if (emailTextBox.value == '')
        {
            emailTextBox.value = defaultEmailText;
            emailTextBox.style.textAlign = 'right';
            emailTextBox.style.color = "#616161";
        }    
    }
}

