﻿
/* PAGE METHODS
----------------------------------------------------------*/

function pageLoad() 
{

}

function check_mail() {
    if (Page_ClientValidate("emailGroup")) {
        showLoader(true);
        var txtMail = document.getElementById(clientIDs.UserEmail);
        var email = txtMail.value;

        PageMethods.CheckEmail(email, OnSucceeded, OnFailed);
    }
    else {
        hidebutton();
    }
}

// Callback function invoked on successful 

// completion of the page method.
function OnSucceeded(result, userContext, methodName) {
    if (result) {
        if (confirm("Το Email που καταχωρίσατε χρησιμοποιείται ήδη.\nΠατήστε ok για να μεταφερθείτε στη σελίδα εισόδου.")) {
            location.href = "Default.aspx?lnkId=a6001";
        }
    }
   else {
       document.getElementById(clientIDs.ImageButton1).style.display = "block";
       alert('Το Email που καταχωρίσατε δεν είναι καταχωρημένο και μπορεί να χρησιμοποιηθεί.\nΜπορείτε να συνεχίσετε με την συμπλήρωση της υπόλοιπης φόρμας.');
   }

    showLoader(false);
}

// Callback function invoked on failure 

// of the page method.
function OnFailed(error, userContext, methodName) {
    if (error !== null) {
        //displayElement.innerHTML = "An error occurred: " + error.get_message();
        alert(error.get_message());
    }
    showLoader(false);


}

if (typeof (Sys) !== "undefined") Sys.Application.notifyScriptLoaded();


/* VARIOUS FUNCTIONS
----------------------------------------------------------*/

function hidebutton() {
    document.getElementById(clientIDs.ImageButton1).style.display = "none";
}
function soTitleChanged(objDrop) 
{
    var currentValue = objDrop.options[objDrop.selectedIndex].value;
    
    var UserTitle = document.getElementById(clientIDs.UserTitle);

    // UserTitle.style.display = ((currentValue == 512) ? "block" : "none");
    if (currentValue == 512)
        UserTitle.style.display = "block";
    else {
        UserTitle.style.display = "none";
        UserTitle.value = objDrop.options[objDrop.selectedIndex].text;
    }

}

