	// GLOBAL VARIABLES
	var flagForInvalidFormVal = true;
	invalidElementsArray = new Array(); 
	var numb = '0123456789';
	var alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ';
	var alphaNum ='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ';
	
//Date:25-September-06
//Coder:Vijaita Khandelwal
//purpose: This function is called everytime when user enters some data , to check that data submitted is valid or not  and to notify user if there is some error.	
	function dataValidation(elementId,typeOfCheck,flagForFormEle){
		data=$e(elementId).value;
		//alert(data);
		if(data == '')return ;
		data = trim(data);
		switch(typeOfCheck){
		case 'email':	status=isvalidEmail(data);
						break;
		case 'loginName':	status = loginNameCheck(data);
							break;
		
		case 'password': status = passCheck(data);
							break;
		
		case 'phnum':		status = isValid(data,numb);
							break;
		
		case 'is_numeric':	//alert('on change test');
							status = isValid(data,numb);
							break;
		
		case 'is_alphanumeric':	status = isValid(data,alphaNum);
								break;
		
		case 'is_alpha': status = isValid(data,alpha);
								break;
		
		default : break;
		}
		//alert('jghjgjghjgh'+status);
		if(status == false || status=='false' || !(status) ){
			if(flagForFormEle == '0' || flagForFormEle == 0){
				flagForInvalidFormVal = false ;
				//alert('0');
				return 0 ;
			}else{
				//invalidElementsArray[invalidElementsArray.length]=elementId;
				$e(elementId).className = 'rongInput' ;
				$e(elementId).style.backgroundColor="red";
				flagForInvalidFormVal = false ;
			}
		}
		else{
			if(flagForFormEle == '0' || flagForFormEle == 0){
				//alert('1');
				return 1 ;
			}else{
				$e(elementId).style.backgroundColor="white";
			}
		}	
	}
	
/*	Date: 4-December-06
	Coder: Vijaita Khandelwal
	 Purpose: This function checks its first argument for its type according   to the second parameter passed to the function .
			HERE type checking is for number , string , or alphaNumberic String.
			-if we  have to check for number then second parametr will have a string of all digits(0-9).
			- if check is for only string then II arg is a string of all alphabets in upper as well as lower case.
			- if check is for alphanumeric string then II arg is a string of all alphabets as well digits.
*/		
	function isValid(parm,val) {
	  if (parm == "") return false;
	  for (var i=0; i<parm.length; i++) {
	    if (val.indexOf(parm.charAt(i),0) == -1) return false;
	  }
	  return true;
	}

	
//Date:3-September-06
//Coder:Vijaita Khandelwal
//purpose: This function is to check the login name ( i.e.   email id ) given by user at the time of registration.  	
	function loginNameCheck(str){
		
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false;
		}else

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false;
		}else

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   return false;
		}else

		 if (str.indexOf(at,(lat+1))!=-1){
		   	return false;
		 }else

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false;
		 }else

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false;
		 }else
		
		 if (str.indexOf(" ")!=-1){
		   	return false;
		 }

 		return true	;				
	}

	
//Date:3-September-06
//Coder:Vijaita Khandelwal
//purpose: This function is to check the password given by user at the time of registration.  
	function passCheck(val){   
		if(val==""){
			return false;
		}
		if(val.length >6){
			return false;
		}	
		return true;
    }
	
//Date:25-September-06
//Coder:Vijaita Khandelwal
//purpose: This function is to check the data entered by user is complete numeric or not.	
	function Is_numeric(val){
		//alert('jjh'+val.length);
		if(val == ""){
			return false;
		}
		//alert(val.length);
		for(var i=0; i < val.length ; i++){
			var c =val.charAt(i);
			if(window.firefox )console.log(c);
			//alert('gfdg'+c);
			if (((c < 48) || (c > 57))){
				return false;
			} 
		}
		return true;
	}
	
//Date:25-September-06
//Coder:Vijaita Khandelwal
//purpose: This function is to check the data entered by user is  alphanumeric or not.		
	function Is_alphanumeric(str){
		if(str == ""){
			return false;
		}
		for(var i=0; i < val.length ; i++){
			var c =str.charAt(i);
			if(window.firefox )console.log(c);
			if(!((c >= "0")|| (c <= "9")|| (c >= "65")|| (c <= "90")|| (c >= "97")|| (c <= "122"))){
				return false;
			}
		}
		return true;
	}	

	
//Date:25-September-06
//Coder:Vijaita Khandelwal
//purpose: This function is to check whether the string entered by user is not having anything other then alphabets.		
	function Is_alpha(str){
		if(str == ""){
			return false;
		}
		for(var i=0; i < str.length ; i++){
			var c =str.charAt(i);
			if(window.firefox )console.log(c);
			if(!((asc(c) >= 65)|| (c <= 90)|| (c >= 97)|| (c <= 122))){
				return false;
			}
		}
		return true;
	}	
	
	function Is_empty(str){
		if(str == "" || str == null){
			alert("empty not allowed");
		}	
	}
	
	function isEmptyArray(inputArr){
		if(inputArr == ''){
			return true;
		}else{
			return false;
		}
	}
	
	function isvalidEmail(email) {
		var email=/^[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/i;	
		emailStr = $e(email).value ;
		if ((email.test(emailStr)) == 0) 
		{
			//alert ("Please enter proper E-Mail");
			//document.forms[0].vis_email.focus();
			if($(elementId))	$e(elementId).style.backgroundColor="red";
			flagForInvalidFormVal = false ;
			return false;
		}
		if($(elementId))	$e(elementId).style.backgroundColor="white";
		return true;
	}

	function echeck(email,typeOfData) {
		//alert(email);
		if(typeOfData == 'directVal'){
			//loginNameCheck(email); 
			//return ;
			var str = email ;
			if(str == '')return true ;
			var at="@"
			var dot="."
			var lat=str.indexOf(at)
			var lstr=str.length
			var ldot=str.indexOf(dot)
			if (str.indexOf(at)==-1)   return false	;
			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)return false	;
			if(str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)return false;
			if (str.indexOf(at,(lat+1))!=-1)  return false	;
			if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)return false	;
			if (str.indexOf(dot,(lat+2))==-1)return false;
			if (str.indexOf(" ")!=-1)return false;
			return true	;
		}
		else{
			var str = $e(email).value ;
			//loginNameCheck(str); 
			//return ;
			if(str == '')return true ;
			//$(email).className = 'rongInput' ;
			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")
			   flagForInvalidFormVal = false ;
			   $e(email).style.backgroundColor="red";
			   return false
			}

			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			   //alert("Invalid E-mail ID")
			   flagForInvalidFormVal = false ;
			   $e(email).style.backgroundColor="red";
			   return false
			}

			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			    //alert("Invalid E-mail ID")
				flagForInvalidFormVal = false ;
				$e(email).style.backgroundColor="red";
			    return false
			}

			 if (str.indexOf(at,(lat+1))!=-1){
			    //alert("Invalid E-mail ID")
				flagForInvalidFormVal = false ;
				$e(email).style.backgroundColor="red";
			    return false
			 }

			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			    //alert("Invalid E-mail ID")
			    flagForInvalidFormVal = false ;
				$e(email).style.backgroundColor="red";
				return false
			 }

			 if (str.indexOf(dot,(lat+2))==-1){
			    //alert("Invalid E-mail ID")
				flagForInvalidFormVal = false ;
				$e(email).style.backgroundColor="red";
			    return false
			 }
			
			 if (str.indexOf(" ")!=-1){
			    //alert("Invalid E-mail ID")
			    flagForInvalidFormVal = false ;
				$e(email).style.backgroundColor="red";
				return false
			 }
			 //$(email).className = '' ;
			 $e(email).style.backgroundColor="white";
	 		 return true
		}		
	}

	
	
