	var gEntryAllValue = "";
	var gExitAllValue = "";
	var gSaveAndExit = false;
		//-------------------------------------------------------------------------------------------------
		//function to select all check boxes in the summary page
		   function fnCheckAll(Me,MasterBox) 
		   { 
	          for (j=0; j<Me.elements.length; j++) 
	          { 
                if (Me.elements(j).type=="checkbox") 
			        Me.elements(j).checked = MasterBox.checked; 
	           } 
		   } 

		//-------------------------------------------------------------------------------------------------
		function fResizePanel(vValue)
		{						
			if (typeof(divMain) != "undefined")
			{
				vHeight = document.body.clientHeight- fGetPosTop(divMain) - 10;//- vValue;
				divMain.style.overflow = "auto";
				divMain.scrollTop = 0;
				divMain.style.height = vHeight;	
				//vHeight = document.body.clientWidth - fGetPosLeft(divMain);//- vValue;
				//divMain.style.overflow = "auto";
				//divMain.scrollLeft = 0;
				//divMain.style.width = vHeight;
				vHeight = document.body.clientHeight- fGetPosTop(divMenu) -10;
				divMenu.style.overflow = "auto";
				divMenu.scrollTop = 0;
				divMenu.style.height = vHeight;							
			}
		}

		//-------------------------------------------------------------------------------------------------
		function fGetPosTop(e)
		{
			var y;

			y = e.offsetTop;
			for (e = e.offsetParent; (e != null) && (e.tagName != "BODY"); e = e.offsetParent)
				y += e.offsetTop - ((typeof(e.scrollTop) != "undefined") ? e.scrollTop : 0);
			return y;
		}

		//-------------------------------------------------------------------------------------------------						
			function fSysOnLoad()
			{	
				if (typeof(tdTab) != "undefined")
				{
					if (typeof(OldTabN) == "undefined") alert("programming error: OldTabN is undefined");
					fBtnSetup(tdTab, "radio", false);
					if (OldTabN.value  == "")
						OldTabN.value = 0;
					setTimeout("fAppTab(" + OldTabN.value + ")", 10);	
				}	
				//fResizePanel(100);	
				if (typeof(fOnLoad) == "function")
					fOnLoad();				
				gEntryAllValue = fCheckSaved();	
				vSearch = window.location.search;
				if (vSearch.indexOf("FromAbandon=True") != -1)				
					top.frameQuery.fPopulateValuestoFrameMain();				
				//window.onresize = fResizePanel;		
			}			
			
			//-------------------------------------------------------------------------------------------------						
			function fSysOnUnLoad()
			{	
				vUrl = window.location.href.toUpperCase();
				if ((vUrl.indexOf("EDIT") != -1) || (vUrl.indexOf("NEW") != -1) || (vUrl.indexOf("DETAIL") != -1))
				{										
					gExitAllValue = fCheckSaved();		
					if (gExitAllValue != gEntryAllValue)
					{
						if (!confirm("Abondon Changes"))			
						{
							top.frameQuery.gNewFormValues = gExitAllValue;
							top.frameQuery.fLoadWhenCancelAbandon(window.location.href);	
							return false;											
						}
						else
							return true;//history.go(top.frameQuery.gNBack);
					}
					else
						return true;
				}
				else
					return true;
				return false;					
			}
			//-------------------------------------------------------------------------------------------------									
			function fCheckSaved()
			{								
				var cDlm = String.fromCharCode(2);
				var vAllValue = cDlm;
				vUrl = window.location.href.toUpperCase();
				if ((vUrl.indexOf("EDIT") != -1) || (vUrl.indexOf("NEW") != -1) || (vUrl.indexOf("DETAIL") != -1))
				{
					if (vUrl.indexOf("NEWPR") == -1)
					{
						for(j = 0; j < document.forms.length; j++)
						{
							e = document.forms[j].getElementsByTagName("input");					
							for(i = 0; i < e.length; i++)																	
								if (e[i].type != "hidden")			
									if (e[i].type == "radio")
									{
										for(k = 0; k < eval(document.forms[j].name + "." + e[i].name + ".length"); k++)
										if (eval(document.forms[j].name + "." + e[i].name + "[" + k +"].checked"))
										{
											vAllValue = vAllValue + document.forms[j].name + "." + e[i].name + "[" + k +"].checked=true" + cDlm; 																			
											break;
										}
									}
									else if (e[i].type == "checkbox")
									{									
										if (eval("typeof(" + document.forms[j].name + "." + e[i].name + "[0])") == "undefined")
										{										
											if (eval(document.forms[j].name + "." + e[i].name + ".checked"))
												vAllValue = vAllValue + document.forms[j].name + "." + e[i].name + ".checked=true" + cDlm;
											else
												vAllValue = vAllValue + document.forms[j].name + "." + e[i].name + ".checked=false" + cDlm;
										}	
										else
										{
											for(k = 0; k < eval(document.forms[j].name + "." + e[i].name + ".length"); k++)
											if (eval(document.forms[j].name + "." + e[i].name + "[" + k +"].checked"))										
												vAllValue = vAllValue + document.forms[j].name + "." + e[i].name + "[" + k +"].checked=true" + cDlm; 																			
											else
												vAllValue = vAllValue + document.forms[j].name + "." + e[i].name + "[" + k +"].checked=false" + cDlm; 																													
										}																	
									}
									else
									{								
										vAllValue = vAllValue + eval("'" + document.forms[j].name + "." + e[i].name + "'") + "=" + e[i].value + cDlm;					
										//alert(vAllValue);
									}								
													
							e = document.forms[j].getElementsByTagName("select");				
							for(i = 0; i < e.length; i++)										
								vAllValue = vAllValue + eval("'" + document.forms[j].name + "." + e[i].name + "'") + "=" + e[i].value + cDlm;
							e = document.forms[j].getElementsByTagName("textarea");	
										
							for(i = 0; i < e.length; i++)
							{				
								vVal = fStrReplace(e[i].value, "\r", "");																				
								//vVal = fStrReplace(e[i].value, "\n", "");
								vAllValue = vAllValue + eval("'" + document.forms[j].name + "." + e[i].name + "'") + "=" + vVal + cDlm;																
							}
						}
					}
					else
						vAllValue = ""
				}
				else
					vAllValue = ""
				return vAllValue;
			}
			
			//-------------------------------------------------------------------------------------------------
			function fStrReplace(s, vSub1, vSub2)
			{
				var s2, i, j;

				s2 = "";
				for (i = 0, j = 0; (i = s.indexOf(vSub1, i)) != -1; i += vSub1.length)
				{
					s2 = s2 + s.substr(j, i-j) + vSub2;
					j = i + vSub1.length;
				}
				s2 = s2 + s.substr(j);
				return s2;
			}
			//-------------------------------------------------------------------------------------------------												
			function fAppTab(vTabN)
			{
				var vHeight, i;
				
				if (typeof(divTab) != "undefined")
				{
					for (i = 0; typeof(divTab[i]) != "undefined"; i++)
						if (i != vTabN)
							divTab[i].style.display = "none";
					if (typeof(divTab[vTabN]) != "undefined")
						divTab[vTabN].style.display = "";
					fBtnCheck(tdTab[vTabN], true);
					//fSet(OldTabN, vTabN);
					OldTabN.value = vTabN;

					if (typeof(divMain) != "undefined")
					{
						//vHeight = document.body.clientHeight - fGetPosTop(divMain) - 6 - 8;
						//if (vHeight < 0)
							//vHeight = 0;
						//divMain.style.overflow = "";
						//if (divMain.offsetHeight > vHeight)
							//divMain.style.overflow = "auto";
						//divMain.style.height = vHeight;
					}
				}
			}
			//-------------------------------------------------------------------------------------------------			
			function AllowNumbersWithDot(ctrl,maxlength,digits) 
			{
				var FValue = 0;
				var result = new String();
				var numbers = "0123456789.";
				var chars = ctrl.value.split("");
				var charsDot = ctrl.value.split(".");
				if (charsDot.length<=2)
				{
					for (i = 0; i < chars.length; i++) 
						if (numbers.indexOf(chars[i]) != -1) result += chars[i];
					FValue = result;
				}
				else	
					FValue = charsDot[0] + "." + charsDot[1];
				if ((charsDot.length==2) && (charsDot[1].length>digits))	
				{
					// var DeciPart = charsDot[1].split("");
					//digits = digits - 1
					FValue = charsDot[0] + "." + charsDot[1].substr(0,digits)
					//DeciPart[0] + DeciPart[1];
				}	
				if (FValue.length > maxlength)
					ctrl.value = FValue.substr(0,maxlength);
				else	
					ctrl.value = FValue;
			}
			//-------------------------------------------------------------------------------------------------			
			//Checking for the given input is valid real number or not?
			function Allow1to9(field)
			{
				var result = new String();		
				var numbers = "0123456789";
				var chars = field.value.split("");
				for (i = 0; i < chars.length; i++) 
					if (numbers.indexOf(chars[i]) != -1) result += chars[i];
				field.value = result;
			}
function AllowFloat(field)
{
	var result = new String();		
	var numbers = "0123456789.";
	var chars = field.value.split("");
	for (i = 0; i < chars.length; i++) 
		if (numbers.indexOf(chars[i]) != -1) result += chars[i];
			field.value = result;
}
//-------------------------------------------------------------------------------------------------
			function fnActionFile(sFileName,formName,sAction)
			{	
				if (sAction=="Post")
				{
					formName.method="post";
					formName.action = sFileName;
					formName.submit();
				}	
				else
					window.location.href= sFileName;
				return false;	
			}				    
		//-------------------------------------------------------------------------------------------------
			var newPopUpWindow
			function PopUPWindow(sPageURL,sHeight,sWidth)
			{
			    var	UserScreenHgt, UserScreenWTh;
			    UserScreenHgt = screen.height - 40;
			    UserScreenWTh = screen.width - 10;
			    if (sHeight<UserScreenHgt)
			    	TPos = parseInt((UserScreenHgt- sHeight)/2);
			    else
			    	TPos =0;
			    if (sWidth<UserScreenWTh)	    	
			    	LPos = parseInt((UserScreenWTh - sWidth)/2);		
			    else
			    	LPos = 0

			    if (!newPopUpWindow || newPopUpWindow.closed)
			    {
				var sFeatures = "toolbar=no,location=no,directories=no,status=no,menubar=no," + "scrollbars=yes,resizable=yes,height=" + sHeight + ",width=" + sWidth + ",left=" + LPos + ",top=" + TPos;
				newPopUpWindow = window.open (sPageURL,"NewWind",sFeatures)                
			        if (!newPopUpWindow.opener)
			             newPopUpWindow.opener = window;
			    }
			    else
			    {
			        // window's already open, bring it to the front
			        newPopUpWindow.location = sPageURL
			        newPopUpWindow.focus() 
			    }   

			}			


//-------------------------------------------------------------------------------------------------
function fTrimDecimal(vNumber, vRadix)
{
	var vDotPos, vNumberStr;

	vNumberStr = vNumber.toString();	
	if (vNumberStr.lenth == 0)
		return "0";
	vDotPos = vNumberStr.indexOf(".");	
	if (vDotPos == "-1")
		return vNumberStr;
	if (vNumberStr.substr(vDotPos, vRadix + 1).length < 3)
		return vNumberStr.substr(0, vDotPos) + vNumberStr.substr(vDotPos, vRadix + 1) + "0";
	else
		return vNumberStr.substr(0, vDotPos) + vNumberStr.substr(vDotPos, vRadix + 1);
} 

//-------------------------------------------------------------------------------------------------
function fParseInt(vNumber)
{
		if (isNaN(parseInt(vNumber)))
			return 0;
		else
			return parseInt(vNumber);
} 

//-------------------------------------------------------------------------------------------------
function fParseFloat(vNumber)
{
		if (isNaN(parseFloat(vNumber)))
			return 0;
		else
			return fTrimDecimal(parseFloat(vNumber), 2);

} 

function fGetPosLeft(e)
{
	var x;

	x = e.offsetLeft;
	for (e = e.offsetParent; (e != null) && (e.tagName != "BODY"); e = e.offsetParent)
		x += e.offsetLeft - ((typeof(e.scrollLeft) != "undefined") ? e.scrollLeft : 0);
	return x;
}