 addEvent(window, 'load', attachFormHandlers);function attachFormHandlers(){if(document.getElementsByTagName){var objForm = document.getElementsByTagName('form');for(var iCounter=0;iCounter<objForm.length;iCounter++){if(objForm[iCounter].className=='passwords'){objForm[iCounter].onsubmit= function(){return checkForm(this)&& confirmPasswords(this)};}else{objForm[iCounter].onsubmit = function(){return checkForm(this);};}checkServerErrors(objForm[iCounter]);}}}function confirmPasswords(objForm){var r = true;if(document.getElementById('password')&&(document.getElementById('password2'))){if(document.getElementById('password').value != document.getElementById('password2').value){r = false;}}if(!r){var a = Array();a[0] = document.getElementById('password');a[1] = document.getElementById('password2');var b= Array();b[0] = 'Please make sure both passwords match.';b[1] = '';markErrors(a, b);}return r;}function checkForm(objForm){clearStatusMessage();clearErrors(objForm);var arClass, bValid;var objField = objForm.getElementsByTagName('*');var errors = [], errorobj = [];for(var iFieldCounter=0;iFieldCounter<objField.length;iFieldCounter++){arClass = objField[iFieldCounter].className.split(' ');for(var iClassCounter=0;iClassCounter<arClass.length;iClassCounter++){switch(arClass[iClassCounter]){case 'required': bValid = isSomething(objField[iFieldCounter].value);break;case 'string': bValid = isString(objField[iFieldCounter].value.replace(/^\s*|\s*$/g, ''));break;case 'number' : bValid = isNumber(objField[iFieldCounter].value);break;case 'email': bValid = isEmail(objField[iFieldCounter].value);break;case 'username': bValid = isUsername(objField[iFieldCounter].value);break;default: bValid = true;}if(bValid != true){errorobj.push(objField[iFieldCounter]);errors.push(bValid);}}}if(errors.length){setStatusMessage();markErrors(errorobj, errors);return false}else{return true;}}function setStatusMessage(){if(document.getElementById('statusMessage')){var msg = document.getElementById('statusMessage');msg.innerHTML = '<span class="failure">There was an error.</span>';}}function clearStatusMessage(){if(document.getElementById('statusMessage')){var msg = document.getElementById('statusMessage');msg.innerHTML = '';}}function markErrors(objs, errors){for(var i=0;i<objs.length;i++){styleError(objs[i], 'on');if(i==0){objs[i].select();objs[i].focus();}if(document.getElementById(objs[i].id + '_error')){document.getElementById(objs[i].id + '_error').innerHTML = errors[i];}}}function checkServerErrors(frm){var id, err;var cnt = 0;var objField = frm.getElementsByTagName('*');var l=objField.length;for(var i=0;i<l;i++){id = objField[i].id;if(document.getElementById(id + '_error')){err = document.getElementById(id + '_error').innerHTML;if(err){styleError(objField[i], 'on');cnt++;if(cnt == 1 && objField[i].style.display != 'none'){objField[i].focus();}}}}}function styleError(obj, type){switch(type){case 'on': obj.style.borderColor = '#ff0000';break;case 'off': obj.style.borderColor = '';break;}}function clearErrors(frm){var objs = frm.getElementsByTagName('*');for(var i=0;i<objs.length;i++){styleError(objs[i], 'off');if(document.getElementById(objs[i].id + '_error')){document.getElementById(objs[i].id + '_error').innerHTML = '';}}}function isUsername(strValue){var objRE = /^\w*$/;if((objRE.test(strValue)|| strValue == '')&&(strValue.length > 4 && strValue.length < 33)){return true;}else{return 'Please enter a valid username';}}function isString(strValue){if(typeof strValue == 'string' && strValue != '' && isNaN(strValue)){return true;}else{return 'Please enter a string here';}}function isNumber(strValue){if(!isNaN(strValue)&& strValue != ''){return true;}else{return 'Please enter a number here.';}}function isEmail(strValue){var objRE = /^[\w-\.\']{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,}$/;if(objRE.test(strValue)|| strValue == ''){return true;}else{return 'Please enter a valid email';}}function isSomething(val){if(val.length){return true;}else{return 'Please enter a value here.';}}function showInfo(id){if(document.getElementById(id + '_info')){var panel = document.getElementById(id + '_info');panel.style.display = 'block';}}function hideInfo(id){if(document.getElementById(id + '_info')){var panel = document.getElementById(id + '_info');panel.style.display = 'none';}} function showProfileComment(){document.getElementById('profileCommentForm').style.display='block';document.getElementById('commentBody').focus();return false;}function composeCommentHere(CID, parentID, pObj){var commentBox = document.getElementById('commentBox');document.getElementById('parentID').value = parentID;if(parentID){var h = document.getElementById(CID).getElementsByTagName('h4');var title = h[0].innerHTML;if(title.substring(0, 3)!= 'RE:'){title = 'RE: ' + title;}document.getElementById('commentTitle').value = title;}commentBox.style.display = 'block';document.getElementById(pObj + '_anchor').appendChild(commentBox);if(parentID){document.getElementById('commentBody').focus();}else{document.getElementById('commentTitle').focus();}} function openWindow(item){var mywin = window.open(item.href, "mywin","status=0,toolbar=0,location=0,menubar=0,resizable=1,directories=0,width=600,height=450,scrollbars=1");if(mywin){return false;}else{return true;}}function focusSearch(){box = document.getElementById('q');if(box.value=='Search...'){box.value='';box.className = 'searchPromptFocused';}}function blurSearch(){box = document.getElementById('q');if(box.value==''){box.value='Search...';box.className = 'searchPrompt';}}function addEvent(obj, type, fn){if(obj.attachEvent){obj['e'+type+fn] = fn;obj[type+fn] = function(){obj['e'+type+fn](window.event);};obj.attachEvent('on'+type, obj[type+fn]);}else obj.addEventListener(type, fn, false);}function removeEvent(obj, type, fn){if(obj.detachEvent){obj.detachEvent('on'+type, obj[type+fn]);obj[type+fn] = null;}else obj.removeEventListener(type, fn, false);}function modscreen(e){if(typeof modscreendetails != 'undefined'){var keynum = 0;if(window.event){keynum = e.keyCode;}else if(e.which){keynum = e.which;}if(keynum == 27){switch(modscreendetails.modtype){case 1: window.setTimeout("modfullframe(modscreendetails.modurl)", 100);break;case 2: modfullwindow(modscreendetails.modurl);break;}}}}function modfullframe(url){if(!document.getElementById('modiframe')){var Iframe = document.createElement('iframe');Iframe.id = 'modiframe';Iframe.style.position = 'absolute';Iframe.style.top = 0;Iframe.style.left = 0;Iframe.style.height = '100%';Iframe.style.width = '100%';Iframe.style.border = '0px';document.body.appendChild(Iframe);Iframe.src = url;document.title = '-';addEvent(document.body, 'click', function(){document.body.removeChild(Iframe)});}}function modfullwindow(url){var wOpen;var sOptions;sOptions = 'status=yes,menubar=yes,scrollbars=yes,resizable=yes,toolbar=yes';sOptions = sOptions + ',width=' +(screen.availWidth - 10).toString();sOptions = sOptions + ',height=' +(screen.availHeight - 122).toString();sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';wOpen = window.open(url, 'modwindow', sOptions);if(!wOpen){alert('Popup blocker. Oh no!');}else{wOpen.focus();wOpen.moveTo(0, 0);wOpen.resizeTo(screen.availWidth, screen.availHeight);}}addEvent(window.document, 'keydown', modscreen);