/*---------- Copyright 2011 Neotek Limited (http://www.neotek.co.nz). All rights reserved. -----------*/
var loginregex='\\w+';function LoginIsValid(value,regex){if(value.length==0)return true;var rx=new RegExp(regex);var matches=rx.exec(value);return(matches!=null&&value==matches[0]);}function Login(){var loginId=document.getElementById('login').value;var password=document.getElementById('password').value;var rememberPassword=document.getElementById('remember').checked;var errorString="";if(loginId==""){errorString+="* Login cannot be blank!\n";}else if(LoginIsValid(loginId,top.loginregex)==false){errorString+="* Login cannot contain non-alphanumeric characters!\n"}if(password==""){errorString+="* Password cannot be blank!\n";}if(errorString!=""){errorString="Your input generated the following error(s):\n\n"+errorString+"\nPlease try again.";alert(errorString);return;}showprocessing();var urlString='/main/CustomerLogin.aspx?ajax=1&LoginId='+loginId+'&Password='+password+'&Remember='+rememberPassword+'&loginHtml=1';neotekscript(urlString);}function loginError(msg){alert(msg);}function loginAccepted(ok){if(ok){var o=document;if(top){o=top.document;}o.location.href='/default.aspx';}}function about(){var settings={Title:'',URL:'/public/about.aspx',IncludeClose:true,AutoResize:true};top.NeotekPopup.Show(settings);}function InitalizeRegistrationValidation(){LoopElementsAddValidation('input');LoopElementsAddValidation('select');LoopElementsAddValidation('textarea');}function LoopElementsAddValidation(tagName){var elements=document.getElementsByTagName(tagName);var lth=elements.length;for(var i=0;i<lth;++i){if(tagName=='select')elements[i].onchange=ValidateControl;else if(elements[i].type=='radio')elements[i].onclick=ValidateControl;else if(elements[i].type.toLowerCase()!='submit')elements[i].onblur=ValidateControl;}}function ValidateControl(e){e=e||window.event;var o=e.target||e.srcElement;FormValidate(o);}function RegisterRedirect(){top.document.location.href='/public/register.aspx';}function Register(){if(FormValidated()){var frm=$('RegisterForm');var formVars=getFormValues(frm);neotekscript(frm.action,formVars,RegisterCallback);}}function RegisterCallback(xmlHttp){if(xmlHttp.readyState==4){if(xmlHttp.status==202){window.location='/Public/RegisterSuccess.aspx';}else{var o=$('loginFailed');if(o)o.innerHTML=xmlHttp.responseText;}}}function CheckLogin(id){var o=$(id);if(o.value.length==0)return;var url='/Public/Register2.aspx?CheckLogin='+o.value;neotekscript(url,null,CheckLoginCallback);}function CheckLoginCallback(xmlHttp){if(xmlHttp.readyState==4){var o=$('LoginStatus');if(!!!o)return;if(xmlHttp.status==202){o.innerHTML='Avalible';o.style.color='Lime';}else{o.innerHTML='Not Avalible';o.style.color='Red';}}}function opensignin(){var settings={Title:'',URL:'userAccess/logIn.htm',AutoResize:true,AllowDrag:false};top.NeotekPopup.Show(settings);}function openForgottenPassword(){var settings={Title:'',URL:'userAccess/ForgottenPassword.htm',AutoResize:true};top.NeotekPopup.Show(settings);}function resetPassword(){var o=$('ResetPasswordLogin');if(o.value.length==0)return;var url='/Ajax/ResetPassword.aspx?Login='+o.value;neotekscript(url,null);}function passwordResetSuccesss(){top.NeotekPopup.Close();statusMessage(1);}function loginRequired(){top.NeotekPopup.Close();statusMessage(2);}function LoginUnknown(){top.NeotekPopup.Close();statusMessage(3);}function statusMessage(statusId){var settings={Title:'',URL:'/Ajax/MessagePopup.aspx?statusId='+statusId};top.NeotekPopup.Show(settings);}
