// Author: James A Hill - augman85@gmail.com // Author: Bryan Smith - bryanesmith@gmail.com function getObj(n) { if (document.getElementById) { return document.getElementById(n); } else if (document.all) { return document.all[n]; } else if (document.layers) { return document.layers[n]; } } function getPos(o) { var curleft = curtop = 0; if (o.offsetParent) { do { var borders = getBorderWidths(o); var scroll = getScrollDimensionsForElem(o); curleft += (o.offsetLeft + borders[3] - scroll[0]); curtop += (o.offsetTop + borders[0] - scroll[1]); } while (o = o.offsetParent); } return [curleft,curtop]; } /** * Returns the inner width of an element (inside the borders). */ function getWidth(elem) { function _Convert(val) { if (!val) {return;} val = val.replace("px",""); if (isNaN(val)) {return 0;} return parseInt(val); } var currentStyle; if (elem.currentStyle) { currentStyle = elem.currentStyle; } else if (window.getComputedStyle) { currentStyle = document.defaultView.getComputedStyle(elem, null); } else { currentStyle = elem.style; } return (elem.offsetWidth - _Convert(currentStyle.marginLeft) - _Convert(currentStyle.marginRight) - _Convert(currentStyle.borderLeftWidth) - _Convert(currentStyle.borderRightWidth)); } function getBorderWidths(elem) { function _Convert(val) { if (!val) {return;} val = val.replace("px",""); if (isNaN(val)) {return 0;} return parseInt(val); } var currentStyle; if (elem.currentStyle) { currentStyle = elem.currentStyle; } else if (window.getComputedStyle) { currentStyle = document.defaultView.getComputedStyle(elem, null); } else { currentStyle = elem.style; } var array = new Array(); array[0] = _Convert(currentStyle.borderTopWidth); array[1] = _Convert(currentStyle.borderRightWidth); array[2] = _Convert(currentStyle.borderBottomWidth); array[3] = _Convert(currentStyle.borderLeftWidth); return array; } function getHeight(elem) { function _Convert(val) { if (!val) {return;} val = val.replace("px",""); if (isNaN(val)) {return 0;} return parseInt(val); } var currentStyle; if (elem.currentStyle) { currentStyle = elem.currentStyle; } else if (window.getComputedStyle) { currentStyle = document.defaultView.getComputedStyle(elem, null); } else { currentStyle = elem.style; } return (elem.offsetHeight - _Convert(currentStyle.marginTop) - _Convert(currentStyle.marginBottom) - _Convert(currentStyle.borderTopWidth) - _Convert(currentStyle.borderBottomWidth)); } function getScreenSize() { var myWidth = 0, myHeight = 0; if (typeof(window.innerWidth) == 'number') { //Non-IE myWidth = window.innerWidth; myHeight = window.innerHeight; } else if (typeof(window.innerWidth) == 'string') { myWidth = window.innerWidth.replace("px", ""); myHeight = window.innerHeight.replace("px", ""); } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { //IE 6+ in 'standards compliant mode' myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight; } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) { //IE 4 compatible myWidth = document.body.clientWidth; myHeight = document.body.clientHeight; } return [myWidth,myHeight]; } function getScrollDimensions() { var scrOfX = 0, scrOfY = 0; if( typeof( window.pageYOffset ) == 'number' ) { //Netscape compliant scrOfY = window.pageYOffset; scrOfX = window.pageXOffset; } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { //DOM compliant scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft; } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { //IE6 standards compliant mode scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft; } return [scrOfX, scrOfY]; } function getScrollDimensionsForElem(o) { return [o.scrollLeft, o.scrollTop]; } function goTo(url) { document.location.href = url; } function showFrameTopRight(f,o,changeLeft,changeTop) { var frame = getObj(f); var pos = getPos(o); frame.style.left = (pos[0]+changeLeft) + 'px'; frame.style.top = (pos[1]+changeTop) + 'px'; showObj(frame); } function show(e) { getObj(e).style.display = 'block'; } function showObj(e) { e.style.display = 'block'; } function showInline(e) { getObj(e).style.display = 'inline'; } function showInlineObj(e) { e.style.display = 'inline'; } function hide(e) { getObj(e).style.display = 'none'; } function hideObj(e) { e.style.display = 'none'; } function clear(e) { getObj(e).innerHTML = ''; } function clearObj(e) { e.innerHTML = ''; } function changeRegionSet(c,r) { // get the country ID var country = getObj(c); var countryID = country.options[country.selectedIndex].value; // get the new inner HTML for the region (AJAX) and send reponse to a function ajax.update("https://proteomecommons.org/scripts/location/selectRegions.jsp?c="+countryID, r); } function getURLSafeString(string) { string = string.replace("%", "%25"); string = string.replace(" ", "%20"); string = string.replace("!", "%21"); string = string.replace("\"", "%22"); string = string.replace("#", "%23"); string = string.replace("&", "%26"); string = string.replace("'", "%27"); string = string.replace("+", "%2b"); string = string.replace(",", "%2c"); string = string.replace("/", "%2f"); string = string.replace("=", "%3d"); string = string.replace("?", "%3f"); return string; } function getHTMLSafeString(string) { string = string.replace("<", "<"); string = string.replace(">", ">"); string = string.replace("\"", """); return string; } function popupOptionOver(o) { o.style.background = '#ccc'; } function popupOptionOut(o) { o.style.background = '#fff'; } // allow toggling of scroll functions var allowScroll = true; function handleScroll() { if (allowScroll == false){ scroll(0,0); } } function setAllowScroll(allow) { allowScroll = allow; if (allow == false) { document.body.style.overflow = 'hidden'; } else { document.body.style.overflow = 'auto'; } } function isEmpty(id) { return getObj(id).value == ''; } // check sign in validity function checkSignInForm(email,pass) { var isProblem = false; var error = 'The following errors have been found in your submission: