
//Added On 14/Dec For checking the valid name ( ie without the single quotes )
function checkFirstCharacter(strName)
{
	if((strName.charAt(0) == "'") || (strName.charAt(0) == '"'))
	{
		return false;
	}
	return true;
}
function checkValidName(strName)
{

	
	if (checkFirstCharacter(strName) == false)
	{
		return 0;
	}	
	var strOutPut ="";
	var strValidName = (new String(strName)).split("'");
	var intCount = 0;
	while(intCount < strValidName.length)
	{
		strOutPut = strOutPut + strValidName[intCount];
		intCount = intCount + 1;
	}
	
	return strOutPut.length;
}

function strReverse(strString)
	{
		var strRev =new String();
		var intLen=strString.length;
		var intIndex;
		for (intIndex=intLen;intIndex>0;intIndex--)
		{
			strRev+= strString.charAt(intIndex-1);
		}
		return strRev;
	}
function lTrim(strString)
	{
		var intIndex,intLen;
		
		intLen=strString.length;
		intIndex=0;
		while(strString.charAt(intIndex)==' ' && intIndex<intLen )
		{
			intIndex++;
		}
		return strString.substring(intIndex,intLen);		
	}
	
	function checkInValidCharacters(strString)
		{
			
		//at present checking only Apstrophe ... 
		var intIndex,intLen;
		intLen=strString.length;
			intIndex=0;
		  while(intIndex<intLen )
			{
				if (strString.charAt(intIndex)=="'" )
				{
				return false;
				}
					intIndex++;
			}
			return true;
			
		}
	
	function rTrim(strString)
	{
		
		var intIndex,intLen;		
		intLen=strString.length;
		strString=strReverse(strString);
		strString=lTrim(strString)
		strString=strReverse(strString);				
		return strString;		
	}
	function trim(strString)
	{
		return rTrim(lTrim(strString));
	}
	
	function removeIntraSpaces(strStringToRemove)
	{
		var intIndex,intLen;
		var strResult;
		var chAtPos;
		
		intLen=strStringToRemove.length;
		intIndex=0;
		for(intIndex =0; intIndex < intLen ; intIndex ++)
		{
			chAtPos = strStringToRemove.charAt(intIndex);
			if(chAtPos==' ')
			{
			}else
			{
				strResult = strResult + chAtPos;
			}
		}	
		return strResult;	
	}
function SplitWithComma(strEntireString,strFindingString)
 { 
        var intLength; 
        var arrEntireString;
        intLength = (new String(strEntireString)).split(",").length;
       arrEntireString = (new String(strEntireString)).split(",");
         for(i = 0; i< intLength; i++) 
        {
             if(strFindingString == arrEntireString[i]) return true;
         } 
        return false;
}


		/*
		Function : To validate phone numbers
		Author	 : Manikandan
		Date	 : 2nd April 2002
		Bug ID	 : AUD0173MR
		Description: 
			Allows only set of 0-9, space, (, ), + and - chars.
		*/
		function isValidPhone(strPhone){
			
			var rePhone = /^[\s0-9()+-]*$/;
				
			return rePhone.test(strPhone);
		}

 
		/*
		Function : For Bulk Printing
		Author	 : Sumathi
		Date	 : 12 May 2002
		CR ID	 : CR-OLO-5
		Description: 
			For Bulk Printing Of TimeSheets
		*/
 
 
		
		function fnBulkPrinting(objform)
		{
        var filledIn = false;
        var strBulkPrintTimesheet;
        var count = 0;
        var strParam = "";
        
        // Use the length property to iterate through each Checkbox
        // to determine if a selection has been made
        for (var counter=0; counter<objform.elements.length; counter++)
        {
			if (objform.elements[counter].checked == true)
			{
              filledIn = true;
			  strParam=strParam + objform.elements[counter].value + ",";
              count++;
             }
        }    
        
        if (filledIn == false)
        {
            alert('Timesheet is not selected for Printing');
            return;
        }
		else
		{
		TimeSheetBulkWindow=window.open('PrintViewBulkTimesheet.asp?Params='+ escape(strParam) ,'timesheetbulk','toolbar=no,scrollbars=yes')   
        addChildToOpenedList(TimeSheetBulkWindow);

		//document.frm.action="PrintViewBulkTimesheet.asp";
		//document.frm.target= "newWin";
		//document.frm.method="post";
		//document.frm.submit();
		}
        
    }

		function fnBulkPrintingMedox(objform)
		{
        var filledIn = false;
        var strBulkPrintTimesheet;
        var count = 0;
        var strParam = "";
        
        // Use the length property to iterate through each Checkbox
        // to determine if a selection has been made
        for (var counter=0; counter<objform.elements.length; counter++)
        {
			if (objform.elements[counter].checked == true)
			{
              filledIn = true;
			  strParam=strParam + objform.elements[counter].value + ",";
              count++;
             }
        }    
        
        if (filledIn == false)
        {
            alert('Timesheet is not selected for Printing');
            return;
        }
		else
		{
		TimeSheetBulkWindow=window.open('PrintViewBulkWeeklyMedoxTimesheet.asp?Params='+ escape(strParam) ,'timesheetbulk','toolbar=no,scrollbars=yes')   
        addChildToOpenedList(TimeSheetBulkWindow);

		//document.frm.action="PrintViewBulkTimesheet.asp";
		//document.frm.target= "newWin";
		//document.frm.method="post";
		//document.frm.submit();
		}
        
    }