// This function is used to validate postcode.
function postcodeValidation(strpostcode)
{	
	var validPostCode = false;
	strpostcode = Trim(strpostcode);
	if (strpostcode.indexOf(' ') > -1)
	{
		var arrValues	= strpostcode.split(" ");
		var firstPart = arrValues[0];
		var secPart = arrValues[1];
		
		var lng = firstPart.length;
		switch(lng)
		{	
			case 2:	
			{		
				if (IsCharactor(firstPart.charAt(0))== true)
				{
					if (IsNumeric(firstPart.charAt(1)) == true)
						validPostCode = true;
					else
						validPostCode = false;
				}
				else
						validPostCode = false;
				break;
			}
			case 3:
			{
				if (IsCharactor(firstPart.charAt(0))== true)
				{
					/*if (IsNumeric(firstPart.charAt(2))== true)
						validPostCode = true;
					else
						validPostCode = false;*/
					validPostCode = true;
				}
				else
					validPostCode = false;
				break;
			}
			case 4:
			{
				if (IsCharactor(firstPart.charAt(0))== true)
				{
					if (IsCharactor(firstPart.charAt(1))== true)
						{
							if (IsNumeric(firstPart.charAt(2)) == true)
								validPostCode = true;
							else
								validPostCode = false;
						}
					else
						validPostCode = false;
				}
				else
						validPostCode = false;
				break;
			}
			default:
			{
				validPostCode = false;
				break;  
			}
		}
			
		//Check Second Part 
		if (validPostCode == true)
		{
			var lng = secPart.length;
			switch(lng)
			{	
				case 3:
				{
					if (IsNumeric(secPart.charAt(0)) == true)
					{
						if (IsCharactor(secPart.charAt(1))== true) 
						{
							if (IsCharactor(secPart.charAt(2)) == true)
								validPostCode = true;
							else
								validPostCode = false;
						}
						else
							validPostCode = false;
					}
					else
							validPostCode = false;
					break;
				}
				default:
				{
					validPostCode = false;
					break;  
				}	
			}
		}
	}	
	return validPostCode;
}
		
		//This is funciton is used to validate textarea length
		function ValidateTextLength(maxLength)
		{
			var obj = event.srcElement;
			var val = obj.value;
			if(val.length > maxLength)
			{
				obj.value = val.substr(0,maxLength);
			}	
		}
// This function is used to trap key press event.
function KeySignedIntegerValidate(maxlng) 
{	
	var el = event.srcElement;
	if (event.keyCode ==45)
	{
		if(el.value.length == 0)
			event.returnValue = true;
		else
			event.returnValue = false;
	}
	else
	{
		if ((event.keyCode < 48) ||(event.keyCode > 57)) 
			event.returnValue = false;
		else
			if (el.value.charAt(0)=='-')
				{if(el.value.length > maxlng)
					event.returnValue = false;}
			else
				if(el.value.length >= maxlng)
					event.returnValue = false
	}
}

function KeySignedDecimalValidate(maxlngIntPart) 
{	
	var el = event.srcElement;
	var chrsign = "-";
	
	if (event.keyCode ==45)
	{
		if(el.value.indexOf(chrsign)>-1)
			event.returnValue = false;
		else
			event.returnValue = true;
	}
	else
	{
		if(el.value.indexOf(chrsign)>-1)
			maxlngIntPart = maxlngIntPart + 1;
		if ((event.keyCode < 46) ||(event.keyCode > 57)) 
			event.returnValue = false;
		else
		{
			var el = event.srcElement;
			var num =".";
			for (var intLoop = 0; intLoop < el.value.length; intLoop++)
			{	
				if (el.value.indexOf(num)>-1 && event.keyCode == 46)
				{	
					event.returnValue = false;
					break;
				}
				if(el.value.indexOf(num) <= -1)			
				{	
					if(el.value.length  == maxlngIntPart && event.keyCode != 46 )
					{
						event.returnValue = false;
						break;
					}				
				}
			}
		}
	}
}

function KeyIntegerValidate() 
{	
	if ((event.keyCode < 48) ||(event.keyCode > 57)) 
		event.returnValue = false;
}

var obj;
var decimalPlaces;
var allowNegative;
var oldValue;
var maxIntPart;

function KeyDecimalValidate(maxlngIntPart) 
{	
	obj = event.srcElement;
	decimalPlaces = obj.maxLength - maxlngIntPart - 1 ;
	allowNegative = false;
	maxIntPart = maxlngIntPart;
	oldValue = obj.value;
	event.srcElement.onkeyup = extractNumber;

	if ((event.keyCode < 46) ||(event.keyCode > 57)||(event.keyCode == 47)) 
		event.returnValue = false;
	else
	{
		var el = event.srcElement;
		var num = el.value.indexOf(".");
		if ( num >-1 )
		{
			if(event.keyCode == 46)
			{
				event.returnValue = false;
			}	
			else
			{
				if(num > maxlngIntPart )
				{
					event.returnValue = false;
				}
			}		
							
		}
		else
		{
			if(event.keyCode != 46)
			{
				if(el.value.length  >= maxlngIntPart )
				{
					event.returnValue = false;
				}
			}				
		}
	}
}

			
		function extractNumber()
		{
		
			var num = obj.value.indexOf(".");
			if (num >  maxIntPart || (num == -1 && obj.value.length > maxIntPart  ))
			{
				obj.value = oldValue;
			}
			
			var temp = obj.value;
			// avoid changing things if already formatted correctly
			var reg0Str = '[0-9]*';
			if (decimalPlaces > 0) {
				reg0Str += '\\.?[0-9]{0,' + decimalPlaces + '}';
			} else if (decimalPlaces < 0) {
				reg0Str += '\\.?[0-9]*';
			}
			reg0Str = allowNegative ? '^-?' + reg0Str : '^' + reg0Str;
			reg0Str = reg0Str + '$';
			var reg0 = new RegExp(reg0Str);
			if (reg0.test(temp)) return true;

			// first replace all non numbers
			var reg1Str = '[^0-9' + (decimalPlaces != 0 ? '.' : '') + (allowNegative ? '-' : '') + ']';
			var reg1 = new RegExp(reg1Str, 'g');
			temp = temp.replace(reg1, '');

			if (allowNegative) {
				// replace extra negative
				var hasNegative = temp.length > 0 && temp.charAt(0) == '-';
				var reg2 = /-/g;
				temp = temp.replace(reg2, '');
				if (hasNegative) temp = '-' + temp;
			}
			
			if (decimalPlaces != 0) {
				var reg3 = /\./g;
				var reg3Array = reg3.exec(temp);
				if (reg3Array != null) {
					// keep only first occurrence of .
					//  and the number of places specified by decimalPlaces or the entire string if decimalPlaces < 0
					var reg3Right = temp.substring(reg3Array.index + reg3Array[0].length);
					reg3Right = reg3Right.replace(reg3, '');
					reg3Right = decimalPlaces > 0 ? reg3Right.substring(0, decimalPlaces) : reg3Right;
					temp = temp.substring(0,reg3Array.index) + '.' + reg3Right;
				}
			}
			
			obj.value = temp;
			
			
	}

// This function is used to show and hide the sub-lists in the TOC.
function fnFlash(oTitle)
{
// The object reference is passed as an argument and used to set the class.
// The class determines if the sub-list is displayed or not.
	
	oList=document.all[oTitle.sourceIndex + 1];
	if(oList.className=="tocItemHide"){
		oList.className="tocItemShow";		

	}
	else{
		oList.className="tocItemHide";
	}
}

function Trim(Value)
{
	var objRE=/^\s+|\s+$/gi;	
	Value = Value.replace(objRE,"");
	objRE = /\s{2,}/gi;
	return Value.replace(objRE," ");
}

	var whitespace =" \t\n\r ";
	//*********************************************************************
	//* Function:	 IsNull 
	//* Description: Returns true if field value is empty or null
	//*				 False if the field value is not empty.
	//*******************************************************************
	function IsNull(Text)
	{
		Text = Trim(Text);
		return (!(Text.length));
	}
	
	// function for checking empty filed

		function isEmpty(str)
		{  
			return ((str == null) || (str.length == 0))
		}

		// end of function
	//*********************************************************************
	//* Function:	 isValidDate 
	//* Description: Returns true if field value is a float number
	//*				 False otherwise
	//*******************************************************************
	function  isValidDate(str)
				{
					try
					{
						var rE=/((\d{1}|\d{2})(\/|\.)(\d{1}|\d{2})(\/|\.)\d{4})$/,rS=/ /,rN=/\./;
						var arrDate;
					
						if(!rE.test(str)||rN.exec(str)||rS.exec(str))
							return false;
						else
						{
							arrDate=str.split("/")		
							arrDate[0]=parseInt(arrDate[0],10);
							arrDate[1]=parseInt(arrDate[1],10);
							arrDate[2]=parseInt(arrDate[2],10);
							if(!(arrDate[2]>1753&&arrDate[2]<=9999)||arrDate[1]==0||arrDate[0]==0) return false;
							if(daycount(arrDate[2],arrDate[1])>=arrDate[0]) return true;
						}
						return false;
			
					}catch(e)
					{
					alert(e.description);
					}
				}	

	//*********************************************************************
	//* Function:	 daycount 
	//* Description: Returns no of day per month
	//*				 False otherwise
	//*******************************************************************
				
	function daycount(Year,Month)
	{
		try
		{
			var arrDay=new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
			if(Month==2&&((Year%100==0 && Year%400==0)||(Year%100!=0 && Year%4==0))) 
				return 29;
			return arrDay[Month];
		}catch(e)
		{
		alert(e.description);
		}		
	}
	
	//****************************************************************************************
	//* Function:	 IsCharactor 
	//* Description: Returns true if the input string contains only
	//*				 0-9, a-z, A-Z  otherwise false.
	//*				 Used to validate the Alpha Numeric fields.
	//*****************************************************************************************
	function IsCharactor(Field)
	{
		var objAddressPattern = /[^a-zA-Z ]{1,}/
		var blnRetVal = true;	
		blnRetVal = (!objAddressPattern.test(Field));
		return blnRetVal;
	}	
				
	//****************************************************************************************
	//* Function:	 IsAlphaNumeric 
	//* Description: Returns true if the input string contains only
	//*				 0-9, a-z, A-Z  otherwise false.
	//*				 Used to validate the Alpha Numeric fields.
	//*****************************************************************************************
	function IsAlphaNumeric(Field)
	{
		var objAddressPattern = /[^a-zA-Z0-9 ]{1,}/
		var blnRetVal = true;	
		blnRetVal = (!objAddressPattern.test(Field));
		return blnRetVal;
	}	
	
	//****************************************************************************************
	//* Function:	 IsVarchar 
	//* Description: Returns true if the input string contains only
	//*				 0-9, a-z, A-Z ? otherwise false.
	//*				 Used to validate the Alpha Numeric fields.
	//*****************************************************************************************
	
	function IsVarchar(Field)
	{
		var objAddressPattern = /[^a-zA-Z0-9? ]{1,}/
		var blnRetVal = true;	
		blnRetVal = (!objAddressPattern.test(Field));
		return blnRetVal;
	}	

	//****************************************************************************************
	//* Function:	 IsNumeric 
	//* Description: Returns true if the input string is a valid integer otherwise false.
	//*				 Does not allow negative numbers.
	//*****************************************************************************************
	function IsNumeric(Field) 
	{
		
			
		var objRE = new RegExp("\\d*");	
		var arrMatches = objRE.exec(Field);
		var blnSuccess = (arrMatches != null && Field == arrMatches[0]);    
		return blnSuccess;
	}
	//****************************************************************************************
	//* Function:	 IsNumeric 
	//* Description: Returns true if the input string is a valid integer otherwise false.
	//*				 Does not allow negative numbers.
	//*****************************************************************************************
	function IsSignedNumeric(Field) 
	{
		
			
		var objRE = new RegExp("-?\\d*");	
		var arrMatches = objRE.exec(Field);
		var blnSuccess = (arrMatches != null && Field == arrMatches[0]);    
		return blnSuccess;
	}
	//****************************************************************************************
	//* Function:	 CheckEmail 
	//* Description: Returns true if the input string is a represents a valid email otherwise false.
	//*				 e.g. abc@yahoo.co.in 
	//*****************************************************************************************
	function CheckEmail(Field) 
	{
			    
		var objRE = new RegExp("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");	
		var arrMatches = objRE.exec(Field);
		var blnSuccess = (arrMatches != null && Field == arrMatches[0]);    
		return blnSuccess;
	}
	//****************************************************************************************
	//* Function:	 IsValidOfficePhone 
	//* Description: Returns true if the input string is a represents a valid OfficePhone otherwise false.
	//*				 e.g. +44 1723 232 323 
	//*****************************************************************************************

	function IsValidOfficePhone(Field)
	{
		var objAddressPattern = /^[0-9\-\+\\\/\(\)]*$/
		var blnRetVal = true;	
		blnRetVal = objAddressPattern.test(Field);
		if(blnRetVal)
		{
			var objRE=/[^0-9]*/gi;	
			Field = Field.replace(objRE,"");
			if(Field.length <6 )
				blnRetVal = false;
		}
		return blnRetVal;
	}
	//****************************************************************************************
	//* Function:	 ValidMobile 
	//* Description: Returns Stripped string if the input string is a represents a valid Mobile number otherwise false.
	//*				 e.g. +44 (0) 723 232 323 
	//*****************************************************************************************

	function ValidMobile(Field)
	{
		var objAddressPattern = /^[0-9\-\+\\\/\(\)]*$/
		var blnRetVal = true;	
		blnRetVal = objAddressPattern.test(Field);
		if(blnRetVal)
		{
			var objRE=/(\(0\))*/gi;	
			Field = Field.replace(objRE,"");
			objRE=/[^0-9]*/gi;	
			Field = Field.replace(objRE,"");
			if(Field.length < 11 || Field.length > 15  )
				return false;
			objAddressPattern = /^(0|44)7/
			blnRetVal = objAddressPattern.test(Field);
			if(blnRetVal)
				return Field;
		}
		return false;
	} 
	//****************************************************************************************
	//* Function:	 ValidFax 
	//* Description: Returns Stripped string if the input string is a represents a valid Fax number otherwise false.
	//*				 e.g. +44 (0) 723 232 323 
	//*****************************************************************************************
	
	function ValidFax(Field)
	{
		var objAddressPattern = /^[0-9\-\+\\\/\(\)]*$/
		var blnRetVal = true;	
		blnRetVal = objAddressPattern.test(Field);
		if(blnRetVal)
		{
			var objRE=/[^0-9]*/gi;	
			Field = Field.replace(objRE,"");
			if(blnRetVal)
				return Field;
		}
		return false;
	} 


//****************************************************************************************
//* Function:	 IsValidFloat
//* Description: Returns true if the input string is a valid real number otherwise false.
//*				 Does not allow negative numbers. For currency , dows not take care of currency symbol
//*****************************************************************************************
function IsValidFloat(Field) 
{    
    
    var objRE = new RegExp("\\d*[.]{0,1}\\d{1,2}");	
    var arrMatches = objRE.exec(Field);
    var blnSuccess = (arrMatches != null && Field == arrMatches[0]);    
    return blnSuccess;
}
//****************************************************************************************
//* Function:	 IsValidFloat
//* Description: Returns true if the input string is a valid real number otherwise false.
//*				 Does not allow negative numbers. For currency , dows not take care of currency symbol
//*****************************************************************************************
function IsValidSingleDecimal(Field) 
{    
    
    var objRE = new RegExp("\\d*[.]{0,1}\\d");	
    var arrMatches = objRE.exec(Field);
    var blnSuccess = (arrMatches != null && Field == arrMatches[0]);    
    return blnSuccess;
}	
//****************************************************************************************
//* Function:	 fnClose
//* Description: Close The Window
//*				 
//*****************************************************************************************
function fnClose()
{		
	window.close();				
}

/********************************************************************************
* Purpose: This function is used to validate To and  From Dates    
* Auth:    Sibaram Pala
* Date:    01-Apr-2004  
* History: Auth     Date           Description
--------  --------  ----------------------------------------------------
   
******************************************************************************/
function fnValidateToFrom(strToDate,strFromDate)
{
 var arrValues= strToDate.split("/");  
 var dtTo = new Date(arrValues[2],arrValues[1]-1,arrValues[0]); 
 dtTo.setHours(0,0,0,0); 
 var arrValues1= strFromDate.split("/");   
 var dtFrom = new Date(arrValues1[2],arrValues1[1]-1,arrValues1[0]); 
 dtFrom.setHours(0,0,0,0);
 if (dtTo.valueOf() >= dtFrom.valueOf())
 {  
  return true;
 }
 else
 { 
  return false;
 }  
}		

// function to check the whitespace

function isWhitespace(str)
{    var i;
	 var flag

 	  // Is s empty?
 	  if (isEmpty(str)) return true;		
 	   // Search through string's characters one by one
 	   // until we find a non-whitespace character.
 	   // When we do, return false; if we don't, return true.
 	   for (i = 0; i < str.length; i++)
 	   {   
 	       // Check that current character isn't whitespace.
 	       var c = str.charAt(i);

		   if (whitespace.indexOf(c) == -1)
		   		return false
 	   }	
 	   // All characters are whitespace.
		    return true;
}

// end of function

//*********************************************************************
//* Function:	 Trim
//* Description: Strips off the  leading & trailing white spaces and 
//*				replaces inner multiple spaces with single space
//*******************************************************************
function Trim(Value)
{
	var objRE=/^\s+|\s+$/gi;	
	Value = Value.replace(objRE,"");
	objRE = /\s{2,}/gi;
	return Value.replace(objRE," ");
}

//****************************************************************************************
//* Function:	 IsValidPhone
//* Description: Returns true if the input string is a valid Phone number otherwise false.
//*				 
//*****************************************************************************************
function IsValidPhone(Field) 
{    
    
    var objRE = new RegExp("\\d{3}\\s\\d{4}\\s\\d{4}");
    var arrMatches = objRE.exec(Field);
    var blnSuccess = (arrMatches != null && Field == arrMatches[0]);    
    return blnSuccess;
}		

//****************************************************************************************
//* Function:	 IsValidUKPhone
//* Description: Returns true if the input string is a valid Phone number otherwise false.
//*				 0-9, a-z, A-Z  otherwise false.
//*				 Used to validate the Alpha Numeric fields.
//*****************************************************************************************
function IsValidUKPhone(Field)
{
	var objAddressPattern = /[^0-9+()\/-]{0,1}/
	 
	//var objAddressPattern = /d{3}(-(\d{4}|\d{2}))?/
	var blnRetVal = true;	
	blnRetVal = (!objAddressPattern.test(Field));
	return blnRetVal;
}	

//****************************************************************************************
//* Function:	 IsAlphabet 
//* Description: Returns true if the input string contains only
//*				 a-z, A-Z  otherwise false.
//*				 Used to validate the Alpha Numeric fields.
//*****************************************************************************************
function IsAlphabet(Field)
{
	var objAddressPattern = /[^a-zA-Z]{1,}/
	var blnRetVal = true;	
	blnRetVal = (!objAddressPattern.test(Field));
	return blnRetVal;
}
/*********************************************************************/
// This Function calculates difference between two dates
// Return  0 if todate and fromdate is same
/*********************************************************************/
function fnDateDiffCal(fday,fmonth,fyear,sday,smonth,syear)
{
	var lclDtDiff;
	var lclDifference;
	lclCurrDtDiff=Date.UTC(syear,smonth,sday,0,0,0) - Date.UTC(fyear,fmonth,fday,0,0,0); 
	lclCurrDifference = lclCurrDtDiff/1000/60/60/24;
	alert(lclCurrDifference);	
	return(lclCurrDifference);
	
} 

//Function to format the date from DD/MM/YYYY to MM/DD/YYYY
function FormatDate(strValue)
{
	var arrValues			= strValue.split("/");
	var strFormattedDate	= arrValues[1] + "/" + arrValues[0] + "/" + arrValues[2];
	return strFormattedDate;
}

function isFinYear(str)
{
	var rE = /([0-9][0-9][0-9][0-9][-][0-9][0-9][0-9][0-9])$/;

	if(rE.test(str))

	{
		var arrDate = str.split("-");

		if ((arrDate[1]<arrDate[0])||((arrDate[1]- arrDate[0]) !=1))
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		return false;
	}
}

function OpenWindow(strURL,strWindow)
{
	window.open(strURL,strWindow,"location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes");
}

function OpenReportWindow(strURL)
{
	OpenWindow(strURL,"Report");
} 

function openPopup(strPopupName,strPopupValue)
{	
	//window.open('frmSearch.aspx?name='+strPopupName +strPopupValue,'mywindow','height=450,width=600,status=1, resizable=0,top=100,left=200');					
	var retVal = window.showModalDialog('frmSearch.aspx?name='+strPopupName +strPopupValue,'','dialogWidth:720px;dialogHeight:430px;status:no;help:no');		
	if(retVal)
	{	
		document.getElementById('txtSearchId').value = retVal;	
		if(retVal != 'ADD')
			document.forms[0].submit();
	}
	return false;
}
  
function openAuditPopup(strPopSource)
{
	window.open(strPopSource,'mywindow','height=180,width=600,status=1, resizable=0,top=200,left=300');					
	return false;
}

	function fnLinkClicked()
	{
		var strAns;
		var intDirtyFlag;
		try
		{
			/*if(intDirtyFlag==1)
			{
				strAns = confirm(C_UNSAVE_MESSAGE);
			}
			if (strAns == false)
			{
				return false;
			}
			intDirtyFlag=0;
			return true;*/
			
			if(document.getElementById("hEditFlag").value=="0")
			{
				
				if(gLink == "lnkEdit" || gLink=="lnkSearch")
				{
					return false;
				}
				
			}
			return true;
			
		}
		catch(e)
		{	
			alert(e.description);
		}	
	}		




		/********************************************************************************
		* Purpose: Following functions are micellaneous for link mose over and out behavior
		* Auth:    
		* Date:    29-9-2004 	
		* History: Auth				Date	          Description
		--------  --------  ----------------------------------------------------
					     29-09-04			Created	
		*******************************************************************************/

		function fnMouseOver(obj)
		{
			try
			{
				eval('document.all.' + obj).className="LinkMouseOverCtrl";
			}
			catch(e)
			{
				alert(e.description);
			}	
		}

		function fnMouseOut(obj)
		{
			try
			{
				eval('document.all.' + obj).className="LinkInternalExternal";
			}
			catch(e)
			{
				alert(e.description);
			}	
		}
		
		
		
		function fnMouseOverSelected(obj,LinkName)
		{		
			
			try
			{
				if(obj==LinkName)
					eval('document.all.' + obj).className="LinkMouseOverSelected";
				else
					eval('document.all.' + obj).className="LinkMouseOverCtrl";
					
					
			}
			catch(e)
			{
				alert(e.description);
			}	
		}
				
		function fnMouseOutSelected(obj,LinkName)
		{
					
			try
			{
				if(obj==LinkName)
					eval('document.all.' + obj).className="LinkSelected";
				else
					eval('document.all.' + obj).className="LinkInternalExternal";
					
					
			}
			catch(e)
			{
				alert(e.description);
			}	
		}
		
		
		
		function fnOpenLink(link)
		{
			try
			{
				switch(link)
				{
					case 1:
						document.location.href="HomePage.aspx";
					break;
					default:
					
					break;   
				}
			}
			catch(e)
			{	
				alert(e.description);		
			}	
		}
		

/*  tab.cs */		

	/********************************************************************************
		* Purpose: delete confirmation confirmation
		* Auth:  Anil Kumar
		* Date:    27-12-2005	
		* History: Auth				Date	          Description
		--------  --------  ----------------------------------------------------
					 27-12-2005			Created	
		*******************************************************************************/
		function DeleteConfirmation()
		{						
				if(confirm("Do you want to delete this record ?"))
				{
					return true;
				}
				else
				{
					return false;	
				}
		}
		
		

		/********************************************************************************
		* Purpose: confirmation for closing a screen
		* Auth:    
		* Date:    27-12-2005	
		* History: Auth				Date	          Description
		--------  --------  ----------------------------------------------------
					 27-12-2005			Created	
		*******************************************************************************/
		function CloseConfirmation()
		{						
				if(confirm("Do you want to close the screen?"))
				{
					return true;
				}
				else
				{
					return false;	
				}
		}
	


/***************************/
function round_decimals(original_number, decimals) 
{
    var result1 = original_number * Math.pow(10, decimals);
    var result2 = Math.round(result1);
    var result3 = result2 / Math.pow(10, decimals);
    return pad_with_zeros(result3, decimals);
}

function pad_with_zeros(rounded_value, decimal_places) 
{
    // Convert the number to a string
    var value_string = rounded_value.toString();
    
    // Locate the decimal point
    var decimal_location = value_string.indexOf(".");

    // Is there a decimal point?
    if (decimal_location == -1) 
    {        
        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0;
        
        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : "" ;
    }
    else 
    {
        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1 ;
    }
    
    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length;
    
    if (pad_total > 0) 
    {        
        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++) 
            value_string += "0"  ;
        }
    return value_string ;
}

//*******************
// Progress bar
// Added by Kalpana on 21/06/2006
//*******************
/*
	var duration=3 // Specify duration of progress bar in seconds
		var _progressWidth = 50;	// Display width of progress bar

		//var _progressBar = new String("");
		var _progressBar = new String("||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||");
		var _progressEnd = 10;
		var _progressAt = 0;


		// Create and display the progress dialog.
		// end: The number of steps to completion
		function ProgressCreate(end) {
			// Initialize state variables
			_progressEnd = end;
			_progressAt = 0;

			// Move layer to center of window to show
			if (document.all) {	// Internet Explorer
				progress.className = 'show';
				progress.style.left = (document.body.clientWidth/2) - (progress.offsetWidth/2);
				progress.style.top = document.body.scrollTop+(document.body.clientHeight/2) - (progress.offsetHeight/2);
			} else if (document.layers) {	// Netscape
				document.progress.visibility = true;
				document.progress.left = (window.innerWidth/2) - 100;
				document.progress.top = pageYOffset+(window.innerHeight/2) - 40;
			} else if (document.getElementById) {	// Netscape 6+
				document.getElementById("progress").className = 'show';
				document.getElementById("progress").style.left = (window.innerWidth/2)- 100;
				document.getElementById("progress").style.top = pageYOffset+(window.innerHeight/2) - 40;
			}

			ProgressUpdate();	// Initialize bar
		}

		// Hide the progress layer
		function ProgressDestroy() {
			// Move off screen to hide
			if (document.all) {	// Internet Explorer
				progress.className = 'hide';
			} else if (document.layers) {	// Netscape
				document.progress.visibility = false;
			} else if (document.getElementById) {	// Netscape 6+
				document.getElementById("progress").className = 'hide';
			}
		}

		// Increment the progress dialog one step
		function ProgressStepIt() {
			_progressAt++;
			if(_progressAt > _progressEnd) _progressAt = _progressAt % _progressEnd;
			ProgressUpdate();
		}

		// Update the progress dialog with the current state
		function ProgressUpdate() {
			var n = (_progressWidth / _progressEnd) * _progressAt;
			if (document.all) {	// Internet Explorer
				var bar = dialog.bar;
 			} else if (document.layers) {	// Netscape
				var bar = document.layers["progress"].document.forms["dialog"].bar;
				n = n * 0.55;	// characters are larger
			} else if (document.getElementById){
						var bar=document.dialog.bar
				}
			var temp = _progressBar.substring(0, n);
			bar.value = temp;
		}

		// Demonstrate a use of the progress dialog.
		function Demo() {			
			ProgressCreate(10);
			window.setTimeout("Click()", 100);
		}

		function Click() {
			if(_progressAt >= _progressEnd) {
				ProgressDestroy();
				return;
			}
			ProgressStepIt();
			window.setTimeout("Click()", (duration-1)*100/10);
		}

		function CallJS(jsStr) { //v2.0		
			return eval(jsStr)
		}

		// Create layer for progress dialog
			document.write("<span id=\"progress\"  bgcolor=\"#6699cc\" class=\"hide\">");
			document.write("<FORM name=dialog>");
			document.write("<TABLE border=0  bgcolor=\"#6699cc\">");
			document.write("<TR><TD  ALIGN=\"center\">");
			//document.write("Progress<BR>");
			document.write("<input bgcolor=\"#6699cc\"  type=text name=\"bar\" size=\"" + _progressWidth/2 + "\"");
			if(document.all||document.getElementById) 	// Microsoft, NS6
				document.write(" bar.style=\"color:#6699cc;\">");
			else	// Netscape
				document.write(">");
			document.write("</TD></TR>");
			document.write("</TABLE>");
			document.write("</FORM>");
			document.write("</span>");
			
			ProgressDestroy();	// Hides

*/			
			// **********************************************************************************
//******************