/* * Jscript defs * $Id: nhls_common.js,v 1.27.2.64.2.6 2007-09-07 18:57:37 akinder Exp $ */ /* * Globals */ var currentForm = ''; var formHandler = ''; var checkOptions = new Array(); var blankRad1 = true; var blankRad2 = true; var imgCaseAdd = 'resources/images/case_add.gif'; var imgCaseDel = 'resources/images/case_delete.gif'; var caseType = 'Add'; // // Use cookies? // var var_can_use_cookies = true; // Declaring required variables var digits = "0123456789"; // non-digit characters which are allowed in phone numbers var phoneNumberDelimiters = "()- "; // characters which are allowed in international phone numbers // (a leading + is OK) var validWorldPhoneChars = phoneNumberDelimiters + "+"; // Minimum no of digits in an international phone no. var minDigitsInIPhoneNumber = 10; /* * Deselect all rows in a multi select */ function deselect_multi_select( propertyName ) { // // Short // var handle = document.getElementById( propertyName ); for( var x=0; x paging_max_page ) { alert( "Requested page cannot be larger than " + paging_max_page ); } else { // // Send // doPaging(paging_dr_howser); } } /* * Generic call for submit */ function do_action( command ) { formHandler.cmd.value = command; formHandler.submit(); } /* * Generic call for canceling */ function cancel_action( location, sublocation ) { // // Set and go // formHandler.action = location; formHandler.cmd.value = sublocation; formHandler.submit(); } /* * Workaround for textonly */ function is_text_only() { // // Grab all the IMG elements // var images = document.getElementsByTagName("IMG"); for( var x = 0; x < images.length; x++ ) { // // Hide them // images[x].style.display = 'none'; // // Just to make sure // images[x].style.height = '1px'; images[x].style.width = '1px'; } } /* * Generic funcs */ function setFormHandler() { var tmp = document.getElementsByName( currentFormID ); formHandler = tmp.item(0); if( currentFormID == 'radiusSearchForm' ) { // // Setup the on focus handler // formHandler.radius1.onfocus = onfocusRad1; formHandler.radius2.onfocus = onfocusRad2; } } /* * Toggle a submit button */ function toggle_submit_button( id, text ) { document.getElementById( id ).value = text; if( document.getElementById( id ).disabled == true ) { document.getElementById( id ).disabled = false; } else { document.getElementById( id ).disabled = true; } } function toggle_div( id, override ) { if( override == '' ) { override = false; } var FIstate = document.getElementById( id ); if( !override ) { if( FIstate.style.display == 'none' ) { FIstate.style.display = 'block'; } else { FIstate.style.display = 'none'; } } else { // // Always on // FIstate.style.display = 'block'; } // // TMP if( window.ie6 ) { var selects = $$('select'); selects.setStyle("display", ""); } } function pop_window( url, width ) { if( width == null ) { width = 770; } window.open( url, 'PrintWin', "resizable=yes, height=600, width="+width+", toolbars=yes, menubar=yes, scrollbars=yes" ); } function validateZIP(field) { // // Length // if( field.length < 5 || field.length > 5 ) { alert( 'Please enter your five digit zipcode.' ); return false; } // // Test the field // if( isNaN( Number(field) ) ) { alert( 'Please enter your five digit zipcode.' ); return false; } else { return true; } } // // Utility functions // function isInteger(s) { var i; for (i = 0; i < s.length; i++) { // Check that current character is number. var c = s.charAt(i); if (((c < "0") || (c > "9"))) return false; } // All characters are numbers. return true; } function stripCharsInBag(s, bag) { var i; var returnString = ""; // Search through string's characters one by one. // If character is not in bag, append to returnString. for (i = 0; i < s.length; i++) { // Check that current character isn't whitespace. var c = s.charAt(i); if (bag.indexOf(c) == -1) returnString += c; } return returnString; } function checkInternationalPhone(strPhone){ s=stripCharsInBag(strPhone,validWorldPhoneChars); return (isInteger(s) && s.length >= minDigitsInIPhoneNumber); } function leftTrim(sString) { while (sString.substring(0,1) == ' ') { sString = sString.substring(1, sString.length); } return sString; } function trimPageBreak(sString) { while (sString.substring(0,1) == '\n') { sString = sString.substring(1, sString.length); } while (sString.substring(sString.length-1, sString.length) == '\n') { sString = sString.substring(0,sString.length-1); } return sString; } function rightTrim(sString) { while (sString.substring(sString.length-1, sString.length) == ' ') { sString = sString.substring(0,sString.length-1); } return sString; } function trimBothEnd(sString){ return leftTrim(rightTrim(sString)); } function trimAll(sString) { while (sString.substring(0,1) == ' '){ sString = sString.substring(1, sString.length); } while (sString.substring(sString.length-1, sString.length) == ' '){ sString = sString.substring(0,sString.length-1); } return sString; } function isEmpty(sString){ var s = trimBothEnd(sString); if (s.length == 0){ return true; } return false; } function isFloat(s){ if(isNaN(parseFloat(s))){ return false; } return true; } function isPositiveFloat(s){ if(isNaN(parseFloat(s))){ return false; } if(parseFloat(s)<=0){ return false; } return true; } function goOutside(url) { if( url != null ) { if(confirm("You have requested a document that is external to HUD's World Wide Website. HUD cannot attest to the accuracy of information provided by linked sites. Linking to a website does not constitute an endorsement by HUD, or any of its employees, of the sponsors of the site or the products presented on the site.")){ window.open(url); } } }