﻿/*$("#tdAR").tooltip({ effect: 'slide' });
$("#tdID").tooltip({ effect: 'slide' });*/
function ProcessLogin(date) {

    $('#divLoginError').attr('style', 'display:none;');
    $("#dialog-Login").dialog({
        height: 140,
        modal: true
    });
    $("#dialog-Login").dialog('open');
	$("#dialog-Login").siblings(".ui-dialog-titlebar").hide();
    $("#dialog-Login").attr('style', 'display:block;');
	var d = new Date(date);
	//alert(d.getHours().toString()+" "+d.getMinutes().toString());
	if ((d.getHours() < 5) || (d.getHours()==5 && d.getMinutes()<30)) {
		$("#dialog-Login").dialog('close');
	    $("#NightTime").dialog({
	        height: 80,
	        width: 400,
	        modal: true,
	        buttons: { "Close": function() {
	            $(this).dialog('close');
	        }
	        }

	    });
	    $("#NightTime").dialog('open');
	    $("#NightTime").siblings(".ui-dialog-titlebar").hide();
	    $("#NightTime").attr('style', 'display:block;');
	    
	}
	else {
	    PageMethods.ValidateLoginInfo(document.getElementById('txtLogin').value, document.getElementById('txtPassword').value, "S", onCompleteUserIdCheckAvailability)
	}
}

function ProcessParentLogin() {
   
    $("#dialog-Login").dialog({
        height: 140,
        modal: true
    });
    $("#dialog-Login").dialog('open');
	$("#dialog-Login").siblings(".ui-dialog-titlebar").hide();
    $("#dialog-Login").attr('style', 'display:block;');
    PageMethods.ValidateParentLoginInfo(document.getElementById('txtPLogin').value, document.getElementById('txtPPassword').value, "P", onCompleteParentCheckAvailability)
}

function onCompleteParentCheckAvailability(result) {

    if (result == "false" || result == "error") {
        // If Email Id not exists insert into database
        $("#dialog-Login").dialog('close');
        alert("Invalid Login...Please try again..");
        $("#txtPLogin").focus();
    }
    else {
        window.location.href = result;
    }
}

function onCompleteUserIdCheckAvailability(result) {


    if (result == "false" || result == "error") {
        // If Email Id not exists insert into database
        $("#dialog-Login").dialog('close');
        alert("Invalid Login...Please try again..");
        $("#txtLogin").focus();
    }
    else {

       

        if (result.toString().indexOf('login/welcome') > -1) {
            //PageMethods.RedirectToWelcome(onCompleteRedirect);
            window.location.href = result;
        }
        else {
            $("#dialog-Login").dialog('close');
            $('#divCourseData').html(result);

            //GetStates("", "rdoCourse", "");
            $("#dialog-Course").dialog({
                width: 500,
                height: 500,
                modal: true
            });
            $("#dialog-Course").dialog('open');
			$("#dialog-Course").siblings(".ui-dialog-titlebar").hide();
            $("#dialog-Course").attr('style', 'display:block;');


        }

    }
}
function AcceptCourse() {
    //alert($('input[name=rdoCourse]:checked').val());
    PageMethods.AcceptUserCourse($('input[name=rdoCourse]:checked').val(), onCompleteCourseAcceptancy)
}

function onCompleteCourseAcceptancy(result) {
    // PageMethods.RedirectToWelcome();
	//alert('xx');
    window.location.href = result;
}
function onCompleteRedirect(restult) {
    window.location.href = restult;
}

function ProcessAdminLogin() {

    //alert('x');
$("#divUserId").html('');
    $("#divPassword").html('');
    
    var txtALogin = $("#txtALogin").val();
    var txtAPassword = $("#txtAPassword").val();

    if (txtALogin.length == 0 || txtAPassword.length == 0) {
        if (txtALogin.length == 0) {
            $("#divUserId").html('<span style="color:red;font-size: 13px;font-weight:normal;">Please enter UserId.</span>');
        }
        else {
            $("#divPassword").html('<span style="color:red;font-size: 13px;font-weight:normal;">Please enter Password.</span>');
        }
        return false;
    }
    else {
   
    $("#dialog-Login").dialog({
        height: 140,
        modal: true
    });
    $("#dialog-Login").dialog('open');
	$("#dialog-Login").siblings(".ui-dialog-titlebar").hide();

    $("#dialog-Login").attr('style', 'display:block;');
    PageMethods.ValidateAdminLogin(document.getElementById('txtALogin').value, document.getElementById('txtAPassword').value, onCompleteAdminCheckAvailability)
}
}

function onCompleteAdminCheckAvailability(result) {

    if (result == "false" || result == "error") {
        // If Email Id not exists insert into database
        $("#dialog-Login").dialog('close');
        alert("Invalid Login...Please try again..");
        $("#txtALogin").focus();
    }
    else {
        window.location.href = result;
    }
}
