function Set_Cookie( name, value, expires, path, domain, secure ) { // set time, it's in milliseconds var today = new Date(); today.setTime( today.getTime() ); /* if the expires variable is set, make the correct expires time, the current script below will set it for x number of days, to make it for hours, delete * 24, for minutes, delete * 60 * 24 */ if ( expires ) { expires = expires * 1000 * 60 * 60 * 24; } var expires_date = new Date( today.getTime() + (expires) ); document.cookie = name + "=" +escape( value ) + ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + ( ( path ) ? ";path=" + path : "" ) + ( ( domain ) ? ";domain=" + domain : "" ) + ( ( secure ) ? ";secure" : "" ); } function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "="); if (c_start!=-1) { c_start=c_start + c_name.length+1; c_end=document.cookie.indexOf(";",c_start); if (c_end==-1) c_end=document.cookie.length; return unescape(document.cookie.substring(c_start,c_end)); } } return ""; } function setCookie(NameOfCookie, value, expiredays) { var ExpireDate = new Date (); ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000)); document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()); } function replaceSubString( originalString , searchForString , replaceWithString ) { var objRegExp = eval( "/" + searchForString + "/g" ); return ( originalString.replace( objRegExp , replaceWithString ) ); } function unsave() { Set_Cookie("AlumniName",'',1,'/'); } function save() { Set_Cookie("AlumniName",document.forms[0].Name.value,1,'/'); Set_Cookie("AlumniPassword",document.forms[0].Password.value,1,'/'); Set_Cookie("AlumniRefresh","Refresh",1,'/'); document.forms[0].submit() } function SaveReg() { document.forms[0].submit() } function SavePerson() { var form = document.forms[0]; if (form.Password.value == form.InitPassword.value) { alert("Sorry, you must change your Password before you can continue"); return; }; if (form.Email.value == "") { alert("Please enter your Email information prior to submitting."); return; }; if (form.Password.value == "") { alert("Please enter a Password prior to submitting."); return; }; if (form.Name.value == "") { alert("Please enter your Last Name prior to submitting."); return; }; if (parent.failNull (form.FirstName, 'Please enter your First Name prior to submitting.','text')) {return}; Set_Cookie("AlumniName",form.Name.value +" "+form.FirstName.value,1,'/'); Set_Cookie("AlumniPassword",form.Password.value,1,'/'); Set_Cookie("AlumniRefresh","Refresh",1,'/'); form.submit(); } // --------------------------------------------- // --- Field Validation -- // --------------------------------------------- function failNull ( vField, vMessage, vType) { //this function will stop the submit if a field is null or contains all spaces //get the field value... theValue = getFieldValue (vField, vType); //if the field value is null, we fail and return true... if ( theValue == "" ) { alertBox ( vField, vMessage, vType ); return ( true ); } //remove any spaces from the value trimField = trimBlanks( theValue ); //if the field value is all spaces, fail and return true... if ( trimField =="" ) { alertBox ( vField, vMessage, vType ); return ( true ); } //otherwise continue... return ( false ); } function getFieldValue ( theField, vType ) { //this function will return the field value (or value list) based on the element type theValue = ""; sep = ""; hits = 0; //text is the user-entered value as a string if ( vType == "text" ) return ( theField.value ); //textarea is the user-entered value as a string array of one element if ( vType == "textarea" ) return ( theField[0].value ); //checkboxes & radio buttons are not so simple if ( vType == "checkbox" || vType == "radio" ) { if ( theField.value == null ) { //if we're here, we are validating a radio button or a nn multi-element checkbox for ( i = 0; i < theField.length; i++ ) { if ( theField[i].checked ) { hits++; if ( hits > 1 ) { sep = "; "; } theValue += sep + theField[i].value; } } } return ( theValue ); } else { //if we are here, must be an ie checkbox, or nn with a one-element checkbox) if ( navigator.appName == "Microsoft Internet Explorer" ) { //ie. return some data so we can validate on the server; return ("can't validate on client") } //nn one-element checkbox, see if its checked ... if (theField.checked ) { return ( theField.value ); } else { return ( "" ); } } //select is an array of selection pointers to an array of strings representing the choices if ( vType == "select" ) { for ( i = 0; i < theField.options.length; i++ ) { if ( theField.options[i].selected ) theValue += theField.options[i].text } return ( theValue ); } } function trimBlanks ( theString, repChar ) { //this function replaces the spaces in a string with the provided character trimString=""; for ( i = 0; i < theString.length; i++) { theChar=theString.substring ( i, i+1); if ( theChar == " ") { trimString += repChar } else { trimString+=theString.substring ( i, i+1); } } return (trimString); } function alertBox (vField, vMessage, vType ) { //this function replaces the spaces in a string with the provided character //if we pass a null message, we are doing a multiple validation test. return so we can check other conditions. if ( vMessage == "null" ) return; //otherwise, display the error message alert ( "Field Contains Incorrect Value:\n\n" + vMessage ) //and set focus (plus select the text if a text element) if ( vType == "text" ) { vField.focus(); vField.select(); } else { vField.focus(); } return; }