/*==================================================================
validfirstchars(string,allowedstring) : Returns true if first charcter of the string is a allowed character.
==================================================================
*/	 
function validfirstchars(strstring,allowedchar){
	    var start_do_name_char;
		var fFlag=false;
        start_do_name_char=strstring.charAt(0);	
        for (j = 0;  j <allowedchar.length; j++){
              if (start_do_name_char == allowedchar.charAt(j)){
			     fFlag=true;
			     break;
			  }   
        }		
        if (!fFlag){
		      return false;
	 	}
		return true;
}
/*==================================================================
validchars(string,allowedstring) : Returns true if all the string character is a allowed character.
==================================================================
*/	
function validchars(strstring,allowedchar,strl){
	            var ch;
				strstring=trim(strstring);
				if(strstring.length>strl){
				   return false;
				}   
		        for (i = 1;  i < strstring.length;i++){
							ch = strstring.charAt(i);
							for (j = 0;  j < allowedchar.length;  j++)
							   if (ch == allowedchar.charAt(j))
								    break;
									
							   if (j == allowedchar.length){
							        return false;
									break;
							   }
                }
	       return true;
}

function checkNumber(t) {
	if(t.value.length == 0 ||  isNaN(t.value) || t.value.substr(0,1) == " " || parseInt(t.value) < 0) {
		t.value="";
	}
}

function checkMail(email)
{
        var str1=email;
        var arr=str1.split('@');
        var eFlag=true;
        if(arr.length != 2)
        {
                eFlag = false;
        }
        else if(arr[0].length <= 0 || arr[0].indexOf(' ') != -1 || arr[0].indexOf("'") != -1 || arr[0].indexOf('"') != -1 || arr[1].indexOf('.') == -1)
        {
                        eFlag = false;
        }
        else
        {
                var dot=arr[1].split('.');
                if(dot.length < 2)
                {
                        eFlag = false;
                }
                else
                {
                        if(dot[0].length <= 0 || dot[0].indexOf(' ') != -1 || dot[0].indexOf('"') != -1 || dot[0].indexOf("'") != -1)
                        {
                                eFlag = false;
                        }

                        for(i=1;i < dot.length;i++)
                        {
                                if(dot[i].length <= 0 || dot[i].indexOf(' ') != -1 || dot[i].indexOf('"') != -1 || dot[i].indexOf("'") != -1 || dot[i].length > 4)
                                {
                                        eFlag = false;
                                }
                        }
                }
        }
                return eFlag;
}


