function fnCalAge(strDD, strMM, strYYYY, objAge)
{
    if ((strDD!="")&&(strMM!="")&&(strYYYY!=""))
        objAge.value=fnComputeAge(strYYYY, strMM, strDD, "years", 0, "rounddown");
}

/*
Ultimate Age calculator script- By JavaScript Kit (http://www.javascriptkit.com)
Over 200+ free scripts here!
Credit must stay intact for use
*/
//Sample usage
//fnComputeAge (year, month, day, unit, decimals, rounding)
//Unit can be "years", "months", or "days"
//Decimals specifies demical places to round to (ie: 2)
//Rounding can be "roundup" or "rounddown"

//fnComputeAge(1997, 11, 24, "years", 0, "rounddown")

function fnComputeAge(yr, mon, day, unit, decimal, round){
today=new Date()
var pastdate=new Date(yr, mon-1, day)

var countunit=unit
var decimals=decimal
var rounding=round


var one_day=1000*60*60*24
var one_month=1000*60*60*24*30
var one_year=1000*60*60*24*30*12

finalunit=(countunit=="days")? one_day : (countunit=="months")? one_month : one_year
decimals=(decimals<=0)? 1 : decimals*10

if (unit!="years"){
if (rounding=="rounddown")
return (Math.floor((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals)
else
return (Math.ceil((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals)
}
else{
yearspast=today.getFullYear()-yr-1
tail=(today.getMonth()>mon-1 || today.getMonth()==mon-1 && today.getDate()>=day)? 1 : 0
pastdate.setFullYear(today.getFullYear())
pastdate2=new Date(today.getFullYear()-1, mon-1, day)
tail=(tail==1)? tail+Math.floor((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals : Math.floor((today.getTime()-pastdate2.getTime())/(finalunit)*decimals)/decimals
return  (yearspast+tail)
}
}



        //InStr(str, SearchForStr) : Returns the location a character (charSearchFor)
                                   //was found in the string str
        //========================================================================

        // InStr function written by: Steve Bamelis - steve.bamelis@pandora.be

        function InStr(strSearch, charSearchFor)
        /*
        InStr(strSearch, charSearchFor) : Returns the first location a substring (SearchForStr)
                                   was found in the string str.  (If the character is not
                                   found, -1 is returned.)
                                   
        Requires use of:
	        Mid function
	        Len function
        */
        {
	        for (i=0; i < Len(strSearch); i++)
	        {
	            if (charSearchFor == Mid(strSearch, i, 1))
	            {
			        return i;
	            }
	        }
	        return -1;
        }


        //mid(string, start, length): Returns a specified number of characters from a string
        //============================================================================

        function Mid(str, start, len)
        /***
                IN: str - the string we are LEFTing
                    start - our string's starting position (0 based!!)
                    len - how many characters from start we want to get

                RETVAL: The substring from start to start+len
        ***/
        {
                // Make sure start and len are within proper bounds
                if (start < 0 || len < 0) return "";

                var iEnd, iLen = String(str).length;
                if (start + len > iLen)
                        iEnd = iLen;
                else
                        iEnd = start + len;

                return String(str).substring(start,iEnd);
        }


        // Keep in mind that strings in JavaScript are zero-based, so if you ask
        // for Mid("Hello",1,1), you will get "e", not "H".  To get "H", you would
        // simply type in Mid("Hello",0,1)

        // You can alter the above function so that the string is one-based.  Just
        // check to make sure start is not <= 0, alter the iEnd = start + len to
        // iEnd = (start - 1) + len, and in your final return statement, just
        // return ...substring(start-1,iEnd)


        //Len(String) : Returns the number of characters in a string
        //===========================================================

        function Len(str)
        /***
                IN: str - the string whose length we are interested in

                RETVAL: The number of characters in the string
        ***/
        {  return String(str).length;  }



	function fnFormatMAddr(strAddr1,strAddr2, strAddr3, strCountry, strState, strCity,strPostal, objMAddr)
		{
			var strMAddr;
			
			strMAddr=strAddr1+"\r\n";
						
			
			if (strAddr2!="")
				strMAddr+=strAddr2+"\r\n";
				
			if (strAddr3!="")
				strMAddr+=strAddr3+"\r\n";
			
			if (strCountry.toLowerCase()!="singapore")
			{
			    if (strState!="")
				    strMAddr+=strState+"\r\n";				
			
			    if (strCity!="")
				    strMAddr+=strCity+"\r\n";								
            }				    

							
			if (strCountry!="")
			{
				if (strCountry.toLowerCase()=="singapore")
				{
					if (strPostal!="")
						strMAddr+="Singapore " +strPostal+"\r\n";	
				}else
				{
					if (strPostal!="")
						strMAddr+=strPostal+"\r\n";	
					strMAddr+=strCountry+"\r\n";
				}
			}
				
											
						
			objMAddr.value=strMAddr;	
		}
		
		function fnFormatMAddrStyle2(strAddr1,strAddr2, strAddr3, strAddr4, strCountry, strState, strCity,strPostal, objMAddr)
		{
			var strMAddr;
			
			strMAddr="Blk "+strAddr1+"\r\n";
						
			
			if (strAddr2!="")
				strMAddr+=strAddr2+"\r\n";
				
			if (strAddr3!="")
				strMAddr+="#"+strAddr3+"\r\n";
				
				
            if (strAddr4!="")
				strMAddr+=strAddr4+"\r\n";				
			
			if (strCountry.toLowerCase()!="singapore")
			{
			    if (strState!="")
				    strMAddr+=strState+"\r\n";				
			
			    if (strCity!="")
				    strMAddr+=strCity+"\r\n";								
            }				    

							
			if (strCountry!="")
			{
				if (strCountry.toLowerCase()=="singapore")
				{
					if (strPostal!="")
						strMAddr+="Singapore " +strPostal+"\r\n";	
				}else
				{
					if (strPostal!="")
						strMAddr+=strPostal+"\r\n";	
					strMAddr+=strCountry+"\r\n";
				}
			}
				
											
						
			objMAddr.value=strMAddr;	
		}
		
		function fnFormatMAddrObj(objAddr1,objAddr2, objAddr3,objCountry, objState, objCity,objPostal, objMAddr)
		{
			var strMAddr;
			
			if (objAddr1!=null)
			{
				strMAddr=objAddr1.value+"\r\n";
			}
						
			if (objAddr2!=null)
			{
				if (objAddr2.value!="")
				strMAddr+=objAddr2.value+"\r\n";
			}
		
				
			if (objAddr3!=null)
			{
				if (objAddr3.value!="")
				strMAddr+=objAddr3.value+"\r\n";
			}
		
			
			if (objCity!=null)
			{
				if (objCity.value!="")
				strMAddr+=objCity.value+"\r\n";		
			}
			
			if (objState!=null)
			{
				if (objState.value!="")
				strMAddr+=objState.value+"\r\n";			
			}
				
			
							
			if (objCountry!=null)							
			{
				if (objCountry.options[objCountry.selectedIndex].text!="")
				{
					if (objCountry.options[objCountry.selectedIndex].text.toLowerCase()=="singapore")
					{
						if (objPostal!=null)
						{
							if (objPostal.value!="")
								strMAddr+="Singapore "+objPostal.value+"\r\n";						
						}
					}else
					{
						if (objPostal!=null)
						{
							if (objPostal.value!="")
								strMAddr+="Postal Code "+objPostal.value+"\r\n";						
							strMAddr+=objCountry.options[objCountry.selectedIndex].text+"\r\n";
						}
					
						
					}
				}
			}															
						
			objMAddr.value=strMAddr;	
		}
		
		function fnFormatMAddrObjStyle2(objAddr1,objAddr2, objAddr3, objAddr4, objCountry, objState, objCity,objPostal, objMAddr)
		{
			var strMAddr;
			
			if (objAddr1!=null)
			{
				strMAddr="Blk "+objAddr1.value+"\r\n";
			}
						
			if (objAddr2!=null)
			{
				if (objAddr2.value!="")
				strMAddr+=objAddr2.value+"\r\n";
			}
		
				
			if (objAddr3!=null)
			{
				if (objAddr3.value!="")
				strMAddr+="#"+objAddr3.value+"\r\n";
			}
		
		    if (objAddr4!=null)
			{
				if (objAddr4.value!="")
				strMAddr+=objAddr4.value+"\r\n";
			}
			
			if (objCity!=null)
			{
				if (objCity.value!="")
				strMAddr+=objCity.value+"\r\n";		
			}
			
			if (objState!=null)
			{
				if (objState.value!="")
				strMAddr+=objState.value+"\r\n";			
			}
				
			
							
			if (objCountry!=null)							
			{
				if (objCountry.options[objCountry.selectedIndex].text!="")
				{
					if (objCountry.options[objCountry.selectedIndex].text.toLowerCase()=="singapore")
					{
						if (objPostal!=null)
						{
							if (objPostal.value!="")
								strMAddr+="Singapore "+objPostal.value+"\r\n";						
						}
					}else
					{
						if (objPostal!=null)
						{
							if (objPostal.value!="")
								strMAddr+="Postal Code "+objPostal.value+"\r\n";						
							strMAddr+=objCountry.options[objCountry.selectedIndex].text+"\r\n";
						}
					
						
					}
				}
			}															
						
			objMAddr.value=strMAddr;	
		}
		
		
		function fnFormatFullname(strFormatType, strSurname, strGivenname, objFullname)
		{
			
			if (strFormatType=="SG")
			{
				objFullname.value=strSurname+" "+strGivenname;
			}else
			{
				objFullname.value=strGivenname+" "+strSurname;
			}
		}
		
		function fnOpenDOBCalendar(strFieldDD,strFieldMM,strFieldYY, strPostbackFunc, strWndName )
			{
			
				window.open('/phv/Component/DatePicker.aspx?strSYear=1970&fieldDD=' + strFieldDD+'&fieldMM=' + strFieldMM+'&fieldYY=' + strFieldYY+'&strPostbackFunc='+strPostbackFunc,strWndName,'width=300,height=260,resizable=yes,scrollbars=1');
			}
			
	
		function fnOpenCalendar(strFieldDD,strFieldMM,strFieldYY,  strWndName )
			{
				window.open('/phv/Component/DatePicker.aspx?fieldDD=' + strFieldDD+'&fieldMM=' + strFieldMM+'&fieldYY=' + strFieldYY,strWndName,'width=300,height=260,resizable=yes,scrollbars=1');
			}
			
					
		function fnOpenFECalendar(strFieldDD,strFieldMM,strFieldYY, strWndName )
			{
				window.open('/phv/Component/DatePicker.aspx?fieldDD=' + strFieldDD+'&fieldMM=' + strFieldMM+'&fieldYY=' + strFieldYY,strWndName,'width=300,height=260,resizable=yes,scrollbars=1');
			}

		function fnOpenProdSearchExt(strField, strPostBackFunc, strWndName)
		{
				window.open('frmProdSearchExt.aspx?strField='+strField+'&strPostBackFunc=' + strPostBackFunc,strWndName,'width=800,height=600,resizable=yes,scrollbars=1');		
		}
		
		function fnOpenProdWLabelSearchExt(strField, strFieldLabel, strPostBackFunc, strWndName)
		{
				window.open('frmProdSearchExt.aspx?strField='+strField+'&strFieldLabel='+strFieldLabel+'&strPostBackFunc=' + strPostBackFunc,strWndName,'width=800,height=600,resizable=yes,scrollbars=1');		
		}

		function fnOpenProdFeatSearchExt(strProdID, strField, strFieldLabel, strPostBackFunc, strWndName)
		{
			window.open('frmProdFeatSearchExt.aspx?strProdID='+strProdID+'&strField='+strField+'&strFieldLabel='+strFieldLabel+'&strPostBackFunc=' + strPostBackFunc,strWndName,'width=800,height=600,resizable=yes,scrollbars=1');		
		}

		function fnOpenProdSearchMulExt(strField, strPostBackFunc, strRetFormat , strWndName)
		{
				window.open('frmProdSearchMulExt.aspx?strField='+strField+'&strRetFormat='+strRetFormat+'&strPostBackFunc=' + strPostBackFunc,strWndName,'width=800,height=600,resizable=yes,scrollbars=1');		
		}

		function fnOpenCountrySearchExt(strField, strPostBackFunc, strWndName)
		{
				window.open('frmCountrySearchExt.aspx?strField='+strField+'&strPostBackFunc=' + strPostBackFunc,strWndName,'width=800,height=600,resizable=yes,scrollbars=1');		
		}
		
		function fnOpenProdCatSearchMulExt(strField, strPostBackFunc, strRetFormat , strWndName)
		{
				window.open('frmProdCatSearchMulExt.aspx?strField='+strField+'&strRetFormat='+strRetFormat+'&strPostBackFunc=' + strPostBackFunc,strWndName,'width=800,height=600,resizable=yes,scrollbars=1');		
		}
		
		function fnOpenPriceSchemeSearchMulExt(strField, strPostBackFunc, strRetFormat , strWndName)
		{
				window.open('frmPriceSchemeSearchMulExt.aspx?strField='+strField+'&strRetFormat='+strRetFormat+'&strPostBackFunc=' + strPostBackFunc,strWndName,'width=800,height=600,resizable=yes,scrollbars=1');		
		}
		
		function fnOpenAffProfileSearchMulExt(strField, strPostBackFunc, strRetFormat , strWndName)
		{
				window.open('frmAffProfileSearchMulExt.aspx?strField='+strField+'&strRetFormat='+strRetFormat+'&strPostBackFunc=' + strPostBackFunc,strWndName,'width=800,height=600,resizable=yes,scrollbars=1');		
		}
		
		function fnOpenCustProfileSearchExt(strFieldID, strPostbackFunc,strWndName)
		{
		window.open('/phv/admin/CustProfile/frmCustProfileSearchExt.aspx?strCtrl='+strFieldID+'&strPostBack='+strPostbackFunc,strWndName, 'left=20,top=20,width=900,height=750,resizable=yes,scrollbars=1')
		}
		function fnOpenVillaSearchExt(strFieldID, strPostbackFunc,strWndName)
		{		
		window.open('/phv/CSPortal/frmVillaSearchExt.aspx?strCtrl='+strFieldID+'&strPostBack='+strPostbackFunc,strWndName, 'left=20,top=20,width=900,height=750,resizable=yes,scrollbars=1')
		}		
		function fnOpenProdDetPopUp(strID, strWndName)
		{
				var newwin;
				newwin=window.open('ProdDetPopUp.aspx?strID='+strID,strWndName,'width=800,height=600,resizable=yes,scrollbars=1');		
				newwin.focus();
		}
		function fnOpenOrderIDSample()
		{		var newwin;
				newwin=window.open('Statics/OrderIDSample.htm','OrderIDSample','width=600,height=200,resizable=yes,scrollbars=1');		
		        newwin.focus();
		}
		
		function fnOpenProdVolDiscPopUp(strID, strWndName)
		{
				var newwin;
				newwin=window.open('ProdVolDiscTablePopUp.aspx?strID='+strID,strWndName,'width=800,height=600,resizable=yes,scrollbars=1');		
				newwin.focus();
		}
		
		function fnOpenProdSKUSearchExt(strField, strProdID, strPostBackFunc, strWndName)
		{
            window.open('frmProdSKUSearchExt.aspx?strProdID='+strProdID+'&strField='+strField+'&strPostBackFunc=' + strPostBackFunc,strWndName,'width=800,height=600,resizable=yes,scrollbars=1');						    
		}
			
		
		function fnAutoCompleteShipInfo()
		{
			
			if ((this.form.ctl00$ContentPlaceHolder1$cboShipSal!=null)&&(this.form.ctl00$ContentPlaceHolder1$cboSal!=null))
			{
			this.form.ctl00$ContentPlaceHolder1$cboShipSal.selectedIndex=this.form.ctl00$ContentPlaceHolder1$cboSal.selectedIndex; 
			}								
			if ((this.form.ctl00$ContentPlaceHolder1$txtShipSurname!=null)&&(this.form.ctl00$ContentPlaceHolder1$txtSurname!=null))
			{
				this.form.ctl00$ContentPlaceHolder1$txtShipSurname.value=this.form.ctl00$ContentPlaceHolder1$txtSurname.value;
			}								
			if ((this.form.ctl00$ContentPlaceHolder1$txtShipGivenname!=null)&&(this.form.ctl00$ContentPlaceHolder1$txtGivenname!=null))
			{
				this.form.ctl00$ContentPlaceHolder1$txtShipGivenname.value=this.form.ctl00$ContentPlaceHolder1$txtGivenname.value;
			}								
			if ((this.form.ctl00$ContentPlaceHolder1$txtShipFullname!=null)&&(this.form.ctl00$ContentPlaceHolder1$txtFullname!=null))
			{
				this.form.ctl00$ContentPlaceHolder1$txtShipFullname.value=this.form.ctl00$ContentPlaceHolder1$txtFullname.value;
			}								
			if ((this.form.ctl00$ContentPlaceHolder1$txtShipCo!=null)&&(this.form.ctl00$ContentPlaceHolder1$txtCo!=null))
			{
				this.form.ctl00$ContentPlaceHolder1$txtShipCo.value=this.form.ctl00$ContentPlaceHolder1$txtCo.value;
			}	
			if ((this.form.ctl00$ContentPlaceHolder1$txtShipDesign!=null)&&(this.form.ctl00$ContentPlaceHolder1$txtDesign!=null))
			{
				this.form.ctl00$ContentPlaceHolder1$txtShipDesign.value=this.form.ctl00$ContentPlaceHolder1$txtDesign.value;
			}	
			
			if ((this.form.ctl00$ContentPlaceHolder1$txtShipTel!=null)&&(this.form.ctl00$ContentPlaceHolder1$txtTel!=null))
			{
				this.form.ctl00$ContentPlaceHolder1$txtShipTel.value=this.form.ctl00$ContentPlaceHolder1$txtTel.value;
			}	
			if ((this.form.ctl00$ContentPlaceHolder1$txtShipMobile!=null)&&(this.form.ctl00$ContentPlaceHolder1$txtMobile!=null))
			{
				this.form.ctl00$ContentPlaceHolder1$txtShipMobile.value=this.form.ctl00$ContentPlaceHolder1$txtMobile.value;
			}	
			if ((this.form.ctl00$ContentPlaceHolder1$txtShipFax!=null)&&(this.form.ctl00$ContentPlaceHolder1$txtFax!=null))
			{
				this.form.ctl00$ContentPlaceHolder1$txtShipFax.value=this.form.ctl00$ContentPlaceHolder1$txtFax.value;
			}	
			if ((this.form.ctl00$ContentPlaceHolder1$txtShipEMail!=null)&&(this.form.ctl00$ContentPlaceHolder1$txtEMail!=null))
			{
				this.form.ctl00$ContentPlaceHolder1$txtShipEMail.value=this.form.ctl00$ContentPlaceHolder1$txtEMail.value;
			}	
							
			
			if ((this.form.ctl00$ContentPlaceHolder1$txtShipAddr1!=null)&&(this.form.ctl00$ContentPlaceHolder1$txtAddr1!=null))
			{
				this.form.ctl00$ContentPlaceHolder1$txtShipAddr1.value=this.form.ctl00$ContentPlaceHolder1$txtAddr1.value;
			}								
			if ((this.form.ctl00$ContentPlaceHolder1$txtShipAddr2!=null)&&(this.form.ctl00$ContentPlaceHolder1$txtAddr2!=null))
			{
				this.form.ctl00$ContentPlaceHolder1$txtShipAddr2.value=this.form.ctl00$ContentPlaceHolder1$txtAddr2.value; 
			}	
			if ((this.form.ctl00$ContentPlaceHolder1$txtShipAddr3!=null)&&(this.form.ctl00$ContentPlaceHolder1$txtAddr3!=null))
			{
				this.form.ctl00$ContentPlaceHolder1$txtShipAddr3.value= this.form.ctl00$ContentPlaceHolder1$txtAddr3.value;
			}
			if ((this.form.ctl00$ContentPlaceHolder1$cboShipCountry!=null)&&(this.form.ctl00$ContentPlaceHolder1$cboCountry!=null))
			{
				this.form.ctl00$ContentPlaceHolder1$cboShipCountry.selectedIndex=this.form.ctl00$ContentPlaceHolder1$cboCountry.selectedIndex; 
			}
			if ((this.form.ctl00$ContentPlaceHolder1$txtShipState!=null)&&(this.form.ctl00$ContentPlaceHolder1$txtState!=null))
			{
				this.form.ctl00$ContentPlaceHolder1$txtShipState.value= this.form.ctl00$ContentPlaceHolder1$txtState.value; 
			}
			if ((this.form.ctl00$ContentPlaceHolder1$txtShipCity!=null)&&(this.form.ctl00$ContentPlaceHolder1$txtCity!=null))
			{
				this.form.ctl00$ContentPlaceHolder1$txtShipCity.value=this.form.ctl00$ContentPlaceHolder1$txtCity.value;
			}
			if ((this.form.ctl00$ContentPlaceHolder1$txtShipPostal!=null)&&(this.form.ctl00$ContentPlaceHolder1$txtPostal!=null))
			{
				this.form.ctl00$ContentPlaceHolder1$txtShipPostal.value=this.form.ctl00$ContentPlaceHolder1$txtPostal.value;
			}
			if ((this.form.ctl00$ContentPlaceHolder1$txtShipMAddr!=null)&&(this.form.ctl00$ContentPlaceHolder1$txtMAddr!=null))
			{
				this.form.ctl00$ContentPlaceHolder1$txtShipMAddr.value= this.form.ctl00$ContentPlaceHolder1$txtMAddr.value;
			}
		}
		
		function fnOpenRecipientSearchExt(strField, strPostBackFunc, strWndName)
		{
				var newwin;
				
				newwin=window.open('frmRecipientSearchExt.aspx?strField='+strField+'&strPostBackFunc=' + strPostBackFunc,strWndName,'width=800,height=600,resizable=yes,scrollbars=1');		
				newwin.focus();
		}
		
		
		function fnRefreshPaymentCal()
		{
			var dblTender 
			var dblChange
			
			dblTender=0
			dblChange=0
			
			//alert(this.form.ctl00$ContentPlaceHolder1$txtCashAmt.value);
			if (this.form.ctl00$ContentPlaceHolder1$txtCashAmt!=null)
			 {
				if (this.form.ctl00$ContentPlaceHolder1$txtCashAmt.value!="")
				{
					
					dblTender+=(this.form.ctl00$ContentPlaceHolder1$txtCashAmt.value)*1.00;
				} 
			 }
			 if (this.form.ctl00$ContentPlaceHolder1$txtCCardAmt1!=null)
			 {
				if (this.form.ctl00$ContentPlaceHolder1$txtCCardAmt1.value!="")
				{
					
					dblTender+=(this.form.ctl00$ContentPlaceHolder1$txtCCardAmt1.value)*1.00;
				} 
			 }
			  if (this.form.ctl00$ContentPlaceHolder1$txtCCardAmt2!=null)
			 {
				if (this.form.ctl00$ContentPlaceHolder1$txtCCardAmt2.value!="")
				{
					
					dblTender+=(this.form.ctl00$ContentPlaceHolder1$txtCCardAmt2.value)*1.00;
				} 
			 }
			 
			 if (this.form.ctl00$ContentPlaceHolder1$txtChequeAmt1!=null)
			 {
				if (this.form.ctl00$ContentPlaceHolder1$txtChequeAmt1.value!="")
				{
					
					dblTender+=(this.form.ctl00$ContentPlaceHolder1$txtChequeAmt1.value)*1.00;
				} 
			 }
			  if (this.form.ctl00$ContentPlaceHolder1$txtChequeAmt2!=null)
			 {
				if (this.form.ctl00$ContentPlaceHolder1$txtChequeAmt2.value!="")
				{
					
					dblTender+=(this.form.ctl00$ContentPlaceHolder1$txtChequeAmt2.value)*1.00;
				} 
			 }
			 
			 if (this.form.ctl00$ContentPlaceHolder1$txtNETSAmt!=null)
			 {
				if (this.form.ctl00$ContentPlaceHolder1$txtNETSAmt.value!="")
				{
					
					dblTender+=(this.form.ctl00$ContentPlaceHolder1$txtNETSAmt.value)*1.00;
				} 
			 }
			
			
			if (this.form.ctl00$ContentPlaceHolder1$txtCNoteAmt1!=null)
			 {
				if (this.form.ctl00$ContentPlaceHolder1$txtCNoteAmt1.value!="")
				{
					
					dblTender+=(this.form.ctl00$ContentPlaceHolder1$txtCNoteAmt1.value)*1.00;
				} 
			 }
			 
			 if (this.form.ctl00$ContentPlaceHolder1$txtCNoteAmt2!=null)
			 {
				if (this.form.ctl00$ContentPlaceHolder1$txtCNoteAmt2.value!="")
				{
					
					dblTender+=(this.form.ctl00$ContentPlaceHolder1$txtCNoteAmt2.value)*1.00;
				} 
			 }
			
			if (this.form.ctl00$ContentPlaceHolder1$txtTTAmt2!=null)
			 {
				if (this.form.ctl00$ContentPlaceHolder1$txtTTAmt2.value!="")
				{
					
					dblTender+=(this.form.ctl00$ContentPlaceHolder1$txtTTAmt2.value)*1.00;
				} 
			 }
						
			//alert(dblTender);
			this.form.ctl00$ContentPlaceHolder1$txtTenderAmt.value=dblTender;
		}
				
		function fnOpenPrtCatalogueExt(strWndName)
		{
				var newwin;
				
				newwin=window.open('frmPrtCatalogueExt.aspx',strWndName,'width=800,height=600,resizable=yes,scrollbars=1');		
				newwin.focus();
		}
				
		function fnOpenUploadMedia(strPostbackFunc, strField, strFieldLabel, strMediaID,  strRefID, strRefTypeID, strMediaTypeID, strUseID, strSizeID, strFolder, strFolderURL, strFilename)
        {   
            var strWndName;        
            if (strRefID=="")
            {
                alert("Missing ID! Please enter the ID before uploading.");
            }else
            {
                strWndName="WndMediaUpload";
                //alert('frmUploadMedia.aspx?strPostbackFunc='+strPostbackFunc+'&strField='+strField+'&strFieldLabel='+strFieldLabel+'&strRefID='+strRefID+'&strRefTypeID='+strRefTypeID+'&strMediaTypeID='+strMediaTypeID+'&strUseID='+strUseID+'&strFolder='+strFolder+'&strFolderURL='+strFolderURL+'&strFilename='+strFilename);
                window.open ('/phv/frmUpload.aspx?strPostbackFunc='+strPostbackFunc+'&strField='+strField+'&strFieldLabel='+strFieldLabel+'&strMediaID='+strMediaID+'&strRefID='+strRefID+'&strRefTypeID='+strRefTypeID+'&strMediaTypeID='+strMediaTypeID+'&strUseID='+strUseID+'&strSizeID='+strSizeID+'&strFolder='+strFolder+'&strFolderURL='+strFolderURL+'&strFilename='+strFilename,strWndName,'width=800,height=600,resizable=yes,scrollbars=1')
                }
        }
        
        function fnOpenFEUploadMedia(strPostbackFunc, strField, strFieldLabel,  strMediaID,  strRefID, strRefTypeID, strMediaTypeID, strUseID, strSizeID, strFolder, strFolderURL, strFilename)
        {   
            var strWndName;        
            if (strRefID=="")
            {
                alert("Missing ID! Please enter the ID before uploading.");
            }else
            {
                strWndName="WndMediaUpload";
                //alert('frmUploadMedia.aspx?strPostbackFunc='+strPostbackFunc+'&strField='+strField+'&strFieldLabel='+strFieldLabel+'&strRefID='+strRefID+'&strRefTypeID='+strRefTypeID+'&strMediaTypeID='+strMediaTypeID+'&strUseID='+strUseID+'&strFolder='+strFolder+'&strFolderURL='+strFolderURL+'&strFilename='+strFilename);
                window.open ('/phv/frmUpload.aspx?strPostbackFunc='+strPostbackFunc+'&strField='+strField+'&strFieldLabel='+strFieldLabel+'&strMediaID='+strMediaID+'&strRefID='+strRefID+'&strRefTypeID='+strRefTypeID+'&strMediaTypeID='+strMediaTypeID+'&strUseID='+strUseID+'&strSizeID='+strSizeID+'&strFolder='+strFolder+'&strFolderURL='+strFolderURL+'&strFilename='+strFilename,strWndName,'width=800,height=600,resizable=yes,scrollbars=1')
                }
        }
        
	function fnOpenUploadMediaImg(strPostbackFunc, strField, strFieldLabel, strMediaID, strRefID, strRefTypeID, strMediaTypeID, strUseID, strSizeID,strFolder, strFolderTURL, strFolderSURL, strFilename,strParameter)
        {   
            var strWndName;        
            strWndName="WndMediaUploadImg";
            //alert('frmUpload.aspx?strPostbackFunc='+strPostbackFunc+'&strField='+strField+'&strFieldLabel='+strFieldLabel+'&strRefID='+strRefID+'&strRefTypeID='+strRefTypeID+'&strMediaTypeID='+strMediaTypeID+'&strUseID='+strUseID+'&strFolder='+ strFolderURL= '+ Replace(ConfigurationManager.AppSettings("CUSTPHOTOURL"), "\", "\\" +'&strFilename='+strFilename);                 
            window.open('/phv/frmUpload.aspx?strPostbackFunc='+strPostbackFunc+'&strField='+strField+'&strFieldLabel='+strFieldLabel+'&strMediaID='+strMediaID+'&strRefID='+strRefID+'&strRefTypeID='+strRefTypeID+'&strMediaTypeID='+strMediaTypeID+'&strUseID='+strUseID+'&strSizeID='+strSizeID+'&strFolder='+strFolder+'&strFolderTURL='+strFolderTURL+'&strFolderSURL='+strFolderSURL+'&strFilename='+strFilename,"WndMediaUploadImg",'width=800,height=600,resizable=yes,scrollbars=1,status=1,menubar =1,location =1,toolbar=1')
            //window.open('/phv/frmUploadTest.aspx?strPostbackFunc='+strPostbackFunc+'&strField='+strField+'&strFieldLabel='+strFieldLabel+'&strMediaID='+strMediaID+'&strRefID='+strRefID+'&strRefTypeID='+strRefTypeID+'&strMediaTypeID='+strMediaTypeID+'&strUseID='+strUseID+'&strSizeID='+strSizeID+'&strFolder='+strFolder+'&strFolderTURL='+strFolderTURL+'&strFolderSURL='+strFolderSURL+'&strFilename='+strFilename+'&strParameter='+strParameter,"WndMediaUploadImg",'width=800,height=600,resizable=yes,scrollbars=1,status=1,menubar =1,location =1,toolbar=1')
        }
	function fnOpenMultiUploadMediaImg(strPostbackFunc, strField, strField1, strField2,strField3, strField4,  strField5, strFieldLabel0,strFieldLabel1,strFieldLabel2,strFieldLabel3,strFieldLabel4,strFieldLabel5, strMediaID, strRefID, strRefTypeID, strMediaTypeID, strUseID, strSizeID,strFolder, strFolderTURL, strFolderSURL, strFilename,strParameter)
        {   
            var strWndName;        
            strWndName="WndMediaUploadImg";
            //alert('frmUpload.aspx?strPostbackFunc='+strPostbackFunc+'&strField='+strField+'&strFieldLabel='+strFieldLabel+'&strRefID='+strRefID+'&strRefTypeID='+strRefTypeID+'&strMediaTypeID='+strMediaTypeID+'&strUseID='+strUseID+'&strFolder='+ strFolderURL= '+ Replace(ConfigurationManager.AppSettings("CUSTPHOTOURL"), "\", "\\" +'&strFilename='+strFilename);                 
            //window.open('/phv/frmUpload.aspx?strPostbackFunc='+strPostbackFunc+'&strField='+strField+'&strFieldLabel='+strFieldLabel+'&strMediaID='+strMediaID+'&strRefID='+strRefID+'&strRefTypeID='+strRefTypeID+'&strMediaTypeID='+strMediaTypeID+'&strUseID='+strUseID+'&strSizeID='+strSizeID+'&strFolder='+strFolder+'&strFolderTURL='+strFolderTURL+'&strFolderSURL='+strFolderSURL+'&strFilename='+strFilename,"WndMediaUploadImg",'width=800,height=600,resizable=yes,scrollbars=1,status=1,menubar =1,location =1,toolbar=1')
            window.open('/phv/frmUploadTest.aspx?strPostbackFunc='+strPostbackFunc+'&strField='+strField+'&strField1='+strField1+'&strField2='+strField2+'&strField3='+strField3+'&strField4='+strField4+'&strField5='+strField5+'&strFieldLabel0='+strFieldLabel0+'&strFieldLabel1='+strFieldLabel1+'&strFieldLabel2='+strFieldLabel2+'&strFieldLabel3='+strFieldLabel3+'&strFieldLabel4='+strFieldLabel4+'&strFieldLabel5='+strFieldLabel5+'&strMediaID='+strMediaID+'&strRefID='+strRefID+'&strRefTypeID='+strRefTypeID+'&strMediaTypeID='+strMediaTypeID+'&strUseID='+strUseID+'&strSizeID='+strSizeID+'&strFolder='+strFolder+'&strFolderTURL='+strFolderTURL+'&strFolderSURL='+strFolderSURL+'&strFilename='+strFilename+'&strParameter='+strParameter,"WndMediaUploadImg",'width=800,height=600,resizable=yes,scrollbars=1,status=1,menubar =1,location =1,toolbar=1')
        }
	    function getElementsByStyleClass (className) 
	    {
            var all = document.all ? document.all :
            document.getElementsByTagName('*');
            var elements = new Array();
            for (var e = 0; e < all.length; e++)
            if (all[e].className == className)
                elements[elements.length] = all[e];
            return elements;
        }
        
        function getElementsCountByID (strIDName) 
	    {
            var all = document.all ? document.all :
            document.getElementsByTagName('*');
            var intElements =0;
            for (var e = 0; e < all.length; e++)
            if (all[e].id.indexOf(strIDName)>-1)
                intElements+=1
                
            return intElements;
        }
        
        function validateProdAttrSel(strIDName)
        {
        
           //alert("2");
            var all = document.all ? document.all :
            document.getElementsByTagName('*');
            var intElements =0;
           
            for (var e = 0; e < all.length; e++)
            {
            //alert(all[e].id);
                if (all[e].id.indexOf(strIDName)>-1)
                {
              //  alert("4");
                    if ((all[e].options[all[e].selectedIndex].value=="")||(all[e].options[all[e].selectedIndex].value=="NA"))
                    {
                //    alert("5");
                        alert(all[e].options[0].text);
                        return false;
                    }
                }
            }    
            return true;
        }


    function SelectAllCheckboxes(spanChk)
	{
		
		// Added as ASPX uses SPAN for checkbox 
		var xState=spanChk.checked;
		var theBox=spanChk;
		
		// Old code for VS 2002 / .NET framework 1.0 code
		//-----------------------------------------------
		// In .NET 1.0 ASP.NET was using SPAN tag with
		// CheckBox control. 
		//
		//var oItem = spanChk.children;
		//var theBox=oItem.item(0)
		//xState=theBox.checked;	
		//-----------------------------------------------
		
		elm=theBox.form.elements;
		for(i=0;i<elm.length;i++)
		if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
		{
			//elm[i].click();
			if(elm[i].checked!=xState)
			elm[i].click();
			//elm[i].checked=xState;
		}
	}	
	
	function SelectAllCheckboxes(spanChk, strSIndexStr)
	{
		
		// Added as ASPX uses SPAN for checkbox 
		var xState=spanChk.checked;
		var theBox=spanChk;
		
		// Old code for VS 2002 / .NET framework 1.0 code
		//-----------------------------------------------
		// In .NET 1.0 ASP.NET was using SPAN tag with
		// CheckBox control. 
		//
		//var oItem = spanChk.children;
		//var theBox=oItem.item(0)
		//xState=theBox.checked;	
		//-----------------------------------------------
		
		elm=theBox.form.elements;
		var i;
		for(i=0;i<elm.length;i++)
		{
		
		    if(elm[i].type=="checkbox" && elm[i].id!=theBox.id )
		    {
		        if ( elm[i].id.match(strSIndexStr)!=null)
		        {
			        //elm[i].click();
			        if(elm[i].checked!=xState)
			        elm[i].click();
			        //elm[i].checked=xState;
                }			        
		    }   
        }
	}	
	
	function testjs()
	{
	    alert("Testing javascript ok!");
	}
	
	
	function testjsobjval(val)
	{
	    alert(val);
	}
	
	
	
	function fnOpenEnrolIntakeSearch(strFieldID, strPostbackFunc,strWndName)
	{		
		window.open('/phv/enrol/frmEnrolIntakeSearchExt.aspx?strCtrl='+strFieldID+'&strPostBack='+strPostbackFunc,strWndName, 'left=20,top=20,width=900,height=750,resizable=yes,scrollbars=1')
	}
	
	
	function fnOpenEnrolProg(strEnrolID, strFieldID, strPostbackFunc,strWndName)
	{
		
		window.open('/phv/enrol/frmEnrolProgExt.aspx?strCtrl='+strFieldID+'&strEnrolID='+strEnrolID+'&strPostBack='+strPostbackFunc,strWndName, 'left=20,top=20,width=900,height=750,resizable=yes,scrollbars=1')
	}		
	
	
	function fnOpenCoSearch(strFieldID, strPostbackFunc,strWndName)
	{		
		window.open('/phv/UserDatabase/Client/frmCoProfileSearchExt.aspx?strCtrl='+strFieldID+'&strPostBack='+strPostbackFunc,strWndName, 'left=20,top=20,width=900,height=750,resizable=yes,scrollbars=1')
	}
	
	function fnOpenEnrolSubEnrol(strEnrolID, strPEnrolID, strURID,  strFieldID, strPostbackFunc,strWndName)
	{
		
		window.open('/phv/enrol/frmEnrolSubEnrolExt.aspx?strCtrl='+strFieldID+'&strPEnrolID='+strPEnrolID+'&strEnrolID='+strEnrolID+'&strURID='+strURID+'&strPostBack='+strPostbackFunc,strWndName, 'left=20,top=20,width=900,height=750,resizable=yes,scrollbars=1')
	}		

    function fnOpenStaffProfileSearch(strFieldID, strPostbackFunc,strWndName)
	{		
		window.open('/phv/UserDatabase/Staff/frmStaffProfileSearchExt.aspx?strCtrl='+strFieldID+'&strPostBack='+strPostbackFunc,strWndName, 'left=20,top=20,width=900,height=750,resizable=yes,scrollbars=1')
	}	

    function fnOpenLecturerStaffSearch(strFieldID, strPostbackFunc,strWndName)
	{		
		window.open('/phv/UserDatabase/Staff/frmLecturerStaffSearchExt.aspx?strCtrl='+strFieldID+'&strPostBack='+strPostbackFunc,strWndName, 'left=20,top=20,width=900,height=750,resizable=yes,scrollbars=1')
	}	


function ConfirmDelMsg()
    {
     if (confirm("Are you sure you want to delete this item?")==true)
        return true;
    else
        return false;
    }
    
    
    function isValidDate(dateStr) {
// Date validation function courtesty of 
// Sandeep V. Tamhankar (stamhankar@hotmail.com) -->

// Checks for the following valid date formats:
// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY

var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit year

var matchArray = dateStr.match(datePat); // is the format ok?
if (matchArray == null) {
alert(dateStr + " Date is not in a valid format.")
return false;
}
month = matchArray[1]; // parse date into variables
day = matchArray[3];
year = matchArray[4];
if (month < 1 || month > 12) { // check month range
alert("Month must be between 1 and 12.");
return false;
}
if (day < 1 || day > 31) {
alert("Day must be between 1 and 31.");
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31) {
alert("Month "+month+" doesn't have 31 days!")
return false;
}
if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap)) {
alert("February " + year + " doesn't have " + day + " days!");
return false;
   }
}
return true;
}

function isValidTime(timeStr) {
// Time validation function courtesty of 
// Sandeep V. Tamhankar (stamhankar@hotmail.com) -->

// Checks if time is in HH:MM:SS AM/PM format.
// The seconds and AM/PM are optional.

var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;

var matchArray = timeStr.match(timePat);
if (matchArray == null) {
alert("Time is not in a valid format.");
return false;
}
hour = matchArray[1];
minute = matchArray[2];
second = matchArray[4];
ampm = matchArray[6];

if (second=="") { second = null; }
if (ampm=="") { ampm = null }

if (hour < 0  || hour > 23) {
alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
return false;
}
if (hour <= 12 && ampm == null) {
if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time")) {
alert("You must specify AM or PM.");
return false;
   }
}
if  (hour > 12 && ampm != null) {
alert("You can't specify AM or PM for military time.");
return false;
}
if (minute < 0 || minute > 59) {
alert ("Minute must be between 0 and 59.");
return false;
}
if (second != null && (second < 0 || second > 59)) {
alert ("Second must be between 0 and 59.");
return false;
}
return true;
}

function dateDiff(dateform) {
date1 = new Date();
date2 = new Date();
diff  = new Date();

if (isValidDate(dateform.firstdate.value) && isValidTime(dateform.firsttime.value)) { // Validates first date 
date1temp = new Date(dateform.firstdate.value + " " + dateform.firsttime.value);
date1.setTime(date1temp.getTime());
}
else return false; // otherwise exits

if (isValidDate(dateform.seconddate.value) && isValidTime(dateform.secondtime.value)) { // Validates second date 
date2temp = new Date(dateform.seconddate.value + " " + dateform.secondtime.value);
date2.setTime(date2temp.getTime());
}
else return false; // otherwise exits

// sets difference date to difference of first date and second date

diff.setTime(Math.abs(date1.getTime() - date2.getTime()));

timediff = diff.getTime();

weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7));
timediff -= weeks * (1000 * 60 * 60 * 24 * 7);

days = Math.floor(timediff / (1000 * 60 * 60 * 24)); 
timediff -= days * (1000 * 60 * 60 * 24);

hours = Math.floor(timediff / (1000 * 60 * 60)); 
timediff -= hours * (1000 * 60 * 60);

mins = Math.floor(timediff / (1000 * 60)); 
timediff -= mins * (1000 * 60);

secs = Math.floor(timediff / 1000); 
timediff -= secs * 1000;

dateform.difference.value = weeks + " weeks, " + days + " days, " + hours + " hours, " + mins + " minutes, and " + secs + " seconds";

return false; // form should never submit, returns false
}


function fnOpenVillaOwnerSearch(strFieldID, strPostbackFunc,strWndName)
{		
	window.open('/phv/admin/VillaOwner/frmVillaOwnerProfileSearchExt.aspx?strCtrl='+strFieldID+'&strPostBack='+strPostbackFunc,strWndName, 'left=20,top=20,width=900,height=750,resizable=yes,scrollbars=1')
}
function fnOpenVillaOwnerProfile(strFieldID, strPostbackFunc,strWndName)
{		
	window.open('/phv/admin/VillaOwner/frmViewVillaOwnerProfileExt.aspx?StrID='+strFieldID+'&strPostBack='+strPostbackFunc,strWndName, 'left=20,top=20,width=650,height=350,resizable=yes,scrollbars=1')
}

function fnOpenVillaAgentProfile(strFieldID, strPostbackFunc,strWndName)
{		
	window.open('/phv/admin/VillaAgent/frmViewCoProfileExt.aspx?StrID='+strFieldID+'&strPostBack='+strPostbackFunc,strWndName, 'left=20,top=20,width=650,height=350,resizable=yes,scrollbars=1')
}
function fnOpenVillaAgentSearch(strFieldID, strPostbackFunc,strWndName)
{		
	window.open('/phv/admin/VillaAgent/frmCoProfileSearchExt.aspx?strCtrl='+strFieldID+'&strPostBack='+strPostbackFunc,strWndName, 'left=20,top=20,width=900,height=750,resizable=yes,scrollbars=1')
}
function wnClose()
{
    window.close();
}
function openWin(URL,strWndName)
{   
 var WndName; 
    WndName="WndWebsite";  
    //alert(URL);
   window.open(URL,"WndWebsite", 'left=20,top=20,width=900,height=750,resizable=yes,scrollbars=1');
}	

function fnOpenUploadVillaMedia(strPostbackFunc, strPhotoArea, strFilenameField, strCaptionField, strMediaIDField, strRefID, strRefTypeID,strSectID, strMediaTypeID)
{   
    var strWndName;
    strWndName="WndMediaUploadImg";    
 //   alert(strRefID);
   // window.open('/phv/admin/Villa/frmVillaUploadMedia.aspx?strPostbackFunc='+strPostbackFunc+'&strPhotoArea='+strPhotoArea+'&strFilenameField='+strFilenameField+'&strCaptionField='+strCaptionField+'&strMediaIDField='+strMediaIDField+'&strRefID='+strRefID+'&strRefTypeID='+strRefTypeID+'&strMediaTypeID='+strMediaTypeID+'&strSectID='+strSectID,"WndMediaUploadImg",'width=800,height=600,resizable=yes,scrollbars=1,status=1,menubar =1,location =1,toolbar=1')
   window.open('frmVillaUploadMedia.aspx?strPostbackFunc='+strPostbackFunc+'&strPhotoArea='+strPhotoArea+'&strFilenameField='+strFilenameField+'&strCaptionField='+strCaptionField+'&strMediaIDField='+strMediaIDField+'&strRefID='+strRefID+'&strRefTypeID='+strRefTypeID+'&strMediaTypeID='+strMediaTypeID+'&strSectID='+strSectID,"WndMediaUploadImg",'width=800,height=600,resizable=yes,scrollbars=1,status=1,menubar =1,location =1,toolbar=1')
}
function fnOpenUploadVillaAttFile(strPostbackFunc, strPhotoArea, strFilenameField, strCaptionField, strMediaIDField, strRefID, strRefTypeID,strSectID, strMediaTypeID)
{   
    var strWndName;
    strWndName="WndMediaUploadImg";    
 //   alert(strRefID);
    window.open('/phv/csportal/frmVillaUploadAttFile.aspx?strPostbackFunc='+strPostbackFunc+'&strPhotoArea='+strPhotoArea+'&strFilenameField='+strFilenameField+'&strCaptionField='+strCaptionField+'&strAttachmentIDField='+strMediaIDField+'&strRefID='+strRefID+'&strRefTypeID='+strRefTypeID+'&strAttachmentTypeID='+strMediaTypeID+'&strSectID='+strSectID,"WndMediaUploadImg",'width=800,height=600,resizable=yes,scrollbars=1,status=1,menubar =1,location =1,toolbar=1')
}
function fnOpenNewVillaOwnerProfile(strPostBack, strFilenameField)
{		
    var strWndName;
    strWndName="WndFrmNewVOwnerProfile";
	window.open('/phv/admin/VillaOwner/frmVillaOwnerProfileExt.aspx?strPostBack='+strPostBack+'&strFilenameField='+strFilenameField,"WndFrmNewVOwnerProfile",'width=1100,height=750,resizable=yes,scrollbars=1,status=1,menubar =1,location =1,toolbar=1')
}
function fnOpenNewCustomerProfile(strPostBack, strFilenameField)
{		
    var strWndName;
    strWndName="WndFrmNewCustomerProfile";
	window.open('/phv/csportal/frmCustProfileExt.aspx?strPostBack='+strPostBack+'&strFilenameField='+strFilenameField,"WndFrmNewVOwnerProfile",'width=1100,height=750,resizable=yes,scrollbars=1,status=1,menubar =1,location =1,toolbar=1')
}
function fnOpenNewVillaAgentProfile(strPostBack, strFilenameField)
{		
    var strWndName;
    strWndName="WndFrmNewVAgentProfile";
	window.open('/phv/admin/VillaAgent/frmCoProfileExt.aspx?strPostBack='+strPostBack+'&strFilenameField='+strFilenameField,"WndFrmNewVAgentProfile",'width=900,height=750,resizable=yes,scrollbars=1,status=1,menubar =1,location =1,toolbar=1')
}
function fnOpenWin(URL,strWndName)
{   
   window.open(URL,strWndName, 'left=20,top=20,width=900,height=750,resizable=yes,scrollbars=1');
}
function PreviewopenWin(strFieldID,strPostbackFunc,strWndName)
{   
 var WndName; 
    WndName="WndWebsite";  
    alert(strFieldID);
   window.open('/phv/VillaDetailExt.aspx?strID='+strFieldID+'&strPostbackFunc='+strPostbackFunc,"WndWebsite", 'left=20,top=20,width=900,height=750,resizable=yes,scrollbars=1');
}	
//------------------------------- Key Event functions -------------------------------
function ctrlKey(){return window.event.ctrlKey;}
function altKey(){return window.event.altKey;}
function shiftKey(){return window.event.shiftKey;}
function enterKey() {if (window.event.keyCode == 13) return true; return false;}
function tabKey(){if (window.event.keyCode == 9) return true; return false;}
function charKey(){if (ctrlKey()||shiftKey()||altKey()) return false; return true;}
function numKey(){var kc=getKeyCode();if (57>=kc&&kc>=48) return true; return false;}

function getKeyCode(){return window.event.keyCode;}
function getCharKeyCode(){if(charKey())return getKeyCode();return -1;}
function getCtrlKeyCode(){if(ctrlKey())return getKeyCode();return -1;}
function getAltKeyCode(){if(altKey())return getKeyCode();return -1;}
function getShiftKeyCode(){if(shiftKey())return getKeyCode();return -1;}

function setKeyCode(keyCode){window.event.keyCode=keyCode}
function setTabKey(keyCode){if(keyCode==getKeyCode())setKeyCode(9);}

function setFocus(destObject, onkeyCode){
    if(isNaN(onkeyCode))onkeyCode=13;
    if(getKeyCode()==onkeyCode){destObject.focus();setKeyCode(9);}
}


function checkTextAreaMaxLength(textBox,e, length)
        {
                        
        var mLen = textBox["MaxLength"];
        if(null==mLen)
        mLen=length;
      
        var maxLength = parseInt(mLen);
        if(!checkSpecialKeys(e))
        {
         if(textBox.value.length > maxLength-1)
         {
            if(window.event)//IE
              e.returnValue = false;
            else//Firefox
                e.preventDefault();
         }
    }   
 }
function checkSpecialKeys(e)
{
    if(e.keyCode !=8 && e.keyCode!=46 && e.keyCode!=37 && e.keyCode!=38 && e.keyCode!=39 && e.keyCode!=40)
        return false;
    else
        return true;
}   



function fnOpenCalendarFDate(strFieldDD,strFieldMM,strFieldYY, strCurDD, strCurMM, strCurYY,  strWndName )
{    
	window.open('/phv/Component/DatePicker.aspx?FDate=Y&fieldDD=' + strFieldDD+'&fieldMM=' + strFieldMM+'&fieldYY=' + strFieldYY+'&CurDD='+strCurDD+'&CurMM='+strCurMM+'&CurYY='+strCurYY,strWndName,'width=300,height=260,resizable=yes,scrollbars=1,left=500,top=300');
}