// JavaScript Document /* * Maximum character count for a textarea */ function textCounter(field, countfield, maxlimit) { if (field.value.length > maxlimit) // if too long...trim it! { field.value = field.value.substring(0, maxlimit); } // otherwise, update 'characters remaining' counter else { var num = maxlimit - field.value.length; var tag = document.getElementById(countfield); tag.innerHTML = num + " Characters Remaining"; } } /* * Cross-browser event handling, by Scott Andrew */ function addEvent(element, eventType, lamdaFunction, useCapture) { if (element.addEventListener) { element.addEventListener(eventType, lamdaFunction, useCapture); return true; } else if (element.attachEvent) { var r = element.attachEvent('on' + eventType, lamdaFunction); return r; } else { return false; } } /* * Kills an event's propagation and default action */ function knackerEvent(eventObject) { if (eventObject && eventObject.stopPropagation) { eventObject.stopPropagation(); } if (window.event && window.event.cancelBubble ) { window.event.cancelBubble = true; } if (eventObject && eventObject.preventDefault) { eventObject.preventDefault(); } if (window.event) { window.event.returnValue = false; } } /* * Safari doesn't support canceling events in the standard way, so we must * hard-code a return of false for it to work. */ function cancelEventSafari() { return false; } /* * Cross-browser style extraction, from the JavaScript & DHTML Cookbook * */ function getElementStyle(elementID, CssStyleProperty) { var element = document.getElementById(elementID); if (element.currentStyle) { return element.currentStyle[toCamelCase(CssStyleProperty)]; } else if (window.getComputedStyle) { var compStyle = window.getComputedStyle(element, ''); return compStyle.getPropertyValue(CssStyleProperty); } else { return ''; } } /* * CamelCases CSS property names. Useful in conjunction with 'getElementStyle()' * From */ function toCamelCase(CssProperty) { var stringArray = CssProperty.toLowerCase().split('-'); if (stringArray.length == 1) { return stringArray[0]; } var ret = (CssProperty.indexOf("-") == 0) ? stringArray[0].charAt(0).toUpperCase() + stringArray[0].substring(1) : stringArray[0]; for (var i = 1; i < stringArray.length; i++) { var s = stringArray[i]; ret += s.charAt(0).toUpperCase() + s.substring(1); } return ret; } /* * Disables all 'test' links, that point to the href '#', by Ross Shannon */ function disableTestLinks() { var pageLinks = document.getElementsByTagName('a'); for (var i=0; i elements. * * by Ross Shannon, http://www.yourhtmlsource.com/ */ addEvent(window, 'load', init, false); function init() { var formInputs = document.getElementsByTagName('input'); for (var i = 0; i < formInputs.length; i++) { var theInput = formInputs[i]; if (theInput.type == 'text' && theInput.className.match(/\bcleardefault\b/)) { /* Add event handlers */ addEvent(theInput, 'focus', clearDefaultText, false); addEvent(theInput, 'blur', replaceDefaultText, false); /* Save the current value */ if (theInput.value != '') { theInput.defaultText = theInput.value; } /* Save the current value */ theInput.style['color'] = '#999'; } } } function clearDefaultText(e) { var target = window.event ? window.event.srcElement : e ? e.target : null; if (!target) return; if (target.value == target.defaultText) { target.value = ''; target.style['color'] = '#000'; } } function replaceDefaultText(e) { var target = window.event ? window.event.srcElement : e ? e.target : null; if (!target) return; if (target.value == '' && target.defaultText) { target.value = target.defaultText; target.style['color'] = '#999'; } }/** * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/ * * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License: * http://www.opensource.org/licenses/mit-license.php * * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for * legal reasons. */ if(typeof deconcept=="undefined"){var deconcept=new Object();} if(typeof deconcept.util=="undefined"){deconcept.util=new Object();} if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();} deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;} this.DETECT_KEY=_b?_b:"detectflash"; this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY); this.params=new Object(); this.variables=new Object(); this.attributes=new Array(); if(_1){this.setAttribute("swf",_1);} if(id){this.setAttribute("id",id);} if(w){this.setAttribute("width",w);} if(h){this.setAttribute("height",h);} if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));} this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion(); if(c){this.addParam("bgcolor",c);} var q=_8?_8:"high"; this.addParam("quality",q); this.setAttribute("useExpressInstall",_7); this.setAttribute("doExpressInstall",false); var _d=(_9)?_9:window.location; this.setAttribute("xiRedirectUrl",_d); this.setAttribute("redirectUrl",""); if(_a){this.setAttribute("redirectUrl",_a);}}; deconcept.SWFObject.prototype={setAttribute:function(_e,_f){ this.attributes[_e]=_f; },getAttribute:function(_10){ return this.attributes[_10]; },addParam:function(_11,_12){ this.params[_11]=_12; },getParams:function(){ return this.params; },addVariable:function(_13,_14){ this.variables[_13]=_14; },getVariable:function(_15){ return this.variables[_15]; },getVariables:function(){ return this.variables; },getVariablePairs:function(){ var _16=new Array(); var key; var _18=this.getVariables(); for(key in _18){_16.push(key+"="+_18[key]);} return _16;},getSWFHTML:function(){var _19=""; if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){ if(this.getAttribute("doExpressInstall")){ this.addVariable("MMplayerType","PlugIn");} _19="0){_19+="flashvars=\""+_1c+"\"";}_19+="/>"; }else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");} _19=""; _19+=""; var _1d=this.getParams(); for(var key in _1d){_19+="";} var _1f=this.getVariablePairs().join("&"); if(_1f.length>0){_19+="";}_19+="";} return _19; },write:function(_20){ if(this.getAttribute("useExpressInstall")){ var _21=new deconcept.PlayerVersion([6,0,65]); if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){ this.setAttribute("doExpressInstall",true); this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl"))); document.title=document.title.slice(0,47)+" - Flash Player Installation"; this.addVariable("MMdoctitle",document.title);}} if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){ var n=(typeof _20=="string")?document.getElementById(_20):_20; n.innerHTML=this.getSWFHTML();return true; }else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}} return false;}}; deconcept.SWFObjectUtil.getPlayerVersion=function(){ var _23=new deconcept.PlayerVersion([0,0,0]); if(navigator.plugins&&navigator.mimeTypes.length){ var x=navigator.plugins["Shockwave Flash"]; if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));} }else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");} catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); _23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";} catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");} catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}} return _23;}; deconcept.PlayerVersion=function(_27){ this.major=_27[0]!=null?parseInt(_27[0]):0; this.minor=_27[1]!=null?parseInt(_27[1]):0; this.rev=_27[2]!=null?parseInt(_27[2]):0; }; deconcept.PlayerVersion.prototype.versionIsValid=function(fv){ if(this.majorfv.major){return true;} if(this.minorfv.minor){return true;} if(this.rev3) { //error = title + " allows only up to 3.\n"; } else { document.getElementById(fldset.name).style.background = '#fafafa'; error = ""; } } return error; } function validateDropdown(fld, title) { var error = ""; if (fld.value.length == 0) { fld.style.background = 'Yellow'; error = title + " is required.\n" } else { fld.style.background = 'White'; } return error; } function validateUsername(fld) { var error = ""; var illegalChars = /\W/; // allow letters, numbers, and underscores if (fld.value == "") { fld.style.background = 'Yellow'; error = "Username is required.\n"; } else if ((fld.value.length < 5) || (fld.value.length > 15)) { fld.style.background = 'Yellow'; error = "The username should be 5 to 15 characters long.\n"; } else if (illegalChars.test(fld.value)) { fld.style.background = 'Yellow'; error = "The username contains illegal characters.\n"; } else { fld.style.background = 'White'; } return error; } function validatePassword(fld) { var error = ""; var illegalChars = /[\W_]/; // allow only letters and numbers if (fld.value == "") { fld.style.background = 'Yellow'; error = "Password is required.\n"; } else if (fld.value.length < 7) { error = "The password needs at least 7 characters. \n"; fld.style.background = 'Yellow'; } else if (fld.value.length > 15) { error = "The password is too long. \n"; fld.style.background = 'Yellow'; } else if (illegalChars.test(fld.value)) { error = "The password contains illegal characters.\n"; fld.style.background = 'Yellow'; } else if (!((fld.value.search(/(a-z)+/)) && (fld.value.search(/(0-9)+/)))) { error = "The password must contain at least one numeral.\n"; fld.style.background = 'Yellow'; } else { fld.style.background = 'White'; } return error; } function validateVerify(fldmatch, fld) { var error = ""; var illegalChars = /[\W_]/; // allow only letters and numbers if (fld.value == "") { fld.style.background = 'Yellow'; error = "Passwords do not match.\n"; } else if ((fldmatch.value != fld.value)) { error = "Passwords do not match. \n"; fld.style.background = 'Yellow'; } else { fld.style.background = 'White'; } return error; } function trim(s) { return s.replace(/^\s+|\s+$/, ''); } function validatePhone(fld) { var error = ""; var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, ''); if (fld.value == "") { error = "Phone number is required.\n"; fld.style.background = 'Yellow'; } else if (isNaN(parseInt(stripped))) { error = "The phone number contains illegal characters.\n"; fld.style.background = 'Yellow'; } else if (!(stripped.length == 10)) { error = "The phone number is the wrong length. Make sure you included an area code.\n"; fld.style.background = 'Yellow'; } return error; } function validateBirthdate(fld) { var error=""; var tfld = trim(fld.value); // value of field with whitespace trimmed off var pattern = /\d{1,2}\/\d{1,2}\/\d{4}/; if (fld.value == "") { fld.style.background = 'Yellow'; error = "Birth date is required.\n"; } else if (!tfld.match(pattern)) { fld.style.background = 'Yellow'; error = "The birthdate contains illegal characters.\n"; } else { fld.style.background = 'White'; } return error; } function validateEmail(fld) { var error=""; var tfld = trim(fld.value); // value of field with whitespace trimmed off var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ; var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ; if (fld.value == "") { fld.style.background = 'Yellow'; error = "Email is required.\n"; } else if (!emailFilter.test(tfld)) { //test email for illegal characters fld.style.background = 'Yellow'; error = "Please enter a valid email address.\n"; } else if (fld.value.match(illegalChars)) { fld.style.background = 'Yellow'; error = "The email address contains illegal characters.\n"; } else { fld.style.background = 'White'; } return error; } function validateMultipleEmail(fld, title) { var error=""; var tfld = trim(fld.value); // value of field with whitespace trimmed off var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ; var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ; if (fld.value == "") { fld.style.background = 'Yellow'; error = title+" is required.\n"; } else if (!emailFilter.test(tfld)) { //test email for illegal characters fld.style.background = 'Yellow'; error = "Please enter a valid "+title+" address.\n"; } else if (fld.value.match(illegalChars)) { fld.style.background = 'Yellow'; error = "The "+title+" address contains illegal characters.\n"; } else { fld.style.background = 'White'; } return error; }