// <CallMSAAutoLogin> function will be called on Login button click with the following parameters: 
//   - parameter <userNameObjId> is the UserName textbox id
//   - parameter <userPasswordObjId> is the Password textbox id
//   - parameter <openType> (possible values: popup/inplace)
function CallMSAAutoLogin(userNameObjId, userPasswordObjId, openType) {
    try {
        //get login credentials
        var userName = document.getElementById(userNameObjId).value;
        var userPassword = document.getElementById(userPasswordObjId).value;
        
        //Define webservice (openttype: inplace/popup)  
        var webServiceURL = "http://verzuimadministratie.ektroncms.nl/WebServices/MSAWebService.asmx/GetUserRemoteLoginQueryString?userName=" + userName + "&password=" + userPassword + "&opentype=" + openType;
        var script = document.createElement("script");
        script.setAttribute("type", "text/javascript");
        script.setAttribute("src", webServiceURL);
        
        //get and register actions
        var head = document.getElementsByTagName("head").item(0);
        head.appendChild(script);

        //clear password for security reasons
        document.getElementById(userPasswordObjId).value = '';
    }
    catch (e) {
        alert('Remote login service unavailable!');
    }
}