var xmlHttp // ------------------------------------------------------------------- // Central AJAX Call // ------------------------------------------------------------------- function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } // ------------------------------------------------------------------- // General Utilities // ------------------------------------------------------------------- // General trim of all white space in string function trim_all(s) { var i; var returnString = ""; // Search through string's characters one by one. // If character is not a whitespace, append to returnString. for (i = 0; i < s.length; i++) { // Check that current character isn't whitespace. var c = s.charAt(i); if (c != " ") returnString += c; } return returnString; } // Specific trim of only whitespace (or specified char) at the end or beginning of a string. // Parameters: // str: string to trim (required). // chars: character to trim from string (optional. defaults to white space char). function trim(str, chars) { return ltrim(rtrim(str, chars), chars); } // Left trim only. function ltrim(str, chars) { chars = chars || "\\s"; return str.replace(new RegExp("^[" + chars + "]+", "g"), ""); } // Right trim only. function rtrim(str, chars) { chars = chars || "\\s"; return str.replace(new RegExp("[" + chars + "]+$", "g"), ""); } function hov(loc,cls) { if(loc.className) loc.className=cls; } function isInt(x) { var y=parseInt(x); if (isNaN(y)) return false; return x==y && x.toString()==y.toString(); } function doClick(buttonName,e) { //the purpose of this function is to allow the enter key to //point to the correct button to click. var key; if (window.event) { key = window.event.keyCode; //IE } else { key = e.which; //firefox } if (key == 13) { //Get the button the user wants to have clicked var btn = document.getElementById(buttonName); if (btn != null) { //If we find the button click it btn.click(); //e.keyCode = 0 key = ""; } } } function textCounter(field, countfield) { countfield.value = field.value.length; } /*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 left' counter else countfield.value = maxlimit - field.value.length; } */ function checkform() { // Ensure password has been specified. var txt = document.getElementById("passwd"); if (txt != null) { if (txt.value == null || txt.value == "") { alert("You must enter your xms gateway password."); return false; } } // Ensure pager has been specified. txt = document.getElementById("pagers"); if (txt != null) { if (txt.value == null || txt.value == "") { alert("You must enter at least one pager/mobile number."); return false; } } // Ensure message has been specifed. txt = document.getElementById("idmsg"); if (txt != null) { if (txt.value == null || txt.value == "") { alert("You must enter a message."); return false; } } // Look for optional email address, and if present, ensure it's valid. txt = document.getElementById("email_reply"); if (txt != null) { if (txt.value != null && txt.value != "") { if (echeck(txt.value)==false) { alert("The reply email is optional. But if entered, it must be a valid email address."); return false; } } } return true; } function echeck(str) { var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1){ //alert("Invalid E-mail ID") return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ //alert("Invalid E-mail ID") return false } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ //alert("Invalid E-mail ID") return false } if (str.indexOf(at,(lat+1))!=-1){ //alert("Invalid E-mail ID") return false } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ //alert("Invalid E-mail ID") return false } if (str.indexOf(dot,(lat+2))==-1){ //alert("Invalid E-mail ID") return false } if (str.indexOf(" ")!=-1){ //alert("Invalid E-mail ID") return false } return true }