// JavaScript Document
//Function to validate group form fields

function checkDropdown(choice) 
{
    if (choice =="" || choice ==0) 
		{
       		//alert("You didn't choose any option from the drop-down list.");
			return false;
    	} 
			else
	{
		return true;
	}

}


// function to valiate input is Alphabet

	function isAlphabet(elem)
	{
	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
	return true;
	}
	else
	{
	return false;
	}
	}


//function to validate radio 
//Pass Radio button value
function validateOnDelete(radios)
{   // alert(radios);
	//var radios = document.forms.tutform.elements.color; (document.forms.formname.elements.radioname) 
	if(radios != undefined)  
	for(var i=0; i<radios.length; i++)
	{        
		if(radios[i].checked) 
		return true;    
	}    
//	alert('You must select radio button.');    
	return true;
}
//To Group.html's Sensmail button...
function validateOnSendMail(radios)
{    
	//var radios = document.forms.tutform.elements.color;    
	for(var i=0; i<radios.length; i++)
	{        
		if(radios[i].checked) 
		alert('You should not select Institute Name.');
	}    
	    
	return false;
}
//function to check email id....
function echeck(str) {
		//alert(str);
		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")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
/*function checkPassword(strng) 
{	alert("kehdj");
    var illegalChars = /[\W_]/; // allow only letters and numbers
    if (illegalChars.test(strng)) {
     alert("The password contains illegal characters.");
}*/

//function to validate phone field
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 6;
function ValidatePhone(phone)
{
	//alert(phone.value);
	if ((checkInternationalPhone(phone.value))==false)
	{
		
		return false;
	}
	return true
 }
function checkInternationalPhone(strPhone)
{	//alert('Enter');
	s=stripCharsInBag(strPhone,validWorldPhoneChars);
	return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
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;
}
//Alphanumeric Validation
function isAlphaNumeric(val)
{
	if (val.match(/^[a-zA-Z0-9]+$/))
	{
		//alert(':))');
		return true;
	}
	else
	{
		//alert(':((');
		return false;
	} 
}
//validation to accept number,alphabet and (-,.,_,,,(,),",') characters
function validateAll(alphane)
{
	var numaric = alphane;
	//alert(numaric);
	for(var j=0; j<numaric.length; j++)
	{
		 var alphaa = numaric.charAt(j);
		  //alert(alphaa);
		 var hh = alphaa.charCodeAt(0);
		 //alert(hh);
		 if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || (hh==95) || (hh==45) || (hh==46) || (hh==44) || (hh==40) || (hh==41) || (hh==34) || (hh==39) || (hh==32) || (hh==35))
		 {
		 	
		 }
		else	
		{
			// return false;
			//alert(':((');
			return false;
		}
	}
	//alert('done');
	return true;
 	
}
//function to validate fax field.
function ValidateNo(NumStr, String) 
{ 
    for(var Idx=0; Idx<NumStr.length; Idx++) 
    { 
        var Char = NumStr.charAt(Idx); 
        var Match = false; 
		
        for(var Idx1=0; Idx1<String.length; Idx1++) 
        { 
            if(Char == String.charAt (Idx1)) 
               
				Match = true; 
        } 

        if (!Match) 
            
			return false; 
    } 
    return true; 
} 

function ValidateDetail(fax) 
{ 
    var temp=fax.value;

    if(!ValidateNo(temp,"1234567890-()")) 
    {  //alert(':((');
        //alert("Please Enter Only Number"); 
        fax.focus(); 
        return false; 
    } 
		//alert(':))');
    return true; 
} 

//function to check maximum and minimum value

function ValidateMaxMin(value,min,max)
{	var result=value.value;
	if((result.length < min)||(result.length > max))
	{
		//alert('not btn max min value...');
		return false;
	}
	else
	{
		//alert('yahoo...');
		return true;
	}
}

//function to validtae start date and end date
function compareDate(sStartDate, sEndDate) 
{ 
	dtStartDate = new Date(sStartDate); 
	dtEndDate = new Date(sEndDate); 
	var bReturn = true; 
	if (dtStartDate > dtEndDate) 
	{ 
	 //	alert('bad');
		bReturn = false; 
	} 
	else 
	{ 
 		//alert('good');
		bReturn = true; 
	} 
	return bReturn; 
}

//function to check for null characters
function its_empty(string_value) {

  // Check for the empty string and null
  //alert(string_value);
  if (string_value == "" || string_value == null) {
  
    // If either, it's empty so return true
	//alert('bad');
    return false
  }
  else
  {
  // Otherwise, it's not empty so return false
  //alert('good');
  return true
  }
}
//function to check numeric
function IsNumeric(value)
{
   var strValidChars = '0123456789.';
   var strChar;
   var blnResult = true;
   var strString = value.value;
	
   if (strString.length == 0) 
		blnResult = false;
   for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
			{
				blnResult = false;
				//blnResult = false;
			}
	}
   return blnResult;
}
function IsPin(value)
{
   var strValidChars = '0123456789';
   var strChar;
   var blnResult = true;
   var strString = value.value;
	
   if (strString.length == 0) 
		blnResult = false;
   for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
			{
				blnResult = false;
				//blnResult = false;
			}
	}
   return blnResult;
}
//function t0 check character limit field
function IsNumericCharLimit(value)
{
   var strValidChars = '0123456789.';
   var strChar;
   var blnResult = true;
   var strString = value.value;
	
   if (strString.length > 2) 
		blnResult = false;
   for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
			{
				blnResult = false;
				//blnResult = false;
			}
	}
   return blnResult;
}
function validateURL(str) { 
    var success = true;

    //var pattern = /[http:\/\/|https:\/\/|ftp:\/\/](www.)((?:[a-zA-Z0-9_-]+\.?)+):?(\d*)/;
	//var pattern = /^(?:http:\/\/|https:\/\/|ftp:\/\/)?(w{3}\.{1})+([a-zA-Z0-9_-]+)+(\.{1})+([a-zA-Z]+)$/;
var pattern = /^(?:http:\/\/|https:\/\/|ftp:\/\/)?(w{3}\.{1})?([a-zA-Z0-9_-]+)(\.{1}[a-zA-Z]+)+$/;
	//var pattern = /((?:[a-zA-Z0-9_-]+\.?)+):?(\d*)/;
	//var myregexp  = 

     if (!pattern.test(str)) 
	 {

        // alert('bad');
		 success = false;
		 
	 }
	 else
	 {
	 //alert('good');
	 success = true;
	 }
     return success;
}

/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=9999;

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++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

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)
{
	if(dtStr.length>0)
	{
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=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 : mm/dd/yyyy")
		return false;
	}
	else if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false;
	}
	else if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false;
	}
	/*else if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false;
	}*/
	else if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false;
	}
return true
}
else
{
	alert("Please enter the date");
	return false;
}
}

function ValidateDateForm(dt)
{
	
	if (isDate(dt.value)==false)
	{
		dt.focus()
		return false
	}
    return true
 }
//document.groupsForm.txtMembStartDate.value
//Accepts numbers,and _ character.
function validateUserID(alphane)
{
	var numaric = alphane;
	//alert(numaric);
	for(var j=0; j<numaric.length; j++)
	{
		 var alphaa = numaric.charCodeAt(0);
		  //alert("ggg "+alphaa);
		 var hh = numaric.charCodeAt(j);
		 //alert(numaric.charAt(0).charCodeAt(0));
		if(alphaa >=97  && alphaa<=122 ||alphaa >=65  && alphaa<=90)
		{
			// alert("ldkl");
			 if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || (hh==95))
			 {
						
			 }
			else	
			{
				//alert(':((');
				return false;
			}
		}
		else
		{
			//alert("gyuku");
			return false;
		}
	}
	//alert('done');
	return true;
 	
}

function ValidateFiles(imgLen)
	{
		//var imgLen = document.forms[0].fileRoomTypeImg.value;		
		var ind = imgLen.lastIndexOf(".");		
		var ext = imgLen.substring(ind+1).toUpperCase();			
		/*if (imgLen=="")
		{
			alert("Room image is mandatory");
			document.forms[0].fileRoomTypeImg.focus();
			
		}else*/
		 if(ext=='JPG' || ext=='JPEG' || ext=='BMP' || ext=='GIF' ){		 	
		 return true;	 
		}else{
			//message+="* "+field+" Supports jpg, jpeg, bmp, gif file formats only\n";
			return false;
		}		
	}
	
	//function to validate first name
	function validateFirstName(value)
{
	//alert("dkjf");
	var blnResult = true;
	var strValue = value.value;
	//alert(value.value);
	if (!isEmpty(strValue))
	{
		//alert("Name ");
		blnResult = false;
	}
	
	else if (strValue.charAt(0) == " "|| (strValue.charCodeAt(0)>=48 && strValue.charCodeAt(0)<=57))
	{
		//alert("Name char");
		blnResult = false;
	}	
	else if (strValue != "")
	{
		for(i=0;i<strValue.length;i++)
		{
			var strChar = strValue.charAt(i)
			if (!((strChar >= "A" && strChar <= "Z" ) || (strChar >= "a" && strChar <= "z") || strChar==" "))
			{	
				//alert ("Only alphabets, space are allowed in " + Cont_Name + " (eg. quality).  Please re-enter correct data.")
				blnResult = false;
			}
		}
	}
	//alert(blnResult);
	return blnResult;
}


function validateYourName(value)
{
	//alert("dkjf");
	var blnResult = true;
	var strValue = value.value;
	//alert(value.value);
	if (!isEmpty(strValue))
	{
		//alert("Name ");
		blnResult = false;
	}
	
	else if (strValue.charAt(0) == " "|| (strValue.charCodeAt(0)>=48 && strValue.charCodeAt(0)<=57))
	{
		//alert("Name char");
		blnResult = false;
	}	
	else if (strValue != "")
	{
		for(i=0;i<strValue.length;i++)
		{
			var strChar = strValue.charAt(i)
			if (!((strChar >= "A" && strChar <= "Z" ) || (strChar >= "a" && strChar <= "z") || strChar==" " ||strChar=="-" ||strChar=="."
			  ||strChar=="," ||strChar=="_" ||strChar=="'" ||strChar=="(" ||strChar==")"||strChar=="/" ))
			{	
				//alert ("Only alphabets, space are allowed in " + Cont_Name + " (eg. quality).  Please re-enter correct data.")
				blnResult = false;
			}
		}
	}
	//alert(blnResult);
	return blnResult;
}


function isEmpty(strValue)
{
	var blnResult = true;
	if (strValue == null || strValue == "")
	{
		blnResult = false;
	}
	return blnResult;
}

function ValidateDocPdfFiles(imgLen)
	{
		//var imgLen = document.forms[0].fileRoomTypeImg.value;		
		var ind = imgLen.lastIndexOf(".");		
		var ext = imgLen.substring(ind+1).toUpperCase();			
		/*if (imgLen=="")
		{
			alert("Room image is mandatory");
			document.forms[0].fileRoomTypeImg.focus();
			
		}else*/
		 if(ext=='DOC' || ext=='PDF'){		 	
		 return true;	 
		}else{
			//message+="* "+field+" Supports jpg, jpeg, bmp, gif file formats only\n";
			return false;
		}		
	}
	
function chkBoxValidation()
{
	//My Code Starts

	var isChecked = false;
	var retArr = new Array();
	var selectedItems = new Array();
	var checkgroup=document.groupUserForm.chkUserIdArray;
	var lastElement = 0;
	if (checkgroup[0]) { 
		for (var i=0; i<checkgroup.length; i++) {
		if (checkgroup[i].checked) {
			retArr.length = lastElement;
			retArr[lastElement] = i;
			lastElement++;
		}
		}
	} 
	else { 
		  if (checkgroup.checked) { 
			 retArr.length = lastElement;
			 retArr[lastElement] = 0; 
		  }
	}
	if (retArr.length != 0) { 
	// alert('U have selected '+retArr.length+' Check Box!');
	 isChecked = true;
     return isChecked;
	}
	else{
		alert('Please select atleast one Check Box!');
		return isChecked;
	}
	
	//My Code Ends
	
	
	/* Ur Code Starts
	
	var isChecked = false;
	temp= document.groupUserForm.chkUserIdArray;
	alert(temp);
	if (typeof document.groupUserForm.chkUserIdArray.length != 'undefined') {
	alert('ghh');
	for (var i = 0; i < document.groupUserForm.chkUserIdArray.length; i++) 
	{	alert(document.groupUserForm.chkUserIdArray[i].checked);
	   if (document.groupUserForm.chkUserIdArray[i].checked) 
	   {
		  isChecked = true;
		  return isChecked;
	   }
   
	}
	}
		alert(isChecked);
		return isChecked;
	Ur Code Ends */

}

function validateAbbreviation(alphane)
{
	var numaric = alphane;
	//alert(numaric);
	for(var j=0; j<numaric.length; j++)
	{
		 var alphaa = numaric.charCodeAt(0);
		  //alert("ggg "+alphaa);
		 var hh = numaric.charCodeAt(j);
		 //alert(numaric.charAt(0).charCodeAt(0));
		if(alphaa >=97  && alphaa<=122 ||alphaa >=65  && alphaa<=90)
		{
			// alert("ldkl");
			 if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || (hh==32) || (hh==45))
			 {
						
			 }
			else	
			{
				//alert(':((');
				return false;
			}
		}
		else
		{
			//alert("gyuku");
			return false;
		}
	}
	//alert('done');
	return true;
 	
}
function validatePreAbbreviation(alphane)
{
	var numaric = alphane;
	//alert(numaric);
	for(var j=0; j<numaric.length; j++)
	{
		 var alphaa = numaric.charCodeAt(0);
		  //alert("ggg "+alphaa);
		 var hh = numaric.charCodeAt(j);
		 //alert(numaric.charAt(0).charCodeAt(0));
		if(alphaa >=97  && alphaa<=122 ||alphaa >=65  && alphaa<=90)
		{
			// alert("ldkl");
			 if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || (hh==32) || (hh==45) ||(hh==46))
			 {
						
			 }
			else	
			{
				//alert(':((');
				return false;
			}
		}
		else
		{
			//alert("gyuku");
			return false;
		}
	}
	//alert('done');
	return true;
 	
}
function validateInstitution(alphane)
{
	var numaric = alphane;
	//alert(numaric);
	for(var j=0; j<numaric.length; j++)
	{
		 var alphaa = numaric.charAt(j);
		  //alert(alphaa);
		 var hh = alphaa.charCodeAt(0);
		 //alert(hh);
		 if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || (hh==32))
		 {
		 	
		 }
		else	
		{
			// return false;
			//alert(':((');
			return false;
		}
	}
	//alert('done');
	return true;
 	
}

//accepts alphanumeric,-,.,-
function validateOther(alphane)
{
	var numaric = alphane;
	//alert(numaric);
	for(var j=0; j<numaric.length; j++)
	{
		 var alphaa = numaric.charAt(j);
		  //alert(alphaa);
		 var hh = alphaa.charCodeAt(0);
		 //alert(hh);
		 if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123)  || (hh==45)  || (hh==32))
		 {
		 	
		 }
		else	
		{
			// return false;
			//alert(':((');
			return false;
		}
	}
	//alert('done');
	return true;
 	
}

//function to validate participants field.It accepts numbers,chracters,and spaces
//this can be used for location field
function validateParticipants(alphane)
{
	var numaric = alphane;
	//alert(numaric);
	for(var j=0; j<numaric.length; j++)
	{
		 var alphaa = numaric.charAt(j);
		  //alert(alphaa);
		 var hh = alphaa.charCodeAt(0);
		 //alert(hh);
		 if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123)  || (hh==32))
		 {
		 	
		 }
		else	
		{
			// return false;
			//alert(':((');
			return false;
		}
	}
	//alert('done');
	return true;
 	
}
function validateMemNenSince(alphane)
{
	var numaric = alphane;
	//alert(numaric);
	for(var j=0; j<numaric.length; j++)
	{
		 var alphaa = numaric.charAt(j);
		  //alert(alphaa);
		 var hh = alphaa.charCodeAt(0);
		 //alert(hh);
		 if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123)  || (hh==32) || (hh==45))
		 {
		 	
		 }
		else	
		{
			// return false;
			//alert(':((');
			return false;
		}
	}
	//alert('done');
	return true;
 	
}

//Checks for Valid Characters in Email-Id field
    function allValidChars(email) {
       var parsed = true;
       var cnt=0;
       var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@._-";
       for (var i=0; i < email.length; i++) {
       c = email.charCodeAt(i);
       if(c==64){
       cnt=cnt+1;
       }
       var letter = email.charAt(i).toLowerCase();
       if (validchars.indexOf(letter) != -1)
       	continue;
       	parsed = false;
       	break;
       }
       if(cnt>1){
       	parsed = false;
       }
       return parsed;
    }

//Checks for Valid Email-Id	
	function isValidEmail(email, required) {
	//alert("dflk");
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
	if(!checkforlimit(email)){
		//alert();
		return false;
	}
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    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) {  // . must not be the last character
       	return false;
    }
    return true;
    }

 //Checks for Email-Id limitations
    function checkforlimit(email)
	{
	   d = email.charCodeAt(0);
	   if((d>=97 && d<=122) || (d>=65 && d<=90) ||(d>=48 && d<=57)) 
	   {
		   var count=0;
		   var s=email.indexOf("@")+1;
		   var partAfterAt=email.substring(s,email.length);
		   var start=partAfterAt.lastIndexOf(".")+1;
		   if(partAfterAt.charAt(start+1)=="")
			return false;
       	}
		else
		{
			return false;
		}
		return true;
	}


function validateEmail(email){
if (! isValidEmail(email)) {
        		alert("Please enter a valid email address");
		return false;
    		}
			return true;

}
//function to validate space,-,_ characters.
function validateLoginCharacters(alphane)
{
	var numaric = alphane;
	//alert(numaric);
	for(var j=0; j<numaric.length; j++)
	{
		 var alphaa = numaric.charAt(j);
		  //alert(alphaa);
		 var hh = alphaa.charCodeAt(0);
		 //alert(hh);
		 if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123)  || (hh==32) || (hh==45) || (hh==95))
		 {
		 	
		 }
		else	
		{
			// return false;
			//alert(':((');
			return false;
		}
	}
	//alert('done');
	return true;
 	
}

//function to validate fax numbers2

function validateFaxNumbers(fax)
{
	var success = true;

    
	var pattern=/^(?:\d\d\d|\d\d\d\d|\(\d\d\d\)|\(\d\d\d\d\)|\+\d\d|\d\d)(\s|-)?(\d+)(\s|-)?(\d+)(\s|-)?(\d+)$/;

	

     if (!pattern.test(fax)) 
	 {

        // alert('bad');
		 success = false;
		 
	 }
	 else
	 {
	 //alert('good');
	 success = true;
	 }
     return success;
}

//function to check whether studentid is alphabet

function validateCharacter(val)
{
	if (val.match(/^[a-zA-Z]+$/))
	{
		//alert(':))');
		return true;
	}
	else
	{
		//alert(':((');
		return false;
	} 
}

function IsMobile(value)
{
   var strValidChars = '0123456789';
   var strChar;
   var blnResult = true;
   var strString = value.value;
	
   if (strString.length == 0)
   {
		blnResult = false;
   }
	if(strString.charCodeAt(0)==43)
	{
	   for (i = 1; i < strString.length && blnResult == true; i++)
		{
			strChar = strString.charAt(i);
			if (strValidChars.indexOf(strChar) == -1)
				{
					blnResult = false;
					//blnResult = false;
				}
		}
	}
	else
	{	
		for (j = 0; j < strString.length && blnResult == true; j++)
		{
			strChar = strString.charAt(j);
			if (strValidChars.indexOf(strChar) == -1)
				{
					blnResult = false;
					//blnResult = false;
				}
		}
	}
   return blnResult;
}
function validateFoundingYear(alphane)
{
	var numaric = alphane;
	//alert(numaric);
	for(var j=0; j<numaric.length; j++)
	{
		 var alphaa = numaric.charAt(j);
		  //alert(alphaa);
		 var hh = alphaa.charCodeAt(0);
		 //alert(hh);
		 if((hh > 47 && hh<59) || (hh==45))
		 {
		 	
		 }
		else	
		{
			// return false;
			//alert(':((');
			return false;
		}
	}
	//alert('done');
	return true;
 	
}


function isCompanyTurnOver(alphane)
{	
	//alert();
	var numaric = alphane;
	//alert(numaric);
	for(var j=0; j<numaric.length; j++)
	{
		 var alphaa = numaric.charAt(j);
		  //alert(alphaa);
		 var hh = alphaa.charCodeAt(0);
		 //alert(hh);
		 if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || (hh==95) || (hh==45) || (hh==46) || (hh==44) || (hh==40) || (hh==41) || (hh==34) || (hh==39) || (hh==36))
		 {
		 	
		 }
		else	
		{
			// return false;
			//alert(':((');
			return false;
		}
	}
	//alert('done');
	return true;
}


//radio btn

function trimAll(sString) 
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
		//alert(sString + "Left")
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
		//alert(sString + "right")
	}
	return sString
}


//email validation
//accepts 3 dots,underscore,hypen,numbers,characters before @ and 4 dots,char and 4-_ and 4 hypen after @
function fnRegvalidateEmail(email,required) {
if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
	if(!checkforlimit(email)){
		return false;
	}
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    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) {  // . must not be the last character
       	return false;
    }
    return true;
}

//function allows -,.(,)'

function validateAllCharacters(alphane)
{
	var numaric = alphane;
	//alert(numaric);
	for(var j=0; j<numaric.length; j++)
	{
		 var alphaa = numaric.charCodeAt(0);
		  //alert("ggg "+alphaa);
		 var hh = numaric.charCodeAt(j);
		 //alert(numaric.charAt(0).charCodeAt(0));
		if(alphaa >=97  && alphaa<=122 ||alphaa >=65  && alphaa<=90)
		{
			// alert("ldkl");
			 if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || (hh==32) || (hh==46) || (hh==44) ||(hh==40) ||   (hh==41) || (hh==45) ||  (hh==39))
			 {
						
			 }
			else	
			{
				//alert(':((');
				return false;
			}
		}
		else
		{
			//alert("gyuku");
			return false;
		}
	}
	//alert('done');
	return true;
 	
}
 
 
 function validateAllCharactersExptNum(alphane)
{
	var numaric = alphane;
	//alert(numaric);
	for(var j=0; j<numaric.length; j++)
	{
		 var alphaa = numaric.charCodeAt(0);
		  //alert("ggg "+alphaa);
		 var hh = numaric.charCodeAt(j);
		 //alert(numaric.charAt(0).charCodeAt(0));
		if(alphaa >=97  && alphaa<=122 ||alphaa >=65  && alphaa<=90)
		{
			// alert("ldkl");
			 if( (hh > 64 && hh<91) || (hh > 96 && hh<123) || (hh==32) || (hh==46) || (hh==44) ||(hh==40) ||   (hh==41) || (hh==45) ||  (hh==39))
			 {
						
			 }
			else	
			{
				//alert(':((');
				return false;
			}
		}
		else
		{
			//alert("gyuku");
			return false;
		}
	}
	//alert('done');
	return true;
 	
}