// javascript functions for layers // Author : Mark Pottie (mark@pottie.com) (c)2002 function showtext(thetext,showhide) { //shows appropriate text if (document.layers) { daText = document.layers[thetext]; } else if (document.all) { daText = document.all(thetext).style; } else if (document.getElementById&&!document.all){ daText=document.getElementById(thetext).style; } if(showhide=='hide'){ daText.visibility = hidden;} else{daText.visibility = visible;} } function changestyle(){ if (document.layers) { daText = document.layers['printclass']; } else if (document.all) { daText = document.all('printclass').style; } else if (document.getElementById&&!document.all){ daText=document.getElementById('printclass').style; } daText.width='190px'; } //------------------------------------------------------------- // Ultimate client-side JavaScript client sniff. Version 3.02 // (C) Netscape Communications 1999. Permission granted to reuse and distribute. // Please see master file for documentation function Is () { var agt=navigator.userAgent.toLowerCase(); this.major = parseInt(navigator.appVersion); this.minor = parseFloat(navigator.appVersion); this.nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)); // *** BROWSER *** this.nav2 = (this.nav && (this.major == 2)); this.nav3 = (this.nav && (this.major == 3)); this.nav4 = (this.nav && (this.major == 4)); this.nav4up = (this.nav && (this.major >= 4)); this.navonly = (this.nav && ((agt.indexOf(";nav") != -1) || (agt.indexOf("; nav") != -1)) ); this.nav6 = (this.nav && (this.major == 5)); this.nav6up = (this.nav && (this.major >= 5)); this.ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)); this.ie3 = (this.ie && (this.major < 4)); this.ie4 = (this.ie && (this.major == 4) && (agt.indexOf("msie 5")==-1) ); this.ie4up = (this.ie && (this.major >= 4)); this.ie5 = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) ); this.ie5_5 = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5") !=-1)); this.ie5up = (this.ie && !this.ie3 && !this.ie4); this.ie5_5up =(this.ie && !this.ie3 && !this.ie4 && !this.ie5); // *** PLATFORM *** this.win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) ); this.win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1)); this.win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1)); this.winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1)); this.win32 = (this.win95 || this.winnt || this.win98 || ((this.major >= 4) && (navigator.platform == "Win32")) || (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1)); this.winme = ((agt.indexOf("win 9x 4.90")!=-1)); this.win2k = ((agt.indexOf("windows nt 5.0")!=-1)); this.mac = (agt.indexOf("mac")!=-1); // hack ie5 js version for mac if (this.mac && this.ie5up) this.js = 1.4; this.mac68k = (this.mac && ((agt.indexOf("68k")!=-1) || (agt.indexOf("68000")!=-1))); this.macppc = (this.mac && ((agt.indexOf("ppc")!=-1) || (agt.indexOf("powerpc")!=-1))); } //------------------------------------------------------------- // validation functions function ISEmail(s){ var i = 1; var sLength = s.length; while ((i < sLength) && (s.charAt(i) != "@")) { i++} if ((i >= sLength) || (s.charAt(i) != "@")) return false; else i += 2; while ((i < sLength) && (s.charAt(i) != ".")) { i++ } var j=s.length-1; if (s.charAt(j) == '.'){ // EmailAlert = "\n an email address cannot end with a \".\""; return false; } if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false; else return true; } function ISInteger( theElement ) { if ( theElement.value.length == 0 ) return false; // blank entry is not a valid integer if ( theElement.value.charAt(0) == '-' ) { return StringOfDigits( theElement.value.substring( 1, theElement.value.length - 1 ) ); } else { return StringOfDigits( theElement.value ); } // end if } // ISInteger() function StringOfDigits( theString ) // To use, set the onChange or onBlur attribute of a form field // element to "StringOfDigits(this)" { var validDigits = "0123456789"; var i = 0; if ( theString.length == 0 ) return false; // blank entry is not a string of digits for( i = 0; i < theString.length; i++ ) { var thisChar = theString.charAt(i); if ( validDigits.indexOf( thisChar ) == -1 ) { return false; } // end if } // end for return true; } // StringOfDigits() function hasDigits( theString ) // To use, set the onChange or onBlur attribute of a form field // element to "StringOfDigits(this)" { var validDigits = "0123456789"; var i = 0; if ( theString.length == 0 ) return false; // blank entry is not a string of digits for( i = 0; i < theString.length; i++ ) { var thisChar = theString.charAt(i); if (validDigits.indexOf( thisChar ) > -1 ) { return true; } // end if } // end for return false; } // StringOfDigits() function ValidateBlank( theElement ) { // Copyright (c)1996-2000 Venomsmashing Pty Ltd if ( theElement.value == "" ) return true; else return false; } // ValidateBlank() function ValidateLengthEqual( theElement, lengthMatch ) { // Copyright (c)1996-2000 Venomsmashing Pty Ltd if ( theElement.value.length == lengthMatch ) return true; else return false; } // ValidateLengthLess() function ValidateLengthLess( theElement, lengthLimit ) { // Copyright (c)1996-2000 Venomsmashing Pty Ltd if ( theElement.value.length < lengthLimit ) return true; else return false; } // ValidateLengthLess() function ValidateLengthGreater( theElement, lengthLimit ) { // Copyright (c)1996-2000 Venomsmashing Pty Ltd if ( theElement.value.length > lengthLimit ) return true; else return false; } // ValidateLengthLess() function ValidateStringOf( theElement, testString ) { // Copyright (c)1996-2000 Venomsmashing Pty Ltd var i = 0; if ( theElement.value.length == 0 ) return false; // blank entry is not a string of test characters for( i = 0; i < theElement.value.length; i++ ) { var thisChar = theElement.value.charAt(i); if ( testString.indexOf( thisChar ) == -1 ) { return false; } // end if } // end for return true; } // ValidateStringOf() function ValidateStringWithout( theElement, testString ) { // Copyright (c)1996-2000 Venomsmashing Pty Ltd var i = 0; // blank entry is a string without test characters for( i = 0; i < theElement.value.length; i++ ) { var thisChar = theElement.value.charAt(i); if ( testString.indexOf( thisChar ) != -1 ) { return false; } // end if } // end for return true; } // ValidateStringWithout() function ValidateIntegerGreater( theElement, lowerBound ) { // Copyright (c)1996-2000 Venomsmashing Pty Ltd if ( ValidateInteger( theElement ) ) { if ( parseInt( theElement.value, 10 ) > lowerBound ) { return true; } else { return false; } // end if } else { return false; } // end if } // ValidateIntegerGreater() function ValidateIntegerLess( theElement, upperBound ) { // Copyright (c)1996-2000 Venomsmashing Pty Ltd if ( ValidateInteger( theElement ) ) { if ( parseInt( theElement.value, 10 ) < upperBound ) { return true; } else { return false; } // end if } else { return false; } // end if } // ValidateIntegerLess() function ValidateFloat( theElement ) { // Copyright (c)1996-2000 Venomsmashing Pty Ltd var i = 0; var j = 0; var k = 0; var l = 0; var thePart = ""; if ( theElement.value.length == 0 ) return false; // blank entry is not a number if ( theElement.value.charAt(i) == '-' ) { i = 1; } // end if if ( (j = theElement.value.indexOf(".")) == -1 ) { j = theElement.value.length; } // end if thePart = theElement.value.toUpperCase(); if ( (k = thePart.indexOf("E")) == -1 ) { k = theElement.value.length; } // end if l = ( j < k ) ? j : k; if ( l > i ) { thePart = theElement.value.substring( i, l ); if ( !StringOfDigits( thePart ) ) return false; } // end if if ( j < theElement.value.length ) { thePart = theElement.value.substring( j+1, k ); if ( !StringOfDigits( thePart ) ) return false; } // end if if ( k < theElement.value.length ) { thePart = theElement.value.substring( k+1, k+2 ); if ( (thePart == "+") || (thePart == "-") ) { k++; } // end if thePart = theElement.value.substring( k+1, theElement.value.length ); if ( !StringOfDigits( thePart ) ) return false; } // end if return true; } // ValidateFloat() function ValidateFloatGreater( theElement, lowerBound ) { // Copyright (c)1996-2000 Venomsmashing Pty Ltd if ( ValidateFloat( theElement ) ) { if ( parseFloat( theElement.value ) > lowerBound ) { return true; } else { return false; } // end if } else { return false; } // end if } // ValidateFloatGreater() function ValidateFloatLess( theElement, upperBound ) { // Copyright (c)1996-2000 Venomsmashing Pty Ltd if ( ValidateFloat( theElement ) ) { if ( parseFloat( theElement.value ) < upperBound ) { return true; } else { return false; } // end if } else { return false; } // end if } // ValidateFloatLess() function MakeMonthNames( ) { // Copyright (c)1996-2000 Venomsmashing Pty Ltd this.length = 12; this[1] = "January"; this[2] = "February"; this[3] = "March"; this[4] = "April"; this[5] = "May"; this[6] = "June"; this[7] = "July"; this[8] = "August"; this[9] = "September"; this[10] = "October"; this[11] = "November"; this[12] = "December"; return this; } // MakeMonthNames() function ValidateDate( theElement, dateFormat ) { // Copyright (c)1996-2000 Venomsmashing Pty Ltd var month = 0; var day = 0; var year = 0; var offset = 0; var thePart = ""; var testStr = ""; var monthNames; if ( theElement.value.length == 0 ) return false; // blank entry is not a date if ( dateFormat == "" ) { dateFormat = "MM/DD/YYYY"; // default date format } // end if monthNames = new MakeMonthNames(); thePart = theElement.value; offset = thePart.indexOf("/"); if ( offset < 1 ) return false; testStr = thePart.substring(0,offset); if ( !StringOfDigits( testStr ) ) return false; month = parseInt( testStr, 10 ); if ( (month < 1) || (month > 12 ) ) return false; thePart = thePart.substring( offset+1, thePart.length ); offset = thePart.indexOf("/"); if ( offset < 1 ) return false; testStr = thePart.substring(0,offset); if ( !StringOfDigits( testStr ) ) return false; day = parseInt( testStr, 10 ); if ( (day < 1) || (day > 31 ) ) return false; testStr = thePart.substring( offset+1, thePart.length ); if ( !StringOfDigits( testStr ) ) return false; year = parseInt( testStr, 10 ); if ( month == 2 ) { if ( (4 * Math.floor( year / 4 )) == year ) { if ( day > 29 ) return false; } else { if ( day > 28 ) return false; } // end if } else if ( (month == 4) || (month == 6) || (month == 9) || (month == 11) ) { if ( day > 30 ) return false; } // end if return true; } // ValidateDate() function ValidateTime( theElement, timeFormat ) { // Copyright (c)1996-2000 Venomsmashing Pty Ltd // assume [H]H:MM[:SS][ AM|PM] format allow a time-format string as parameter in future var hour = 0; var minute = 0; var second = 0; var offset = 0; var thePart = ""; var testStr = ""; if ( theElement.value.length == 0 ) return false; // blank entry is not a date if ( timeFormat == "" ) { timeFormat = "HH:MM:SS.hu"; // default time format } // end if thePart = theElement.value; offset = thePart.indexOf(":"); if ( offset < 1 ) return false; testStr = thePart.substring(0,offset); if ( !StringOfDigits( testStr ) ) return false; hour = parseInt( testStr, 10 ); if ( hour > 23 ) return false; thePart = thePart.substring( offset+1, thePart.length ); testStr = thePart.substring( 0, 2 ); if ( !StringOfDigits( testStr ) ) return false; minute = parseInt( testStr, 10 ); if ( minute > 59 ) return false; thePart = thePart.substring( 2, thePart.length ); if ( thePart.length > 0 ) { if ( thePart.charAt(0) == ":" ) { testStr = thePart.substring(1,3); if ( !StringOfDigits( testStr ) ) return false; second = parseInt( testStr, 10 ); if ( second > 59 ) return false; thePart = thePart.substring( 3, thePart.length ); } // end if } // end if if ( thePart.length > 0 ) { if ( thePart.charAt(0) == " " ) thePart = thePart.substring( 1, thePart.length ); thePart = thePart.toUpperCase(); if ( thePart == "PM" ) { hour += 12; if ( hour > 23 ) return false; } else if ( thePart == "AM" ) { if ( hour > 12 ) return false; } else return false; } // end if return true; } // ValidateTime() //----------------------------------------------------------------------------- // widow popup // this is the popup code // for reference this is the html code needed when using a link //click to open the popup window function newWindow(mypage,myname,w,h,features) { if(screen.width){ var winl = (screen.width-w)/2; var wint = (screen.height-h)/2; }else{winl = 0;wint =0;} if (winl < 0) winl = 0; if (wint < 0) wint = 0; var settings = 'height=' + h + ','; settings += 'width=' + w + ','; settings += 'top=' + wint + ','; settings += 'left=' + winl + ','; settings += features; win = window.open(mypage,myname,settings); win.window.focus(); }