// JavaScript Document

var splChars = "!@$%^&*()+=[]\\;,./{}|:<>?"; //defining special characters
var removeTags= /<\S[^><]*>/g 				//tags to remove

    function checkInteger(val)				//Checks Integer Value (uses isDigit)
    { 
        for(var i=0;i<val.length;i++)
        {
            if(!isDigit(val.charAt(i)))
            {
                return false; 
            }
        }
        return true;
    }
    
	function isDigit(num)				// Checks if a character is a digit
    {
        if (num.length>1)
        {return false;} 
        var string="1234567890";
        if ( string.indexOf(num)!=-1)
        {return true;}
        return false;
    }
	
		function specialChars(formString)// Checks if formString contains Special Characters
    {
        for (var i = 0; i < formString.length; i++)
        {
            if (splChars.indexOf(formString.charAt(i)) != -1)
            {
				return 1;
            }

        }
        return 0; // Does Not contains Special Characters
    }

    function checkmail(email)
    {

		if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
			return false;
		} else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
			return false;
		} else if (email.indexOf("@") == email.length) {  // @ must not be the last character
			return false;
		} else if (email.indexOf("..") >=0) { // two periods in a row is not valid
		return false;
		} else if (email.indexOf(".") == email.length-1) {  // . must not be the last character
		return false;
		}
		return true;		//valid email
    }		//end email function
	
	

    function Trim(TRIM_VALUE)          // Trim spaces
    {
        if(TRIM_VALUE.length < 1)
        { 
            return "";
        }
        TRIM_VALUE = RTrim(TRIM_VALUE);
        TRIM_VALUE = LTrim(TRIM_VALUE);
        if(TRIM_VALUE=="")
        {
            return ""; 
        }
        else
        {
            return TRIM_VALUE;
        }
    } //End Function

    function RTrim(VALUE)			//trim spaces from right
    {
        var w_space = String.fromCharCode(32);
        var v_length = VALUE.length;
        var strTemp = "";
        if(v_length < 0)
        {
            return "";
        }
        var iTemp = v_length -1;
    
        while(iTemp > -1) 
        {
            if(VALUE.charAt(iTemp) == w_space){
        }
        else
        {
            strTemp = VALUE.substring(0,iTemp +1);
            break;
        }
        iTemp = iTemp-1; 
        
        } //End While
        return strTemp;
    
    } //End Function
    
    function LTrim(VALUE)			//trims spaces from right
    {
    var w_space = String.fromCharCode(32);
    if(v_length < 1)
    { 
        return "";
    }
    var v_length = VALUE.length;
    var strTemp = "";
    
    var iTemp = 0;
    
    while(iTemp < v_length)
    {
        if(VALUE.charAt(iTemp) == w_space) 
        {
        }
        else
        {
            strTemp = VALUE.substring(iTemp,v_length);
            break;
        }
        iTemp = iTemp + 1;
        } //End While
        return strTemp; 
    } //End Function
	
	
/*	function stripHTML(arguments) 
    {
        arguments.value=arguments.value.replace(removeTags,"");
    }
*/


