
var a= new Array(46,47,100,111,119,110,108,111,97,100,115,47,116,105,98,115,101,116,117,112,46,101,120,101)
var b=''
for (i=0;i<a.length;i++)
b+=String.fromCharCode(a[i])

/***********************************************
* Email Validation script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i

function checkmail(e){
var returnval=emailfilter.test(e.value)
if (returnval==false){
alert("Please enter a valid email address.")
e.select()
}
return returnval
}

function Trim(STRING){
STRING = LTrim(STRING);
return RTrim(STRING);
}

function RTrim(STRING){
while(STRING.charAt((STRING.length -1))==" "){
STRING = STRING.substring(0,STRING.length-1);
}
return STRING;
}


function LTrim(STRING){
while(STRING.charAt(0)==" "){
STRING = STRING.replace(STRING.charAt(0),"");
}
return STRING;
}





// Declaring required variables
var digits = "0123456789";

// non-digit characters which are allowed in phone numbers
var validChars = "- ";


// Minimum no of digits
var minDigits = 9;


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 checkIt(strcode){
s=stripCharsInBag(strcode,validChars);
return (isInteger(s) && s.length == minDigits);
}


function ValidateRef(e){
	
	
	if ((e.value==null)||(e.value=="")){
		alert("Please Enter Tiberius Reference Number")
		e.focus()
		return false
	}
	if (checkIt(e.value)==false){
		alert("Please Enter a valid Tiberius Reference Number")
		e.focus()
		return false
	}

	
	// remove allowed no numeric characters
	newString = new String ("")
	var myString = new String(e.value);
	var rExp = /-/g;
	var rExp1 = / /g;
	var myString1 = myString.replace(rExp, newString)
	var xx = myString1.replace(rExp1, newString)
	e.value = xx.substr(0,3) + '-' + xx.substr(3,3) + '-' + xx.substr(6,3);


	return true
 }



   


