
/*
===================================================
Filename : Lib.asp
Author   : Pooja Mehra
Purpose  : General Client side validations. 
===================================================
*/

var whitespace = " \t\n\r";
function gIsNumeric (pString, pCtrl, pCtrlName)

{   var i;

 // Search through string's characters one by one
 // until we find a non-numeric character.
 // When we do, return false; if we don't, return true.

 for (i = 0; i < pString.length; i++)
 {   
     // Check that current character is number.
     var c = pString.charAt(i);
 	if (!( (c >= "0") && (c <= "9") ) )
 	{	var lString;
 	    lString = pCtrlName + " is not a valid number.";
 		window.alert(lString);
 		pCtrl.focus();
 		return true;
 	}
 }

 // All characters are numbers.
 return false;
}
	
function gChkPass (pString, pCtrl, pCtrlName)
{   
var i;
 // Search through string's characters one by one
 // until we find a non-numeric character.
 // When we do, return false; if we don't, return true.

 for (i = 0; i < pString.length; i++)
 {   
     // Check that current character is number.
     var c = pString.charAt(i);
 	if (c == "!" || c == "@" || c == "#"  || c == "$"  || c == "%"  || c == "^"  || c == "&"  || c == "*"  || c == "'" || c == '"' || c == "~") 
 	{	var lString;
 	    lString = pCtrlName + " cannot have special character " + c + ".";
 		window.alert(lString);
 		pCtrl.focus();
 		return true;
 	}
 }

 // All characters are numbers.
 return false;
}


function gcharInString (c, s)
{   for (i = 0; i < s.length; i++)
 {   if (s.charAt(i) == c) return true;
 }
 return false;
}
		
function gLTrim (pString)
{
 var i = 0;
 while ((i < pString.length) && gcharInString(pString.charAt(i), whitespace))
    i++;
 return pString.substring (i, pString.length);
}


function gen_Password()
{

//if  ((document.resrc_add_frm.resrc_name.value != "") && (document.resrc_add_frm.resrc_id.value != ""))
//	{
			//alert("called")
			var resName,resourceID,password
			resName=document.resrc_add_frm.resrc_name.value;
			resourceID=document.resrc_add_frm.resrc_id.value;
			//if ( resName != "" &&  resourceID != "")
			//{
			password=resName.substr(0,4)+resourceID.substr(0,2);
			document.resrc_add_frm.resrc_password.value=password;
			//}
}


function gCheckEmail2(pCheckString, pCtrl, pCtrlName)
{
	 var at = false;
	var dot = false;
	var atcnt=0;
	var ErrFlag=false;

	for (var i = 0; i < pCheckString.length; i++)
	{
		 ch = pCheckString.substring(i, i + 1)
		if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z") || (ch == "@") || (ch == ".") || (ch == "_") || (ch == "-") || (ch >= "0" && ch <= "9"))
         {
             if (ch == "@") 
             {
                 at=true;
				 atcnt++;
             }
             if (ch == ".") 
             {
                 dot=true;
             }
 	    }
		else 
		{
			ErrFlag=true
			break;
		}
   }
 if ((at == true) && (dot == true)&&(atcnt==1) && (ErrFlag==false)) 
 {
     return false;
 }
 else 
 {
 lString = pCtrlName + " is not in correct format. Please input it in the following format :- abc@xyz.com";
   window.alert (lString);
   pCtrl.focus();
   return true;
   }
}

function gCheckEmail(pCheckString, pCtrl, pCtrlName)
{
	 var at = false;
	var dot = false;
	var atcnt=0;
	var ErrFlag=false;

	for (var i = 0; i < pCheckString.length; i++)
	{
		 ch = pCheckString.substring(i, i + 1)
		if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z") || (ch == "@") || (ch == ".") || (ch == "_") || (ch == "-") || (ch >= "0" && ch <= "9"))
         {
             if (ch == "@") 
             {
                 at=true;
				 atcnt++;
             }
             if (ch == ".") 
             {
                 dot=true;
             }
 	    }
		else 
		{
			ErrFlag=true
			break;
		}
   }
 if ((at == true) && (dot == true)&&(atcnt==1) && (ErrFlag==false)) 
 {
     return false;
 }
 else 
 {
 lString = pCtrlName + " is not in correct format. Please input it in the following format :- abc@xyz.com";
   window.alert (lString);
      pCtrl.focus();
   return true;
   
 }
}

		



function gSpaceCheck (s, pCtrl, pText)
 {   
 	var i;
 	var lString;
	for (i = 0; i < s.length; i++)
     {   
         // Check that current character isn't whitespace.
         var c = s.charAt(i);
	     if (whitespace.indexOf(c) != -1) 
         {
 			lString = pText + " cannot have emmbedded spaces.";
 			window.alert(lString);
 			pCtrl.focus();
 			return true;
         }
     }
     // All characters are whitespace.
     return false;
 }


// checks whether the first space is blank or not
function gFirstSpace (s, pCtrl, pText)
 {   
 	var i;
 	var lString;
	     // Check that current character isn't whitespace.
         var c = s.charAt(0);
	     if (whitespace.indexOf(c) != -1) 
         {
 			lString = pText + " cannot have first character as blank space.";
 			window.alert(lString);
 			pCtrl.focus();
 			return true;
		 }
     // All characters are whitespace.
     return false;
 }







			  
function gEmptyCheck(pCtrl, pCtrlName)
 {
     if (gLTrim(pCtrl.value) == "") 
     {
        var lString = pCtrlName + " cannot be empty.";
        window.alert(lString);

        pCtrl.focus();
        return true;
     }
     else
     {
        return false;
     }
 }

// this functionis used to check hether the date enteres through a combo display
// is a valid date or not
function isdate(pDateControl,pMonthControl,pYearControl,pDateName)
{	
	var pvMessage;
	var pvIndex = pDateControl.selectedIndex
	var pvDate=pDateControl[pvIndex].text;
	pvIndex = pMonthControl.selectedIndex
	var pvMonth=pMonthControl[pvIndex].text;
	var pvsYear = pYearControl.value;
	var pvYear = parseInt(pYearControl.value);
	
	if (!isNumeric(pYearControl.value,pYearControl,pDateName))
	    return false;
	if(pvsYear.length != 4)
	{
		alert("Year Should be of Four Digits.");
		return false;
	}
	if (isempty(pDateControl,"Date","C"))
	   return false;
	if (isempty(pMonthControl,"Month","C"))
	   return false;
	if (isempty(pYearControl,"Year","T"))
	   return false;
	if(pvDate<1) //Date should not be 0
	{   
		pvMessage=pDateName + 	" Date is not valid.";
		window.alert(pvMessage);
		pDateControl.focus();
		return false;
	}
	if(pvMonth<1 || pvMonth>12) //Month Validation
	{
		pvMessage=pDateName + 	" Month is not valid.";
		window.alert(pvMessage);
		pMonthControl.focus();
		return false;
	}		  
	if(pvMonth==2)//Date validation for Leap Year
	{
		if ((pvYear%4)==0)
		{
			if (pvDate>29)
			{
				pvMessage=pDateName + 	" Date is not valid.";
				window.alert(pvMessage);
				pDateControl.focus();
				return false;
			}
		}
		else
		{
			if (pvDate>28)
			{
				pvMessage=pDateName + 	" Date is not valid.";
				window.alert(pvMessage);
				pDateControl.focus();
				return false;
			}
		}
	}
	
	//Date Validation for Leap Year ends here		  
	if(pvMonth == 1 || pvMonth == 3 ||pvMonth ==5 || pvMonth == 7 || pvMonth == 8 || pvMonth == 10 || pvMonth == 12)
	{
			if (pvDate>31)
			{
				pvMessage=pDateName + 	" Date is not valid.";
				window.alert(pvMessage);
				pDateControl.focus();
				return false;
			}
	}
	else
	{
			if (pvDate>30)
			{
				pvMessage=pDateName + " Date is not valid.";
				window.alert(pvMessage);
				pDateControl.focus();
				return false;
			}

	}
	if (pvYear<0)
	{
		pvMessage=pDateName + 	" Year is not valid.";
		window.alert(pvMessage);
		pYearControl.focus();
		return false;
	}
	return true;
}

// this is a datecompare function
function gDateComp(pDateCtrl,pDateCtr2)  //returns true if date1 is greater than date2
{
	Date1 = pDateCtrl.value;
	Date2 = pDateCtr2.value;

	SplitDate1 = Date1.split("/");
	SplitDate2 = Date2.split("/");

	for(i=2;i>=0;i--)
	{
		if(parseInt(SplitDate2[i], 10) < parseInt(SplitDate1[i],10)) 
		{
			window.alert( "End date can not be less than start date");
			pDateCtr2.focus();
			return true;
		}
		if(parseInt(SplitDate2[i], 10) == parseInt(SplitDate1[i], 10))
				continue;
		else
				return false;
	}
	return false;
}


 //returns true if date1 is greater than date2
function gDateCompSpl(pDateCtrl,pDateCtr2) 
{
var Date1;
var Date2;
	Date1 = pDateCtrl;
	Date2 = pDateCtr2;

	SplitDate1 = Date1.split("/");
	SplitDate2 = Date2.split("/");

	for(i=2;i>=0;i--)
	{
		if(parseInt(SplitDate2[i], 10) < parseInt(SplitDate1[i],10)) 
		{			
			return true;
		}
		if(parseInt(SplitDate2[i],10) == parseInt(SplitDate1[i],10))
				continue;
		else
				return false;
	}
	return false;
}

function gDateComp1(pDateCtrl,pDateCtr2, pDate1,pDate2)  //returns true if date1 is greater than date2
{
	Date1 = pDateCtrl.value;
	Date2 = pDateCtr2.value;

	SplitDate1 = Date1.split("/");
	SplitDate2 = Date2.split("/");

	for(i=2;i>=0;i--)
	{
		if(parseInt(SplitDate2[i], 10) < parseInt(SplitDate1[i],10)) 
		{
			window.alert(pDate1+" can not be greater  than " +pDate2);
			   
			return true;
		}
		if(parseInt(SplitDate2[i], 10) == parseInt(SplitDate1[i], 10))
				continue;
		else
				return false;
	}
	return false;
}
//----------------------------------------------------------------
function gDateCompDob(pDateCtrl,pDateCtr2, pDate1,pDate2)  //returns true if date1 is greater than date2
{
	Date1 = pDateCtrl.value;
	Date2 = pDateCtr2.value;
	//alert(Date1)
	
	date1=Date.parse(Date1)
	date2=Date.parse(Date2)

	if(parseInt(date1)==parseInt(date2))
	{
		alert(pDate1 + ' & '+pDate2+' Can not be same');
		return true;
	}
		
	SplitDate1 = Date1.split("/");
	SplitDate2 = Date2.split("/");
	
	for(i=2;i>=0;i--)
	{
		if(parseInt(SplitDate2[i], 10) < parseInt(SplitDate1[i],10)) 
		{
			window.alert(pDate1+" can not be greater  than " +pDate2);
			return true;
		}
		if(parseInt(SplitDate2[i], 10) == parseInt(SplitDate1[i], 10))
		{
		//	alert('Date of Birth & Date of Anniversary Can not be same')
		//	return false;
		continue;
		}		
		else
				return false;
	}
	return false;
}



//------------------------------------------------------------------


function gIsHour (pCtrl, pCtrlName)

{   var i, lString, lDisp, lDeci_Str;
    lString = pCtrl.value;

 // Search through string's characters one by one
 // until we find a non-numeric character.
 // When we do, return false; if we don't, return true.

    for (i = 0; i < lString.length; i++)
      {   
        // Check that current character is number.
        var c = lString.charAt(i);
 	    if (!((c >= "0") && (c <= "9") ||(c == ".")))
 	      {	
 	        lDisp = pCtrlName + " is not a valid hour ";
 		    window.alert(lDisp);
 		    pCtrl.focus();
 		    return true;
 	      }
      }

    lDeci_Str =  lString.split(".");

  if(lDeci_Str.length >2 || lDeci_Str[0].length >2 ||( lDeci_Str.length == 2 && lDeci_Str[1].length >2))
        {
	      lDisp = pCtrlName + " is not a valid hour";
		  window.alert(lDisp);
 		  pCtrl.focus();
 		  return true;
        }

  if( (parseInt(lDeci_Str[0],10) > 24) || ( (lDeci_Str.length == 2)  && (parseInt(lDeci_Str[0],10) == 24) && (parseInt(lDeci_Str[1],10) > 0)))
       {
		  lDisp = pCtrlName + " cannot be greater than 24 ";
		  window.alert(lDisp);
 		  pCtrl.focus();
 		  return true;
       }
 // All characters are numbers.
 return false;
}


function gIsFloat (pCtrl, pCtrlName)

{   var i, lString, lDisp, lDeci_Str;
    lString = pCtrl.value;

 // Search through string's characters one by one
 // until we find a non-numeric character.
 // When we do, return false; if we don't, return true.

    for (i = 0; i < lString.length; i++)
      {   
        // Check that current character is number.
        var c = lString.charAt(i);
 	    if (!((c >= "0") && (c <= "9") ||(c == ".")))
 	      {	
 	        lDisp = pCtrlName + " should be numeric only.";
 		    window.alert(lDisp);
 		    pCtrl.focus();
 		    return true;
 	      }
      }

    lDeci_Str =  lString.split(".");

  if(lDeci_Str.length >2 || lDeci_Str[0].length >14 ||( lDeci_Str.length == 2 && lDeci_Str[1].length >2))
        {
	      lDisp = pCtrlName + " should be numeric only";
		  window.alert(lDisp);
 		  pCtrl.focus();
 		  return true;
        }
 // All characters are numbers.
 return false;
}

// this funcion is used to check the length of a string passed through a control.
// it returns false if the length of the string exceeds the max length passed
function gCheck_Str_Len(pCtrl,pMax_Len,pCtrlName)
{  
   var lString, lCheckString;
     lCheckString = pCtrl.value;
	  if(lCheckString.length > pMax_Len)
					{
						lString = pCtrlName + " length should not exceed " + pMax_Len + " characters.";
						window.alert (lString);
						pCtrl.focus()
						return false;
					}
	return true;
}	



function isNumber(s, bag)
	{
		var i,flag;
		flag=0;
		for(i=0;i<s.length;i++)
		{
			var c = s.charAt(i);
			if(bag.indexOf(c)==-1)
			{
				continue;
			}
			else
			{
				break;
			}
		}
	}


	function rePost(myOption)
{
	document.frmHolidays.hddMode.value= myOption ; 
	document.frmHolidays.method="POST";
	document.frmHolidays.action="holidaymaster.asp";
	document.frmHolidays.submit();
}

/*function displayPage(type,page)
{
		if(type=='P')
		{
			page=page-1;
		}
		else
		{
			page=page+1;

		}
		document.frmConsolidatedDsr.hddPost.value="Y";
		document.frmConsolidatedDsr.mviCurrentPage.value=page;
		document.frmConsolidatedDsr.method="post";
		document.frmConsolidatedDsr.action="rep_DSR.asp" ;
		document.frmConsolidatedDsr.submit();
}*/


function checkFirstChar(pString, pCtrlName)
{ 
    var c = pString.charAt(0);
    if(c == "`" || c == "~"  || c == "!"  || c == "@"  || c == "#"  || c == "$"  || c == "%"  || c == "^" || c == "&"|| c=="*" || c=="(" || c==")" || c=="_" || c=="-" || c=="+" || c=="=" || c=="|" || c=="\\" || c=='{' || c=='[' || c=="}" || c=="]" || c==";" || c==":"|| c=='"'|| c=="'"|| c=="<" || c==","|| c==">"|| c=="."|| c=="?"|| c=="/"|| c=="_"|| c=="_")
 	{	
	var lString;
 	 lString = pCtrlName + " cannot have the first character as a special character " + c ;
 	window.alert(lString);
 	   
 	return true;
 	}
 }

function checkHash(pString, pCtrlName)
{ 
    var c = pString.charAt(0);
    if(c == "`" || c == "~"  || c == "!"  || c == "@"  || c == "$"  || c == "%"  || c == "^" || c == "&"|| c=="*" || c=="(" || c==")" || c=="_" || c=="-" || c=="+" || c=="=" || c=="|" || c=="\\" || c=='{' || c=='[' || c=="}" || c=="]" || c==";" || c==":"|| c=='"'|| c=="'"|| c=="<" || c==","|| c==">"|| c=="."|| c=="?"|| c=="/"|| c=="_"|| c=="_")
 	{	
	var lString;
 	 lString = pCtrlName + " cannot have the first character as a special character " + c ;
 	window.alert(lString);
 	   
 	return true;
 	}
 }


function gChkPassAll(pString, pCtrl, pCtrlName)
{   var i;
 // Search through string's characters one by one
 // until we find a non-numeric character.
 // When we do, return false; if we don't, return true.

 for (i = 0; i < pString.length; i++)
 {   
     // Check that current character is number.
     var c = pString.charAt(i);
 	if(c == "`" || c == "~"  || c == "!"  || c == "@"  || c == "#"  || c == "$"  || c == "%"  || c == "^" || c == "&"|| c=="*" || c=="(" || c==")" || c=="_" || c=="-" || c=="+" || c=="=" || c=="|" || c== "\\" || c=="{" || c=="[" || c=="}" || c=="]" || c==";" || c==":"|| c=='"'|| c=="'"|| c=="<" || c==","|| c==">"|| c=="."|| c=="?"|| c=="/"|| c=="_"|| c=="_")
	//if (c == "@" || c == "#"  || c == "$"  || c == "%"  || c == "^"  || c == "&"  || c == "*"  || c == "'" || c == '"'|| c=="!" || c=="-" || c=="_" || c=="+" ) 

	{	var lString;
 	    lString = pCtrlName + " cannot have a special character " + c ;
 		window.alert(lString);
 		pCtrl.focus();
 		return true;
 	}
 }
 // All characters are numbers.
 return false;
}

function gChkPass_event(pString, pCtrl, pCtrlName)
{   var i;
 // Search through string's characters one by one
 // until we find a non-numeric character.
 // When we do, return false; if we don't, return true.

 for (i = 0; i < pString.length; i++)
 {   
     // Check that current character is number.
     var c = pString.charAt(i);
 	if(c == "`" || c == "~"  || c == "!"  || c == "@"  || c == "#"  || c == "$"  || c == "%"  || c == "^" || c == "&"|| c=="*" || c=="(" || c==")" || c=="_" || c=="-" || c=="+" || c=="=" || c=="|" || c== "\\" || c=="{" || c=="[" || c=="}" || c=="]" || c==";" || c==":"|| c=='"'|| c=="'"|| c=="<" || c==","|| c==">"|| c=="."|| c=="?"|| c=="/"|| c=="_"|| c=="_")
	//if (c == "@" || c == "#"  || c == "$"  || c == "%"  || c == "^"  || c == "&"  || c == "*"  || c == "'" || c == '"'|| c=="!" || c=="-" || c=="_" || c=="+" ) 

	{	var lString;
 	    lString = pCtrlName + " cannot have a special character " + c ;
 		//window.alert(lString);
 		pCtrl.focus();
 		return true;
 	}
 }
 // All characters are numbers.
 return false;
}
function checkProbChar(pString, pCtrl, pCtrlName)
{   var i;

 for (i = 0; i < pString.length; i++)
 {   
     var c = pString.charAt(i);
 	if(c == "%"  || c == "&"|| c=="=" || c=="|" || c==";" || c=='"'|| c=="<" || c==","|| c==">"||  c=="/"|| c=="_")

	{	var lString;
 	    lString = pCtrlName + " cannot have a special character " + c ;
 		window.alert(lString);
 		pCtrl.focus();
 		return true;
 	}
 }
 return false;
}

function gChkPassNotAll(pString, pCtrl, pCtrlName)
{   var i;
 // Search through string's characters one by one
 // until we find a non-numeric character.
 // When we do, return false; if we don't, return true.

 for (i = 0; i < pString.length; i++)
 {   
     // Check that current character is number.
     var c = pString.charAt(i);
 	if(c == "`" || c == "~"  || c == "!"  || c == "@"  || c == "#"  || c == "$"  || c == "%"  || c == "^" || c == "&"|| c=="*" || c=="(" || c==")" || c=="-" || c=="+" || c=="=" || c=="|" || c== "\\" || c=="{" || c=="[" || c=="}" || c=="]" || c==";" || c=='"'|| c=="'"|| c=="<" || c==">"|| c=="?")
	//if (c == "@" || c == "#"  || c == "$"  || c == "%"  || c == "^"  || c == "&"  || c == "*"  || c == "'" || c == '"'|| c=="!" || c=="-" || c=="_" || c=="+" ) 

	{	var lString;
 	    lString = pCtrlName + " cannot have a special character " + c ;
 		window.alert(lString);
 		pCtrl.focus();
 		return true;
 	}
 }
 // All characters are numbers.
 return false;
}

function textarea(max,val,newv)
{

	if(val.length>max-1)
	{
		newv.value=val.substring(0,max-1)
		
	}
}

function gChkAspPage(pString, pCtrl, pCtrlName)
{   var i;
 // Search through string's characters one by one
 // until we find a non-numeric character.
 // When we do, return false; if we don't, return true.

 for (i = 0; i < pString.length; i++)
 {   
     // Check that current character is number.
     var c = pString.charAt(i);
 	if(c == "`" || c == "~"  || c == "!"  || c == "@"  || c == "#"  || c == "$"  || c == "%"  || c == "^" || c == "&"|| c=="*" || c=="(" || c==")" || c=="-" || c=="+" || c=="=" || c=="|" || c== "\\" || c=="{" || c=="[" || c=="}" || c=="]" || c==";" || c==":"|| c=='"'|| c=="'"|| c=="<" || c==","|| c==">"|| c=="?")
	//if (c == "@" || c == "#"  || c == "$"  || c == "%"  || c == "^"  || c == "&"  || c == "*"  || c == "'" || c == '"'|| c=="!" || c=="-" || c=="_" || c=="+" ) 

	{	var lString;
 	    lString = pCtrlName + " cannot have a special character " + c ;
 		window.alert(lString);
 		pCtrl.focus();
 		return true;
 	}
 }
 // All characters are numbers.
 return false;
}

// to check whether phone number is valid or not
function isPhone(pCtrlName,pString,pCtrl)
{
var j=0;
var k=0;
 for (i = 0; i < pString.length; i++)
 {   
     // Check that current character is number.
     var c = pString.charAt(i);
	if(c == "`" || c == "~"  || c == "!"  || c == "@"  || c == "#"  || c == "$"  || c == "%"  || c == "^" || c == "&"|| c=="*" || c=="(" || c==")" || c=="_" || c=="=" || c=="|" || c== "\\" || c=="{" || c=="[" || c=="}" || c=="]" || c==";" || c==":"|| c=='"'|| c=="'"|| c=="<" || c==","|| c==">"|| c=="."|| c=="?"|| c=="/"|| c=="_"|| c=="_" || isAlphabetic(c) || whitespace.indexOf(pString.charAt(i)) != -1)
	//if(c == "`" || c == "~"  || c == "!"  || c == "@"  || c == "#"  || c == "$"  || c == "%"  || c == "^" || c == "&"|| c=="*" || c=="(" || c==")" || c=="_" || c=="=" || c=="|" || c== "\\" || c=="{" || c=="[" || c=="}" || c=="]" || c==";" || c==":"|| c=='"'|| c=="'"|| c=="<" || c==","|| c==">"|| c=="."|| c=="?"|| c=="/"|| c=="_"|| c=="_" || isAlphabetic(c))
	{	
		var lString;
 	    lString = pCtrlName + " is not a valid Phone Number ";
 		window.alert(lString);
 		pCtrl.focus();
 		return true;
 	}
   }
 return false;
}

function showSize(strName,strValue,strLength)
{
if(strValue.length>strLength)
{
alert("You have entered " + strValue.length+" characters. Maximum characters you can add in " + strName+" is " + strLength)
return false
}
else
return true;
}
function gChkDoubleQuotes(pString, pCtrl, pCtrlName)
{   var i;
 // Search through string's characters one by one
 // until we find a double quotes.
 // When we do, return false; if we don't, return true.

 for (i = 0; i < pString.length; i++)
 {   
     // Check that current character is number.
     var c = pString.charAt(i);
 	if(c == '"')
	{	var lString;
 	    lString = pCtrlName + " cannot have a double quotes." ;
 		window.alert(lString);
 		pCtrl.focus();
 		return true;
 	}
 }
 return false;
}
function gChkComas(pString, pCtrl, pCtrlName)
{   var i;
 // Search through string's characters one by one
 // until we find a non-numeric character.
 // When we do, return false; if we don't, return true.

 for (i = 0; i < pString.length; i++)
 {   
     // Check that current character is number.
     var c = pString.charAt(i);
 	if(c == "`" || c == "~"  || c == "!"  || c == "@"  || c == "#"  || c == "$"  || c == "%"  || c == "^" || c == "&"|| c=="*" || c=="(" || c==")" || c=="_" || c=="-" || c=="+" || c=="=" || c=="|" || c== "\\" || c=="{" || c=="[" || c=="}" || c=="]" || c==";" || c==":"|| c=='"'|| c=="'"|| c=="<" || c==">"|| c=="."|| c=="?"|| c=="/"|| c=="_"|| c=="_")
	//if (c == "@" || c == "#"  || c == "$"  || c == "%"  || c == "^"  || c == "&"  || c == "*"  || c == "'" || c == '"'|| c=="!" || c=="-" || c=="_" || c=="+" ) 

	{	var lString;
 	    lString = pCtrlName + " cannot have a special character " + c ;
 		window.alert(lString);
 		pCtrl.focus();
 		return true;
 	}
 }
 // All characters are numbers.
 return false;
}
function gChkExp (pString, pCtrl, pCtrlName)
{   
var i;
 // Search through string's characters one by one
 // until we find a non-numeric character.
 // When we do, return false; if we don't, return true.

 for (i = 0; i < pString.length; i++)
 {   
     // Check that current character is number.
     var c = pString.charAt(i);
 	if (c != "0" && c != "1" && c != "2"  && c != "3"  && c != "4"  && c != "5"  && c != "6"  && c != "7"  && c != "8" && c != '9' && c != "-" && c != ".") 
 	{	var lString;
 	    lString = " Invalid Value in experience"
 		window.alert(lString);
 		pCtrl.focus();
 		return false;
 	}
 }

 // All characters are numbers.
 return true;
}

function ChkDec(pString)
{   
var i;
  for (i = 0; i < pString.length; i++)
 {   
     var c = pString.charAt(i);
 	if (c == ".") 
 	{	
	return false;
 	}
 }
 return true	;
}


function trim(js_str){
    if(js_str != "")
   while(js_str.charAt(0) == " ")
     js_str = js_str.substring(1,js_str.length);
   while(js_str.charAt(js_str.length-1) == " ")
     js_str = js_str.substring(0,js_str.length-1);
  return js_str; 
}

function goBack()
{
 history.go(-1);
}