var MESSAGE_USERNAME_REQUIRED = "Please enter the username."; var MESSAGE_PASSWORD_REQUIRED = "Please enter the password."; var MESSAGE_PASSWORD_CONFIRM = "Password and confirmation must coincide. Please retype password and confirmation."; var MESSAGE_EMAIL_REQUIRED = "Please enter a valid email address."; var MESSAGE_USERNAME_USED = "The username is already in use. Please enter a different username."; function HDW_locate_field(item,form) { for(i=0;i < form.elements.length;i++) if (form.elements[i].name == item) return i; return -1; } function HDW_validate_registration(form) { var username_f = form.hdwusername.value; var password_f = form.hdwpassword.value; var passwordc_f = form.hdwconfirm.value; var password_f = form.hdwpassword.value; var activationemail_f = form.hdwactivation_email.value; if (form.elements[HDW_locate_field(username_f,form)].value == '') { alert(MESSAGE_USERNAME_REQUIRED); return false; } if (form.elements[HDW_locate_field(password_f,form)].value == '') { alert(MESSAGE_PASSWORD_REQUIRED); return false; } if (passwordc_f != '' && form.elements[HDW_locate_field(password_f,form)].value != form.elements[HDW_locate_field(passwordc_f,form)].value) { alert(MESSAGE_PASSWORD_CONFIRM); return false; } if (activationemail_f != '') { var email = form.elements[HDW_locate_field(activationemail_f,form)].value; if (email.indexOf("@")<1) { alert(MESSAGE_EMAIL_REQUIRED); return false; } } return HDW_verify_username(form); } function HDW_verify_username(form) { var username_f = form.hdwusername.value; var table = form.hdwtablename.value; http_request = HDW_getRequest(); http_request.open("GET", "/ASPHDWRegistrationAndLogin/verify_username.asp?table="+table+"&field="+username_f+"&username="+form.elements[HDW_locate_field(username_f,form)].value, false); http_request.send(null); var text = http_request.responseText; if (text == 'OK') return true; else if (text == 'USED') { alert(MESSAGE_USERNAME_USED); return false; } else return true; } function HDW_logout() { http_request = HDW_getRequest(); http_request.open("GET", "/ASPHDWRegistrationAndLogin/logout.asp", false); http_request.send(null); var text = http_request.responseText; document.location.reload(true); } function HDW_verify_Login(form) { var username_v = form.username.value; var password_v = form.password.value; var table = form.hdwtable.value; http_request = HDW_getRequest(); http_request.open("GET", "/ASPHDWRegistrationAndLogin/login.asp?table="+table+"&username="+username_v+"&password="+password_v, false); http_request.send(null); var text = http_request.responseText; if (text == 'OK') return true; else { alert(text); return false; } } function HDW_getRequest() { http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { // set type accordingly to anticipated content type //http_request.overrideMimeType('text/xml'); http_request.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Cannot create XMLHTTP instance'); return false; } return http_request; } function HDW_showILMP() { var divlogin = document.getElementById("hdwdivlogin"); divlogin.style.display = "none"; var divlogin = document.getElementById("hdwdivILMP"); divlogin.style.display = ""; var divlogin = document.getElementById("hdwdivLink"); divlogin.style.display = "none"; } function HDW_showLogin() { var divlogin = document.getElementById("hdwdivlogin"); divlogin.style.display = ""; var divlogin = document.getElementById("hdwdivILMP"); divlogin.style.display = "none"; var divlogin = document.getElementById("hdwdivLink"); divlogin.style.display = ""; } function HDW_submitILMP() { var email_v = document.getElementById("hdwILMPemail").value; var table = document.getElementById("hdwtable").value; http_request = HDW_getRequest(); http_request.open("GET", "/ASPHDWRegistrationAndLogin/ilmp.asp?table="+table+"&email="+email_v, false); http_request.send(null); var text = http_request.responseText; if (text == 'OK') return true; else { alert(text); return false; } }