﻿////////////////////////////////////////////////////
// Survey functions file - (c) Impel Systems 2006
////////////////////////////////////////////////////

var m_onsubmit = "";

function checkStep()
{
  // form activation
  var tf=returnObjById('aspnetForm');
  var doc=document;
  var okcomputer = true;

  switch (tf.ctl00_cphMain_hfSectionIndex.value)
  {
    case "1": // section 1
        if (tf.ctl00_cphMain_q6_drpAnswers[tf.ctl00_cphMain_q6_drpAnswers.selectedIndex].value == "14")
        {
            toggleVisibility("qwrap7",false);
            toggleVisibility("qwrap8",false);
            toggleVisibility("qwrap9",false);
            toggleVisibility("qwrap11",false);
            toggleVisibility("qwrap12",false);
            toggleVisibility("qwrap14",false);
            toggleVisibility("qwrap15",false);
            toggleVisibility("qwrap16",false);
            switchValidation(true);
        }
        else
        {
            toggleVisibility("qwrap7",true);

            if (tf.ctl00_cphMain_q7_chkAnswers_6.checked == true)
            {
                toggleVisibility("qwrap8",false);
                toggleVisibility("qwrap9",false);
                toggleVisibility("qwrap11",false);
                toggleVisibility("qwrap12",false);
                toggleVisibility("qwrap14",false);
                toggleVisibility("qwrap15",false);
                toggleVisibility("qwrap16",false);
                switchValidation(true);        
                
                tf.ctl00_cphMain_q7_chkAnswers_0.checked = false;                
                tf.ctl00_cphMain_q7_chkAnswers_1.checked = false;                
                tf.ctl00_cphMain_q7_chkAnswers_2.checked = false;                
                tf.ctl00_cphMain_q7_chkAnswers_3.checked = false;                
                tf.ctl00_cphMain_q7_chkAnswers_4.checked = false;                
                tf.ctl00_cphMain_q7_chkAnswers_5.checked = false;
            } 
            else
            {
                toggleVisibility("qwrap8",true);
                toggleVisibility("qwrap9",true);
                
                if (tf.ctl00_cphMain_group9_q9_32.checked == true)
                {
                    toggleVisibility("qwrap11",false);
                    toggleVisibility("qwrap12",false);
                    toggleVisibility("qwrap14",false);
                    toggleVisibility("qwrap15",false);
                    toggleVisibility("qwrap16",false);
                    switchValidation(true);
                    
                    tf.ctl00_cphMain_group9_q9_29.checked = false;
                    tf.ctl00_cphMain_group9_q10_0.checked = false;
                    tf.ctl00_cphMain_group9_q10_1.checked = false;
                    tf.ctl00_cphMain_group9_q10_2.checked = false;
                    tf.ctl00_cphMain_group9_q9_30.checked = false;
                    tf.ctl00_cphMain_group9_q13_0.checked = false;
                    tf.ctl00_cphMain_group9_q13_1.checked = false;
                    tf.ctl00_cphMain_group9_q13_2.checked = false;
                    tf.ctl00_cphMain_group9_q13_3.checked = false;
                    tf.ctl00_cphMain_group9_q13_4.checked = false;
                    tf.ctl00_cphMain_group9_q9_31.checked = false;
                }
                else
                {
                    toggleVisibility("qwrap11",true);
                    toggleVisibility("qwrap12",true);
                    
                    if (tf.ctl00_cphMain_group9_q10_0.checked == true || tf.ctl00_cphMain_group9_q10_1.checked == true || tf.ctl00_cphMain_group9_q10_2.checked == true)
                    {
                        tf.ctl00_cphMain_group9_q9_29.checked = true;
                    }
                    if (tf.ctl00_cphMain_group9_q13_0.checked == true || tf.ctl00_cphMain_group9_q13_1.checked == true || tf.ctl00_cphMain_group9_q13_2.checked == true || tf.ctl00_cphMain_group9_q13_3.checked == true || tf.ctl00_cphMain_group9_q13_4.checked == true)
                    {
                        tf.ctl00_cphMain_group9_q9_30.checked = true;
                    }
                    
                    if (tf.ctl00_cphMain_q12_rlstAnswers_4.checked == true)
                    {
                        toggleVisibility("qwrap14",false);
                        toggleVisibility("qwrap15",false);
                        toggleVisibility("qwrap16",false);
                        switchValidation(true);                
                    }
                    else
                    {                   
                        toggleVisibility("qwrap14",true);
                        toggleVisibility("qwrap15",true);
                        
                        if (tf.ctl00_cphMain_q15_chkAnswers_2.checked == true)
                        {
                            tf.ctl00_cphMain_q15_chkAnswers_0.checked = false;
                            tf.ctl00_cphMain_q15_chkAnswers_1.checked = false;                            
                        
                            toggleVisibility("qwrap16",false);
                            switchValidation(true);                
                        }
                        else
                        {
                            toggleVisibility("qwrap16",true);
                            switchValidation(false);                
                        }
                    }
                }
            }  
        }
    
        otherSpecifyBool(tf.ctl00_cphMain_q6_drpAnswers.selectedIndex, (tf.ctl00_cphMain_q6_drpAnswers.length-1), tf.ctl00_cphMain_q6_q6_468_specify);
        otherSpecifyBool((trim(tf.q14_q14_61.value)==""), false, tf.q14_q14_61_specify);
        break;
        
    case "2": // section 2
        
        if (tf.ctl00_cphMain_group17_q18_0.checked == true || tf.ctl00_cphMain_group17_q18_1.checked == true)
        {
            tf.ctl00_cphMain_group17_q17_75.checked = true;
        }        
        if (tf.ctl00_cphMain_group17_q19_0.checked == true || tf.ctl00_cphMain_group17_q19_1.checked == true)
        {
            tf.ctl00_cphMain_group17_q17_76.checked = true;
        }        
        if (tf.ctl00_cphMain_group17_q20_0.checked == true || tf.ctl00_cphMain_group17_q20_1.checked == true)
        {
            tf.ctl00_cphMain_group17_q17_77.checked = true;
        }  
        if (tf.ctl00_cphMain_group17_q21_0.checked == true || tf.ctl00_cphMain_group17_q21_1.checked == true)
        {
            tf.ctl00_cphMain_group17_q17_78.checked = true;
        }      
        if (tf.ctl00_cphMain_group17_q22_0.checked == true || tf.ctl00_cphMain_group17_q22_1.checked == true)
        {
            tf.ctl00_cphMain_group17_q17_79.checked = true;
        }                               
        if (tf.ctl00_cphMain_group17_q23_0.checked == true || tf.ctl00_cphMain_group17_q23_1.checked == true)
        {
            tf.ctl00_cphMain_group17_q17_80.checked = true;
        }    
        if (tf.ctl00_cphMain_group17_q24_0.checked == true || tf.ctl00_cphMain_group17_q24_1.checked == true)
        {
            tf.ctl00_cphMain_group17_q17_81.checked = true;
        }    
        if (tf.ctl00_cphMain_group17_q25_0.checked == true || tf.ctl00_cphMain_group17_q25_1.checked == true)
        {
            tf.ctl00_cphMain_group17_q17_82.checked = true;
        }    
        if (tf.ctl00_cphMain_group17_q26_0.checked == true || tf.ctl00_cphMain_group17_q26_1.checked == true)
        {
            tf.ctl00_cphMain_group17_q17_83.checked = true;
        }    
        if (tf.ctl00_cphMain_group17_q27_0.checked == true || tf.ctl00_cphMain_group17_q27_1.checked == true)
        {
            tf.ctl00_cphMain_group17_q17_84.checked = true;
        }         
        if (tf.ctl00_cphMain_group17_q28_0.checked == true || tf.ctl00_cphMain_group17_q28_1.checked == true)
        {
            tf.ctl00_cphMain_group17_q17_85.checked = true;
        }
        if (tf.ctl00_cphMain_group17_q29_0.checked == true || tf.ctl00_cphMain_group17_q29_1.checked == true)
        {
            tf.ctl00_cphMain_group17_q17_86.checked = true;
        }                                          
        otherSpecifyBool(tf.ctl00_cphMain_group17_q17_111.checked, true, tf.ctl00_cphMain_group17_q17_111_specify);    
    
        if (tf.ctl00_cphMain_q32_chkAnswers_3.checked == true)
        {
            toggleVisibility("qwrap33",false);
        
            tf.ctl00_cphMain_q32_chkAnswers_0.checked = false;
            tf.ctl00_cphMain_q32_chkAnswers_1.checked = false;                    
            tf.ctl00_cphMain_q32_chkAnswers_2.checked = false;
        }
        else
        {
            toggleVisibility("qwrap33",true);        
        }
        
        forceNumericValue(tf.ctl00_cphMain_q33_q33_139);
        forceNumericValue(tf.ctl00_cphMain_q33_q33_140);
        forceNumericValue(tf.ctl00_cphMain_q33_q33_141);  
        
        // q16
        if (tf.ctl00_cphMain_group34_q35_drpAnswers.selectedIndex > 0)
        {
            tf.ctl00_cphMain_group34_q34_531.checked = true;
        }
        if (tf.ctl00_cphMain_group34_q36_drpAnswers.selectedIndex > 0)
        {
            tf.ctl00_cphMain_group34_q34_532.checked = true;
        }
        if (tf.ctl00_cphMain_group34_q37_drpAnswers.selectedIndex > 0)
        {
            tf.ctl00_cphMain_group34_q34_533.checked = true;
        }
        if (tf.ctl00_cphMain_group34_q38_drpAnswers.selectedIndex > 0)
        {
            tf.ctl00_cphMain_group34_q34_534.checked = true;
        }
        
        
        // q17
        if (tf.ctl00_cphMain_group39_q39_172.checked == true)
        {
            tf.ctl00_cphMain_group39_q39_166.checked = false;        
            tf.ctl00_cphMain_group39_q40_0.checked = false;
            tf.ctl00_cphMain_group39_q40_1.checked = false;
            tf.ctl00_cphMain_group39_group102_q102_469.value = "";
            tf.ctl00_cphMain_group39_q41_0.checked = false;
            tf.ctl00_cphMain_group39_q41_1.checked = false;
            tf.ctl00_cphMain_group39_group103_q103_470.value = "";
            tf.ctl00_cphMain_group39_q39_167.checked = false;
        }
        else
        {
            if (tf.ctl00_cphMain_group39_q40_0.checked == true || tf.ctl00_cphMain_group39_q40_1.checked == true || isNumeric(tf.ctl00_cphMain_group39_group102_q102_469.value,""))
            {
                tf.ctl00_cphMain_group39_q39_166.checked = true;
            }             
            forceNumericValue(tf.ctl00_cphMain_group39_group102_q102_469);   

            if (tf.ctl00_cphMain_group39_q41_0.checked == true || tf.ctl00_cphMain_group39_q41_1.checked == true || isNumeric(tf.ctl00_cphMain_group39_group103_q103_470.value,""))
            {
                tf.ctl00_cphMain_group39_q39_167.checked = true;
            }      
            forceNumericValue(tf.ctl00_cphMain_group39_group103_q103_470);    
        }
        

        
    
        // q18
        forceNumericValue(tf.ctl00_cphMain_q42_q42_173);
    
        // this section still vis?
        if (tf.ctl00_cphMain_q43_chkAnswers_3)
        {
        // q19
        otherSpecifyBool(tf.ctl00_cphMain_q43_chkAnswers_3.checked, true, tf.ctl00_cphMain_q43_q43_507_specify);            
        
        // q21
        otherSpecifyBool(tf.ctl00_cphMain_q45_chkAnswers_13.checked, true, tf.ctl00_cphMain_q45_q45_508_specify);            
        }
    
        break;
        
    case "3": // section 3

        // q23
        otherSpecifyBool(tf.ctl00_cphMain_q47_rlstAnswers_1.checked, true, tf.ctl00_cphMain_q47_q47_200_specify);
    
        // q24
        otherSpecifyBool(isNumeric(tf.q48_q48_471.value,""), true, tf.q48_q48_471_specify);
        
        // q25
        // grant fund
        // loc
        if (tf.ctl00_cphMain_group49_group50_q50_211.checked == true || tf.ctl00_cphMain_group49_group50_q51_0.checked == true)
        {
            if (tf.ctl00_cphMain_group49_group50_q51_0.checked == true)
            {
                tf.ctl00_cphMain_group49_group50_q50_211.checked = true;
            }

            tf.ctl00_cphMain_group49_q49_208.checked = true;
        }
        // state
        if (tf.ctl00_cphMain_group49_group50_q50_212.checked == true || tf.ctl00_cphMain_group49_group50_q52_0.checked == true
        || trim(tf.ctl00_cphMain_group49_group50_group105_q105_473.value) != "")
        {
            if (trim(tf.ctl00_cphMain_group49_group50_group105_q105_473.value) != "")
            {
                tf.ctl00_cphMain_group49_group50_q52_0.checked = true;
            }
            if (tf.ctl00_cphMain_group49_group50_q52_0.checked == true)
            {
                tf.ctl00_cphMain_group49_group50_q50_212.checked = true;
            }

            tf.ctl00_cphMain_group49_q49_208.checked = true;
        }   
        // commonwealth
        if (tf.ctl00_cphMain_group49_group50_q50_213.checked == true || tf.ctl00_cphMain_group49_group50_q104_0.checked == true
        || trim(tf.ctl00_cphMain_group49_group50_group53_q53_216.value) != "")
        {
            if (trim(tf.ctl00_cphMain_group49_group50_group53_q53_216.value) != "")
            {
                tf.ctl00_cphMain_group49_group50_q104_0.checked = true;
            }
            if (tf.ctl00_cphMain_group49_group50_q104_0.checked == true)
            {
                tf.ctl00_cphMain_group49_group50_q50_213.checked = true;
            }

            tf.ctl00_cphMain_group49_q49_208.checked = true;
        }                  
        
        if (tf.ctl00_cphMain_group49_q49_207.checked == true)
        {
            toggleVisibility("qwrap54",true);
        }
        else
        {
            toggleVisibility("qwrap54",false);
        }
        if (tf.ctl00_cphMain_group49_q49_208.checked == true)
        {
            toggleVisibility("qwrap55",true);
            toggleVisibility("qwrap56",true);            
        }
        else
        {
            toggleVisibility("qwrap55",false);
            toggleVisibility("qwrap56",false);            
        }        
        toggleVisibility("qwrap57",tf.ctl00_cphMain_group49_q49_209.checked);
        toggleVisibility("qwrap58",tf.ctl00_cphMain_group49_q49_210.checked);        

        // q28
        forceNumericValueMax(tf.ctl00_cphMain_q56_q56_237,100);           
        forceNumericValueMax(tf.ctl00_cphMain_q56_q56_238,100);           
        forceNumericValueMax(tf.ctl00_cphMain_q56_q56_239,100);                           
        
        // q31
        if (tf.ctl00_cphMain_q59_drpAnswers.selectedIndex == 2)
        {
            toggleVisibility("qwrap60",false);
            toggleVisibility("qwrap61",false);   
        }
        else
        {
            toggleVisibility("qwrap60",true);
            toggleVisibility("qwrap61",true);                    
        }
    
        break;
        
    case "4": // section 4
    
        if (tf.ctl00_cphMain_q66_chkAnswers_3.checked == true)
        {
            tf.ctl00_cphMain_q66_chkAnswers_0.checked = false;
            tf.ctl00_cphMain_q66_chkAnswers_1.checked = false;
            tf.ctl00_cphMain_q66_chkAnswers_2.checked = false;                        
        }
        
        // q35
        forceNumericValue(tf.ctl00_cphMain_q65_q65_291);
        forceNumericValue(tf.ctl00_cphMain_q65_q65_292);
        forceNumericValue(tf.ctl00_cphMain_q65_q65_293);
        forceNumericValue(tf.ctl00_cphMain_q65_q65_294);
        forceNumericValue(tf.ctl00_cphMain_q65_q65_295);
        forceNumericValue(tf.ctl00_cphMain_q65_q65_296);                                        
        forceNumericValue(tf.ctl00_cphMain_q65_q65_297);                                                
        forceNumericValue(tf.ctl00_cphMain_q65_q65_298);                                                        
        otherSpecifyBool(isNumeric(tf.ctl00_cphMain_q65_q65_298.value,""), true, tf.ctl00_cphMain_q65_txtOtherSpecify);        
        
        // q36
        toggleVisibility("qwrap67",false);        
        toggleVisibility("qwrap68",false);        
        toggleVisibility("qwrap70",false);        
        toggleVisibility("qwrap71",false);                                                        
        toggleVisibility("qwrap72",false);

        if (tf.ctl00_cphMain_q66_chkAnswers_0.checked == true)
        {
            toggleVisibility("qwrap67",true);
        }
        if (tf.ctl00_cphMain_q66_chkAnswers_1.checked == true)
        {
            toggleVisibility("qwrap68",true);
            toggleVisibility("qwrap69",true);                    
            toggleVisibility("qwrap70",true);                                
        }
        if (tf.ctl00_cphMain_q66_chkAnswers_2.checked == true)
        {
            toggleVisibility("qwrap71",true);        
            toggleVisibility("qwrap72",true);        
        }

        // q37
        forceNumericValue(tf.ctl00_cphMain_q67_q67_303);        
        forceNumericValueMax(tf.ctl00_cphMain_q67_q67_304,100); 
        
        // q38
        forceNumericValue(tf.ctl00_cphMain_group68_q107_q107_475);      
        forceNumericValueMax(tf.ctl00_cphMain_group68_q69_q69_307,100);        
        forceNumericValueMax(tf.ctl00_cphMain_group68_q69_q69_308,100);                   
        
        // q41
        otherSpecifyBool(tf.ctl00_cphMain_group72_q110_chkAnswers_5.checked, true, tf.ctl00_cphMain_group72_q110_q110_486_specify);
        otherSpecifyBool(tf.ctl00_cphMain_group72_q112_chkAnswers_5.checked, true, tf.ctl00_cphMain_group72_q112_q112_498_specify);
        otherSpecifyBool(tf.ctl00_cphMain_group72_q113_chkAnswers_5.checked, true, tf.ctl00_cphMain_group72_q113_q113_504_specify);
        otherSpecifyBool(tf.ctl00_cphMain_group72_q124_chkAnswers_5.checked, true, tf.ctl00_cphMain_group72_q124_q124_529_specify);                        
        
    
        // q42
        forceNumericValue(tf.ctl00_cphMain_group73_group115_q115_510);
        forceNumericValue(tf.ctl00_cphMain_group73_group116_q116_511);
        forceNumericValue(tf.ctl00_cphMain_group73_group117_q117_512);
        forceNumericValue(tf.ctl00_cphMain_group73_group118_q118_513);
        
        if (tf.ctl00_cphMain_group73_q73_325.checked == true || tf.ctl00_cphMain_group73_q73_324.checked == true)
        {
            tf.ctl00_cphMain_group73_q73_320.checked = false;
            tf.ctl00_cphMain_group73_q73_321.checked = false;
            tf.ctl00_cphMain_group73_q73_322.checked = false;
            tf.ctl00_cphMain_group73_q73_323.checked = false;
            
            tf.ctl00_cphMain_group73_group115_q115_510.value = "";
            tf.ctl00_cphMain_group73_group116_q116_511.value = "";
            tf.ctl00_cphMain_group73_group117_q117_512.value = "";
            tf.ctl00_cphMain_group73_group118_q118_513.value = "";  
        
            if (tf.ctl00_cphMain_group73_q73_325.checked == true)
            {
                tf.ctl00_cphMain_group73_q73_324.checked = false;
                        
                toggleVisibility("qwrap74",false);
                toggleVisibility("qwrap75",false);
                toggleVisibility("qwrap76",false);                        
            }
            else
            {
                // q43
                if (tf.ctl00_cphMain_q74_drpAnswers.selectedIndex == 1)
                {
                    toggleVisibility("qwrap75",false);
                    toggleVisibility("qwrap76",false);  
                }
                else
                {
                    toggleVisibility("qwrap75",true);

                    if (tf.ctl00_cphMain_q75_drpAnswers.selectedIndex == 1)
                    {
                        toggleVisibility("qwrap76",false);                
                    }
                    else
                    {                
                        toggleVisibility("qwrap76",true);
                    }
                }            
            }
            
        }
        else
        {
            if (trim(tf.ctl00_cphMain_group73_group115_q115_510.value) != "")
            {
                tf.ctl00_cphMain_group73_q73_320.checked = isNumeric(tf.ctl00_cphMain_group73_group115_q115_510.value,"");
            }
            if (trim(tf.ctl00_cphMain_group73_group116_q116_511.value) != "")
            {
                tf.ctl00_cphMain_group73_q73_321.checked = isNumeric(tf.ctl00_cphMain_group73_group116_q116_511.value,"");
            }            
            if (trim(tf.ctl00_cphMain_group73_group117_q117_512.value) != "")
            {
                tf.ctl00_cphMain_group73_q73_322.checked = isNumeric(tf.ctl00_cphMain_group73_group117_q117_512.value,"");
            }            
            if (trim(tf.ctl00_cphMain_group73_group118_q118_513.value) != "")
            {
                tf.ctl00_cphMain_group73_q73_323.checked = isNumeric(tf.ctl00_cphMain_group73_group118_q118_513.value,"");
            }            
        
            toggleVisibility("qwrap74",true);
            
            // q43
            if (tf.ctl00_cphMain_q74_drpAnswers.selectedIndex == 1)
            {
                toggleVisibility("qwrap75",false);
                toggleVisibility("qwrap76",false); 
            }
            else
            {
                toggleVisibility("qwrap75",true);

                if (tf.ctl00_cphMain_q75_drpAnswers.selectedIndex == 1)
                {
                    toggleVisibility("qwrap76",false);                
                }
                else
                {                
                    toggleVisibility("qwrap76",true);
                }
            }
            
        }
        
    
        // q45
        otherSpecifyBool(tf.ctl00_cphMain_q76_chkAnswers_4.checked, true, tf.ctl00_cphMain_q76_q76_505_specify);        
        
        // q48
        otherSpecifyBool(tf.ctl00_cphMain_q81_chkAnswers_4.checked, true, tf.ctl00_cphMain_q81_q81_368_specify);        
    
        break;
        
    case "5": // section 5
        
        // q51
        forceNumericValue(tf.ctl00_cphMain_q84_q84_381);
        forceNumericValue(tf.ctl00_cphMain_q84_q84_382);
        
        // q52
        forceNumericValue(tf.ctl00_cphMain_group85_group119_q119_514);
        forceNumericValue(tf.ctl00_cphMain_group85_group120_q120_515);
        forceNumericValue(tf.ctl00_cphMain_group85_group121_q121_516);
        forceNumericValue(tf.ctl00_cphMain_group85_group122_q122_517);    
        
        if (isNumeric(tf.ctl00_cphMain_group85_group119_q119_514.value,""))
        {
            tf.ctl00_cphMain_group85_q85_383.checked = true;
        }
        if (isNumeric(tf.ctl00_cphMain_group85_group120_q120_515.value,""))
        {
            tf.ctl00_cphMain_group85_q85_384.checked = true;
        }
        if (isNumeric(tf.ctl00_cphMain_group85_group121_q121_516.value,""))
        {
            tf.ctl00_cphMain_group85_q85_385.checked = true;
        }
        if (isNumeric(tf.ctl00_cphMain_group85_group122_q122_517.value,""))
        {
            tf.ctl00_cphMain_group85_q85_386.checked = true;
        }
        
        // q53
        if (tf.ctl00_cphMain_q86_drpAnswers.selectedIndex == 1)
        {
            toggleVisibility("qwrap87",false);
        }
        else
        {
            toggleVisibility("qwrap87",true);        
        }
        
        break;      
        
    case "6": // section 6
    
        // q57
        if (tf.ctl00_cphMain_group90_q91_0.checked == true || tf.ctl00_cphMain_group90_q91_1.checked == true || tf.ctl00_cphMain_group90_q91_2.checked == true)
        {
            tf.ctl00_cphMain_group90_q90_412.checked = true;
        }
        otherSpecifyBool(tf.ctl00_cphMain_group90_q90_506.checked, true, tf.ctl00_cphMain_group90_q90_506_specify);                
        
        // q59
        if (tf.ctl00_cphMain_q93_q93_421.checked == false)
        {
            tf.ctl00_cphMain_q93_q123_chkAnswers_0.checked = false;
            tf.ctl00_cphMain_q93_q123_chkAnswers_1.checked = false;
            tf.ctl00_cphMain_q93_q123_chkAnswers_2.checked = false;
            tf.ctl00_cphMain_q93_q123_chkAnswers_3.checked = false;                                    
        }
        
        otherSpecifyBool(tf.ctl00_cphMain_q93_q123_chkAnswers_3.checked, true, tf.ctl00_cphMain_q93_q123_q123_521_specify);                
        
        // q62
        if (tf.ctl00_cphMain_q97_drpAnswers.selectedIndex == 5)
        {
            
            toggleVisibility("qwrap98",false);
        }
        else
        {
            toggleVisibility("qwrap98",true);   
        }
    
        break;  
  }
}

function switchValidation(off)
{
  var tf=returnObjById("aspnetForm");
  var sv=returnObjById("ctl00_cphMain_hfSkipValidation"); 
  var valsum=returnObjById("ctl00_cphMain_valsumMain");   
  if (off)
  {
    m_onsubmit = tf.getAttribute("onsubmit");
    tf.setAttribute("onsubmit","");
    sv.value = "1";
    valsum.style.color = "#ffffff";  
  }
  else
  {
    if (m_onsubmit != "") { tf.setAttribute("onsubmit",""); }
    sv.value = "0";      
    valsum.style.color = "Red";              
  }
  
}

function toggleVisibility(tv_name, tv_visible) {
  //shows/hides id passed
  var tv_element = returnObjById(tv_name);
  if (tv_visible == true) {
    //visible
    //ableChildren(false,tv_element);
    if (tv_element.className != "cssVisible")
    {
        tv_element.className = "cssVisible";
    }

  } else {
    //hidden
    //ableChildren(true,tv_element);
    if (tv_element.className != "cssHidden")
    {
        tv_element.className = "cssHidden";
    }

  }
}

function ableChildren(tv_switch, tv_element) {
  for (var i = 0; i < tv_element.childNodes.length; i++)
  {
    if (tv_element.childNodes[i].childNodes.length > 0)
    {
      ableChildren(tv_switch, tv_element.childNodes[i]);
    }
    try {
    tv_element.childNodes[i].disabled = tv_switch;
    } catch (error) {
    }
  }
}

function otherSpecifyBool(ros_val1, ros_val2, ros_specify) {
  //enables/disables radio other/specify
  if (ros_val1 == ros_val2) {
    ros_specify.disabled = false;
  } else {
    ros_specify.value = "";
    ros_specify.disabled = true;
    }
}
function otherSpecify(ros_val, ros_specify) {
  //enables/disables radio other/specify
  if (ros_val.checked == true) {
    ros_specify.disabled = false;
  } else {
    ros_specify.value = "";
    ros_specify.disabled = true;
    }
}

function checkRating(cr_obj_in, cr_tag, cr_maxval, cr_maxrating, cr_msg) {
  var cr_obj;
  var cr_exvals = new Array();
  var cr_wrapObj;
  var cr_validlist="";
  var cr_i;
  
  cr_obj = returnObjById(cr_obj_in);

  for (cr_i=1; cr_i<(cr_maxrating+1); cr_i++) {
    cr_validlist += ""+ cr_i;
    }

  if (isNumeric(cr_obj.value,cr_validlist) == false && trim(cr_obj.value) != "") {
    cr_obj.value = "";
    if (cr_msg != "")
    {
      alert(cr_msg);
    }
    else
    {
      alert("Please indicate rating from 1 to "+cr_maxrating+".");
    }
    cr_obj.focus();
    }

  //get array of other vals
  cr_wrapObj = returnObjById(cr_tag);
  if (cr_wrapObj != null)
  {
    var e = cr_wrapObj.getElementsByTagName("input");
    for(var i=0;i<e.length;i++){ 
      if (trim(""+cr_obj.value) == trim(""+e[i].value) && e[i].value != "" && cr_obj.id != e[i].id) {
        //if (cr_obj.value != "") {
          alert("You have already entered this value for another option. Please check and try again.");
        //}
        cr_obj.value = "";
        cr_obj.focus();
        return;
        }
    }    
  }
}

function forceNumericValue(obj)
{
    if (obj){
        if (trim(obj.value) != "" && !isNumeric(obj.value,""))
        {
            alert("Please enter a numeric value.");
            obj.value = "";
        }
    }
}
function forceNumericValueMax(obj,maxval)
{
    if (obj){
        if (trim(obj.value) != "")
        {
            if (!isNumeric(obj.value,""))
            {
                alert("Please enter a numeric value of " + maxval + " or under");
                obj.value = "";                
            }
            else
            {
                if ((obj.value-0) > maxval)
                {
                    alert("Please enter a numeric value of " + maxval + " or under");
                    obj.value = "";                    
                }
            }
        }
    }
}

function returnObjById(id)
{
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}

function trim(str) {
  //trims leading and trailing spaces
  str = this != window ? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}
function isNumeric(inputText,inpList) {
  if (trim(inpList) != "") {
    var okChars = inpList;
  } else {
    var okChars = "1234567890";
    }

  if (trim(inputText) == "") { return false; }
  var isNumber=true;
  var cChar;
  for (i = 0; i < inputText.length && isNumber == true; i++) {
    cChar = inputText.charAt(i);
    if (okChars.indexOf(cChar) == -1) {
      isNumber = false;
      }
    }
  return isNumber;
}