function formItem(formName,name) { var form = formByName(formName); return form.elements[name]; } function getFrame(owner,frameName) { return owner.frames[frameName]; } function setIFrameLocation(frameName,loc) { var frame = document.layers[frameName]; frame.src = loc; } function createWindow(loc,name,w,h) { w+= 20; h+= 30; wX = (screen.width-w)/2; wY = (screen.height-h)/2; var w = window.open(loc, name, 'top=' + wY + 'px,left=' + wX + 'px,width=' + w + ',height=' + h + ',resizable=yes,scrollbars=yes'); w.focus(); return w; // var w = window.open(loc, name, 'width=' + (w+20) + ',height=' + (h+30) + ',resizable=yes,scrollbars=yes'); // w.focus(); } function help() { window.open('help.pdf','_top'); if(top.opener.done=="okay") top.window.close(); } function open_file(aid,vid) { if(aid.substr(0,4) == '8200') { //by id href = "&AID=" + aid + "," + vid; } else { //by name href = "&ANM=" + vid + "," + aid; } href = "/searching.asp?IIO_Name=Opening document&IIO_Page=/ipo/attach_view_frame.asp" + href; createWindow(href, 'File', 800,600 ); } function formByName(formName) { return document.forms[formName]; } function selectedItem(formName,name) { var item = formItem(formName,name); var CurSel = item.selectedIndex; return item.options[CurSel].value; } function toggleExpand(img,id) { if(id.style.display == "") { id.style.display="none"; img.src = "/common/images/splus.gif"; } else { id.style.display=""; img.src = "/common/images/sminus.gif"; } } function buttonToggleTree(img,id) { var re; if(id.style.display == "") { id.style.display="none"; img.innerHTML = img.innerHTML.replace("hidetoc.gif","showtoc.gif"); re = /Hide/g; img.innerHTML = img.innerHTML.replace(re,"Show"); SetCookie("TreeHidden","True"); } else { id.style.display=""; img.innerHTML = img.innerHTML.replace("showtoc.gif","hidetoc.gif"); re=/Show/g; img.innerHTML = img.innerHTML.replace(re,"Hide"); SetCookie("TreeHidden","False"); } } function buttonMinMax(img,id) { var re; if(id.style.display == "") { id.style.display="none"; img.innerHTML = img.innerHTML.replace("sminimize.gif","smaximize.gif"); re = /Hide/g; img.innerHTML = img.innerHTML.replace(re,"Show"); } else { id.style.display=""; img.innerHTML = img.innerHTML.replace("smaximize.gif","sminimize.gif"); re=/Show/g; img.innerHTML = img.innerHTML.replace(re,"Hide"); } } function toggleMinMax(img,id) { if(id.style.display == "") { id.style.display="none"; img.src = "/common/images/smaximize.gif"; } else { id.style.display=""; img.src = "/common/images/sminimize.gif"; } } //04-04-2002 EK Added condition to check if document.location already contains '?' followed by arguments //If it doesn't (ex. you click on your default workplace) then append '?' before 'Refresh' argument first. function refresh() { var sUrl; sUrl = document.URL; if (sUrl.indexOf("?") < 0) document.location = document.location + "?Refresh=1"; else document.location = document.location + "&Refresh=1"; } function open_note(did,fid,nid) { var w = window.open("viewnote.asp?ID=" + did + "," + fid + "," + nid, 'Note', 'width=640px,height=480px,resizable=yes,scrollbars=yes'); w.focus(); } function subscribe(did,fid) { createWindow("/ipo/folder_subscribe_form.asp?ID=" + did + "," + fid, 'subscribe',550,210); } function addDocument(fid) { createWindow("/ipo/attach_new_doc.asp?ID=" + fid, 'addDoc',620,350); } function addLink(fid) { createWindow("/ipo/attach_new_link.asp?ID=" + fid, 'addDLink',620,350); } function addLogo() { createWindow("/customize_add_logo.asp", 'addLogo',500,200); } function beginDiscussion(fid) { createWindow("/ipo/discussion.asp?Action=AN&ID=" + fid, 'Discussion', 500,350); } function viewDiscussion(fid,nid) { createWindow("/ipo/discussion.asp?ID=" + fid + "&NID="+nid, 'Discussion', 700,350); } function downloadFile(did,fid,aid,vid) { location = "/ipo/downloadfile.asp?ID="+did+","+fid+","+aid+","+vid } function open_folder(path) { location = "/Views/include/get_view.asp?Path=/" + path; } function openFolder(fid,target) { if(typeof(target) != "object") target=self; target.location = "/Views/include/get_view.asp?Path="+fid; } var versionWindow; function versionCheckIn(aid) { if (versionWindow != null) if (!(versionWindow.closed)) versionWindow.close(); versionWindow = createWindow("/ipo/version_checkin.asp?ID=" + aid, 'Version', 550,210); versionWindow.focus(); createWindow("/ipo/version_checkin.asp?ID=" + aid, 'Version', 550,210); } function versionCheckOut(aid) { createWindow("/ipo/version_checkout.asp?ID=" + aid, 'Version', 550,210); } function versionCheckUndo(aid) { if (versionWindow != null) if (!(versionWindow.closed)) versionWindow.close(); createWindow("/ipo/version_checkundo.asp?ID=" + aid, 'Version', 550,210); } function reloadFolder(fid,target) { if(typeof(target) != "object") target=self; // SS: 2000-11-15 : Added escape(location) so that a page with parameters will get carried over from the reloadFolder.ap target.location = "/ipo/reloadFolder.asp?IIO_Page=" + escape(target.location) + "&IIO_ID=" + fid; } function gotoSavedQuery(to,params,name) { if(params.length > 0) params = "&" + params; location = "/searching.asp?IIO_Page=" + escape(to) + "&IIO_Name=" + escape("Saved Query > " + name) + params + "&IIO_From=" + escape(location.href); } function doVote() { var frm = formByName('voteForm'); frm.submit(); } function addFolderToWorkplace(did,fid) { var w = createWindow("/Views/include/addToWorkplace.asp?ID=" + did + "," + fid,'addWrk',400,600); } function isEmail(string) { if (string.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) != -1) return true; else return false; } /* The function isEmail comes from http://www.netpedia.com/features/javascript/vform/ Ok. Shall we move on to the isMail() function? The Regular Expression is /^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/. 1.The email regular expression begins with a /, again representing the leftmost delimiter. 2.Once again, we have a ^ symbol, representing the absolute beginning of the string for the same reason as before. 3.The following \w+ again matches one or more alphanumeric characters. The next chunk is where this gets interesting. I will try to break it down into manageable pieces, so please bear with me. The part we will look at is ((-\w+)|(\.\w+))* 1.First, note that the whole thing is surrounded by ()* which means that we want to match zero or more of them. Inside the parentheses, we have (-\w+)|(\.\w+) which means to match EITHER -\w+ OR \.\w+ so lets take a look at each of them in turn. The first one indicates that we should have a match if we find a hyphen followed immediately by a set of alphanumeric characters. The second part matches if we find a period followed immediately by a set of alphanumeric characters. Remember that a period by itself is a special character so we must delimit it by placing a backslash in front of it. In essence, what this inside bit does is allow someone to submit an email address that has a hyphenated or dot-separated email address before an "at" sign. 2.After this match, comes an @ sign. This is delimited to ensure that it isn't taken for special meaning. 3.Immediately following the "at" sign is anther \w+ which matches a set of alphanumeric characters. 4.The final / is the rightmost delimiter for the regular expression. 4.After this, we have another interesting bit ((\.|-)\w+)*. Let's go through it. 5.Again, note that we are matching one or none of a match using the * sign. Since parentheses are used, the entire match is taken into consideration. Let's look inside at the (\.|-)\w+ pattern. Inside the parentheses, we have \.|- which implies that we will match either a period or a hyphen. Since this pattern is followed by a \w+, the match only works if the period or hyphen is followed by a set of alphanumeric characters. This effectively represents an email address that contains a (possible) set of .word or -word sections. Because the * is used, the pattern works if they are present and also if they aren't. 6.The last \.\w+ pattern matches a period followed by a set of alphanumerics. Because it is the last part of the regular expression, it represents the final part of the email address, which is the top level domain. Because \w+ does not match non-alphanumerics, this pattern will not match email addresses that do not contain some sort of "real-looking" domain. 7.The final $ symbol ensures that the pattern is against the end of string for the same reasons as the previous example. This pattern allows for email addresses like the following. With this particular regular expression, the bare minimum that a person could enter as an email address is x@x.x, where x is any alphanumeric character: someone@somewhere.com someone.somebody@somewhere.com someone.sombody@somewhere.where.com some-one@somewhere.com some-one.somewhere@wherever.com some-one.somewhere@where-ever.com */ function emailPage(did,fid) { w = createWindow("/ipo/folder_email_form.asp?ID=" + did + "," + fid, 'emailPage',550,300); w.focus(); } function routeFolder(did,fid) { w = createWindow("/ipo/folder_route_form.asp?ID=" + did + "," + fid, 'routeFolder',550,300); w.focus(); } function file_properties(did,fid,aid,vid) { //change the size of the window w = createWindow("/ipo/attach_properties.asp?ID=" + did + "," + fid + "," + aid + "," + vid, 'fileProperties',600,450); w.focus(); } function folder_properties(fid) { w = createWindow("/ipo/folder_properties.asp?ID=" + fid, 'FolderProperties',600,450); w.focus(); } function publish_folder(sPath, sId) { w = createWindow("/ipo/folder_publish.asp?Path=" + sPath + "&ID=" + sId, 'PublishFolder',370,200); w.focus(); } function mailbox_remove(mboxid,fid) { location = "/ipo/mailbox_remove.asp?MBOXID=" + mboxid + "&ID=" + fid; } // Create a cookie with the specified name and value. // The cookie expires at the end of the 20th century. function SetCookie(sName, sValue) { document.cookie = sName + "=" + escape(sValue) + "; expires=31 Dec 2050 23:59:59 UTC;"; } function SetCookie (name, value) { var argv = SetCookie.arguments; var argc = SetCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } // Retrieve the value of the cookie with the specified name. function GetCookie(sName) { // cookies are separated by semicolons var aCookie = document.cookie.split("; "); for (var i=0; i < aCookie.length; i++) { // a name/value pair (a crumb) is separated by an equal sign var aCrumb = aCookie[i].split("="); if (sName == aCrumb[0]) return unescape(aCrumb[1]); } // a cookie with the requested name does not exist return null; } // Function ltrim: Returns a copy of a string without leading spaces function ltrim ( str ) { return str.replace( /^\s*/, "" ) } // Function rtrim: Returns a copy of a string without trailing spaces function rtrim ( str ) { return str.replace( /\s*$/, "" ); } // Function trim: Returns a copy of a string without leading or trailing spaces function trim ( str ) { return rtrim(ltrim(str)); }