﻿// JScript File

    ///////////////////////////////////////////////////////
    // do registration check  //
    //////////////////////////////////////////////////////

    function  doRegistrationCheck_ViewSubmit(checkBoxControl)
    {
        // prompt if use enter a non-no. value or blank
      
        var chk1; 
        var chk2;
        var chkMain;
        var ddlRegisterType;
        
        chkMain = document.getElementById('chkMain');
        chk2 = document.getElementById('chkDay1');
        chk3 = document.getElementById('chkDay2');
        ddlRegisterType = document.getElementById('ddlRegisterType');
    
        if (checkBoxControl.id != chkMain.id)
            {
                chkMain.checked = false;
            }

        if (checkBoxControl.id != chk2.id)
            {
                chk2.checked = false;
            }
        
        if (checkBoxControl.id != chk3.id)
            {
                chk3.checked = false;
            }
       
        
        if (ddlRegisterType.options[ddlRegisterType.selectedIndex].value == 'LOCAL')
            {
                PaymentCalculation_submit();
            }
        else if (ddlRegisterType.options[ddlRegisterType.selectedIndex].value == 'OVERSEA')
            {
                PaymentCalculationOversea_submit();
            }   

        
    }
    
    ///////////////////////////////////////////////////////
    // do registration check  //
    //////////////////////////////////////////////////////

    function  doRegistrationCheck(checkBoxControl)
    {
        // prompt if use enter a non-no. value or blank
      
        var chk1; 
        var chk2;
        var chkMain;
        
        chkMain = document.getElementById('chkMain');
        chk2 = document.getElementById('chkDay1');
        chk3 = document.getElementById('chkDay2');
    
        if (checkBoxControl.id != chkMain.id)
            {
                chkMain.checked = false;
            }

        if (checkBoxControl.id != chk2.id)
            {
                chk2.checked = false;
            }
        
        if (checkBoxControl.id != chk3.id)
            {
                chk3.checked = false;
            }    
        PaymentCalculation();
    }
    
    function  doRegistrationCheckOversea(checkBoxControl)
    {
        // prompt if use enter a non-no. value or blank
      
        var chk1; 
        var chk2;
        var chkMain;
        
        chkMain = document.getElementById('chkMain');
        chk2 = document.getElementById('chkDay1');
        chk3 = document.getElementById('chkDay2');
    
        if (checkBoxControl.id != chkMain.id)
            {
                chkMain.checked = false;
            }

        if (checkBoxControl.id != chk2.id)
            {
                chk2.checked = false;
            }
        
        if (checkBoxControl.id != chk3.id)
            {
                chk3.checked = false;
            }    
        PaymentCalculationOversea();
    }    
    
    ///////////////////////////////////////////////////////
    // Display Cert Name based on Family and Given Name  //
    //////////////////////////////////////////////////////

    function  doDispname() 
    {
        // prompt if use enter a non-no. value or blank
        
        

        var fname = document.getElementById('txtLastName');
        var lname = document.getElementById('txtFirstName');
        var certname = document.getElementById('txtCertName');             

        var tempname;
        
        tempname = lname.value + ' ' + fname.value;
        certname.value = tempname;
      
    }

    function workShopChecking(checkBoxControl)
    {
        var ddlRegisterType;
        
        ddlRegisterType = document.getElementById('ddlRegisterType');    
        
        if (ddlRegisterType.options[ddlRegisterType.selectedIndex].value == 'LOCAL')
            {
                doWorkshopCheck(checkBoxControl);
            }
        else if (ddlRegisterType.options[ddlRegisterType.selectedIndex].value == 'OVERSEA')
            {
                doWorkshopCheckOverSea(checkBoxControl);
            }         
    }
    
    function PaymentCalculationTypeChecking()
    {
        var ddlRegisterType;
        
        
        ddlRegisterType = document.getElementById('ddlRegisterType'); 
  
        
        if (ddlRegisterType.options[ddlRegisterType.selectedIndex].value == 'LOCAL')
            {
                PaymentCalculation_submit();
            }
        else if (ddlRegisterType.options[ddlRegisterType.selectedIndex].value == 'OVERSEA')
            {
                PaymentCalculationOversea_submit();
            }         
    }    
    
    ///////////////////////////////////////////////////////
    // do workshop check (local)//
    //////////////////////////////////////////////////////    
    function  doWorkshopCheck_Day1(checkBoxControl)
    {
        // prompt if use enter a non-no. value or blank
        var JRF1; 
        var JRF2;
        var JRF3;
        var JRF4;
        var JRF5;
        var JRF6;
        var JRF7;    
        
        JRF1 = document.getElementById('JRF1');
        JRF2 = document.getElementById('JRF2');
        JRF3 = document.getElementById('JRF3');
        JRF4 = document.getElementById('JRF4');
        WS1A = document.getElementById('WS1A');
        WS1B = document.getElementById('WS1B');
        // JRF7 = document.getElementById('JRF7');

        if (checkBoxControl.id != JRF1.id)
            {
                JRF1.checked = false;
            }

        if (checkBoxControl.id != JRF2.id)
            {
                JRF2.checked = false;
            }

        if (checkBoxControl.id != JRF3.id)
            {
                JRF3.checked = false;
            }

        if (checkBoxControl.id != JRF4.id)
            {
                JRF4.checked = false;
            }

        if (checkBoxControl.id != WS1A.id)
            {
                WS1A.checked = false;
            }

        if (checkBoxControl.id != WS1B.id)
            {
                WS1B.checked = false;
            }
    }     
    
    ///////////////////////////////////////////////////////
    // do workshop check (local)//
    //////////////////////////////////////////////////////    
    function  doWorkshopCheck_Day2(checkBoxControl)
    {
        // prompt if use enter a non-no. value or blank
        var JRF8; 
        var JRF9;
        var JRF10;
        var JRF11;
        var JRF12;
        var JRF13;
   
        
        JRF5 = document.getElementById('JRF5');
        JRF6 = document.getElementById('JRF6');
        JRF7 = document.getElementById('JRF7');
        JRF8 = document.getElementById('JRF8');
        WS2A = document.getElementById('WS2A');
        WS2B = document.getElementById('WS2B');
        
        if (checkBoxControl.id != JRF5.id)
            {
                JRF5.checked = false;
            }

        if (checkBoxControl.id != JRF6.id)
            {
                JRF6.checked = false;
            }

        if (checkBoxControl.id != JRF7.id)
            {
                JRF7.checked = false;
            }

        if (checkBoxControl.id != JRF8.id)
            {
                JRF8.checked = false;
            }

        if (checkBoxControl.id != WS2A.id)
            {
                WS2A.checked = false;
            }

        if (checkBoxControl.id != WS2B.id)
            {
                WS2B.checked = false;
            }
    }         
    ///////////////////////////////////////////////////////
    // do workshop check (local) //
    //////////////////////////////////////////////////////    
    function  doWorkshopCheck1(checkBoxControl)
    {
        // prompt if use enter a non-no. value or blank
        var chkPaperday1; 
        var chkPaperday2;
        var chkPublishday1;
        var chkPublishday2;    
        
        chkPaperday1 = document.getElementById('chkPaperDay1');
        chkPaperday2 = document.getElementById('chkPaperDay2');
        chkPublishday1 = document.getElementById('chkPublishDay1');
        chkPublishday2 = document.getElementById('chkPublishDay2');
        
        if (checkBoxControl.id == 'chkPaperDay1')
            {
                if (chkPaperday1.checked)
                    {
                        if (chkPublishday1.checked)
                        {
                            checkBoxControl.checked = false;
                            alert('Only one workshop allow for the same day!' );
                            return;
                        }
                        else
                        {
                            chkPaperday2.checked = false;
                            PaymentCalculation();
                            return;
                        }
                    } 
                else
                    {
                        PaymentCalculation();
                    }                         
            }


        if (checkBoxControl.id == 'chkPaperDay2')
            {
                if (chkPaperday2.checked)
                    {            
                        if (chkPublishday2.checked)
                        {
                            checkBoxControl.checked = false;
                            alert('Only one workshop allow for the same day!' );
                            return;
                        }
                        else
                        {
                            chkPaperday1.checked = false;
                            PaymentCalculation();
                            return;
                        }
                    }
                else
                    {
                        PaymentCalculation();
                    }                
            }
        
         if (checkBoxControl.id == 'chkPublishDay1')
            {
                if (chkPublishday1.checked)
                    {
                        if (chkPaperday1.checked)
                        {
                            checkBoxControl.checked = false;
                            alert('Only one workshop allow for the same day!' );
                            return;
                        }
                        else
                        {
                            chkPublishday2.checked = false;
                            PaymentCalculation();
                            return;
                        }                     
                    }
                else
                    {
                        PaymentCalculation();
                    }                 
            }    
        
         if (checkBoxControl.id == 'chkPublishDay2')
            {
                if (chkPublishday2.checked)
                    {
                        if (chkPaperday2.checked)
                        {
                            checkBoxControl.checked = false;
                            alert('Only one workshop allow for the same day!' );
                            return;
                        }
                        else
                        {
                            chkPublishday1.checked = false;
                            PaymentCalculation();
                            return;
                        }             
                    }
                else
                    {
                        //alert('tsting');
                        PaymentCalculation();
                    }                 
            }                  
    } 

    ///////////////////////////////////////////////////////
    // do workshop check  (oversea)//
    //////////////////////////////////////////////////////    
    function  doWorkshopCheckOverSea(checkBoxControl)
    {
        // prompt if use enter a non-no. value or blank
        var chkPaperday1; 
        var chkPaperday2;
        var chkPublishday1;
        var chkPublishday2;    
        
        chkPaperday1 = document.getElementById('chkPaperDay1');
        chkPaperday2 = document.getElementById('chkPaperDay2');
        chkPublishday1 = document.getElementById('chkPublishDay1');
        chkPublishday2 = document.getElementById('chkPublishDay2');
        
        if (checkBoxControl.id == 'chkPaperDay1')
            {
                if (chkPaperday1.checked)
                    {
                        if (chkPublishday1.checked)
                        {
                            checkBoxControl.checked = false;
                            alert('Only one workshop allow for the same day!' );
                            return;
                        }
                        else
                        {
                            chkPaperday2.checked = false;
                            PaymentCalculationOversea();
                            return;
                        }
                    } 
                else
                    {
                        PaymentCalculationOversea();
                    }                         
            }


        if (checkBoxControl.id == 'chkPaperDay2')
            {
                if (chkPaperday2.checked)
                    {            
                        if (chkPublishday2.checked)
                        {
                            checkBoxControl.checked = false;
                            alert('Only one workshop allow for the same day!' );
                            return;
                        }
                        else
                        {
                            chkPaperday1.checked = false;
                            PaymentCalculationOversea();
                            return;
                        }
                    }
                else
                    {
                        PaymentCalculationOversea();
                    }                
            }
        
         if (checkBoxControl.id == 'chkPublishDay1')
            {
                if (chkPublishday1.checked)
                    {
                        if (chkPaperday1.checked)
                        {
                            checkBoxControl.checked = false;
                            alert('Only one workshop allow for the same day!' );
                            return;
                        }
                        else
                        {
                            chkPublishday2.checked = false;
                            PaymentCalculationOversea();
                            return;
                        }                     
                    }
                else
                    {
                        PaymentCalculationOversea();
                    }                 
            }    
        
         if (checkBoxControl.id == 'chkPublishDay2')
            {
                if (chkPublishday2.checked)
                    {
                        if (chkPaperday2.checked)
                        {
                            checkBoxControl.checked = false;
                            alert('Only one workshop allow for the same day!' );
                            return;
                        }
                        else
                        {
                            chkPublishday1.checked = false;
                            PaymentCalculationOversea();
                            return;
                        }             
                    }
                else
                    {
                        //alert('tsting');
                        PaymentCalculationOversea();
                    }                 
            }                  
    } 
    ///////////////////////////////////////////////////////
    // do payment check  //
    //////////////////////////////////////////////////////    
    function  doPaymentCheck(RadioButtonControl)
    {
        // prompt if use enter a non-no. value or blank
        var rbChequePayment; 
        var rbSponsorshipPayment;
        var rbCreditCardPayment;
        
        
        rbChequePayment = document.getElementById('rbCheque');
        rbSponsorshipPayment = document.getElementById('rbSponsorship');
        rbCreditCardPayment = document.getElementById('rbCreditCard');
        
        
        if (RadioButtonControl.id != rbChequePayment.id)
            {
                rbChequePayment.checked = false;
            }           

        if (RadioButtonControl.id != rbSponsorshipPayment.id)
            {
                rbSponsorshipPayment.checked = false;
            } 
    
        if (RadioButtonControl.id != rbCreditCardPayment.id)
            {                
                rbCreditCardPayment.checked = false;
            }        
    } 
    
    ///////////////////////////////////////////////////////
    // Payment Calculation  //
    ////////////////////////////////////////////////////// 
    function PaymentCalculation()
    {
    
        var chkMain; 
        var chkDay1;
        var chkDay2;    
        var lblTotalAmount;
        var TodayDate = new Date();
        var earlybirddate = new Date("July 1 2008");
        var amount = 0;
        var blnEarlybird = false;
        var blnInstitution = false; // newly add
        
        var main_earlybird = 770.00;
        var main_latebird = 925.00;
        var main_earlybird_institution = 695.00;
        var main_latebird_institution = 850.00;
        
        var day1_earlybird = 430.00;
        var day1_latebird = 540.00;
        
        var day1_earlybird_institution = 385.00;
        var day1_latebird_institution = 465.00;
        
        var ddlInstitutions;
        chkMain = document.getElementById('chkMain');
        chkDay1 = document.getElementById('chkDay1');
        chkDay2 = document.getElementById('chkDay2'); 
        ddlInstitutions = document.getElementById('ddlInstitutions');

        
        
        if (TodayDate > earlybirddate)
        {
            blnEarlybird = false;
        }
        else if (TodayDate <= earlybirddate)
        {
            blnEarlybird = true;
        }         
        
        if (ddlInstitutions.options[ddlInstitutions.selectedIndex].value == '-') // newly add
        {
            blnInstitution = false;
        }
        else
        {
            blnInstitution = true;          
        }
        
        
        if (chkMain.checked == true) // main conference
        {
            if (blnInstitution)
            {
                // institution
                if (blnEarlybird)
                {
                    amount = main_earlybird_institution;                
                }
                else
                {
                    amount = main_latebird_institution;
                } 
            }
            else
            {
                // non institution
                if (blnEarlybird)
                {
                    amount = main_earlybird;                
                }
                else
                {
                    amount = main_latebird;
                }                 
            }
            
           
        }
        else
        {
            if (chkDay1.checked == true || chkDay2.checked == true) // either day 1 or day 2 conference 
            {
                if (blnInstitution)
                {
                    // inistitution discount
                    if (blnEarlybird)
                    {
                        amount = day1_earlybird_institution;                
                    }
                    else
                    {
                        amount = day1_latebird_institution;
                    }                     
                }
                else
                {
                    // non institution, no discount
                    if (blnEarlybird)
                    {
                        amount = day1_earlybird;                
                    }
                    else
                    {
                        amount = day1_latebird;
                    }                         
                }
            }        
        }
        document.getElementById("lblTotalAmount").innerHTML = 'S$' + Math.round(amount*100)/100;
    }

    function PaymentCalculation_submit()
    {
    
        var chkMain; 
        var chkDay1;
        var chkDay2;    
        var lblTotalAmount;
        var TodayDate = new Date();
        var earlybirddate = new Date("July 1 2008");
        var amount = 0;
        var blnEarlybird = false;
        var blnInstitution = false; // newly add
        
        var main_earlybird = 770.00;
        var main_latebird = 925.00;
        var main_earlybird_institution = 695.00;
        var main_latebird_institution = 850.00;
        
        var day1_earlybird = 430.00;
        var day1_latebird = 540.00;
        
        var day1_earlybird_institution = 385.00;
        var day1_latebird_institution = 465.00;
        
        var ddlInstitutions;
        var txtTotalPayableAmount;
        
        chkMain = document.getElementById('chkMain');
        chkDay1 = document.getElementById('chkDay1');
        chkDay2 = document.getElementById('chkDay2'); 
        ddlInstitutions = document.getElementById('ddlInstitutions');
        txtTotalPayableAmount = document.getElementById('txtTotalPayableAmount');  
        
        if (TodayDate > earlybirddate)
        {
            blnEarlybird = false;
        }
        else if (TodayDate <= earlybirddate)
        {
            blnEarlybird = true;
        }         
        
        if (ddlInstitutions.options[ddlInstitutions.selectedIndex].value == '-') // newly add
        {
            blnInstitution = false;
        }
        else
        {
            blnInstitution = true;          
        }
        
        
        if (chkMain.checked == true) // main conference
        {
            if (blnInstitution)
            {
                // institution
                if (blnEarlybird)
                {
                    amount = main_earlybird_institution;                
                }
                else
                {
                    amount = main_latebird_institution;
                } 
            }
            else
            {
                // non institution
                if (blnEarlybird)
                {
                    amount = main_earlybird;                
                }
                else
                {
                    amount = main_latebird;
                }                 
            }
            
           
        }
        else
        {
            if (chkDay1.checked == true || chkDay2.checked == true) // either day 1 or day 2 conference 
            {
                if (blnInstitution)
                {
                    // inistitution discount
                    if (blnEarlybird)
                    {
                        amount = day1_earlybird_institution;                
                    }
                    else
                    {
                        amount = day1_latebird_institution;
                    }                     
                }
                else
                {
                    // non institution, no discount
                    if (blnEarlybird)
                    {
                        amount = day1_earlybird;                
                    }
                    else
                    {
                        amount = day1_latebird;
                    }                         
                }
            }        
        }
        document.getElementById("lblTotalAmount").innerHTML = 'S$' + Math.round(amount*100)/100;
        txtTotalPayableAmount.value = Math.round(amount*100)/100;
    }

    ///////////////////////////////////////////////////////
    // Payment Calculation  oversea//
    ////////////////////////////////////////////////////// 
    function PaymentCalculationOversea()
    {
    
        var chkMain; 
        var chkDay1;
        var chkDay2;    
        var lblTotalAmount;
        var TodayDate = new Date();
        var earlybirddate = new Date("July 1 2008");
        var amount = 0;
        //var earlybirddate = new Date("Jan 01 2008")
        
        var blnEarlybird = false;
        var ddlInstitutions;
          
          
        var main_earlybird = 500.00;
        var main_latebird = 600.00;
        var main_earlybird_institution = 450.00;
        var main_latebird_institution = 550.00;
        
        var day1_earlybird = 275.00;
        var day1_latebird = 350.00;
        
        var day1_earlybird_institution = 250.00;
        var day1_latebird_institution = 300.00;
                  
          
        chkMain = document.getElementById('chkMain');
        chkDay1 = document.getElementById('chkDay1');
        chkDay2 = document.getElementById('chkDay2');
        ddlInstitutions = document.getElementById('ddlInstitutions'); 

        
        
        if (TodayDate > earlybirddate)
        {
            blnEarlybird = false;
        }
        else if (TodayDate <= earlybirddate)
        {
            blnEarlybird = true;
        }         
        
        if (ddlInstitutions.options[ddlInstitutions.selectedIndex].value == '-') // newly add
        {
            blnInstitution = false;
            //alert(blnInstitution);
        }
        else
        {
            blnInstitution = true;         
        }
                
        if (chkMain.checked == true) // main conference
        {
            if (blnInstitution)
            {
                // institution
                if (blnEarlybird)
                {
                    amount = main_earlybird_institution;                
                }
                else
                {
                    amount = main_latebird_institution;
                } 
            }
            else
            {
                // non institution
                if (blnEarlybird)
                {
                    amount = main_earlybird;                
                }
                else
                {
                    amount = main_latebird;
                }                 
            }         
        }
        else
        {
            if (chkDay1.checked == true || chkDay2.checked == true) // either day 1 or day 2 conference 
            {
                if (blnInstitution)
                {
                    // inistitution discount
                    if (blnEarlybird)
                    {
                        amount = day1_earlybird_institution;                
                    }
                    else
                    {
                        amount = day1_latebird_institution;
                    }                     
                }
                else
                {
                    // non institution, no discount
                    if (blnEarlybird)
                    {
                        amount = day1_earlybird;                
                    }
                    else
                    {
                        amount = day1_latebird;
                    }                         
                }        
            }        
        }
        document.getElementById("lblTotalAmount").innerHTML = 'US$' + Math.round(amount*100)/100;        
    }    
    
    function PaymentCalculationOversea_submit()
    {
    
        var chkMain; 
        var chkDay1;
        var chkDay2;    
        var lblTotalAmount;
        var TodayDate = new Date();
        var earlybirddate = new Date("July 1 2008");
        var amount = 0;
        //var earlybirddate = new Date("Jan 01 2008")
        
        var blnEarlybird = false;
        var ddlInstitutions;
          
          
        var main_earlybird = 500.00;
        var main_latebird = 600.00;
        var main_earlybird_institution = 450.00;
        var main_latebird_institution = 550.00;
        
        var day1_earlybird = 275.00;
        var day1_latebird = 350.00;
        
        var day1_earlybird_institution = 250.00;
        var day1_latebird_institution = 300.00;
        var txtTotalPayableAmount;
                          
          
        chkMain = document.getElementById('chkMain');
        chkDay1 = document.getElementById('chkDay1');
        chkDay2 = document.getElementById('chkDay2');
        ddlInstitutions = document.getElementById('ddlInstitutions'); 
        txtTotalPayableAmount = document.getElementById('txtTotalPayableAmount');  
        
        
        if (TodayDate > earlybirddate)
        {
            blnEarlybird = false;
        }
        else if (TodayDate <= earlybirddate)
        {
            blnEarlybird = true;
        }         
        
        if (ddlInstitutions.options[ddlInstitutions.selectedIndex].value == '-') // newly add
        {
            blnInstitution = false;
            //alert(blnInstitution);
        }
        else
        {
            blnInstitution = true;         
        }
                
        if (chkMain.checked == true) // main conference
        {
            if (blnInstitution)
            {
                // institution
                if (blnEarlybird)
                {
                    amount = main_earlybird_institution;                
                }
                else
                {
                    amount = main_latebird_institution;
                } 
            }
            else
            {
                // non institution
                if (blnEarlybird)
                {
                    amount = main_earlybird;                
                }
                else
                {
                    amount = main_latebird;
                }                 
            }         
        }
        else
        {
            if (chkDay1.checked == true || chkDay2.checked == true) // either day 1 or day 2 conference 
            {
                if (blnInstitution)
                {
                    // inistitution discount
                    if (blnEarlybird)
                    {
                        amount = day1_earlybird_institution;                
                    }
                    else
                    {
                        amount = day1_latebird_institution;
                    }                     
                }
                else
                {
                    // non institution, no discount
                    if (blnEarlybird)
                    {
                        amount = day1_earlybird;                
                    }
                    else
                    {
                        amount = day1_latebird;
                    }                         
                }        
            }        
        }
        document.getElementById("lblTotalAmount").innerHTML = 'US$' + Math.round(amount*100)/100;  
        txtTotalPayableAmount.value = Math.round(amount*100)/100;
    } 
        
    function DisableControl(htmlControl)
    {
        htmlControl.disabled=true;
    }    
    
    
    function textCounter(field, countfield, maxlimit)
    {
        
        if (field.value.length > maxlimit) // if too long...trim it! 
	    {
	        field.value = field.value.substring(0, maxlimit); 
	    }
	    // otherwise, update 'characters left' counter 
	    else
	    {
	        //alert(countfield.value);
	        countfield.value = maxlimit - field.value.length; 
	        //alert(countfield.value);
	        //alert('substring');
	        countfield.innerHTML = maxlimit - field.value.length;
	    }
	    

    }
    
    function absctractchecking(checkBoxControl)
    {
        var chkDiabetes; 
        var chkObesity;
        var chkMetabolic;
     
        
        chkDiabetes = document.getElementById('chkDiabetes');
        chkObesity = document.getElementById('chkObesity');
        chkMetabolic = document.getElementById('chkMetabolic');

    
        if (checkBoxControl.id != chkDiabetes.id)
            {
                chkDiabetes.checked = false;
            }

        if (checkBoxControl.id != chkObesity.id)
            {
                chkObesity.checked = false;
            }
        
        if (checkBoxControl.id != chkMetabolic.id)
            {
                chkMetabolic.checked = false;
            }    
    }
    

    function wordCount(textField, countField, maxLimit)
    {          
    	var fieldcontent;
	    var fieldsplitting;
	    var wordsLength;
	    var lastwordindex;
	    var lastword;
	    var obj1;
	    var obj2;
	    var charcount;
	    var hidWordCount;
	   // replacing of interior multiple spaces is to replace all instances of one or more spaces with a single space
        hidWordCount = document.getElementById('hidWordCount');

        
        fieldcontent = textField.value;
        fieldcontent = fieldcontent.replace(/\s+/g, ' ');  //replace all instances of one-or-more spaces with a single space
	    fieldsplitting = fieldcontent.split(/[\s]+/);
	    wordsLength = fieldsplitting.length;
	    if (wordsLength > maxLimit)
	    {
	        charcount = textField.value.length;
	        returnWordsLimit(textField.value,250,textField);
	        countField.value = '0';
	    }
	    else
	    {
	        if (wordsLength == 1)
	        {
	            if (fieldsplitting[0] == '')
	            {
	                countField.value = 250; 	                
	            }
	            else
	            {
	                countField.value = maxLimit - wordsLength; 
	            }
	        }
	        else
	        {
	            countField.value = maxLimit - wordsLength;  
	        }
	              
	    }
	    hidWordCount.value = wordsLength;	    	  	    
    }
    
    function returnWordsLimit(wordsvalue, wordslimit,textboxcontrol)
    {
        var fieldcontent;
        var fieldsplitting;
        var counter;
        var concatstring;
        var lastindex;
        var lastwords;
        var returnstring;
        returnstring = wordsvalue;
	    fieldcontent = wordsvalue;
	    var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
        if (obj.test(fieldcontent)) { fieldcontent = fieldcontent.replace(obj, '$2'); }
        var obj = / +/g;
        fieldcontent = fieldcontent.replace(obj, " ");
        if (fieldcontent == " ") { fieldcontent = ""; }
        fieldsplitting = fieldcontent.split(' ');

        if (fieldsplitting.length > 250)
        {            
            lastindex = wordsvalue.lastIndexOf(fieldsplitting[wordslimit-1]);
            lastwords = wordsvalue.substring(0,lastindex);  
            returnWordsLimit(lastwords,wordslimit,textboxcontrol);            
        }
        else
        {
            textboxcontrol.value = returnstring;      
            return returnstring;
        }
  
    }
  
    function confirmDialog()
    {
    
        var ans;
        ans = window.confirm('No editing of this abstract is allowed after submission.\n confirm to go ahead?');
        return ans;        
    }
    
    function testing()
    {
        alert('testing');
        return true;
    }
    
