﻿var common=new Common();var http_request=common.CreateXmlHttpRequest();function showWait(){var fileToUpload=document.getElementById("fuPhoto").value;var upProgress=document.getElementById("upProgress");var regex=/^.+\.(jpg|JPG|jpeg|JPEG|bmp|BMP|gif|GIF)$/;if(fileToUpload.length>0&&fileToUpload.match(regex)){upProgress.style.display='block';return true;}else{return false;}}function checkUsername(){var spUsernameAlert=document.getElementById("spUsernameAlert");var txtUserName=getInputValue(document.getElementById("txtUserName"));var regEx=/^\w.+?$/;if(txtUserName.match(regEx)){spUsernameAlert.style.display="none";return true;}else
{spUsernameAlert.style.display="inline";return false;}}function checkNewUsername(){var spCheckingNameAlert=document.getElementById("spCheckingNameAlert");var spUsernameAlert=document.getElementById("spUsernameAlert");spCheckingNameAlert.style.display="inline";var spSpecialChar=document.getElementById("spSpecialChar");var spNewUsernameAlert=document.getElementById("spNewUsernameAlert");var txtUserName=getInputValue(document.getElementById("txtUserName"));var regExSpecial=/\W$/;var url="/ImageService.asmx/CheckUsername";var params="strUsername="+txtUserName;try
{var divImages=document.getElementById("divImages");http_request.open("post",url,true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Content-length",params.length);http_request.setRequestHeader("Connection","close");http_request.onreadystatechange=function(){if(http_request.readyState==4){if(http_request.status==200){spCheckingNameAlert.style.display="none";var xml=http_request.responseXML.getElementsByTagName("boolean");if(xml[0].firstChild.data=="true"){if(txtUserName.match(regExSpecial)){spSpecialChar.style.display="inline";spUsernameAlert.style.display="none";spNewUsernameAlert.style.display="none";return false;}else
{spNewUsernameAlert.style.display="none";spUsernameAlert.style.display="none";spSpecialChar.style.display="none";return true;}}else
{spNewUsernameAlert.style.display="inline";spUsernameAlert.style.display="none";spSpecialChar.style.display="none";return false;}}}};http_request.send(params);}catch(Error){alert(Error);}}function checkPassword(){var spPasswordAlert=document.getElementById("spPasswordAlert");var password=getInputValue(document.getElementById("txtPassword"));var regEx=/^[a-zA-Z0-9]{8,10}$/;if(password.match(regEx)){spPasswordAlert.style.display="none";return true;}else
{spPasswordAlert.style.display="inline";return false;}}function checkConfirmPassword(){var spRePasswordAlert=document.getElementById("spRePasswordAlert");var password=getInputValue(document.getElementById("txtPassword"));var confirmPassword=getInputValue(document.getElementById("ConfirmPassword"));if(password==confirmPassword){spRePasswordAlert.style.display="none";return true;}else
{spRePasswordAlert.style.display="inline";return false;}}function checkEmail(){var spEmailAlert=document.getElementById("spEmailAlert");var email=getInputValue(document.getElementById("txtEmail"));var regEx=/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;if(email.match(regEx)){spEmailAlert.style.display="none";return true;}else
{spEmailAlert.style.display="inline";return false;}}function CheckForAgree(){var chkTermsAndConditions=document.getElementById("chkTermsAndConditions");var btnCreateUser=document.getElementById("btnCreateUser");if(chkTermsAndConditions.checked){btnCreateUser.disabled=false;return true;}else
{btnCreateUser.disabled=true;return false;}}function checkAll(){var spNewUsernameAlert=document.getElementById("spNewUsernameAlert");var spCheckingNameAlert=document.getElementById("spCheckingNameAlert");var checkUsernameStatus=checkUsername();var checkEmailStatus=checkEmail();var checkTermsStatus=CheckForAgree();var password=document.getElementById("txtPassword");var confirmPassword=document.getElementById("ConfirmPassword");if(password!=null&&confirmPassword!=null){var checkPasswordStatus=checkPassword();var checkConfirmPasswordStatus=checkConfirmPassword();if(spNewUsernameAlert.style.display=="none"&&spCheckingNameAlert.style.display=="none"){if(checkUsernameStatus&&checkEmailStatus&&checkPasswordStatus&&checkConfirmPasswordStatus&&checkTermsStatus){return true;}else
{return false;}}else
{return false;}}}function checkNewPassword(){var password=document.getElementById("txtPassword");var confirmPassword=document.getElementById("ConfirmPassword");if(password!=null&&confirmPassword!=null){var checkPasswordStatus=checkPassword();var checkConfirmPasswordStatus=checkConfirmPassword();if(checkPasswordStatus&&checkConfirmPasswordStatus){return true;}else
{return false;}}}function resetPassword(){var oldPassword=document.getElementById("txtOldPassword");oldPassword.value="";var spOldPasswordAlert=document.getElementById("spOldPasswordAlert");spOldPasswordAlert.style.display="none";var password=document.getElementById("txtPassword");password.value="";var spPasswordAlert=document.getElementById("spPasswordAlert");spPasswordAlert.style.display="none";var confirmPassword=document.getElementById("ConfirmPassword");confirmPassword.value="";var spRePasswordAlert=document.getElementById("spRePasswordAlert");spRePasswordAlert.style.display="none";return true;}function reset(){var firstName=document.getElementById("txtUserName");firstName.value="";var spUsernameAlert=document.getElementById("spUsernameAlert");spUsernameAlert.style.display="none";var spCheckingNameAlert=document.getElementById("spCheckingNameAlert");spCheckingNameAlert.style.display="none";var spNewUsernameAlert=document.getElementById("spNewUsernameAlert");spNewUsernameAlert.style.display="none";var spSpecialChar=document.getElementById("spSpecialChar");spSpecialChar.style.display="none";var password=document.getElementById("txtPassword");password.value="";var spPasswordAlert=document.getElementById("spPasswordAlert");spPasswordAlert.style.display="none";var confirmPassword=document.getElementById("ConfirmPassword");confirmPassword.value="";var spRePasswordAlert=document.getElementById("spRePasswordAlert");spRePasswordAlert.style.display="none";var email=document.getElementById("txtEmail");email.value="";var spEmailAlert=document.getElementById("spEmailAlert");spEmailAlert.style.display="none";var chkTermsAndConditions=document.getElementById("chkTermsAndConditions");var btnCreateUser=document.getElementById("btnCreateUser");chkTermsAndConditions.checked=false;btnCreateUser.disabled=true;return true;}function resetSendUrl(){var spToAlert=document.getElementById("spToAlert");spToAlert.style.display="none";var btnSendEmail=document.getElementById("btnSendEmail");btnSendEmail.disabled=false;}function SendEmail(){var emailToAddress=document.getElementById("txtTo").value;var emailSubject=document.getElementById("txtSubject").value;var emailBody=document.getElementById("taBody").value;var url="/ImageService.asmx/SendEmail";var params="strTo="+emailToAddress+"&strSubject="+emailSubject+"&strBody="+emailBody;try
{http_request.open("post",url,true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Content-length",params.length);http_request.setRequestHeader("Connection","close");http_request.onreadystatechange=function(){if(http_request.readyState==4){if(http_request.status==200){var xml=http_request.responseXML.getElementsByTagName("boolean");if(xml[0].firstChild.data=="true"){alert("E-mails sent.");}else
{alert("E-mails not sent. Please try again.");}}}};http_request.send(params);}catch(Error){alert(Error);}}