//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:: general_functions_js.asp //:: created: christopher j falvey (05.13.01) //:: //:: version: 2.0 //:: desc: general javascript functions //:: //:: //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:: javascript globals //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: var giMouseX var giMouseY //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:: captureMouseMove //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: function captureMouseMove(e) { } document.onmousemove = captureMouseMove; //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:: javascript functions //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /*==========================================================================# # * Function for adding a Filter to an Input Field # # * @param : [filterType ] Type of filter 0=>Alpha, 1=>Num, 2=>AlphaNum # # * @param : [evt ] The Event Object # # * @param : [allowDecimal] To allow Decimal Point set this to true # # * @param : [allowCustom ] Custom Characters that are to be allowed # #==========================================================================*/ function filterInput(filterType, evt, allowDecimal, allowCustom){ var keyCode, Char, inputField, filter = ''; var alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; var num = '0123456789-.'; // Get the Key Code of the Key pressed if possible else - allow if(window.event){ keyCode = window.event.keyCode; evt = window.event; }else if (evt)keyCode = evt.which; else return true; // Setup the allowed Character Set if(filterType == 0) filter = alpha; else if(filterType == 1) filter = num; else if(filterType == 2) filter = alpha + num; if(allowCustom)filter += allowCustom; if(filter == '')return true; // Get the Element that triggered the Event inputField = evt.srcElement ? evt.srcElement : evt.target || evt.currentTarget; // If the Key Pressed is a CTRL key like Esc, Enter etc - allow if((keyCode==null) || (keyCode==0) || (keyCode==8) || (keyCode==9) || (keyCode==13) || (keyCode==27) )return true; // Get the Pressed Character Char = String.fromCharCode(keyCode); // If the Character is a number - allow if((filter.indexOf(Char) > -1)) return true; // Else if Decimal Point is allowed and the Character is '.' - allow else if(filterType == 1 && allowDecimal && (Char == '.') && inputField.value.indexOf('.') == -1)return true; else return false; } function getNextElement (field) { var form = field.form; for (var e = 0; e < form.elements.length; e++) { if (field == form.elements[e]) break; } return form.elements[++e % form.elements.length]; } function noenter() { return !(window.event && window.event.keyCode == 13); } function tabOnEnter(e, field) { var key; if(window.event) { key = window.event.keyCode; //IE } else { key = e.which; //firefox } if (key == 13) { var el=getNextElement(field); if (el.type!='hidden') { el.focus(); } else { while (el.type=='hidden') el=getNextElement(el); el.focus(); } return false; } else { return true; } } function enter(nextfield) { if(window.event && window.event.keyCode == 13) { nextfield.focus(); return false; } else return true; } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:: popUp //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: function popUp(sUrl , sWin, iWidth , iHeight , bScrollBars) { window.open(sUrl , sWin , "status=1,scrollbars=" + bScrollBars + ",width=" + iWidth + ",height=" + iHeight + ",resizable=no"); } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:: flipImage //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: function flipImage(sImageName , sFlipTo , sExtension) { document.images[sImageName].src = "images/" + sImageName + "_" + sFlipTo + "." + sExtension } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:: flipCustomImage //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: function flipCustomImage(sImageName , sImageFile , sFlipTo , sExtension) { sNewImagePath = "http://www.futurarecords.com/sites/FUT/images/" + sImageFile + "_" + sFlipTo + "." + sExtension document.images[sImageName].src = sNewImagePath } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:: refreshPage //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: function refreshPage() { document.location = document.location } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:: getStyleAttribute //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: function getStyleAttribute(sID , sAttribute) { sCurrentTop = new String(eval("document." + sID + "." + sAttribute)) return sCurrentTop } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:: setStyleAttribute //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: function setStyleAttribute(sID , sAttribute , sValue) { sStyleToSet = "document." + sID + "." + sAttribute + "='" + sValue + "'" eval(sStyleToSet) } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:: moveDiv //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: function moveDiv(sID , sAttribute , iValue) { iCurrentPos = getStyleAttribute(sID , sAttribute) iCurrentPos = cPxToInt(iCurrentPos) sNextTopNumber = new String(iCurrentPos + iValue) sNextPos = sNextTopNumber + "px" setStyleAttribute(sID , sAttribute , sNextPos) } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:: cPxToInt //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: function cPxToInt(sPx) { iInt = Number(sPx.replace(/px/gi,"")) return iInt } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:: getRandomNumber //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: function getRandomNumber(iBeginNum , iEndNum) { iNumberToSend = iBeginNum - 1 while(iNumberToSend < iBeginNum || iNumberToSend > iEndNum) { iNumberToSend = iBeginNum + (Math.random() * iEndNum) } return Math.round(iNumberToSend) } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:: (decimal to hex functions) //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: function cHex(i) { a2 = '' ihex = hexQuot(i); idiff = eval(i + '-(' + ihex + '*16)') a2 = itohex(idiff) + a2; while( ihex >= 16) { itmp = hexQuot(ihex); idiff = eval(ihex + '-(' + itmp + '*16)'); a2 = itohex(idiff) + a2; ihex = itmp; } a1 = itohex(ihex); return a1 + a2 ; } function hexQuot(i) { return Math.floor(eval(i +'/16')); } function itohex(i) { if(i == 0){aa = '0'} if(i == 1){aa = '1'} if(i == 2){aa = '2'} if(i == 3){aa = '3'} if(i == 4){aa = '4'} if(i == 5){aa = '5'} if(i == 6){aa = '6'} if(i == 7){aa = '7'} if(i == 8){aa = '8'} if(i == 9){aa = '9'} if(i == 10){aa = 'A'} if(i == 11){aa = 'B'} if(i == 12){aa = 'C'} if(i == 13){aa = 'D'} if(i == 14){aa = 'E'} if(i == 15){aa = 'F'} return aa } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:: functions_js.asp //:: created: //:: //:: version: 0.0 //:: desc: site-specific javascript functions //:: //:: //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:: javascript functions //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:: functionName //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::