	
			
//////////////////////////////////////////////////////////////////////////////////////////////
// This file contains the javascript functions that are used by the application pages.		//
// It does not contain page specific functions.												//
// Creator: Aditya Mahajan																	//
//////////////////////////////////////////////////////////////////////////////////////////////

	// Below defined are the global javascript variables.
	var g_AllowJavaScript = true;	// To disable Javascript throughout the system
	var g_ShowIndividualError = true;	// If True, then every function will show its own Error Msg, If False then combined error msg is shown.
	var g_ErrMsg = "";	// If g_ShowIndividualError = True, then all error msg will get concatenated into this string for one time display.

//////////////////////////////////////////////////////////////////////////////////////////////

	function RemoveCharsNoDecimal(ObjControl)
	{
		// Remove all occurence of character instances from the string & returns only integer values with NO decimal part.
		// Date:12 March 2004
		// Creator: Aditya Mahajan
	
		var text;
		text = ObjControl.value;
		
		for (var i = 0; i < text.length; i++)
		{
		    var c = text.charAt(i);
			if(!IsDigit(c) && !((c == '+' || c == '-') && i == 0))
			{	
			    // Check for each digit, whether its an integer or not.
			    // If an error is found in the value, return the substring that is correct.
			    ObjControl.value = text.substr(0,i);
			    ObjControl.focus();
			    return false;
			}
		}
		return true;
		/*
			//Below code commented. future use undetermined
			When the entered digits are all integers, then to check if length doesn't exceed the allowed limit.
			 
				LabelId: id of label associated with the textbox;
				Length= desired length
				text=ObjControl.value;	// Refresh the value of text since the text may have been changed.
				if (text.length > Length)
				{
					ObjControl.value = text.substr(0,Length);
					var LabelName = document.getElementById(LabelId).innerText
					ShowMsg("Maximum " + Length + " digits allowed for " + LabelName);
					return;
				}
		*/
	}

		/////////////////////////

	function RemoveCharsAllowDecimal(ObjControl)
	{
		// Remove all character instances from the string & returns only float values.
		// Date:12 March 2004
		// Creator: Aditya Mahajan
		
		var text;
		text = ObjControl.value;
		var iDotCnt = 0;
		var iDigitCount;
		for (iDigitCount = 0; iDigitCount < text.length; iDigitCount++)
		{
			if (IsDot(text.charAt(iDigitCount)))
			{
				iDotCnt++;
			} 
			if(!(IsDigitOrDot(text.charAt(iDigitCount)) && iDotCnt<2))
			{
			 	ObjControl.value = text.substr(0, iDigitCount);
			 	ObjControl.focus();
			 	//break;
			 	return false;
			} 
		}
		return true;
	}	

		/////////////////////////

	function IsDigitOrDot(chr)
	{	
		// Checks if the character is a decimal point or a integer. returns false if it isn't.
		// Date:12 March 2004
		// Creator: Aditya Mahajan
	
		if (((chr < "0") || (chr > "9")) && (chr != "."))
		{
			return false;
		}
		return true;
	}		

		/////////////////////////

	function IsDot(chr)
	{
		// Checks if the character is decimal point. returns false if it is not.
		// Date:12 March 2004
		// Creator: Aditya Mahajan

		if (chr == ".")
			return true;
		else
			return false;
	}
		
		/////////////////////////
		
	function IsDigit(chr)
	{
		// Checks if the character is an Integer string. returns false if it isnt.
		// Date:12 March 2004
		// Creator: Aditya Mahajan

		if ((chr < "0") || (chr > "9"))
			return false;
		else 
			return true;
	}
		
		/////////////////////////
		
	function Trim(objValue)
	{
		// Trims the blank space from the start and end of string
		// Source: MedAppz Old

		var lRegExp = /^\s*/;
		var rRegExp = /\s*$/;
		objValue = objValue.replace(lRegExp, ""); //Perform LTRim
		objValue = objValue.replace(rRegExp, ""); //perform RTrim
		return objValue; 
	}
		
		/////////////////////////
		
	function LTrim(objValue)
	{
		// Trims the blank space from the start of string
		// Source: MedAppz Old

		var lRegExp = /^\s*/;
		objValue = objValue.replace(lRegExp, ""); //Perform LTRim
		return objValue; 
	}
		
		/////////////////////////

	function RTrim(objValue)
	{
		// Trims the blank space from the end of string		
		// Source: MedAppz Old

		var rRegExp = /\s*$/;
		objValue = objValue.replace(rRegExp, ""); //perform RTrim
		return objValue; 
	}

		/////////////////////////
		
	function IsEqual(ObjValue, CompareValue)
	{
		// Checks whether the ObjValue equals the CompareValue.
		// Creator: Aditya Mahajan

		if (ObjValue == CompareValue)
		{
			return true;	//Equal
		}
		else
		{
			return false;	//Not equal
		}
	}
		
		/////////////////////////
		
	function IsLessThan(ObjValue, CompareValue)
	{
		// Checks whether the ObjValue equals the CompareValue.
		// Creator: Aditya Mahajan

		if (ObjValue < CompareValue)
		{
			return true;	// Less
		}
		else
		{
			return false;	// Not Less
		}
	}
		
		/////////////////////////
		
	function IsGreaterThan(ObjValue, CompareValue)
	{
		// Checks whether the ObjValue equals the CompareValue.
		// Creator: Aditya Mahajan

		if (ObjValue > CompareValue)
		{
			return true;	// Greater
		}
		else
		{
			return false;	// Not Greater
		}
	}
		
		/////////////////////////
		
	function IsDateEqual(DateValue1, DateValue2)
	{
		// Checks whether two date are equal.
		// Creator: Aditya Mahajan
			
		var DaysDiff;
		var Date1 =  new Date(DateValue1);
		var Date2 =  new Date(DateValue2);
//		var Date1 = convertDateToStandard(DateValue1)
//		var Date2 = convertDateToStandard(DateValue2)
		DaysDiff =  Math.floor((Date1.getTime() - Date2.getTime())/(1000*60*60*24));
		if(DaysDiff == 0)
			return true;
		else
			return false;
	}
		
		/////////////////////////
		
	function IsDateLess(DateValue1, DateValue2)
	{
		// Checks whether the first date is less than the second date
		// Creator: Aditya Mahajan

		var DaysDiff;
		var Date1 =  new Date(DateValue1);
		var Date2 =  new Date(DateValue2);
//		var Date1 = convertDateToStandard(DateValue1)
//		var Date2 = convertDateToStandard(DateValue2)
		DaysDiff =  Math.floor((Date1.getTime() - Date2.getTime())/(1000*60*60*24));
		if(DaysDiff < 0)
			return true;
		else
			return false;
	}
		
		/////////////////////////
		
	function IsDateGreater(DateValue1, DateValue2)
	{
		// Checks whether the first date is greater than the second date
		// Creator: Aditya Mahajan
		
		var DaysDiff;
		//alert('Date 1 : ' + DateValue1 + ' Date 2 : ' + DateValue2);
		var Date1 =  new Date(DateValue1);
		var Date2 =  new Date(DateValue2);
//		var Date1 = convertDateToStandard(DateValue1);
//		var Date2 = convertDateToStandard(DateValue2);
		//alert('Date 1 : ' + Date1 + ' Date 2 : ' + Date2);
		DaysDiff =  Math.ceil((Date1.getTime() - Date2.getTime())/(1000*60*60*24));
		if(DaysDiff > 0)
			return true;
		else
			return false;
	}
		
		
		
		function convertDateToStandard(dtDDMMYY)
		{
		    dtDDMMYY =  dtDDMMYY.split("/");
		    var dtMMDDYYYY = new Date(dtDDMMYY[1] + '/' + dtDDMMYY[0] + '/' + dtDDMMYY[2]);
		    return(dtMMDDYYYY);
		}
		function convertDateToDDMMYY(dtMMDDYY)
		{
		    var dtDDMMYY =  dtMMDDYY.getDate() + '/' + (dtMMDDYY.getMonth()+1) + '/' + dtMMDDYY.getFullYear();
		    return(dtDDMMYY);
		}
		/////////////////////////
		
		function MakeControlInvisible()
		{
			// Takes the array containing the names of controls on the page to be made invisible and hides them.
			// InvisibleControlsList is generated by the aspx codebehind.
			// Creator: Aditya Mahajan;
			// Date: 10 June 2004
		
			var iCtr;
			var Obj;			
			for(iCtr = 0; iCtr < InvisibleControlsList.length ; iCtr++)
			{
				Obj = document.getElementById(InvisibleControlsList[iCtr]);
				if(Obj != null)
				{	// Only if a particular control exists on the page.
					Obj.style.display="none";
				}
			}
		}

		/////////////////////////

		function MakeControlDisable()
		{
			// Takes the array containing the names of controls on the page to be diabled and hides them.
			// DisableControlsList is generated by the aspx codebehind.
			// Creator: Aditya Mahajan;
			// Date: 10 June 2004
		
			var iCtr;
			var Obj;
			var IsComboBox = null;
			for(iCtr = 0; iCtr < DisableControlsList.length ; iCtr++)
			{
				//alert(" DisableControlsList[" + iCtr + "] = " + DisableControlsList[iCtr]);
				Obj = document.getElementById(DisableControlsList[iCtr]);
				if(Obj != null)
				{	// Only if a particular control exists on the page.
					if(Obj.tagName == "A")
					{	
						//If the control is a LinkButton, it is implemented as an Anchor Tag, which is determined by Obj.tagName == "A"
						Obj.href = "javascript:void(0)";
						//Obj.removeAttribute("href")
					}
					else
					{
						// For non link tags, just disabling is enough.
						IsComboBox = DisableControlsList[iCtr].match(/_cmbSimple/g);
						if(IsComboBox == null)
						{
							Obj.disabled = true;
						}
						else
						{
							// If the combo is used then the drop down is called 'XYZ_cmbSimple' where '_cmbSimple' is the id for 
							// dropdown portion, which needs to be disabled by the below line
							Obj.enabled = false;
							IsComboBox = null;
						}
					}	// End of if(Obj.tagName == "A")
				}	// End if(Obj != null)
			}
		}
        
        
        function createDate(objDate)
        {
            return(objDate.getDate() + '/' + (objDate.getMonth()+1) + '/' + objDate.getFullYear());
        }
		/////////////////////////

		function round(number,X)
		{
			// calculate the value of the given float number to the provided number of significance- X.
			// rounds number to X decimal places, defaults to 2
			X = (!X ? 2 : X);
			return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
		}

		/////////////////////////

		function change_index(objC)
		{
			// Written by Satya for the combo drop down control
			var flag="false";
			for(x=0;x<objC.options.children.length;x++)
			{
				if(objC.selectedIndex=="-1")
				{
				
					if( Trim(objC.value)==Trim(objC.options[x].text) )
					{
					flag="true";
					return true;
					}
				}else
				{
					if( Trim(objC.value)==Trim(objC.options[x].value) )
					{
					flag="true";
					return true;
					}
				}				
			}
		
			if(flag=="false")
			{
				objC.value="";
				return false;
			}
											
		}
		
		function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
		}


		/////////////////////////


		/////////////////////////

