﻿//Subject:    Login authentication
//Author:     Lucifer
//CreateDate: 2010-10-28
//FixedResume:
//FixedTime:

//bind function
$(document).ready(function() {
    $("#btnLogin").click(checkLogin);

//    if ("" != userInfo) {
//        var userName = userInfo.split(',')[0];
//        var email = userInfo.split(',')[1];
//        $("#toggle").empty();
//        $("#hidEmail").val(email);
//        $("div#panel").slideUp("slow");
//        $("#userNameMe").html("Hi " + userName);
//        $("#toggle").html("<a href='#' onclick='edmitUsersHander()'> My Profile</a>");
//        $("#register").html("<a href='SelectQuerySport.aspx' >MatchFit</a>&nbsp;&nbsp;<span style='color:#414141'>|</span>&nbsp;&nbsp;<a href='QuerySchoolInfo.aspx' >College Profiler</a><span style='color:#414141'>&nbsp;&nbsp;|</span>&nbsp;&nbsp;<a href='#'onclick='logoffUsers();'>Logout</a>");
//    }
    if ("3" == tag) {
        if ("false" == isSucess.toLowerCase()) {
            alert('Password or user name wrong!');
            $("#toggle").show();
        } 
    }
});

//check login In
function checkLogin() {
    $("#spEmailMessage").hide();
    $("#spPasswordMessage").hide();

    var email = $("#Email").val();
    var password = $("#pwd").val();

    if ("" == email) {
        $("#Email").focus();
        $("#spEmailMessage").show();
        return false
    }
    if ("" == password) {
        $("#pwd").focus();
        $("#spPasswordMessage").show();
        return false;
    }

    if (!checkEmail(email)) {
        $("#spEmailMessage").show();
        $("#spEmailMessage").html("Message format is wrong! Please re-enter");
        return false;
    }
    $("#Action").val(3);

}

//Logout Users
function logoffUsers() {
    var yes = confirm("Are you sure logout?");
    if (!yes) return false;
    window.location.href = '/Logout.aspx';
    
}
//function logoutCallBack(json) {
//    if (json.success == null || json.success) {
//        data = json;
//    }
//    else {
//        return;
//    }
//    if (data.Sucess) {
//        window.location.href = "Index.aspx";
//    }
//}

//Edmit users
function edmitUsersHander() {
    window.location.href = "/UpdateUserInfo.aspx?Email=" + $("#hidEmail").val();
}


function edmitUsersHander2() {
    window.location.href = "/CollegeProfiler/UpdateUserInfo.aspx?Email=" + $("#hidEmail").val();
}


function edmitUsersHander3() {
    window.location.href = "/Sp/UpdateUserInfo.aspx?Email=" + $("#hidEmail").val();
}

// Script for Navigation and Sub-Navigation Menus
$(document).ready(function() {

    $("ul.subnav").parent().append("<span></span>"); // Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav

    $("ul#navmenu li span").click(function() { // When trigger is clicked...

        // Following events are applied to the subnav itself (moving subnav up and down)
        $(this).parent().find("ul.subnav").slideDown('fast').show(); // Drop down the subnav on click

        $(this).parent().hover(function() {
        }, function() {
            $(this).parent().find("ul.subnav").slideUp('slow'); // When the mouse hovers out of the subnav, move it back up
        });

        // Following events are applied to the trigger (Hover events for the trigger)
    }).hover(function() {
        $(this).addClass("subhover"); // On hover over, add class "subhover"
    }, function() {	// On Hover Out
        $(this).removeClass("subhover"); // On hover out, remove class "subhover"
    });

    //update Lufcier 2010-10-31
    $("#aSport").click(function() { // When trigger is clicked...
        // Following events are applied to the subnav itself (moving subnav up and down)
        $(this).parent().find("ul.subnav").slideDown('fast').show(); // Drop down the subnav on click

        $(this).parent().hover(function() {
        }, function() {
            $(this).parent().find("ul.subnav").slideUp('slow'); // When the mouse hovers out of the subnav, move it back up
        });

        // Following events are applied to the trigger (Hover events for the trigger)
    }).hover(function() {
        $(this).addClass("subhover"); // On hover over, add class "subhover"
    }, function() {	// On Hover Out
        $(this).removeClass("subhover"); // On hover out, remove class "subhover"
    });

    $("#aService").click(
        function() { // When trigger is clicked...
            // Following events are applied to the subnav itself (moving subnav up and down)
            $(this).parent().find("ul.subnav").slideDown('fast').show(); // Drop down the subnav on click

            $(this).parent().hover(function() {
            }, function() {
                $(this).parent().find("ul.subnav").slideUp('slow'); // When the mouse hovers out of the subnav, move it back up
            });

            // Following events are applied to the trigger (Hover events for the trigger)
        }).hover(function() {
            $(this).addClass("subhover"); // On hover over, add class "subhover"
        }, function() {	// On Hover Out
            $(this).removeClass("subhover"); // On hover out, remove class "subhover"
        }
    );

});
                           
