var dtCh= "/";
var minYear=1000;
var maxYear=9999;

 
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++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function isAlphabetic(sText)
	{
		
		   var ValidChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    	   var IsValid=true;
		   var Char;
		   for (i = 0; i < sText.length && IsValid == true; i++) 
			    { 
			        Char = sText.charAt(i); 
			        if (ValidChars.indexOf(Char) == -1) 
				        {
				            IsValid = false;
				        }
			    }
		    return IsValid;
	}

function isFullName(sText)
	{
		
		   var ValidChars = ".- abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    	   var IsValid=true;
		   var Char;
		   for (i = 0; i < sText.length && IsValid == true; i++) 
			    { 
			        Char = sText.charAt(i); 
			        if (ValidChars.indexOf(Char) == -1) 
				        {
				            IsValid = false;
				        }
			    }
		    return IsValid;
	}


function isAlphaNumeric(sText)
{
    var ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";
    var IsNumber=true;
    var Char;
	if(sText.length==0)	
	{
	  return false;
	}
	else
	{
    for (i = 0; i < sText.length && IsNumber == true; i++) 
    { 
        Char = sText.charAt(i); 
        if (ValidChars.indexOf(Char) == -1) 
        {
            IsNumber = "false1";
        }
    }  	
    return IsNumber;
   }	
}

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;
}
//valid phone number

function isValidPhone( sText )
	{
		
		   var ValidChars = '- 0123456789';
    	   var IsValid=true;
		   var Char;
		   for (i = 0; i < sText.length && IsValid == true; i++) 
			    { 
			        Char = sText.charAt(i); 
			        if (ValidChars.indexOf(Char) == -1) 
				        {
				            IsValid = false;
				        }
			    }
		    return IsValid;
	}


function isValidTime(timeStr) 
{
	// Checks if time is in HH:MM format.
	var timePat = /^(\d{2})(:(\d{2}))?$/;
	var matchArray = timeStr.match(timePat);
	if (matchArray == null)
	 {
		alert("Time is not in a valid format.");
		return false;
	 }
	var hour = matchArray[1];
	var minute = matchArray[3];
	if (hour < 0  || hour > 23) 
	{
		alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
		return false;  
	}
 
	if (minute < 0 || minute > 59) 
	{
		alert ("Minute must be between 0 and 59.");
		return false;
	}
	else
	return true;
}
 
/*
==================================================================
LTrim(string) : Returns a copy of a string without leading spaces.
==================================================================
*/
function LTrim(str)
/*
   PURPOSE: Remove leading blanks from our string.
   IN: str - the string we want to LTrim
*/
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {
      // We have a string with leading blank(s)...

      var j=0, i = s.length;

      // Iterate from the far left of string until we
      // don't have any more whitespace...
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;

      // Get the substring from the first non-whitespace
      // character to the end of the string...
      s = s.substring(j, i);
   }
   return s;
}

/*
==================================================================
RTrim(string) : Returns a copy of a string without trailing spaces.
==================================================================
*/
function RTrim(str)
/*
   PURPOSE: Remove trailing blanks from our string.
   IN: str - the string we want to RTrim

*/
{
   // We don't want to trip JUST spaces, but also tabs,
   // line feeds, etc.  Add anything else you want to
   // "trim" here in Whitespace
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      // We have a string with trailing blank(s)...

      var i = s.length - 1;       // Get length of string

      // Iterate from the far right of string until we
      // don't have any more whitespace...
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;


      // Get the substring from the front of the string to
      // where the last non-whitespace character is...
      s = s.substring(0, i+1);
   }

   return s;
}

/*
=============================================================
Trim(string) : Returns a copy of a string without leading or trailing spaces
=============================================================
*/
function Trim(str)
/*
   PURPOSE: Remove trailing and leading blanks from our string.
   IN: str - the string we want to Trim

   RETVAL: A Trimmed string!
*/
{
   return RTrim(LTrim(str));
}

/*
=============================================================
IsNumeric(string) : Returns a trun if the value passed is Numeric
=============================================================
*/
function isResult(str)
{
	var strr = str;
	var cnt = 0;
	var i;
	str1 = new String(strr);
	for(i=0;i<str1.length;i++)    // check if the string is valid result format or not.
	{
		if(str1.charAt(0) == "%")  
		{
			return false;
		}
		
		else if((parseInt(str1.charAt(i)) >= parseInt(0)) && (parseInt(str1.charAt(i)) <= parseInt(9)))   // numbres
		continue;
		
		else if(str1.charAt(i) == ".")
		continue;

		else if(str1.charAt(i) == " ")
		continue;
		
		else if(!((str1.charAt(i) >= "a") && (str1.charAt(i) <= "z") || (str1.charAt(i) >= "A") &&  (str1.charAt(i) <= "Z") || (str1.charAt(i) <= " ")))
		{ 
			return false;
		}
	}
	return true;
}

function isEmail (emailIn){
	var isEmailOk = false;
	var filter = /^[a-zA-Z0-9][a-zA-Z0-9._-]*\@[a-zA-Z0-9-]+(\.[a-zA-Z][a-zA-Z-]+)+$/
	if(emailIn.search(filter) != -1)
		{
			isEmailOk = true;
		/*	var arr = emailIn.split(".");
			if(arr[1]!="edu")
		    isEmailOk = false;*/
		}
	if(emailIn.indexOf("..") != -1)
		isEmailOk = false;
	if(emailIn.indexOf(".@") != -1)
		isEmailOk = false;
	return isEmailOk;
}

function validateEmail(param1)
{
	var atcnt = 0;
	var dtcnt = 0;
	var flag = true;
	var i;
	param = new String(param1);
	if(param.charAt(0) == "@") return false;
  if(param.charAt(0) == ".") return false;
	for (i=0;i<param.length;i++)
	{
		if((parseInt(param.charAt(i)) >= parseInt(0)) && (parseInt(param.charAt(i)) <= parseInt(9))) continue;
		if((param.charAt(i) == "@") || (param.charAt(i) == ".")) continue;
		if(!((param.charAt(i) >= "a") && (param.charAt(i) <= "z")))
		{ 
			return false;
		}
	}
	atcnt = param.indexOf("@",0);
	if(param.lastIndexOf("@") > atcnt) return false;
	dtcnt = param.indexOf(".");
	if((dtcnt - atcnt) < 3 ) return false;
	if((param.length - 1) - (param.lastIndexOf(".")) < 2) return false;
	return true;
}

function validName(param1)
{
	var flag = true;
	param = new String(param1);
	for(i=0;i < param.length;i++) 
	{
	  if(isNaN(param.charAt(i))==false) 
			if (param.charAt(i)!=" ")	return false;
	}
	return flag; 
} 

 
function daysInFebruary (year){
 // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
 for (var i = 1; i <= n; i++) {
  this[i] = 31
  if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
  if (i==2) {this[i] = 29}
   } 
   return this
}
 
function isDate(dtStr){
 var daysInMonth = DaysArray(12)
 var pos1=dtStr.indexOf(dtCh)
 var pos2=dtStr.indexOf(dtCh,pos1+1)
 var strDay=dtStr.substring(0,pos1)
 var strMonth=dtStr.substring(pos1+1,pos2)
 var strYear=dtStr.substring(pos2+1)
 strYr=strYear
 if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
 if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
 for (var i = 1; i <= 3; i++) {
  if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
 }
 month=parseInt(strMonth)
 day=parseInt(strDay)
 year=parseInt(strYr)
 if (pos1==-1 || pos2==-1){
 // alert("The date format should be : dd/mm/yyyy")
  return false
 }
 if (strMonth.length<1 || month<1 || month>12){
 // alert("Please enter a valid month")
  return false
 }
 if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
 // alert("Please enter a valid day")
  return false
 }
 if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
 // alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
  return false
 }
 if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
//  alert("Please enter a valid date")
  return false
 }
return true
}

function submitme(url)
{
	document.form1.action=url;
	document.form1.method="post";
	document.form1.submit();

}

function redirect(url)
{
	document.location.href = url;
	return true;
}

function validateForm_Alumni(url)
{

	if((document.form1.RegisterType.value == "alumni")){
		if ( RTrim(LTrim(document.form1.gradyear.value)) == "") {
			alert('Enter your Graduation Year');	
			document.form1.gradyear.focus();
			return false;
		}
		else if ( RTrim(LTrim(document.form1.gradyear.value)) != "") {
				if ( getyear(document.form1.bday.value) >= (document.form1.gradyear.value)) 
				{
					alert('Graduation year must be greater than Birth Date');	
					document.form1.gradyear.focus();
					return false;
				}
				else{
				document.form1.gradyear.value = RTrim(LTrim(document.form1.gradyear.value));
				}
			}
	}
		
	if (document.form1.course.value=="") {
	document.form1.course.focus();
	alert("Select your Department or Course");
	return false;
	}

	if (RTrim(LTrim(document.form1.address.value))=="") {
		alert("Enter Address");
		document.form1.address.focus();
		return false;
	}
	else if (RTrim(LTrim(document.form1.address.value)) !=""){
		document.form1.address.value = RTrim(LTrim(document.form1.address.value));
	}

	if (RTrim(LTrim(document.form1.city.value))== '' ) {
		alert("Enter City address");
		document.form1.city.focus();
		return false;
	}
	else if ( ! checkalphaname(RTrim(LTrim(document.form1.city.value))) ){
		alert("Invalid City address");
		document.form1.city.focus();
		return false;
		}
		else{
		document.form1.city.value = RTrim(LTrim(document.form1.city.value));
		}

	if (RTrim(LTrim(document.form1.state.value))== '' ) {
		alert("Enter state address");
		document.form1.state.focus();
		return false;
	}
	else if ( ! checkalphaname(RTrim(LTrim(document.form1.state.value))) ){
		alert("Invalid state address");
		document.form1.state.focus();
		return false;
		}
		else{
		document.form1.state.value = RTrim(LTrim(document.form1.state.value));
		}


	if ( RTrim(LTrim(document.form1.phone1.value)) != "") {
		if ( ! isInteger(RTrim(LTrim(document.form1.phone1.value))) )
    	{
			alert('Enter Valid ISD Code for Phone(Res.)');
			document.form1.phone1.focus();
			return false;
		}	
		else{
		document.form1.phone1.value = RTrim(LTrim(document.form1.phone1.value));
		}
	}
	if ( RTrim(LTrim(document.form1.phone2.value)) != "") {
		if ( ! isInteger(RTrim(LTrim(document.form1.phone2.value))) )
    	{
			alert('Enter Valid STD Code for Phone(Res.)');
			document.form1.phone2.focus();
			return false;
		}	
		else{
		document.form1.phone2.value = RTrim(LTrim(document.form1.phone2.value));
		}
	}


	if ( document.form1.email.value=='' )
	{
		alert('Enter valid email');
		document.form1.email.focus();
		return false;		
	}				
	else
	if ( !checkemail() )
	{
		alert('Enter valid email');
		document.form1.email.focus();
		return false;		
	}
//	emailCheck();
document.form1.action=url;
document.form1.method="post";
document.form1.submit();
return true;
}


function validateForm(url)
{

if(document.form1.RegisterType.value == "alumni"){
	if(document.form1.uname.value=="")
	{
		alert(" Please Select The User Name For Further Access.. ");
		document.form1.uname.focus();
		return false;
	}
}

	if (RTrim(LTrim(document.form1.fname.value))== '' ) {
		alert("Enter First Name");
		document.form1.fname.focus();
		return false;
	}
	else if ( ! checkalphaname(RTrim(LTrim(document.form1.fname.value))) ){
			alert("Invalid First Name");
			document.form1.fname.focus();
			return false;
		}
		else{
		document.form1.fname.value = RTrim(LTrim(document.form1.fname.value));
		}

	if (RTrim(LTrim(document.form1.lname.value))== '' ) {
		alert("Enter Last Name");
		document.form1.lname.focus();
		return false;
	}
	else if ( ! checkalphaname(RTrim(LTrim(document.form1.lname.value))) ){
			alert("Invalid Last Name");
			document.form1.lname.focus();
			return false;
		}
		else{
		document.form1.lname.value = RTrim(LTrim(document.form1.lname.value));
		}

	if ( document.form1.bday.value =='' )
	{
		alert('Enter valid Birth date');
		document.form1.bday.focus();
		return false;
	}				
	else
	if ( !checkbirthdate() )
	{
		alert('Enter valid Birth date');
		document.form1.bday.focus();
		return false;
	}
	var bday = document.form1.bday.value;			
	var pos1 = bday.indexOf(dtCh)
	var pos2 = bday.indexOf(dtCh,pos1+1)
	var strDay = bday.substring(0,pos1)
	var strMonth = bday.substring(pos1+1,pos2)
	var strYear = bday.substring(pos2+1)
	var newdate = strYear+"/"+strMonth+"/"+strDay;
						
	if (Date.parse(newdate) >= Date.parse(document.form1.CurrDate.value)) 
	{
		alert('The Birth date must be less than Current Date');	
		document.form1.bday.focus();
		return false;
	}

/*	if((document.form1.RegisterType.value != "alumni")){
		if ( RTrim(LTrim(document.form1.joinyear.value)) == "") {
			alert('Enter your Joining Year');	
			document.form1.joinyear.focus();
			return false;
		}
		else if ( RTrim(LTrim(document.form1.joinyear.value)) != "") {
				if ( getyear(document.form1.bday.value) >= (document.form1.joinyear.value)) 
				{
					alert('Joining date must be greater than Birth Date');	
					document.form1.joinyear.focus();
					return false;
				}
				else{
				document.form1.joinyear.value = RTrim(LTrim(document.form1.joinyear.value));
				}
			}
	}
*/	
	if (document.form1.gradyear.value=="") {
			alert("Enter your Graduation Year");	
			document.form1.gradyear.focus();
			return false;
		}
		else {
				if ( getyear(document.form1.joinyear.value) >= (document.form1.gradyear.value)) 
				{
					alert('Joining Graduation Year be greater than Birth Date');	
					document.form1.gradyear.focus();
					return false;
				}
				else{
				document.form1.gradyear.value = RTrim(LTrim(document.form1.gradyear.value));
				}
			}


/*

		if ( RTrim(LTrim(document.form1.gradyear.value)) == "") {
			alert('Enter your Graduation Year');	
			document.form1.gradyear.focus();
			return false;
		}
		else if ( RTrim(LTrim(document.form1.gradyear.value)) != "") {
				if ( getyear(document.form1.bday.value) >= (document.form1.gradyear.value)) 
				{
					alert('Graduation year must be greater than Birth Date');	
					document.form1.gradyear.focus();
					return false;
				}
				else{
				document.form1.gradyear.value = RTrim(LTrim(document.form1.gradyear.value));
				}
			}
	}
		*/
	if((document.form1.RegisterType.value == "Student")){
		if (RTrim(LTrim(document.form1.rollno.value))=="") {
			alert("Enter Roll No");
			document.form1.rollno.focus();
			return false;
		}	
		else if (RTrim(LTrim(document.form1.rollno.value))!="") {
			if ( ! isInteger(RTrim(LTrim(document.form1.rollno.value))) ){
			alert('Enter Valid Roll No');
			document.form1.rollno.focus();
			return false;
			}
		}

		if (document.form1.clas.value=="") {
		document.form1.clas.focus();
		alert("Select your Class ");
		return false;
		}
	}
	
	if (document.form1.course.value=="") {
	document.form1.course.focus();
	alert("Select your Department or Course");
	return false;
	}

	if (RTrim(LTrim(document.form1.address.value))=="") {
		alert("Enter Address");
		document.form1.address.focus();
		return false;
	}
	else if (RTrim(LTrim(document.form1.address.value)) !=""){
		document.form1.address.value = RTrim(LTrim(document.form1.address.value));
	}

	if (RTrim(LTrim(document.form1.city.value))== '' ) {
		alert("Enter City address");
		document.form1.city.focus();
		return false;
	}
	else if ( ! checkalphaname(RTrim(LTrim(document.form1.city.value))) ){
		alert("Invalid City address");
		document.form1.city.focus();
		return false;
		}
		else{
		document.form1.city.value = RTrim(LTrim(document.form1.city.value));
		}

	if (RTrim(LTrim(document.form1.state.value))== '' ) {
		alert("Enter state address");
		document.form1.state.focus();
		return false;
	}
	else if ( ! checkalphaname(RTrim(LTrim(document.form1.state.value))) ){
		alert("Invalid state address");
		document.form1.state.focus();
		return false;
		}
		else{
		document.form1.state.value = RTrim(LTrim(document.form1.state.value));
		}

	if (RTrim(LTrim(document.form1.zip.value))=="") {
		alert("Enter zip code");
		document.form1.zip.focus();
		return false;
	}	
	else if (RTrim(LTrim(document.form1.zip.value))!="") {
		if ( ! isInteger(RTrim(LTrim(document.form1.zip.value))) ){
		alert('Enter Valid Zipcode');
		document.form1.zip.focus();
		return false;
		}
	}
	
	if ( RTrim(LTrim(document.form1.phone1.value)) != "") {
		if ( ! isInteger(RTrim(LTrim(document.form1.phone1.value))) )
    	{
			alert('Enter Valid ISD Code for Phone(Res.)');
			document.form1.phone1.focus();
			return false;
		}	
		else{
		document.form1.phone1.value = RTrim(LTrim(document.form1.phone1.value));
		}
	}
	if ( RTrim(LTrim(document.form1.phone2.value)) != "") {
		if ( ! isInteger(RTrim(LTrim(document.form1.phone2.value))) )
    	{
			alert('Enter Valid STD Code for Phone(Res.)');
			document.form1.phone2.focus();
			return false;
		}	
		else{
		document.form1.phone2.value = RTrim(LTrim(document.form1.phone2.value));
		}
	}

	if ( RTrim(LTrim(document.form1.phone3.value)) != "") {
		if ( ! isInteger(RTrim(LTrim(document.form1.phone3.value))) )
    	{
			alert('Enter Valid Phone(Res.) No.');
			document.form1.phone3.focus();
			return false;
		}	
		else{
		document.form1.phone3.value = RTrim(LTrim(document.form1.phone3.value));
		}
	}

	if ( RTrim(LTrim(document.form1.mobile.value)) != "") {
		if ( ! isValidPhone(RTrim(LTrim(document.form1.mobile.value))) )
    	{
			alert('Enter Valid Phone(Res.) No.');
			document.form1.mobile.focus();
			return false;
		}	
		else{
		document.form1.mobile.value = RTrim(LTrim(document.form1.mobile.value));
		}
	}

	if ( document.form1.email.value=='' )
	{
		alert('Enter valid email');
		document.form1.email.focus();
		return false;		
	}				
	else
	if ( !isEmail(trim(document.form1.email.value)) )
	{
		alert('Enter valid email');
		document.form1.email.focus();
		return false;		
	}

	if (document.form1.question1.value=="") {
	document.form1.question1.focus();
	alert("Please answer Verification Question ");
	return false;
	}
	if (document.form1.question2.value=="") {
	document.form1.question2.focus();
	alert("Please answer Verification Question  ");
	return false;
	}

//	emailCheck();
	
document.form1.action=url;
document.form1.method="post";
document.form1.submit();
return true;
}

 function checkalphaname(aText)
 {
  	var obText = aText;
        return(isAlphabetic(obText))
 }

 function checkbirthdate()
 {
  	var obdate = document.form1.bday.value;
        return(isDate(obdate))
 }

 function checkemail()
 {
  	var obemail = document.form1.email.value;
        return(validateEmail(obemail))
 }

 function checkdate()
 {
  	var obdate = document.form1.date.value;
        return(isDate(obdate))
 }

 function checktime()
 {
  	var obtime = document.form1.time.value;
        return(isValidTime(obtime))
 }
 
 function checkfullname(aText)
 {
  	var obText = aText;
        return(isFullName(obText))
 }
 
 function trim(inputString) 
{
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   
   while (ch == " ") { 
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { 
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { 
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
   }
   return retValue;
}
function getyear(dtStr)
{
 var daysInMonth = DaysArray(12)
 var pos1=dtStr.indexOf(dtCh)
 var pos2=dtStr.indexOf(dtCh,pos1+1)
 var strDay=dtStr.substring(0,pos1)
 var strMonth=dtStr.substring(pos1+1,pos2)
 var strYear=dtStr.substring(pos2+1)
 strYr=strYear
 if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
 if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
 for (var i = 1; i <= 3; i++) {
  if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
 }
 month=parseInt(strMonth)
 day=parseInt(strDay)
 year=parseInt(strYr)

 return(year)
}


function checkall()
{
	for(i=0; i<document.form1.elements.length; i++)
	{
		var e = document.form1.elements[i];
			if(e.type=="checkbox")
			{
			var chkname="";
			chkname=document.form1.elements[i].name;
			if(chkname.substr(0,10)=='leftchkbox')
			{
			e.checked = document.form1.chkall.checked;
			}
		}
	}
}//checkall

function SubmitCheckList(flag,MemberStatus)
{
	dlrec = 0;
	
	if(document.form1.elements.length == 8)
	{
		for(i=0; i<document.form1.elements.length; i++){
			var e = document.form1.elements[i];
			if(e.type=="checkbox"){
				var chkname="";
				chkname=document.form1.elements[i].name;
				if(chkname == "chkall")
				{
					alert("Sorry! No Records Found");
					return false;
				}
			}
		}	
	}

	for(i=0; i<document.form1.elements.length; i++)
	{
		var e = document.form1.elements[i];

		if (e.checked==true)
		{
			dlrec = 1;
		}
	}
		
	if (dlrec==0)
	{
		alert("Select atleast one record");
		return false;
	}
	else if (dlrec == 1)
	{
	//when record is to be deleted
		if(flag=="del")
		{
				if (confirm(" Are you sure delete selected record ?"))
				{
				document.form1.action ="Member_Manager.php?mode="+2+"&process="+flag+"&RegisterType="+document.form1.RegisterType.value+"&Membstatus="+MemberStatus;
				document.form1.method="post";
				document.form1.submit();
				return true;
				}
		}
		//when record is updated
		else if(flag != "del")
		{
			document.form1.action ="Member_Manager.php?mode="+2+"&process="+flag+"&RegisterType="+document.form1.RegisterType.value+"&Membstatus="+MemberStatus;
			document.form1.method="post";
			document.form1.submit();
			return true;
		}
	}	// if any of the checkbox is checked
}//updrec

function readchoice(MemberStatus)
{
	var Type = document.form1.RegisterType.value;
	var searchvalue = document.form1.searchlike.value;
	var choicevalue = document.form1.choice.value;

	if (MemberStatus == "")
	{
		MemberStatus = "Inactive";
	}

	if( (searchvalue == "") && (choicevalue == ""))
	{
		alert("Plese Enter atleast one criteria to Search");
		document.form1.searchlike.focus();
		return false;
	}

	document.form1.action="Member_Manager.php?searchlike="+searchvalue+"&choice="+choicevalue+"&RegisterType="+Type+"&Membstatus="+MemberStatus;
	document.form1.method = "post";
	document.form1.submit();
	return true;
}

function openWindow(theURL,winName,features)
{
	window.open(theURL,winName,features);
}

	
//Function to Validate Fields & Email in the Form.
//written by K.Santosh		date:09/11/2004.


function validateText(type)
{
	// Only Alphabets 
	if (type=="A")
	{
		// If the keycode of the pressed key is not in the required range then return false.
		if ((event.keyCode < 65 || event.keyCode > 90) &&(event.keyCode < 97 || event.keyCode > 122))
		event.returnValue = false;
	}
	// Only Alphabets along with . and /
	if (type=="AL")
	{
		// If the keycode of the pressed key is not in the required range then return false.
		if ((event.keyCode < 65 || event.keyCode > 90)&&(event.keyCode < 97 || event.keyCode > 122)&&(event.keyCode!=46)&&(event.keyCode!=32)&&(event.keyCode!=47)) 
		event.returnValue = false;
	}
	// Only numbers
	else if(type=="N")
	{
		// If the keycode of the pressed key is not in the required range then return false.
		if (event.keyCode < 48 || event.keyCode > 57)
		event.returnValue = false;
	}
	// All the characters without " and '
	else if(type=="AN")
	{
		// If the keycode of the pressed key is not in the required range then return false.
		if (event.keyCode==34 || event.keyCode==39) 
		event.returnValue = false;
	}
		// Only Alphabets 
	if (type=="NAME")
	{
		// If the keycode of the pressed key is not in the required range then return false.
		if ((event.keyCode < 65 || event.keyCode > 90) &&(event.keyCode < 97 || event.keyCode > 122) && 
			(event.keyCode != 32 ) && (event.keyCode != 46 ))
		event.returnValue = false;
	}

	// It allows numbers and -
	else if(type=="PHNO")
	{			
		// If the keycode of the pressed key is not in the required range then return false.
		if ((event.keyCode < 48 || event.keyCode >57 )&& (event.keyCode != 45 ))
			event.returnValue = false;			
	}	

	// Only Alphabets ,Numbers, @ and .
	if (type=="EMAIL")
	{
		// If the keycode of the pressed key is not in the required range then return false.
		if ((event.keyCode < 65 || event.keyCode > 90) && (event.keyCode < 97 || event.keyCode > 122) && 
			(event.keyCode < 48 || event.keyCode > 57) && (event.keyCode != 64 ) && (event.keyCode != 46 ))
		event.returnValue = false;
	}

	// Only Alphabets ,Numbers, @ and .
	if (type=="URL")
	{
		// If the keycode of the pressed key is not in the required range then return false.
		if ((event.keyCode < 65 || event.keyCode > 90) && (event.keyCode < 97 || event.keyCode > 122) && 
			(event.keyCode < 48 || event.keyCode > 57) && (event.keyCode != 46 ) && (event.keyCode != 58 ) && (event.keyCode != 47 ))
		event.returnValue = false;
	}
				
	// It allows numbers and .
	else if(type=="MONEY")
	{			
		// If the keycode of the pressed key is not in the required range then return false.
		if ((event.keyCode < 48 || event.keyCode > 57) && (event.keyCode != 46 ) && (event.keyCode != 44))
			event.returnValue = false;			
	}				
	// It allows numbers and /
	else if(type=="DATE")
	{			
		// If the keycode of the pressed key is not in the required range then return false.
		if ((event.keyCode < 48 || event.keyCode > 57 ) && (event.keyCode != 47 ))
			event.returnValue = false;			
	}
	// It allows numbers and :
	else if(type=="TIME")
	{			
		// If the keycode of the pressed key is not in the required range then return false.
		if ((event.keyCode < 48 || event.keyCode > 57 ) && (event.keyCode != 58 ))
			event.returnValue = false;
	}

	// It allows albhbets and numbers				
	else if (type=="PAN")
	{
		// If the keycode of the pressed key is not in the required range then return false.
		if ((event.keyCode < 65 || event.keyCode > 90)&&(event.keyCode < 97 || event.keyCode > 122)&&(event.keyCode < 48 || event.keyCode > 57))
		event.returnValue = false;
	}
	// It allows all the characers without < and >
	else if (type=="PROFILE")
	{
		// If the keycode of the pressed key is not in the required range then return false.
		if ((event.keyCode == 62 )||( event.keyCode == 60)||(event.keyCode==34) ||( event.keyCode==39))
		event.returnValue = false;
	}	
// acepts only letters numbers or .
	else if (type=="RESULT")
	{
		if ((event.keyCode < 65 || event.keyCode > 90) && (event.keyCode < 97 || event.keyCode > 122) && 
		(event.keyCode < 48 || event.keyCode > 57) && (event.keyCode != 46 )&& (event.keyCode != 32 ))
//		&& (event.keyCode != 64 ) 
		event.returnValue = false;
	}	
// Aplphabets and numbers.... e.g. Exam numbers which includes aplhabets and numbers
	else if(type=="ALPHANM")   // or PAN
	{
		if ((event.keyCode < 65 || event.keyCode > 90) && (event.keyCode < 97 || event.keyCode > 122) && 
			(event.keyCode < 48 || event.keyCode > 57)) 
			event.returnValue = false;
	}
// Accepts only aplphabets , numbers and spaces.
	else if (type=="TITLE")
	{
		// If the keycode of the pressed key is not in the required range then return false.
		if ((event.keyCode < 65 || event.keyCode > 90)&&(event.keyCode < 97 || event.keyCode > 122)&&
		(event.keyCode < 48 || event.keyCode > 57)&& (event.keyCode != 32))
		event.returnValue = false;
	}
	
	
}

function login_validate()
{
	if (document.frmlogin.user.value=="") {
	document.frmlogin.user.focus();
	alert("Enter Login Name");
	return false;
	}
	if (document.frmlogin.pwrd.value=="") {
	document.frmlogin.pwrd.focus();
	alert("Enter Password");
	return false;
	}

//document.frmlogin.action = url;
document.frmlogin.method = "post";
document.frmlogin.submit();
return true;
}

		
		var str = '';
		var n = '';
	
		/*********************************************/
		
		function getIt(m){	
   			 n=m.name; 
			str=m;
			validateTcNew(str,m.name);
		} 

		/*********************************************/
		
		/* function for introducing ":" */

		function validateTcNew() {

			val=str.value;
			len=val.length;

			if(len==2&&val.charAt(1)!==':'){
			tmp1=val;
			var lastchar=tmp1.charAt(2);
			var tmp2=tmp1.substring(0,2);
			var val=tmp2+':'+lastchar;
			eval("document.form1."+n+".value=\"\";");
			eval("document.form1."+n+".value=val;"); 
			} 
			
			setTimeout(validateTcNew,100);
		}
