// Validate form fields depending on type function validateField(oElem, displayid, valType, displayMsg) { var isValid = false; var imageRegexp = /\.(jpg|gif|tif|tiff|png)$/i; switch (valType) { case "email": { isValid = /^([^ @]+(?:[^ @]+)*)@([^ @]+(?:[^ @]+)*)\.([^ @]+(?:[^ @]+)*)$/.test(oElem.value); break; } case "zipcode": { isValid = /^[0-9]{5}(-[0-9]{4})?$/.test(oElem.value); break; } case "nonnull": { isValid = (!trim(oElem.value) == ""); break;} case "image": { isValid = imageRegexp.test(oElem.value); break; } case "password": { isValid = /^[^\s]{4,15}$/.test(oElem.value); break; } case "alphanum": { isValid = /^[A-Za-z0-9]+$/.test(oElem.value); break; } case "alpha": { isValid = /^[A-Za-z\-\.]+$/.test(oElem.value); break; } case "numeric": { isValid = /^[0-9]+$/.test(oElem.value); break; } default: { break; } } if (isValid == false) { validationMsg(displayid, displayMsg); } return isValid; } // display form validation message function validationMsg( fld, // id of element to display message message) // string to display { var displaymsg = ""; //alert(message); // fixes issue with ie when there is an empty string if (/^\s*$/.test(message)) displaymsg = String.fromCharCode(nbsp); else displaymsg = message; var elem = $(fld); if (!elem == null) elem.firstChild.nodeValue = displaymsg; else elem.innerHTML = displaymsg; } // Validate photo fields // Fix bug00041, bug00042, bug00084 function isValidImage() { var noErrs = true; // let's clear any existing messages $("photoValidate").type="hidden"; // validate fields this is not working and is preventing upload of valid JPG noErrs = validateField(document.getElementById('photo'), 'photoValidate', 'image', 'Please select a valid image type [ jpg,gif,tif,png ].'); return noErrs; } function getUserInfo(username) { var requestURL = getWebrootURI() + "user/getPublicUserInfo?username=" + username; var request = new Ajax.Request(requestURL, {method: 'post', onComplete: displayUserInfo}); } /** Realizes an Ajax request for mail contact */ function requestUserInfoByMail(requestURL) { $('requestlink').style.display = "none"; $('imageprogress').style.display = ""; var request = new Ajax.Request(requestURL, {method: 'post', onComplete: completeRequestByMail}); } function displayUserInfo(request) { dimRightSidebar(); dimLeftSidebar(); $('userPopup').style.position = "absolute"; //make it so the dialog floats in the viewport not page var resp = request.responseText; // if this is a request for volunteering, then changes the height if( resp.match(/Thanks for volunteering/) ){ $('userBody').setStyle({ height: '150px' }); }else{ $('userBody').setStyle({ height: '350px' }); } $('userBody').innerHTML = request.responseText; var x = 0; if (document.documentElement && document.documentElement.scrollTop) x = document.documentElement.scrollTop; // ie6+ else if (document.body.scrollTop) x = document.body.scrollTop; // ie5? else if (window.pageYOffset) x = window.pageYOffset; // moz $('userPopup').style.top = (x + 50) + "px"; //top offset in viewport $('userPopup').style.left = "100px"; //left offset in viewport //alert('Desplegar PopUp') $('userPopup').style.display = ""; } /** Receives the Ajax request done by requestUserInfoByMail function */ function completeRequestByMail(request) { hidePopup(); $('imageprogress').style.display = "none"; } function deletePostConfirm(folder, id) { if (confirm('Are you sure you want to delete this forum entry?\nAll comments on this post will also be deleted.')) { loc = folder + "/deletePost?post=" + id; location.href = loc; } } function deletePostCommentConfirm(folder, post, returnId) { if (confirm('Are you sure you want to delete this comment?')) { location.href = folder + "/deletePost?post=" + post + "&return=" + returnId; } } function inactivateAccountConfirm() { if (confirm('Are you sure you want to inactivate this account?')) { location.href = "inactivateAccount"; } } function deleteAccountConfirm() { if (confirm('If you delete this account your communities will be deleted. Are you sure you want to delete this account?' )) { location.href = "deleteAccount"; } } function hidePopup() { $('userPopup').style.display = "none"; liteRightSidebar(); liteLeftSidebar(); } function isValidTitle() { var noErrs = true; // let's clear any existing messages $("titleValidate").type="hidden"; // validate fields this is not working and is preventing upload of valid JPG noErrs = validateField(document.getElementById('title'), 'titleValidate', 'nonnull', 'Please insert a title'); return noErrs; } function open_window(page, width, height) { x = (640 - width)/2, y = (480 - height)/2; if (screen) { y = (screen.availHeight - height)/2; x = (screen.availWidth - width)/2; } window.open (page, 'CtrlWindow','scrollbars=1,top='+ y +',left='+ x +',screenY='+ y +',screenX='+ x +',width=' + width + ',height=' + height); } function getWebrootURI() { return httpProtocol + "://" + serverName + "/" + webroot; } function trim(stringToTrim) { return stringToTrim.replace(/^\s+|\s+$/g,""); } function ltrim(stringToTrim) { return stringToTrim.replace(/^\s+/,""); } function rtrim(stringToTrim) { return stringToTrim.replace(/\s+$/,""); } function doSearch() { var value = escape(document.getElementById('searchID').value); window.location = "/discuss/search?search=" + value; } function applyStyles() { $('searchlabel').setStyle({cursor:'pointer'}); $('searchlabel').setStyle({'text-decoration':'underline'}); } function unapplyStyles() { $('searchlabel').setStyle({'text-decoration':'none'}); } function pressEnter(e) { key = e.keyCode; if(window.event) // IE { key = e.keyCode; } else if(e.which) // Netscape/Firefox/Opera { key = e.which; } if (key==13) { doSearch() //presionaron enter return true; }else{ return false } } function cancel(url) { location.href = url; } function externalLinks() { if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName("a"); for (var i=0; i