 function textAreaMaxLength(field, maxlen) { if (field.value && field.value.length > maxlen)  { field.value = field.value.substring(0, maxlen); field.scrollTop = field.scrollHeight; } }   function validateContactInput() { var error = "";  var elem = document.getElementById('email'); if ("" == elem.value)  { error += "Email address is required.\n\n"; }  elem = document.getElementById('name'); if ("" == elem.value)  { error += "Name is required.\n\n"; }  elem = document.getElementById('message'); if ("" == elem.value)  { error += "Message is required.\n\n"; }  if ("" != error)  { alert(error); return false; }  return true; }   function validateLoginInput(emailobjname, pwobjname) { var elem = document.getElementById(emailobjname); if (!elem || "" == elem.value) { window.location = "login.php"; return false; } else { elem = document.getElementById(pwobjname); if (!elem || "" == elem.value) { window.location = "login.php"; return false; } }  return true; }   function validateEditProfileInput() { var error = "";  elem = document.getElementById("name"); if ("" == elem.value)  { error += "Display Name is required.\n\n"; } else { if (elem.value.length < 3) error += "Display Name must be at least 3 characters long.\n\n"; }  elem = document.getElementById("passwordNew1"); var elem2 = document.getElementById("passwordNew2"); if ("" != elem.value || "" != elem2.value)  { if (elem.value != elem2.value) error += "Password mismatch, both fields must contain the same password.\n\n"; if (elem.value.length < 6) error += "Password must be at least 6 characters long.\n\n";  var elem3 = document.getElementById("passwordOld"); if ('' == elem3.value) error += "You have to enter your old password if you want to change it.\n\n"; }  if ("" != error)  { alert(error); return false; }  return true; }   function validateRegInput() { var error = "";  var elem = document.getElementById("email"); if (null == elem || "" == elem.value) error += "Email is required.\n\n";  elem = document.getElementById("displayname"); if (null == elem || "" == elem.value)  { error += "Display Name is required.\n\n"; } else { if (elem.value.length < 3) error += "Display Name must be at least 3 characters long.\n\n"; }  elem = document.getElementById("password1"); var elem2 = document.getElementById("password2"); if (null == elem || "" == elem.value || null == elem2 || "" == elem2.value)  { error += "Both password fields is required.\n\n"; } else { if (elem.value != elem2.value) error += "Password mismatch, both fields must contain the same password.\n\n"; if (elem.value.length < 6) error += "Password must be at least 6 characters long.\n\n"; }   elem = document.getElementById("birthyear"); if (null == elem || "" == elem.value) error += "Birthyear is required.\n\n";  elem = document.getElementById("country"); if (null == elem || "" == elem.value) error += "Country is required.\n\n";    elem = document.getElementById("terms"); if (null == elem || !elem.checked) error += "You must agree to our Terms of Use.\n\n";  if ("" != error)  { alert(error); return false; }  return true; }   function validateResetInput() { elem = document.getElementById("password1"); var elem2 = document.getElementById("password2"); if ("" == elem.value || "" == elem2.value)  { error += "Both password fields is required\n\n"; } else { if (elem.value != elem2.value) error += "Password mismatch, both fields must contain the same password\n\n"; }  if ("" != error)  { alert(error); return false; }  return true; }   function validateResetPasswordInput() { var elem = document.getElementById("reset_email"); if ("" == elem.value) return false;  return true; }   function validateTerminateAccountInput() { var elem = document.getElementById("terminatepw"); if ("" == elem.value)  { alert("You must enter your password to remove your Donut Games account!"); return false; }  return confirm("Warning! You can't undo this later on!\n\nDo you really want to terminate your Donut Games account?\n"); }   function warnUserOnLeave() { return "You have attempted to leave this page. If you have made any changes to your avatar without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?"; }   function askUserIfTheyWantToBuy(id, price, product, avatar, dc, game) {  if (typeof (showUnloadWarning) != 'undefined') { if (showUnloadWarning) { if (confirm("If you have made any changes to your avatar without clicking the Save button, your changes will be lost. Are you sure you want to continue without saving?\n")) { showUnloadWarning = false; window.onbeforeunload = null; } else { return; } } }  if (0 == dc) { window.location = wwwServer + "shop/shop.php"; } else if (confirm("Do you want to buy '" + product + "' for " + price + " Donut Coins?\n")) { window.location = wwwServer + "shop_buy.php?id=" + id + "&a=" + avatar + "&g=" + game; } } 


