﻿$(document).ready(function () {
    /* login watermark */
    addWatermarkScript("#tbloginemail", "email", "logintxtb", "logintxtbwater");
    addPwdWatermarkScript("#labelloginpwd", "#tbloginpwd", "");
    headerLoginAdjust();
});

function addPwdWatermarkScript(label, input, defaultValue) {
    $(label).click(function () {
        $(this).css("z-index", "-1");
        $(input).focus();
    });

    jQuery(input).focus(function () {
        $(label).css("z-index", "-1");
    });

    jQuery(input).blur(function () {
        /* We only want this to apply if there's not something actually entered */
        if (jQuery(this).val() == "" || jQuery(this).val() == defaultValue) {
            jQuery(label).css("z-index", "");
        }
    });
}

function headerLoginAdjust() {
    var browser = GetBrowser();
    if (browser == "ie") {
        $("#labelloginpwd").css("top", "3px");
    }
}

function headerLoginClick() {
    var email = $("#tbloginemail").val();
    var pwd = $("#tbloginpwd").val();

    if (email == "email") {
        alert("To login to your account please enter your email.");
        return false;
    }
    else if (CheckEmail(email) == false)
        return false;
    else if (pwd == "") {
        alert("Please enter your password to login to your account.");
        return false;
    }
    else
        return true;
}

function retirevePwdClick() {
    document.getElementById("result").innerHTML = "";
    var email = $("#tbretrieveemail").val();

    if (email == "") {
        alert("To login to your account please enter your email.");
        return false;
    }
    else if (CheckEmail(email) == false)
        return false;
    else {
        return true;
    }
}

function studentoginClick() {
    document.getElementById("result").innerHTML = "";
    
    var email = $("#tbstudentloginemail").val();
    var pwd = $("#tbstudentloginpwd").val();

    if (email == "") {
        alert("To login to your account please enter your email.");
        return false;
    }
    else if (CheckEmail(email) == false)
        return false;
    else if (pwd == "") {
        alert("Please enter your password to login to your account.");
        return false;
    }
    else {
        return true;
    }
}

