/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function name	: openCashWindow
Argument List	: ctlNames, submitForm, path, focusCtl			  
Purpose			: to Get Cash Receipt No,Cash Receipt Date,Amount
Created by		: Sachin Garg (HCL Technologies Ltd.)
Dated			: 18-May-2006 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

function openCashWindow(ctlNames, submitForm, path, focusCtl){		
	var pageProperty ="left=50,top=50,width=500,height=400,menubar=0,toolbar=0,statusbar=0,scrollbars=1,resizable=1";
	if ((path == undefined) || (path == "")) 
		var pageUrl = "../Common/frmCashReceiptSearchCommon.aspx?submitForm="+submitForm+"&ctlNames="+ctlNames+"&focusCtl="+focusCtl;					
	else
		var pageUrl = path + "Common/frmCashReceiptSearchCommon.aspx?submitForm="+submitForm+"&ctlNames="+ctlNames+"&focusCtl="+focusCtl;	

	window.open(pageUrl,'NEW_WIND',pageProperty);
	}	
		


var whitespace = " \t\n\r";
var smallChars = "abcdefghijklmnopqrstuvwxyz";
var capitalChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var characters = smallChars + capitalChars;
var numericChars = "0123456789";
var alphaNumeric = characters + numericChars;
/*====================================================
	Modified by		:	Ashok Kr. Singh
	Dateed			:	14-Jan-2006
	Purpose			:	Not To Allow other than integer
	Modified by		:	Ashok Kr. Singh
	Dateed			:	16-Jan-2006
	Purpose			:	To reset the function in the previous position
	Requested by	:	Vishal

=====================================================*/

function IsValidInteger(object)
{	
	if(window.event.keyCode < 48 || window.event.keyCode > 57)
	{
		return false;
	}
	//Code Added by Ashok Kr. Singh on 14-Jan-2006
	/*
	if(window.event.keyCode == 48)
	{
		var InputLength = object.value.length;
		if(parseInt(InputLength) == 0)
		{
			return false;
		}
	}
	*/
	//End of modification done by Ashok Kr. Singh on 14-Jan-2006
}



/*====================================================
	Modified by		:	Ashok Kr. Singh
	Dateed			:	14-Jan-2006
	Purpose			:	Not To Allow other than integer
	Modified by		:	Ashok Kr. Singh
	Dateed			:	16-Jan-2006
	Purpose			:	To reset the function in the previous position
	Requested by	:	Vishal

=====================================================*/

function IsValidReal(object)
{	
	if((window.event.keyCode < 48 || window.event.keyCode > 57) && window.event.keyCode != 46)
	{
			return false;
	}
	//Code Added by Ashok Kr. Singh on 14-Jan-2006
	/*
	if(window.event.keyCode == 48)
	{
		var InputLength = object.value.length;
		if(parseInt(InputLength) == 0)
		{
			return false;
		}
	}
	*/
	//End of modification done by Ashok Kr. Singh on 14-Jan-2006
}



/*====================================================
	Created by		:	Ashok Kr. Singh
	Creation Date	:	15-Jan-2006
	Purpose			:	Not to Allow inputs except Natural nombers
	Paraameter		:	object reference
	Requested by	:	Ashok Kr. Singh

=====================================================*/

function IsValidNaturalNumber(object)
{	
	if(window.event.keyCode < 48 || window.event.keyCode > 57)
	{
		return false;
	}
	
	if(window.event.keyCode == 48)
	{
		var InputLength = object.value.length;
		if(parseInt(InputLength) == 0)
		{
			return false;
		}
	}	
}

/*====================================================
	Created by		:	Ashok Kr. Singh
	Creation Date	:	07-FEB-2006
	Purpose			:	Not to Allow inputs except Alphabets
	Paraameter		:	object reference
	Requested by	:	Ashok Kr. Singh

=====================================================*/

function IsAlphabate(object)
{	
	var Flag = false;
	if(window.event.keyCode == 32)
	{
		var InputLength = object.value.length;
		if(parseInt(InputLength) != 0)
		{
			Flag = true;
		}
	}

	if(window.event.keyCode >= 65 && window.event.keyCode  <=90)
	{
		Flag = true;
	}
	
	if(window.event.keyCode >= 97 && window.event.keyCode  <=122)
	{
		Flag = true;
	}
	
	if(Flag)
	{
		return true;
	}
	else
	{
		return false;
	}
}

/*====================================================
	Created by		:	Ashok Kr. Singh
	Creation Date	:	07-FEB-2006
	Purpose			:	Not to Allow User inputs except AlphaNumerics
	Paraameter		:	object reference
	Requested by	:	Rakesh Rawat and Sachin

=====================================================*/

function IsAlphaNumeric(object)
{	
	var Flag = false;
	if(window.event.keyCode >= 48 && window.event.keyCode  <=57)
	{
		Flag = true;
	}

	if(window.event.keyCode >= 65 && window.event.keyCode  <=90)
	{
		Flag = true;
	}
	
	if(window.event.keyCode >= 97 && window.event.keyCode  <=122)
	{
		Flag = true;
	}
	if(Flag)
	{
		return true;
	}
	else
	{
		return false;
	}
}
	
function FindChar(strValue,chr){
		var intCount = strValue.split(".").length;		
		if(parseFloat(intCount) >= parseFloat(2))
			return true;
		else
			return false;
	}

function IsValidFloat(object,scale,prec)
{
	//alert(window.event.keyCode);
	//var MaxLength = parseFloat(scale) + parseFloat(prec) + parseFloat(1)
	//object.maxlength = MaxLength;
	//object.maxlength = "5";
	//object.disabled = true
	//alert(MaxLength);
	objValue = object.value;
	
	//Discarding characters other than 1,2,3,4,5,6,7,8,9,0,and .
	//But if prec is zero then also discard char "."
	
	var tempChar = 46;
	if (parseFloat(prec) == parseFloat(0)) tempChar = 48	
	
	if(window.event.keyCode < parseFloat(tempChar) || window.event.keyCode > 57 || window.event.keyCode == 47)
	{
		window.event.keyCode = 0;
		return false;
	}
	
	//Find if entered Character is "." 
	if(window.event.keyCode == 46)
	{
		objValue = object.value;
		
		// If there is already a char ".", discard it
		if (FindChar(objValue,"."))
		{
			window.event.keyCode = 0;
			return false;
		}
	}
	else
	{
		var MaxLength = parseFloat(scale) + parseFloat(prec) + parseFloat(1)
		//objValue = objValue + "."
		var ScaleValue = objValue.split(".")[0];
		var PrecsValue = objValue.split(".")[1];
		//find whether char "." already exists
		//alert(FindChar(objValue,"."))//Disabled By Plaban
		//alert(intPrecs);
		//return false;
		//alert(intPrecs == undefined)
		if(PrecsValue != undefined && PrecsValue != "")
		{
			//alert("Inside");
			//return false;
			//alert("Precs Value " + PrecsValue.length);//Disabled By Plaban
			//alert("Passed " + prec)//Disabled By Plaban
			//var flgDecimal = PrecsValue.substr(0,prec);
			if(parseFloat(PrecsValue.length) >= parseFloat(prec))
			{
				//alert("Greater Decimal")
				//alert(PrecsValue.substr(0,prec));
				//object.value = ScaleValue + "." + PrecsValue.substr(0,prec)
				//object.value = "OK"
				window.event.keyCode = 0;
				return false;
			}
		}
		//alert(objEvent);
	}	
}

/*====================================================
	Modified by		:	Ashok Kr. Singh
	Dateed			:	03--Jan-2006
	Purpose			:	To Check trim the whitespaces
	Requested by	:	

=====================================================*/

function IsBlank(object,msg)
{	
	var objValue = trimSpace(object.value);
	//alert(trimSpace(object.value));
	object.value = objValue;
	if (parseFloat(objValue.length) <= 0)
	{
		alert(" Please Enter " + msg);
		object.value = "";
		object.focus();
		return false;
	}
	//return msg;
}


//function to trim leading and trailing white spaces
function trimSpace(str)
{
     return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

/*====================================================
	Created by		:	Ashok Kr. Singh
	Creation Date	:	03--Jan-2006
	Purpose			:	To Check that Dropdown List must be selected
	Paraameter		:	Dropdown object Reference, value at index 0
						(that should not be selected),and message
	Requested by	:	Ashok Kr. Singh

=====================================================*/

function IsSelected(object,value,msg)
{
//alert(object.options[object.options.selectedIndex].value)
	if ((object.value) == value)
	{
		alert(" Please Select " + msg);
		object.focus();
		return false;
	}	
}

function isNumber(object,allowZero,msg)
{
	var objValue = trimSpace(object.value);
	//alert(trimSpace(object.value));
	object.value = objValue;
	if(isNaN(objValue))
	{
		alert("Please Enter correct value of " + msg);
		object.focus();
		return false;
	}
	
	if(!allowZero)
	{
		if(parseFloat(objValue) == parseFloat(0))
		{
			alert(msg + " can not be Zero.     ");
			object.focus();
			return false;
		}
	}
}


function highlightButton(s){
	if ("BUTTON"==event.srcElement.tagName){		
		var strClassName = event.srcElement.className.toUpperCase();
		if ((strClassName == "BUTTON")||(strClassName == "BUTTONOVER"))
			event.srcElement.className=s;				
		else
			event.srcElement.className="Browse" + s;	
		}	
		/*if (event.srcElement.value == "...")
			event.srcElement.className="Browse" + s;				
		else
			event.srcElement.className=s;					
		*/	
	}
/*
Created By	: Rakesh Kumar
Dated		: 2005-12-09
Purpose		: This function is used to call the calender aspx page.
*/
function showCalender(ctlName, strParentPath){
	var ctlValue = eval('document.forms[0].'+ctlName).value;
	var pageProperty = 'left=100,top=100,width=250,height=225,menubar=0,toolbar=0,statusbar=0,scrollbars=0,resizable=1,modal=yes';
	var pageUrl = strParentPath + '/Include/frmCalender.aspx?ctlName='+ctlName+'&ctlValue='+ctlValue;	
	window.open(pageUrl,'NEW_WIND',pageProperty)
	}
	
/*================================================================	
	Function Made by Ashok Kr. Singh on 19-Dec-2005
	Purpose		-	To reset the form values
	Paraameter	-	Form Name (reference of form should be passed)
	Requested by-	Sachin
=================================================================*/
	function ResetForm(frmName,objError){
		frmName = eval(frmName);
		var frmLength = frmName.length;		
		var intCount;		
		frmName.reset();		
		for (intCount = 0 ; intCount < frmLength; intCount ++){				
			if(frmName.elements[intCount].type == "text" && frmName.elements[intCount].disabled == false){
				frmName.elements[intCount].value = "";
				}					
			if ((frmName.elements[intCount].type	== "select-one")||(frmName.elements[intCount].type	== "select")){
				frmName.elements[intCount].selectedIndex = 0;
				}
			if (frmName.elements[intCount].type	== "checkbox"){
				frmName.elements[intCount].checked = false;
				}
			if (frmName.elements[intCount].type	== "radio"){
				frmName.elements[intCount].checked = false;
				}	
				
			}	
		if (eval('document.all.'+objError) == '[object]'){
			eval('document.all.'+objError).innerHTML = "";
			return false;
			}
		return false;
		}
	

	/*==========================================================	
		Function Made by Ashok Kr. Singh on 19-Dec-2005
		Purpose		-	To check valid string for the control
		Paraameter	-	reference of form control should be passed
		Requested by-	Sachin
	============================================================
	*/

	function IsValidString(object)
	{
		//alert(window.event.keyCode);
		var arrNotValid = new Array(34,39,58,59)
		var intCount;
		for(intCount = 0; intCount < arrNotValid.length; intCount ++)
		{
			if(window.event.keyCode == arrNotValid[intCount])
			{
				//window.event.keyCode = 0;
				return false;
			}
		}
	}
	
	
	/*==========================================================	
		Created by	:	Ashok Kr. Singh
		DAted		:	21-Dec-2005
		Purpose		:	To check minimum length of the control value
		Paraameter	:	reference of form control, and minimum length should be passed
		Requested by:	Sachin
	============================================================
	*/


	function CheckMinLength(object,msg,Length)
	{
		//alert(window.event.keyCode);
		var objLength = object.value.length
		if(parseInt(objLength) < parseInt(Length))
		{
			alert(" Please Enter at least " + Length + " Characters in " + msg + ".")
			object.focus();
			return false;
		}
	}

	/*==========================================================	
		Function Made by Ashok Kr. Singh on 21-Dec-2005
		Purpose		-	To check minimum length of the control value
		Paraameter	-	reference of controls to be compared, and messages should be passed
		Requested by-	Sachin
	============================================================
	*/
	
	function CompareValues(object1,object2, strMsg1,strMsg2)
	{
		if(object1.value > object2.value)
		{
			alert(strMsg1 + " Can not Be Greater than " + strMsg2);
			object1.focus();
			return false;
		}
	}
	
	
	/*==========================================================	
		Created by	-	N/A
		Purpose		-	To show the report made in Crystal Report
		Paraameter	-	path of the rpt file, paramater values, parameter type
		Incorporated by-Ashok Kr. Singh
	============================================================
	*/
	function showReport(strReportName, strParamValue, strParamType, sPath)
	{
		var sPageProperty;
		var sPageName;
		var sPagePath;
		var sQueryString;
		var Url;

		sPageName		= "NewWind";
		//sPageProperty	= "menubar=0,statusbar=1,toolbar=0,left=80,top=80,width=700,height=450,scrollbars=no,resizable=yes";
		//sPageProperty	= "menubar=0,statusbar=1,toolbar=0,left=0,top=0,width=800,height=550,scrollbars=no,resizable=yes";
		sPageProperty	= "menubar=0,statusbar=1,toolbar=0,left=40,top=40,width=700,height=400,scrollbars=yes,resizable=yes,maximize=yes";
		//sPagePath		= sPath + "showReport.asp";
		sPagePath		= sPath + "showReport.aspx";
		sQueryString	= "?ReportName="+strReportName+"&ParamValue="+strParamValue+"&paramType="+strParamType;

		Url = sPagePath + sQueryString;		
		window.open(Url,sPageName,sPageProperty); 						
	}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
							Functions List
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	1. isEmpty 
	2. isInteger
	3. isPosInteger
	4. isUnsignedInteger
	5. isReal
	6. isPosReal
	7. leftTrim
	8. rightTrim
	9. trim
   10. isEmail
   11. isInvalid
   12. valueCopy
   13. charFromCharCode
   15. findCharacter
   16. inputCheck
   17. checkDate
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/	

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function name	: isEmpty
Argument List	: strInput: input value 				  
Purpose			: return true if strInput variable is empty.
Created by		: Rakesh Kumar (HCL Technologies Ltd.)
Dated			: 26-Dec-2006
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function isEmpty(strInput){
	for(i=0;i<strInput.length;i++){
		 var ch = strInput.charAt(i);
		if(whitespace.indexOf(ch)==-1){			
			return false;
			}
		}
	return true;
	}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/	

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function name	: checkDate
Argument List	: 
Purpose			: to campare two date.
Created by		: Rakesh Kumar (HCL Technologies Ltd.)
Dated			: 26-Dec-2005
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/	
	function checkDate(strFirstDate,strSecondDate,strMsg){	
		var arrFirstDate = strFirstDate.split("/");
		
		var arrSecondDate = strSecondDate.split("/");		
		var strMonth = arrFirstDate[1]
		var strDay = arrFirstDate[0]
		var strYear = arrFirstDate[2]
	
		
		var strCurMonth = arrSecondDate[1]
		var strCurDay = arrSecondDate[0]
		var strCurYear = arrSecondDate[2]
		
		if ((strMonth > 12) || (strCurMonth > 12)){
			alert("Invalid Date format!(use: dd/mm/yyyy)")
			return false;
			}  
		if ((strDay > 31) || (strCurDay > 31)){
			alert("Invalid Date format!(use: dd/mm/yyyy)")
			return false;
			}  			
		if (parseFloat(strYear) > parseFloat(strCurYear)){	
			alert(strMsg);
			return false;
			}
		if(parseFloat(strYear)==parseFloat(strCurYear)){ 
			if(parseFloat(strMonth)>parseFloat(strCurMonth)){	
				alert(strMsg);
				return false;
				}					
			if(parseFloat(strMonth)==parseFloat(strCurMonth)){	
				if(parseFloat(strDay)>parseFloat(strCurDay)){	
					alert(strMsg);
					return false;
					}	
				}	
			return true;
			}
		return true;
		}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function name	: leftTrim
Argument List	: strInput: input value 				  
Purpose			: trims white spaces on left side of the input.
Created by		: Rakesh Kumar (HCL Technologies Ltd.)
Dated			: 26-Dec-2006
Modified by		: Ashok Kr. Singh
Reason			: Variable whitspce was not defined
Dated			: 05-Jan-2006
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function leftTrim(strInput){
	var i=0;
	len = strInput.length;
	var whitespace = " ";
	for(i=0;i<len;i++){
		if(whitespace.indexOf(strInput.charAt(i)) == -1) break;
		}
	strInput = strInput.substr(i);
	return strInput;
	}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function name	: rightTrim
Argument List	: strInput: input value 				  
Purpose			: trims white spaces on right side of the input.
Created by		: Rakesh Kumar (HCL Technologies Ltd.)
Dated			: 26-Dec-2006
Modified by		: Ashok Kr. Singh
Reason			: Variable whitspce was not defined
Dated			: 05-Jan-2006
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function rightTrim(strInput){
	var i = 0;
	len = strInput.length;
	var whitespace = " ";
	for(i=len-1;i>=0;i--){
		if(whitespace.indexOf(strInput.charAt(i)) == -1) break;
		}
	if(i != len-1){
		strInput = strInput.substr(i);
		}
	return strInput;
	}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function name	: trim
Argument List	: strInput: input value 				  
Purpose			: trims white spaces of the input.
Created by		: Rakesh Kumar (HCL Technologies Ltd.)
Dated			: 26-Dec-2006
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function trim(strInput){
	return leftTrim(rightTrim(strInput));
	}	
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function name	: isValidDate
Argument List	: obj: name of the source control with document and form name. 				  
Purpose			: To validate the user input dates in dd/mm/yyyy format.
Created by		: Rakesh Kumar (HCL Technologies Ltd.)
Dated			: 06-Jan-2006
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/	
	function isValidDate(obj){			
		var dateValue = obj.value;		
		if (trim(dateValue).length == 0){
			return true;
			} 
		if (dateValue.length != 10){
			alert("Please enter date in dd/mm/yyyy format!");
			obj.focus();
			return false;
			}
		
		var arrFirstDate = dateValue.split("/");			
		var strDay = arrFirstDate[0];
		var strMonth = arrFirstDate[1];		
		var strYear = arrFirstDate[2];
		
		if (strMonth > 12){
			alert("Month can not be greater than 12!");
			obj.focus();
			return false;
			}  
		
		var bLeapYear = 0;
		if (((parseInt(strYear) % 4) == 0) && ((parseInt(strYear) % 100) != 0)){ 
			bLeapYear = 1;
			}
		else if ((parseInt(strYear) % 400) == 0){
			bLeapYear = 1;
			}	 
		var arrDays;
		if (parseInt(bLeapYear) == 1){
			arrDays = new Array(31,29,31,30,31,30,31,31,30,31,30,31);
			}
		else{
			arrDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);	
			}
				
		if (parseInt(strDay) > arrDays[parseInt(strMonth)-1]){
			alert("Day can not greater than " + arrDays[parseInt(strMonth)-1]);
			obj.focus();
			return false;
			}	
		return true;
		}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function name	: renderDate
Argument List	: obj: this pointer of the textbox object. 				  
Description		: it will validate the user inputs and only allow dd/mm/yyyy format of date.
				  it will not allow users to enter day value greater than 31.
				  it will not allow users to enter month value greater than 12.	
				  The "/" character will come automatically.
Purpose			: checks the keystrokes entered by user for date validation.
Created by		: Rakesh Kumar (HCL Technologies Ltd.)
Dated			: 06-Jan-2006
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	function renderDate(obj){
		var keyCode = window.event.keyCode;
		var dateValue = obj.value;		
		
		if(parseInt(keyCode) >= 47 && parseInt(keyCode) <= 57){							 	
			for (var intCounter=0; intCounter <= intLength; intCounter++){
					var chrChar = dateValue.charAt(intCounter);  			
					if (chrChar == "/"){
						intSlashCount = parseInt(intSlashCount) + 1
						}
					}					
				if (parseInt(intSlashCount) == 2){ 		
					return false;
					}			
			if (parseInt(keyCode) == 47){
				var intLength = dateValue.length;
				var intSlashCount = 0;						
				if (dateValue.length == 0){
					obj.value = "01";				
					}								
				else if (dateValue.length == 1){
					obj.value = "0" + obj.value;
					}								
				else  if (dateValue.length == 3){
					obj.value = obj.value + "01";
					}
				else  if (dateValue.length == 4){
					obj.value = dateValue.substr(0,3) +  "0" + dateValue.substr(3,1);
					}										
				}					
			
			if (dateValue.length == 2){									
				if(parseInt(dateValue) > 31){
					 obj.value = "";
					 return false;
					 }
				else{	 
					if (parseInt(keyCode) != 47){
						obj.value =obj.value + "/";				
						}						
					}							
				}
			if (dateValue.length == 5){							
				var monthPart = dateValue.substr(3,2);			
				if(parseInt(monthPart) > 12){
					 obj.value = dateValue.substr(0,3);
					 return false;
					 }
				else{	 
					if (parseInt(keyCode) != 47){
						obj.value = obj.value + "/";				
						}						
					}							
				}					
			}	
		else{
			return false;				
			}
		}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function name	: charFromCharCode
Argument List	: charCode: Ascii value for a character. 				  
Purpose			: return the chracter value of an Ascii value.(Hexadecimal base)
Created by		: Rakesh Kumar (HCL Technologies Ltd.)
Dated			: 26-Dec-2005
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function charFromCharCode (charCode){
		return unescape('%' + charCode.toString(16));
	}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function name	: findCharacter
Argument List	: strValue		: string to serach. 
				  chrCharacter	: charater to be find. 	
Purpose			: to find a particular pattern in a string.
Created by		: Rakesh Kumar (HCL Technologies Ltd.)
Dated			: 26-Dec-2005
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/	
	function findCharacter(strValue, chrCharacter){
		var intLength;
		var intCounter;
		var chrChar;
		//alert("fFindChar:" + sValue);
		intLength = strValue.length;
		for (intCounter=0; intCounter <= intLength; intCounter++){
			chrChar = strValue.charAt(intCounter);  			
			if (chrChar == chrCharacter){
				//alert ("findCharacter:" + cChar);
				return intCounter;
			}
		}
		return -1;
	}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function name	: inputCheck
Argument List	: strObjName	: name of the source control with document and form name. 
				  strInputs		: allowed chracters string(e.g. "0123456789."). 	
				  intBefore		: maximum characters allowed before decimal
				  intAfter		: maximum characters allowed after decimal
				  chrOneTimeChar: One time character	
Purpose			: To check the valid/allowed characters.
Created by		: Rakesh Kumar (HCL Technologies Ltd.)
Dated			: 26-Dec-2005
Example			: inputCheck("documet.form1.txt", "1234567890.","5","3",".")				  
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/	
	function inputCheck(strObjName,strInputs,intBefore,intAfter, chrOneTimeChar){
	   	var iLengthAfterDecimal,iLengthBeforeDecimal;	   	
	   	//set the allowed characters string
	   	
		if (strInputs == ""){ 
			strInputs = "0123456789.";  
			}		
		
		//get the key pressed by the user
		var cKeyPressed;
		cKeyPressed = charFromCharCode(window.event.keyCode);	
				
		//serach the character in the input string
		var iFoundChar;
		iFoundChar = findCharacter(strInputs,cKeyPressed);
		
		if (iFoundChar == -1){
			window.event.keyCode = 0;	
			return false;
		}			
		var objTextBox;
		var sValue;
		
		//get the value of text box
		objTextBox	= eval(strObjName);
		sValue		= objTextBox.value;
		
		//get the deciaml char position
		var iDecimalChar;
		iDecimalChar =findCharacter(sValue,chrOneTimeChar);		
		
		//if keypressed is chrOneTimeChar e.g. "." 
		if (cKeyPressed == chrOneTimeChar){
			// if "." character is alraedy there
			if (iDecimalChar != -1){
				window.event.keyCode = 0;	
				return false;
				}
			}
		//if "." character is alraedy there in the textbox				
		if (iDecimalChar != -1){
			var sAfterDecimal;		
			sAfterDecimal = sValue.substring(iDecimalChar + 1); 
			iLengthAfterDecimal	=  sAfterDecimal.length;
			//if allowed characters after decimal is equal to characters already there in the textbox value
			if (iLengthAfterDecimal == intAfter){
				window.event.keyCode = 0;	
				return false;
				}
			}
		//if chrOneTimeChar(e.g. ".") character is not there in the textbox				
		else{
			var sBeforeDecimal;			
			sBeforeDecimal = sValue.substring(0,(sValue.length - iDecimalChar)-1);
			iLengthBeforeDecimal	=  sBeforeDecimal.length; 
			//if allowed chararters before decimal is equal to the characters already there in the textbox value
			if ((iLengthBeforeDecimal == intBefore) && (cKeyPressed != ".")){
				window.event.keyCode = 0;	
				return false;
				}
			}		
	}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/	

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function name	: isEmail
Argument List	: strInput: input value 				  
Purpose			: return true if strInput variable is a valid email address(syntactical).
Created by		: Rakesh Kumar (HCL Technologies Ltd.)
Dated			: 26-Dec-2006
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function isEmail (strInput){   
	if(isEmpty(strInput)){
		return false;
		}
	var invalidChars = " \t\n\r\\\"\'#$%^&*()+=!~`/;:<>?,[]{}"
	var intPosFirst, intPosLast, intPosPeriod;
	strInput = trim(strInput);	
	//filter for invalid chars
	for(var i=0;i<strInput.length;i++){
		if(invalidChars.indexOf(strInput.charAt(i)) != -1){
			return false;
			}	
		}	
	//starts with alphabet
	if(characters.indexOf(strInput.charAt(0)) == -1){
		return false; 
		}	
	intPosFirst = strInput.indexOf("@");
	// @ present and not first char
	if(intPosFirst == -1 || intPosFirst == 0){
		return false; 
		}	
	// multiple at present
	intPosLast = strInput.lastIndexOf("@");
	if(intPosLast != intPosFirst){
		return false; 
		}	
	intPosPeriod = strInput.lastIndexOf(".");	
	if(intPosPeriod == -1 || intPosPeriod < (intPosFirst + 2) || intPosPeriod == (strInput.length-1)){
		return false; 
		}	
	return true;
	}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/


/*====================================================
	Created by		:	Ashok Kr. Singh
	Creation Date	:	22-Feb-2006
	Purpose			:	To Reset/Clear Label Text
	Paraameter		:	object reference
=====================================================*/
			
function ClearLabel(object)
{
	if(object == '[object]')
	{
		object.innerHTML = "";
	}
}
/*====================================================
	Created by		:	Ashok Kr. Singh
	Creation Date	:	22-Feb-2006
	Purpose			:	To Reset/Clear Table/Grid
	Paraameter		:	object reference
=====================================================*/
function ClearGrid(object)
{
	if(object == '[object]')
	{
		object.parentNode.removeChild(object);
	}
}

/*====================================================
	Created by		:	Ashok Kr. Singh
	Creation Date	:	08-Feb-2006
	Purpose			:	To Set Focus on specied object,if First Object is disabled
						Focus is Set to second object
	Paraameter		:	name of the objects (Note that you should pass only names 
						not the reference of objects/controls)
=====================================================*/
function SetFocus(object1,object2)
{
	var objParam1 = eval('document.forms[0].'+object1);
	var objParam2 = eval('document.forms[0].'+object2)
	//alert(objParam1)
	if(objParam1 == '[object]' && objParam1.disabled !=true)
	{
		objParam1.focus();
	}
	else if(objParam2 == '[object]' && objParam2.disabled !=true)
	{
		objParam2.focus();
	}
}


/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function name	: isInteger
Argument List	: strInput: input value 				  
Purpose			: return true if strInput variable is an integer.
Created by		: Rakesh Kumar (HCL Technologies Ltd.)
Dated			: 26-Dec-2006
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function isInteger(strInput){
	if(strInput.charAt(0)=="-" || strInput.charAt(0)=="+"){
		i = 1;
		}	
	else{
		i = 0;
		}
	for(;i<strInput.length;i++){
		var ch = strInput.charAt(i);
		if(ch < "0" || ch > "9"){
			return false;
			}
		}
	return true;
	}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/		

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function name	: isUnsignedInteger
Argument List	: strInput: input value 				  
Purpose			: return true if strInput variable is an unsigned integer.
Created by		: Rakesh Kumar (HCL Technologies Ltd.)
Dated			: 26-Dec-2006
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function isUnsignedInteger(strInput){
	if(isInteger(strInput)){
		if(strInput.charAt(0) == "-" && strInput.charAt(0) == "+"){
			return false;
			}
		else{
			return true;
			}	
		}
	else{
		return false;
		}	
	}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/



/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function name	: isReal
Argument List	: strInput: input value 				  
Purpose			: return true if strInput variable is real.
Created by		: Rakesh Kumar (HCL Technologies Ltd.)
Dated			: 26-Dec-2006
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function isReal(strInput){
	strTemp = new String("0" + strInput);
	decimalPos = strTemp.indexOf(".");
	if (decimalPos != strTemp.lastIndexOf(".")){
		return false;
		}
	if(decimalPos > -1){
		return isInteger(strTemp.substring(0,decimalPos)) & isUnsignedInteger(strTemp.substring(decimalPos+1,strTemp.length));		
		}	
	else{	
		return(isInteger(str));	
		}
	}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function name	: isPosReal
Argument List	: strInput: input value 				  
Purpose			: return true if strInput variable is positive real.
Created by		: Rakesh Kumar (HCL Technologies Ltd.)
Dated			: 26-Dec-2006
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function isPosReal(strInput){
	if(isReal(strInput)){
		return !(strInput.charAt(0) == "-") ;
		}
	else{
		return false;
		}
	}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/


/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function name	: 
Argument List	: 
Purpose			: 
Created by		: Rakesh Kumar (HCL Technologies Ltd.)
Dated			: 08-March-2006
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function initiateWebService(WebServiceURL){
	var InitiateService = WebServiceURL;
	Service.useService(InitiateService,"DotNetWebService");				
	}
	
function isEmployee(obj){
	var strEmpCode = obj.value;	
	if (strEmpCode.length > 0){
		if ((strEmpCode.length != 6)||(isInteger(strEmpCode)==false)||(strEmpCode.substring(0,1)!="1")){
			alert("Invalid Employee Code");
			obj.select();
			obj.focus();
			return false;
			} 	
		}	
	return true;
	}
	
function callEmployeeWS(WebServiceURL, obj){		
	if (obj != "[object]"){
		alert("Not an Object!");
		return false;
		}
		
	var strEmpCode = obj.value;
	if (strEmpCode == ""){
		return false;
		}	
	
	if (isEmployee(strEmpCode)==false){
		return false;
		}
			
	var objControlName = document.getElementById("hdControlName");
	var strControlName = objControlName.value;
	
	if (strControlName == ""){
		alert("Control String is empty!");
		return false;
		}	
		
	initiateWebService(WebServiceURL);		
	if (Service.DotNetWebService){
		intCalled = Service.DotNetWebService.callService(getEmployeeWS,"GetEmployeeDetail",strEmpCode);			
		}			
	return true;
	}
	
function getEmployeeWS(objResult){
	var objControlName = document.getElementById("hdControlName");
	var strControlName = objControlName.value;	
	var arrControlName = strControlName.split(",");
	
	if (objResult.error){	
		alert(objResult.errorDetail.string);
		return false;
		}
	var strResult = objResult.value;
	if (strResult == ""){
		alert("No Data Found!");
		var obj = document.getElementById(arrControlName[0]);		
		obj.select();
		obj.focus();
		return false;
		}	
	
	var arrResult = strResult.split("$");					
	if (arrResult[0] == "0"){
		alert("Error Occured!Try Again");
		var obj = document.getElementById(arrControlName[0]);		
		obj.select();
		obj.focus();
		return false;
		}	
	
	var obj;
	for(var i=0;i<arrControlName.length;i++){
		obj = document.getElementById(arrControlName[i]);		
		if (obj == "[object]"){
			obj.value = arrResult[i];
			}			
		}
	
	var objSubmit = document.getElementById("hdSubmit");
	if (objSubmit == "[object]"){
		if (objSubmit.value == "1"){
			document.forms[0].submit();			
			}		
		}	
	return true;	
	}
	
function openEmployeeWindow(ctlNames, submitForm, path, focusCtl){		
	var pageProperty ="left=50,top=50,width=500,height=400,menubar=0,toolbar=0,statusbar=0,scrollbars=1,resizable=1";
	if ((path == undefined) || (path == "")) 
		var pageUrl = "../Common/frmEmployeeSearch.aspx?submitForm="+submitForm+"&ctlNames="+ctlNames+"&focusCtl="+focusCtl;					
	else
		var pageUrl = path + "Common/frmEmployeeSearch.aspx?submitForm="+submitForm+"&ctlNames="+ctlNames+"&focusCtl="+focusCtl;	

	window.open(pageUrl,'NEW_WIND',pageProperty);
	}

function openCityWindow(ctlName, path){		
	var pageProperty ="left=50,top=50,width=500,height=400,menubar=0,toolbar=0,statusbar=0,scrollbars=1,resizable=1";
	if ((path == undefined) || (path == ""))
		var pageUrl = "../Common/frmCitySearch.aspx?ctlName="+ctlName;					
	else
		var pageUrl = path + "Common/frmCitySearch.aspx?ctlName="+ctlName;

	window.open(pageUrl,'NEW_WIND',pageProperty);
	}	
	
function openStateWindow(ctlName, path){		
	var pageProperty ="left=50,top=50,width=500,height=400,menubar=0,toolbar=0,statusbar=0,scrollbars=1,resizable=1";
	if ((path == undefined)|| (path == ""))
		var pageUrl = "../Common/frmStateSearch.aspx?ctlName="+ctlName;					
	else
		var pageUrl = path + "Common/frmStateSearch.aspx?ctlName="+ctlName;

	window.open(pageUrl,'NEW_WIND',pageProperty);
	}		
	
	
function isAlphaNumericInput(obj){
	var strInput = obj.value;
	for(var i=0;i<strInput.length;i++){
		if((numericChars.indexOf(strInput.charAt(i)) == -1)&&(characters.indexOf(strInput.charAt(i)) == -1)&&(whitespace.indexOf(strInput.charAt(i)) == -1)){
			return false;
			}				
		}
	return true;
	}
	
function openItemWindow(ctlNames, submitForm, path, focusCtl, itemType, typeMode){
	var pageProperty ="left=50,top=50,width=500,height=400,menubar=0,toolbar=0,statusbar=0,scrollbars=1,resizable=1";
	if ((path == undefined) || (path == "")) 
		var pageUrl = "../Common/frmItemSearch.aspx?submitForm="+submitForm+"&ctlNames="+ctlNames+"&focusCtl="+focusCtl+"&itemType="+itemType+"&typeMode="+typeMode;					
	else
		var pageUrl = path + "Common/frmItemSearch.aspx?submitForm="+submitForm+"&ctlNames="+ctlNames+"&focusCtl="+focusCtl+"&itemType="+itemType+"&typeMode="+typeMode;	
	
		window.open(pageUrl,'NEW_WIND',pageProperty);
	}


function openVendorWindow(ctlNames, submitForm, path, focusCtl ,vendorType){		
	var pageProperty ="left=50,top=50,width=500,height=400,menubar=0,toolbar=0,statusbar=0,scrollbars=0,resizable=1";
	if ((vendorType == undefined) || (vendorType == ""))
		var strVendorType = 'NULL';
		else
		var strVendorType = vendorType;
		
	if ((path == undefined) || (path == "")) 
		var pageUrl = "../Common/frmVendorSearch.aspx?submitForm="+submitForm+"&ctlNames="+ctlNames+"&focusCtl="+focusCtl+"&vendorType="+strVendorType;					
	else
		var pageUrl = path + "Common/frmVendorSearch.aspx?submitForm="+submitForm+"&ctlNames="+ctlNames+"&focusCtl="+focusCtl+"&vendorType="+strVendorType;	

	window.open(pageUrl,'NEW_WIND',pageProperty);
	}

function openWorkFlowWindow(reqId, path){
	var pageProperty ="left=50,top=50,width=500,height=400,menubar=0,toolbar=0,statusbar=0,scrollbars=1,resizable=1";
	if ((path == undefined) || (path == "")) 
		var pageUrl = "../workflow/frmViewPath.aspx?req_id="+reqId;					
	else
		var pageUrl = path + "Common/workflow/frmViewPath.aspx?req_id="+reqId;	
	
		window.open(pageUrl,'NEW_WIND',pageProperty);
	}	

function checkLength(object, maxLength){
	var strValue = object.value;
	if (strValue.length >= parseFloat(maxLength)){
		window.event.keyCode = 0;
		}	
	}

	