var unCache=new Array;function addEvent(elm,evType,fn,useCapture){if(elm.addEventListener){elm.addEventListener(evType,fn,useCapture);return true;}else if(elm.attachEvent){var r=elm.attachEvent('on'+evType,fn);return r;}else{elm['on'+evType]=fn;}}function doUsernameCheck(){var enteredUsername=document.getElementById('username');if(enteredUsername&&enteredUsername.value&&enteredUsername.value!=''){if(unCache[enteredUsername.value]){if(unCache[enteredUsername.value]==true){setChecker('username','The username you entered is already in use by another turnkey customer. Please select another username.');}else{closeChecker('username');}}else{var unCheck=new xmlServerObject();unCheck.setURL("ajax/index.php");unCheck.setMethod("POST");unCheck.setVar("POST","action","un-check");unCheck.setVar("POST","username",enteredUsername.value);unCheck.onLoad=function(){var stat=unCheck.xml;if(stat.getElementsByTagName('true').item(0)){unCache[enteredUsername.value]=true;setChecker('username','The username you entered is already in use by another turnkey customer. Please select another username.');}else{unCache[enteredUsername.value]=false;closeChecker('username');}};unCheck.doRequest();}}else{closeChecker('username');}}function doSimpleNoValueCheck(name,nice_name){var theField=document.getElementById(name);if(theField){if(document.getElementById('catchErrors_'+name)){if(theField.value==''){setChecker(name,'You must enter a value for \''+nice_name+'\'');}else{closeChecker(name);}}}}function closeChecker(fieldName){if(document.getElementById('catchErrors_'+fieldName)){document.getElementById('catchErrors_'+fieldName).style.display='none';}}function setChecker(fieldName,message){if(document.getElementById('catchErrors_'+fieldName)){var field=document.getElementById('catchErrors_'+fieldName);removeChildren(field);field.appendChild(document.createTextNode(message));field.style.display='block';}}function removeChildren(node){while(node.firstChild){node.removeChild(node.firstChild);}}function checkPasswords(){var firstPassword=document.getElementById('password_1').value;var secondPassword=document.getElementById('password_2').value;if(firstPassword!=''&&secondPassword!=''){if(firstPassword.length<6||secondPassword.length<6){setChecker('password','Your password must be at least 6 characters in length.');}else if(firstPassword!=secondPassword){setChecker('password','The passwords you entered did not match.');}else{closeChecker('password');}}else{closeChecker('password');}}addEvent(document.getElementById('username'),'blur',function(){doUsernameCheck();},false);addEvent(document.getElementById('password_1'),'blur',function(){checkPasswords();},false);addEvent(document.getElementById('password_2'),'blur',function(){checkPasswords();},false);var applyTo={"name":"name","surname":"lastname","address line 1":"address_1","city/state":"state","zip/postal code":"zip","country":"country","email":"email","phone":"phone"};for(var i in applyTo){eval('addEvent(document.getElementById(\''+applyTo[i]+'\'),\'blur\',function(){doSimpleNoValueCheck(\''+applyTo[i]+'\',\''+i+'\');},false);');}