function replaceString(oldS,newS,fullS) {
	// Replaces oldS with newS in the string fullS
	for (var i=0; i<fullS.length; i++) {
	if (fullS.substring(i,i+oldS.length) == oldS) {
	fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length)
							}
					}	
	return fullS
	}
	
function validateSQL(str) {
	var badstrings = new Array(32);
	badstrings[0] = 'select';
	badstrings[1] = 'update';
	badstrings[2] = 'drop';
	badstrings[3] = 'alert';
	badstrings[4] = 'create';
	badstrings[5] = 'dump';
	badstrings[6] = 'kill';
	badstrings[7] = 'truncate';
	badstrings[8] = 'reconfig';
	badstrings[9] = 'revoke';
	badstrings[10] = 'setuser';
	badstrings[11] = 'shutdown';
	badstrings[12] = 'disk';
	badstrings[13] = 'scripting.';
	badstrings[14] = 'exec';
	badstrings[15] = 'dbcc';
	badstrings[16] = '--';
	badstrings[17] = '@@';
	badstrings[18] = ';';
	badstrings[19] = '*';
	badstrings[20] = '+';
	badstrings[21] = '[';
	badstrings[22] = ']';
	badstrings[23] = '""';
	badstrings[24] = 'xp_';
	badstrings[25] = 'sp_';
	badstrings[26] = 'ole_';
	badstrings[27] = 'convert(';
	badstrings[28] = 'chr(';
	badstrings[29] = 'char(';
	badstrings[30] = 'insert';
	badstrings[31] = 'delete';
	var strip;
	var checkflag;
	strip = str;
	
	strip = replaceString(" ", "", strip);
	
	strip = replaceString("'", "", strip);
	
	strip = replaceString("\t", "", strip);
	
	strip = replaceString("\n", "", strip);
	
	strip = replaceString("\r", "", strip);
	
	
	checkflag = "";
	var i;
	for (i = 0; i < badstrings.length; i++) {
		if ( strip.indexOf(badstrings[i])!= -1) {
			checkflag = "error";
		}
	}

	return checkflag;
}


function promptFileName(obj) {
	if (obj!=null) {
	   alert('Please use the browse button to specify your filename.');	
		
	}
}

/** 
******************************************************************************** 
* System Name  : eLiTeS                                                        * 
* Component Id : field.js                                                      * 
* Description  : JavaScript functions to validate common formatted fields.     * 
******************************************************************************** 
* Revision History                                                             * 
******************************************************************************** 
* Date         : 12 February 2004                                              * 
* By           : TIMS                                                          * 
* Reference No : -                                                             * 
* Description  : Initial Release                                               * 
******************************************************************************** 
*/ 


/********************************************************************** 
 * Component ID : isBlank 
 * Input        : Name          Type                    Description 
 *                ------------- ----------------------- ------------ 
 *                str           string 
 * Output       : int 
 * Description  : To check whether a string is blank. 
 *                Return 0 - if str is blank. 
 *                       1 - otherwise. 
 ********************************************************************** 
 */ 
function isBlank(str) { 
        // check if field string value is blank 
        for (var i = 0; i < str.length; i++) { 
                var c = str.charAt(i); 
                if ((c != ' ') && (c != '\n') && (c != '\t')) { 
                        return 1; 
                } 
        } 

        return 0; 
} 

/********************************************************************** 
 * Component ID : isValidLength 
 * Input        : Name          Type                    Description 
 *                ------------- ----------------------- ------------ 
 *                str           string 
 *                min           int                     minimum length 
 *                max           int                     maximum length 
 * Output       : int 
 * Description  : To check whether a string length falls within the required length. 
 *                Return 0 - if str is of valid length. 
 *                       1 - if str is blank. 
 *                       2 - if str is longer than max. 
 *                       3 - if str is shorter than min. 
 ********************************************************************** 
 */ 
function isValidLength(str, min, max) { 
        if (isBlank(str) == 0 ) { 
                return 1; 
        } 

        if (str.length >= min && str.length <= max) { 
                return 0; 
        } else if (str.length > max) { 
                return 2; 
        } else if (str.length < min) { 
                return 3; 
        } 
} 

/********************************************************************** 
 * Component ID : isNumeric 
 * Input        : Name          Type                    Description 
 *                ------------- ----------------------- ------------ 
 *                str           string 
 * Output       : int 
 * Description  : To check whether a string consists of all numeric characters. 
 *                Return 0 - if str contains all numeric characters. 
 *                       1 - if str is blank. 
 *                       2 - otherwise. 
 ********************************************************************** 
 */ 
function isNumeric(str) { 
        if (isBlank(str) == 0) { 
                return 1; 
        } 

        if (isNaN(str) != 0) { 
                return 2; 
        } 

        if (str.indexOf('.') != -1) { 
                return 2; 
        } 

        if (str.indexOf('-') != -1) { 
                return 2; 
        } 

        return 0; 
} 

/********************************************************************** 
 * Component ID : isOptionSelected 
 * Input        : Name          Type                    Description 
 *                ------------- ----------------------- ------------ 
 *                radio         radio button group obj 
 * Output       : int 
 * Description  : To check whether one of the radio button in the radio button group is checked. 
 *                Return 0 - if one of the radio button is selected. 
 *                       1 - otherwise. 
 ********************************************************************** 
 */ 
function isOptionSelected(radio) { 

        for (var i = 0; i < radio.length; i++) { 
                if (radio[i].checked == true) { 
                        return 0; 
                } 
        } 

        return 1; 
} 

/********************************************************************** 
 * Component ID : isCharacter 
 * Input        : Name          Type                    Description 
 *                ------------- ----------------------- ------------ 
 *                Str           string 
 * Output       : int 
 * Description  : To check whether the str consists of all characters. 
 *                Return 0 - if true 
 *                       1 - if false 
 ********************************************************************* 
 */ 
function isCharacter(str,zeroAllowed) { 
        for (i = 0; i < str.length; i++) { 
                var cha = str.charAt(i); 

                if (((cha >= 'A') && (cha <= 'Z')) || 
                                ((cha >= 'a') && (cha <= 'z')) || 
                                ((cha >= '0') && (cha <= '9'))) { 
                        continue; 
                } else { 
                        return 1; 
                } 
        } 

        return 0; 
} 

/********************************************************************** 
 * Component ID : trim, ltrim, reverse 
 * Input        : Name          Type                    Description 
 *                ------------- ----------------------- ------------ 
 *                Str           string                  the string need to add 
 * Output       : String - the trimmed string 
 * Description  : To trim a string, and two other helper functions 
 ********************************************************************** 
 */ 
function ltrim(str) { 
        var first = true; 
        var newStr = ""; 

        for (i = 0; i < str.length; i++) { 
                var ch = str.charAt(i); 

                if ((ch == " ") && (first)) { 
                        continue; 
                } else { 
                        first = false; 
                        newStr += ch; 
                } 
        } 

        return newStr; 
} 

function trim(str) { 
        var t1 = ltrim(str); 
        var t2 = reverse(t1); 
        var t3 = ltrim(t2); 
        var t4 = reverse(t3); 

        return t4; 
} 

function reverse(str) { 
        var newStr = ""; 

        for (i = str.length - 1; i >= 0; i--) { 
                var ch = str.charAt(i); 
                newStr += ch; 
        } 

        return newStr; 
} 

/********************************************************************** 
 * Component ID : getIndexInList 
 * Input        : Name          Type                    Description 
 *                ------------- ----------------------- ------------ 
 *                listbox       Listbox object 
 *                value         String                  value in the listbox 
 * Output       : int - the corresponding index of the value in the listbox 
 * Description  : To get a index of specified value in the list box 
 ********************************************************************** 
 */ 
function getIndexInList(listbox, value) { 
        for (i1 = 0; i1 < listbox.length; i1++) { 
                var v = listbox.options[i1].value; 

                if (v == value) { 
                        return i1; 
                } 
        } 

        return 0; 
} 

/********************************************************************** 
 * Component ID : isNumberBlank 
 * Input        : Name          Type                    Description 
 *                ------------- ----------------------- ------------ 
 *                Str           string                  one value need validation 
 * Output       : int,0:true;1:false. 
 * Description  : To check whether a string is blank or just 0 
 * author   : YanFeng 
 * date     : 2/11/2001 
 **********************************************************************/ 
function isNumberBlank(numStr) { 
        var newStr = numStr.replace(/0/g, " "); 
        newStr = trim(newStr); 

        if (newStr == "") { 
                return 0; 
        } 

        return 1; 
} 

/********************************************************************** 
 * Component ID : isInArray 
 * Input        : Name          Type                    Description 
 *                ------------- ----------------------- ------------ 
 *                myData         string                 data need check 
 *                arr            array                  the array 
 * Output       : int 
 * Description  : To check whether a data is in the list of array 
 *                Return 0 - if true 
 *                       1 - id false 
 ********************************************************************** 
 */ 
function isInArray(str, arr) { 
        for (var h = 0; h < arr.length; h++) { 
                if (arr[h] == str) { 
                        return 0; 
                } 
        } 

        return 1; 
} 

/********************************************************************** 
 * Component ID : isDouble 
 * Input        : Name          Type                    Description 
 *                ------------- ----------------------- ------------ 
 *                str           string 
 *                max           maximum number 
 * Output       : int 
 * Description  : To check whether a string is numeric double type. 
 *                Return 0 - true. 
 *                       1 - false. 
 ********************************************************************** 
 */ 
function isDouble(str, max) { 
        if (!isNaN(str)) { //is Numeric 
                if ((str > 0) && (str <= max)) { //maximum double 
                        return 0; 
                } 
        } 

        return 1; 
} 

/********************************************************************** 
 * Component ID : replaceSpace 
 * Input        : Name          Type                    Description 
 *                ------------- ----------------------- ------------ 
 *                str           string 
 * Output       : String will all white space replaced with "%20" 
 * Description  : To replace all white space in str with "%20". 
 ********************************************************************** 
 */ 
function replaceSpace(str) { 
        var start = 0; 
        var index = 0; 
        var converted = ""; 

        if (str == "") { 
                return ""; 
        } 

        while (index != -1) { 
                if (start < str.length) { 
                        index = str.indexOf(' ', start); 
                } else { 
                        break; 
                } 

                if (index != -1) { 
                        converted += str.substring(start, index); 
                        converted += "%20"; 
                } else { 
                        break; 
                } 

                start = index + 1; 
        } 

        converted += str.substring(start, str.length); 

        return converted; 
} 


/********************************************************************** 
 * Component ID : isEmail 
 * Input        : Name          Type                    Description 
 *                ------------- ----------------------- ------------ 
 *                email         string 
 * Output       : int 
 * Description  : To check whether an email is valid format. 
 *                Return 0 - if email is invalid 
 *                       1 - if email is valid 
 ********************************************************************** 
 */ 
function isEmail(emailStr) { 
    if (emailStr.length == 0) { 
       return 1; 
    } 
   var emailPat=/^(.+)@(.+)$/; 
   var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"; 
   var validChars="\[^\\s" + specialChars + "\]"; 
   var quotedUser="(\"[^\"]*\")"; 
   var ipDomainPat=/^(\d{1,3})[.](\d{1,3})[.](\d{1,3})[.](\d{1,3})$/; 
   var atom=validChars + '+'; 
   var word="(" + atom + "|" + quotedUser + ")"; 
   var userPat=new RegExp("^" + word + "(\\." + word + ")*$"); 
   var domainPat=new RegExp("^" + atom + "(\\." + atom + ")*$"); 
   var matchArray=emailStr.match(emailPat); 
   if (matchArray == null) { 
       return 0; 
   } 
   var user=matchArray[1]; 
   var domain=matchArray[2]; 
   if (user.match(userPat) == null) { 
       return 0; 
   } 
   var IPArray = domain.match(ipDomainPat); 
   if (IPArray != null) { 
       for (var i = 1; i <= 4; i++) { 
          if (IPArray[i] > 255) { 
             return 0; 
          } 
       } 
       return 1; 
   } 
   var domainArray=domain.match(domainPat); 
   if (domainArray == null) { 
       return 0; 
   } 
   var atomPat=new RegExp(atom,"g"); 
   var domArr=domain.match(atomPat); 
   var len=domArr.length; 
   if ((domArr[domArr.length-1].length < 2) || 
       (domArr[domArr.length-1].length > 3)) { 
       return 0; 
   } 
   if (len < 2) { 
       return 0; 
   } 
   return 1; 
} 


function limitTextArea(formobj, size){ 
        returnvalue = true; 

        if (formobj.value.length > size) { 
                returnvalue = false; 
        } 

        return returnvalue; 
} 

<!--
function containSpecialChar(aString) 
/* to Check whether there is special character in a string */
{
	var aChar = null;
	var status = true;

	for (var i = 0; i < aString.length; i++)
	{
		aChar = aString.charAt(i);
		if (aChar == "&" || aChar == "'" || aChar == "%" || aChar == ";" || aChar == "*")
			return (aChar);
	} // for
	
	aChar = "";
	return (aChar);
}  // containSpecialChar

function containSpace(aString) 
/* to Check whether there is space character in a string */
{
	var aChar = null;
	var bChar = null;
	var status = true;

	aChar = aString.charAt(0);
	if (aChar == " ")
	return aChar;

	aChar = "";
	return (aChar);
}  // containSpace

function isValidPhone(aString) 
/* to Check whether a string can be converted to an integer */
{
	var aChar = null;
		
	for (var i = 0; i < aString.length; i++)
	{
		aChar = aString.charAt(i);
		if (!(aChar >= '0' && aChar <= '9') && !(aChar == '+' || aChar == '-' || aChar == '(' || 

aChar == ')'))
			return false;
	} // for
	
	return true;
}  // isValidPhone

function isInteger(aString) 
/* to Check whether a string can be converted to an integer */
{
	var aChar = null;
		
	for (var i = 0; i < aString.length; i++)
	{
		aChar = aString.charAt(i);
		if (!(aChar >= '0' && aChar <= '9'))
			return false;
	} // for
	
	return true;
}  // isInteger


function gonext()
{  

//if (document.feedback.category.selectedIndex == 0)
//	{
//	alert ("Please select a category.");
	//document.feedback.category.focus();
//	return false;
//	} //end of category


 var sChar;

	var name = document.feedback.name.value;
	if(name=="") {
	alert ("Please enter your name.");
	document.feedback.name.focus();
	return false;
	}	
	
	
	sChar = containSpace(name);	
	if (!(sChar == ""))
	{
		alert("Please ensure there are no extra spaces in Last Name.");
		document.feedback.name.focus();		
		return false;
	}

	
// contact number
	var officeNo = document.feedback.Contact_Number.value;
	if(officeNo != "") {

	if (isValidPhone(officeNo) == 0)
	{
		alert("Please enter a valid Contact Number.");
		document.feedback.Contact_Number.focus();
		return false;
		
	}
	}


	
	// Salutation
	var title;
	for (count = 0; count < 6; count++)
	{
		if (document.feedback.salutation[count].selected)
		{
			title = document.feedback.salutation[count].value
			count = 6;
		}
	}

	/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var emailStr = document.feedback.email.value;

if(emailStr=="") {
alert ("Please enter the email address.")
document.feedback.email.focus();
return false;
}

sChar = containSpace(emailStr);	
	if (!(sChar == ""))
	{
		alert("You have entered an invalid email, please ensure there are no extra spaces.");
		document.feedback.email.focus();		
		return false;
	}
var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

alert("Please enter a valid email address.");
document.feedback.email.focus();
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("The email address contains invalid characters.");
document.feedback.email.focus();
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("This domain name contains invalid characters.");
document.feedback.email.focus();
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

alert("The email address doesn't seem to be valid.");
document.feedback.email.focus();
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
document.feedback.email.focus();
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.");
document.feedback.email.focus();
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The address must end in a well-known domain or two letter " + "country.");
document.feedback.email.focus();
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
alert("This email address is missing a hostname!");
document.feedback.email.focus();
return false;
}	


  //  document.feedback.encoding="multipart/form-data";
  //  document.feedback.action="feedback_sent.asp";
 // 	document.feedback.submit();
}


function gocancel()
{
    window.location="feedback_new3.asp"
}







-->
//-->
