gabrielcastillo 40 Web Developer

Hello, Im having issue's with this jquery code for enabling and disabling select/input box's. I have been googing everything but can not find a solution.

Any help would be appreciated. Thanks

<?php
session_start();

require_once 'includes/ncjhs_summerschool.php';

foreach($_POST as $key => $value ) {
  if( in_array($key,$CAPTURE_FIELDS) ) {
    $_SESSION[$key] = $value; 
  }
}

AuthSession();

mysql_close();

$root="../../";

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Summer Session Application -- New Community Jewish High School</title>
<link href="/css/stylesheet2010.css" rel="stylesheet" type="text/css" />

</head>

<body>

<div class="mainwrapper">
<?php include_once("subheader.php"); ?>
    <script type="text/javascript" src="js/jquery-validate/jquery.validate.min.js"></script>
    <script type="text/javascript" src="js/jquery.calculation.min.js"></script>

<div class="contentwrapper" style="overflow:hidden;">
        <div class="leftcolumn">
            <p><a href="../../assets/pdf/SUMMER_SESSION_2012_CATALOG.pdf" target="_blank">Course Catalog</a></p>
            <p><a href="../../assets/pdf/Summer_Session_2012_Emergency_Form.pdf" target="_blank">Emergency Medical Form</a></p>
            <p>&nbsp;</p>
        </div>
<!-- close left column -->

        <div class="rightcolumnwide">
            <div class="contenttitle">
                <h1>Summer Session</h1>
          </div>
                <div class="contentwide">


    <div id="container">
        <div id="header">
            <div id="header_1024">
                <center><h3>New Community Jewish High School</h3></center>

                <center>
                    <h2>SUMMER SESSION 2012 REGISTRATION FORM</h2></center>

                <div class="priority">
                    <center><h2>&nbsp;</h2></center>
                </div>


            </div>
        </div>       <div id="content">

            <div id="content_1024">
                                <div style="width: 663px; margin: 25px auto; ">
                    <form action="paymethod.php" method="post">
                        <div style="width: 80%; padding-left: 30px;">
                            <p style="margin-top: 20px;">&nbsp;</p>
                            <p style="margin: 10px 0px;">STUDENT NAME: <?php echo $_SESSION['fname'] ?>  <?php echo $_SESSION['lname'] ?></p>
                            <p>PLEASE PUT A CHECK (•) NEXT TO THE COURSES YOU WANT AND SELECT THE TYPE OF SESSION</p>

                        </div>
                        <div style="width: 100%; height: 40px; margin-top: 25px;">
                            <div style="width: 37%; float: left; text-align: left; margin-left: 10px; margin-top:-12px; ">
                                <p><input id="algebra_1_checkbox" type="checkbox" name="algebra_1" value="algebra_1" rel="algebra_1" /> ALGEBRA 1</p>
                            </div>
                            <div style="width: 32%; float: left; text-align: left; margin-top:-12px;">
                                <p>SESSION TYPE: <select id="algebra_1_selection" class="algebra_1_selection course_session_selection" name="algebra_1_session_type" rel="algebra_1" disabled="disabled" onchange="showUser('algebra_1',this.value)">

                                    <?php PrintCourseSessionOptions('algebra_1'); ?>
                                </select></p>
                            </div>

                            <div style="width: 24%; float: left; text-align: left; margin-left: 15px;">
                                <input id="algebra_1_selectionresult" type="text" class="price" name="algebra_1_price" value="" rel="algebra_1" disabled="disabled"/>
                                <p id="algebra_1_result">&nbsp;</p>
                            </div>

                        </div>
                        <div style="width: 100%; height: 40px;clear:both;">
                            <div style="width: 37%; float: left; text-align: left; margin-left: 10px; margin-top:-12px;">
                                <p><input id="anatomy_physiology_checkbox" type="checkbox" name="anatomy_physiology" value="anatomy_physiology" rel="anatomy_physiology" /> ANATOMY & PHYSIOLOGY</p>

                            </div>
                            <div style="width: 32%; float: left; text-align: left; margin-top:-12px;">
                                <p>SESSION TYPE: <select id="anatomy_physiology_selection" class="anatomy_physiology_selection course_session_selection" name="anatomy_physiology_session_type" rel="anatomy_physiology" disabled="disabled" onchange="showUser('anatomy_physiology',this.value)">
                                    <?php PrintCourseSessionOptions('anatomy_physiology'); ?>
                                </select></p>
                            </div>
                            <div style="width: 24%; float: left; text-align: left; margin-left: 15px;">
                                <input id="anatomy_physiology_selectionresult" type="text" class="price" name="anatomy_physiology_price" value="" rel="anatomy_physiology" disabled="disabled" >
                                <p id="anatomy_physiology_result">&nbsp;</p>
                            </div>
                        </div>

                        <div style="width: 100%; height: 40px;clear:both;">
                            <div style="width: 37%; float: left; text-align: left; padding-left: 10px; margin-top:-12px;">
                                <p><input id="anatomy_physiology_honors_checkbox" type="checkbox" name="anatomy_physiology_honors" value="anatomy_physiology_honors" rel="anatomy_physiology_honors" /> ANATOMY & PHYSIOLOGY - HONORS</p>
                            </div>
                            <div style="width: 32%; float: left; text-align: left; margin-top:-12px;">
                                <p>SESSION TYPE: <select id="anatomy_physiology_honors_selection" class="anatomy_physiology_honors_selection course_session_selection" name="anatomy_physiology_honors_session_type" rel="anatomy_physiology_honors" disabled="disabled" onchange="showUser('anatomy_physiology_honors',this.value)">
                                    <?php PrintCourseSessionOptions('anatomy_physiology_honors'); ?>
                                </select></p>
                            </div>
                            <div style="width: 24%; float: left; text-align: left; margin-left: 15px;">
                                <input id="anatomy_physiology_honors_selectionresult" type="text" class="price" name="anatomy_physiology_honors_price" value="" rel="anatomy_physiology_honors" disabled="disabled" >

                                <p id="anatomy_physiology_honors_result">&nbsp;</p>
                            </div>
                        </div>
                        <div style="width: 100%; height: 40px;clear:both;">
                            <div style="width: 37%; float: left; text-align: left; padding-left: 10px; margin-top:-12px;">
                                <p><input id="biology_checkbox" type="checkbox" name="biology" value="biology" rel="biology" /> BIOLOGY</p>
                            </div>
                            <div style="width: 32%; float: left; text-align: left; margin-top:-12px;">

                                <p>SESSION TYPE: <select id="biology_selection" class="biology_selection course_session_selection" name="biology_session_type" rel="biology" disabled="disabled" onchange="showUser('biology',this.value)">
                                    <?php PrintCourseSessionOptions('biology'); ?>
                                </select></p>

                            </div>
                            <div style="width: 24%; float: left; text-align: left; margin-left: 15px;">
                                <input id="biology_selectionresult" type="text" class="price" name="biology_price" value="" rel="biology" disabled="disabled" >
                                <p id="biology_result">&nbsp;</p>
                            </div>
                        </div>
                        <div style="width: 100%; height: 40px;clear:both;">
                            <div style="width: 37%; float: left; text-align: left; padding-left: 10px; margin-top:-12px;">
                                <p><input id="chemistry_checkbox" type="checkbox" name="chemistry" value="chemistry" rel="chemistry" /> CHEMISTRY</p>

                            </div>
                            <div style="width: 32%; float: left; text-align: left; margin-top:-12px;">
                                <p>SESSION TYPE: <select id="chemistry_selection" class="chemistry_selection course_session_selection" name="chemistry_session_type" rel="chemistry" disabled="disabled" onchange="showUser('chemistry',this.value)">
                                    <?php PrintCourseSessionOptions('chemistry'); ?>
                                </select></p>
                            </div>
                            <div style="width: 24%; float: left; text-align: left; margin-left: 15px;">
                                <input id="chemistry_selectionresult" type="text" class="price" name="chemistry_price" value="" rel="chemistry" disabled="disabled" >
                                <p id="chemistry_result">&nbsp;</p>
                            </div>
                        </div>

                        <div style="width: 100%; height: 40px;clear:both;">
                            <div style="width: 37%; float: left; text-align: left; padding-left: 10px; margin-top:-12px;">
                                <p><input id="geometry_checkbox" type="checkbox" name="geometry" value="geometry" rel="geometry" /> GEOMETRY</p>
                            </div>
                            <div style="width: 32%; float: left; text-align: left; margin-top:-12px;">
                                <p>SESSION TYPE: <select id="geometry_selection" class="geometry_selection course_session_selection" name="geometry_session_type" rel="geometry" disabled="disabled" onchange="showUser('geometry',this.value)">
                                    <?php PrintCourseSessionOptions('geometry'); ?>
                                </select></p>
                            </div>
                            <div style="width: 24%; float: left; text-align: left; margin-left: 15px;">
                                <input id="geometry_selectionresult" type="text" class="price" name="geometry_price" value="" rel="geometry" disabled="disabled" >

                                <p id="geometry_result">&nbsp;</p>
                            </div>
                        </div>
                        <div style="width: 100%; height: 40px;clear:both;">
                            <div style="width: 37%; float: left; text-align: left; padding-left: 10px; margin-top:-12px;">
                                <p><input id="hebrew_checkbox" type="checkbox" name="hebrew" value="hebrew" rel="hebrew" /> HEBREW</p>
                            </div>
                            <div style="width: 32%; float: left; text-align: left; margin-top:-12px;">

                                <p>SESSION TYPE: <select id="hebrew_selection" class="hebrew_selection course_session_selection" name="hebrew_session_type" rel="hebrew" disabled="disabled" onchange="showUser('hebrew',this.value)">
                                    <?php PrintCourseSessionOptions('hebrew'); ?>
                                </select></p>

                            </div>
                            <div style="width: 24%; float: left; text-align: left; margin-left: 15px;">
                                <input id="hebrew_selectionresult" type="text" class="price" name="hebrew_price" value="" rel="hebrew" disabled="disabled" >
                                <p id="hebrew_result">&nbsp;</p>
                            </div>
                        </div>
                        <div style="width: 100%; height: 40px;clear:both;">
                            <div style="width: 37%; float: left; text-align: left; padding-left: 10px; margin-top:-12px;">
                                <p><input id="jewish_studies_checkbox" type="checkbox" name="jewish_studies" value="jewish_studies" rel="jewish_studies" /> JEWISH STUDIES</p>

                            </div>
                            <div style="width: 32%; float: left; text-align: left; margin-top:-12px;">
                                <p>SESSION TYPE: <select id="jewish_studies_selection" class="jewish_studies_selection course_session_selection" name="jewish_studies_session_type" rel="jewish_studies" disabled="disabled" onchange="showUser('jewish_studies',this.value)">
                                    <?php PrintCourseSessionOptions('jewish_studies'); ?>
                                </select></p>
                            </div>
                            <div style="width: 24%; float: left; text-align: left; margin-left: 15px;">
                                <input id="jewish_studies_selectionresult" type="text" class="price" name="jewish_studies_price" value="" rel="jewish_studies" disabled="disabled" >
                                <p id="jewish_studies_result">&nbsp;</p>
                            </div>
                        </div>

                        <div style="width: 100%; height: 40px;clear:both;">
                            <div style="width: 37%; float: left; text-align: left; padding-left: 10px; margin-top:-12px;">
                                <p><input id="physics_checkbox" type="checkbox" name="physics" value="physics" rel="physics" /> PHYSICS</p>
                            </div>
                            <div style="width: 32%; float: left; text-align: left; margin-top:-12px;">
                                <p>SESSION TYPE: <select id="physics_selection" class="physics_selection course_session_selection" name="physics_session_type" rel="physics" disabled="disabled" onchange="showUser('physics',this.value)">
                                    <?php PrintCourseSessionOptions('physics'); ?>
                                </select></p>
                            </div>
                            <div style="width: 24%; float: left; text-align: left; margin-left: 15px;">
                                <input id="physics_selectionresult" type="text" class="price" name="physics_price" value="" rel="physics" disabled="disabled" >

                                <p id="physics_result">&nbsp;</p>
                            </div>
                        </div>
                        <div style="width: 100%; height: 40px;clear:both;">
                            <div style="width: 37%; float: left; text-align: left; padding-left: 10px; margin-top:-12px;">
                                <p><input id="pre_algebra_checkbox" type="checkbox" name="pre_algebra" value="pre_algebra" rel="pre_algebra" /> PRE-ALGEBRA</p>
                            </div>
                            <div style="width:32%; float: left; text-align: left;margin-top:-12px;">
                                <p>SESSION TYPE: <select id="pre_algebra_selection" class="pre_algebra_selection course_session_selection" name="pre_algebra_session_type" rel="pre_algebra" disabled="disabled" onchange="showUser('pre_algebra',this.value)">
                                    <?php PrintCourseSessionOptions('pre_algebra'); ?>
                                </select></p>

                            </div>
                            <div style="width: 24%; float: left; text-align: left; margin-left: 15px;">
                                <input id="pre_algebra_selectionresult" type="text" class="price" name="pre_algebra_price" value="" rel="pre_algebra" disabled="disabled" >
                                <p id="pre_algebra_result">&nbsp;</p>
                            </div>
                        </div>

                        <div style="width: 100%; height: 40px;clear:both;">
                            <div style="width: 37%; float: left; text-align: left; padding-left: 10px; margin-top:-12px;">
                                <p><input id="satprep_1_checkbox" type="checkbox" name="satprep" value="satprep" rel="satprep" /> SAT PREP</p>

                            </div>
                            <div style="width: 32%; float: left; text-align: left; margin-top:-12px;">
                                <p>SESSION TYPE: <select id="satprep_selection" class="satprep_selection course_session_selection" name="satprep_session_type" rel="satprep" disabled="disabled" onchange="showUser('satprep',this.value)">
                                    <?php PrintCourseSessionOptions('satprep'); ?>
                                </select></p>
                            </div>
                            <div style="width: 24%; float: left; text-align: left; margin-left: 15px;">
                                <input id="satprep_selectionresult" type="text" class="price" name="satprep_price" value="" rel="satprep" disabled="disabled" >
                                <p id="satprep_result">&nbsp;</p>
                            </div>
                        </div>


                        <div style="width: 100%; height: 40px;clear:both;">
                            <div style="width: 37%; float: left; text-align: left; padding-left: 10px; margin-top:-12px;">
                                <p><input id="spanish_1_checkbox" type="checkbox" name="spanish_1" value="spanish_1" rel="spanish_1" /> SPANISH 1</p>

                            </div>
                            <div style="width: 32%; float: left; text-align: left; margin-top:-12px;">
                                <p>SESSION TYPE: <select id="spanish_1_selection" class="spanish_1_selection course_session_selection" name="spanish_1_session_type" rel="spanish_1" disabled="disabled" onchange="showUser('spanish_1',this.value)">
                                    <?php PrintCourseSessionOptions('spanish_1'); ?>
                                </select></p>
                            </div>
                            <div style="width: 24%; float: left; text-align: left; margin-left: 15px;">
                                <input id="spanish_1_selectionresult" type="text" class="price" name="spanish_1_price" value="" rel="spanish_1" disabled="disabled" >
                                <p id="spanish_1_result">&nbsp;</p>
                            </div>
                        </div>

                        <div style="width: 100%; height: 40px;clear:both;">
                            <div style="width: 37%; float: left; text-align: left; padding-left: 10px; margin-top:-12px;">
                                <p><input id="spanish_2_checkbox" type="checkbox" name="spanish_2" value="spanish_2" rel="spanish_2" /> SPANISH 2</p>
                            </div>
                            <div style="width: 32%; float: left; text-align: left; margin-top:-12px;">
                                <p>SESSION TYPE: <select id="spanish_2_selection" class="spanish_2_selection course_session_selection" name="spanish_2_session_type" rel="spanish_2" disabled="disabled" onchange="showUser('spanish_2',this.value)">
                                    <?php PrintCourseSessionOptions('spanish_2'); ?>
                                </select></p>
                            </div>
                            <div style="width: 24%; float: left; text-align: left; margin-left: 15px;">
                                <input id="spanish_2_selectionresult" type="text" class="price" name="spanish_2_price" value="" rel="spanish_2" disabled="disabled" >

                                <p id="spanish_2_result">&nbsp;</p>
                            </div>
                        </div>

                        <div style="width: 100%; height: 40px;clear:both;">
                            <div style="width: 37%; float: left; text-align: left; padding-left: 10px; margin-top:-12px;">
                                <p><input id="spanish_3_checkbox" type="checkbox" name="spanish_3" value="spanish_3" rel="spanish_3" /> SPANISH 3</p>

                            </div>
                            <div style="width: 32%; float: left; text-align: left; margin-top:-12px;">
                                <p>SESSION TYPE: <select id="spanish_3_selection" class="spanish_3_selection course_session_selection" name="spanish_3_session_type" rel="spanish_3" disabled="disabled" onchange="showUser('spanish_3',this.value)">
                                    <?php PrintCourseSessionOptions('spanish_1'); ?>
                                </select></p>
                            </div>
                            <div style="width: 24%; float: left; text-align: left; margin-left: 15px;">
                                <input id="spanish_3_selectionresult" type="text" class="price" name="spanish_3_price" value="" rel="spanish_3" disabled="disabled" >
                                <p id="spanish_3_result">&nbsp;</p>
                            </div>
                        </div>

                        <div style="width: 100%; height: 40px;clear:both;">
                            <div style="width: 37%; float: left; text-align: left; padding-left: 10px; margin-top:-12px;">
                                <p><input id="spanish_4_checkbox" type="checkbox" name="spanish_4" value="spanish_4" rel="spanish_4" /> SPANISH 4</p>
                            </div>
                            <div style="width: 32%; float: left; text-align: left; margin-top:-12px;">
                                <p>SESSION TYPE: <select id="spanish_4_selection" class="spanish_4_selection course_session_selection" name="spanish_4_session_type" rel="spanish_4" disabled="disabled" onchange="showUser('spanish_4',this.value)">
                                    <?php PrintCourseSessionOptions('spanish_2'); ?>
                                </select></p>
                            </div>
                            <div style="width: 24%; float: left; text-align: left; margin-left: 15px;">
                                <input id="spanish_4_selectionresult" type="text" class="price" name="spanish_4_price" value="" rel="spanish_4" disabled="disabled" >

                                <p id="spanish_4_result">&nbsp;</p>
                            </div>
                        </div>



                        <div style="width: 100%; height: 40px;clear:both;">
                            <div style="width: 37%; float: left; text-align: left; padding-left: 10px; margin-top:-12px;">
                                <p><input onchange="" id="writing_checkbox" type="checkbox" name="writing" value="writing" rel="writing" /> TECHNIQUES FOR <br />
                                    WRITING WELL</p>
                            </div>
                            <div style="width: 32%; float: left; text-align: left; margin-top:-12px;">

                                <p>SESSION TYPE: <select id="writing_selection" class="writing_selection course_session_selection" name="writing_session_type" rel="writing" disabled="disabled" onchange="showUser('writing',this.value)">
                                    <?php PrintCourseSessionOptions('writing'); ?>
                                </select></p>

                            </div>
                            <div style="width: 24%; float: left; text-align: left; margin-left: 15px;">
                                <input id="writing_selectionresult" type="text" class="price" name="writing_price" value="" rel="writing" disabled="disabled" >
                                <p id="writing_result">&nbsp;</p>
                            </div>
                        </div>
                        <div style="width: 100%; height: 40px;clear:both;">
                            <div style="width: 37%; float: left; text-align: left; padding-left: 10px; margin-top:-12px;">
                                <p><input id="us_history_checkbox" type="checkbox" name="us_history" value="us_history" rel="us_history" /> U.S. HISTORY</p>

                            </div>
                            <div style="width: 32%; float: left; text-align: left; margin-top:-12px;">
                                <p>SESSION TYPE: <select id="us_history_selection" class="us_history_selection course_session_selection" name="us_history_session_type" rel="us_history" disabled="disabled" onchange="showUser('us_history',this.value)">
                                    <?php PrintCourseSessionOptions('us_history'); ?>
                                </select></p>
                            </div>
                            <div style="width: 24%; float: left; text-align: left; margin-left: 15px;">
                                <input id="us_history_selectionresult" type="text" class="price" name="us_history_price" value="" rel="us_history" disabled="disabled" >
                                <p id="us_history_result">&nbsp;</p>
                            </div>
                        </div>



                        <div style="font-size:13px">
                            <table align="right" style="width:550px;" border="0" cellpadding="4">
                                <tr>
                                    <td align="right" width="90%">Total - </td><td nowrap>$<input id="sumtotal" type="text" name="sumtotal" value="" readonly="readonly" ></td><td nowrap><input type="button" value="Calculate Total" id="idTotalTextSum"</td>
                                </tr>
                                <tr class="sum_cs_discount" style="display:none">
                                    <td class="sum_cs_discount" style="display:none" align="right" nowrap>LESS NCJHS STUDENT DISCOUNT - </td><td colspan="2">$100.00</td>
                                </tr>
                                <tr class="sum_cs_discount" style="display:none">
                                    <td class="sum_cs_discount" style="display:none" align="right" nowrap>Discounted Total - </td><td colspan="2" style="font-weight:bold;">$<span id="sum_cs_discount_total"></span></td>
                                </tr>
                            </table>
                        </div>
                        <input id="sumtotal2" type="text" name="sumtotal_cs" value="" readonly="readonly" style="display:none">


                        <div style="width: 418px; float: left; text-align: left; padding-left: 12px;">
                            <p>PLEASE NOTE:</p>
                            <ul style="margin-top: 20px;">
                                <li>In addition to completing this online registration form, you must also download the Emergency Medical Form (see left menu bar), sign it, mail or fax it to the office by June 1, 2012.  </li>
                                <li>Students will not be able to attend class unless this form has been turned in.   </li>
                                <li>Class size is limited, and enrollment is on a first-come, first-served basis. Confirmation of enrollment and class schedule will be sent by June 1st. </li>
                                <li>The school reserves the right to cancel any offerings due to underenrollment or other reasons. Should this happen, you will be notified on or before June 1st.</li>
                            </ul>
                        </div>

                        <div style="background-color: #993333;
    border: 1px solid #000000;
    float: left;
    margin-left: 32px;
    margin-top: 54px;
    padding: 20px 15px;" >
                        <button type="submit" style="width: 120px; height: 30px; margin-top: 25px;  margin-bottom: 25px; text-align: center; float:left;">Submit</button>
                        </div>
                    </form>

                    <div style="width: 612px; float: left; text-align: left; padding-left: 12px;">
                        <p style="font-weight: 700px;">REFUND POLICY:</p>
                        <p style="margin-top: 25px;">Tuition for each course includes a $50 non-refundable administrative fee.  A student will receive a full refund (less $50 deposit) when withdrawing prior to June 1, 2012.  Withdrawals made between June 4-8 will receive a 40% refund.  No refunds will be given for withdrawals after June 8. There are no exceptions to this policy.  A full (100%) refund including administrative fee will be made in all cases when a class is cancelled.                    </p>
                    </div>




                </div>
                            </div>
        </div>
    </div>



<script type="text/javascript">
function showUser(item,value) {

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
        if( $("#" + item + "_selection").val() != '- Session -' ) {
          if( xmlhttp.responseText == 'unavailable') {
            $("#" + item + "_selectionresult").attr('value', 'session unavailable');
          } else if(xmlhttp.responseText != '') {
              $("#" + item + "_selectionresult").attr('value',xmlhttp.responseText);
          } else {
            $("#" + item + "_selectionresult").attr('value', '');
          }

          UpdateTotalCost();
       }
    }
  }
xmlhttp.open("GET","pquery.php?course=" + item + "&session=" + value,true);
xmlhttp.send();
}
</script>

<script type="text/javascript">
var sessions_selected = 0;

function GetCourseCount() {
  var courses = 0;
  $("select[id$=selection]").each(function(i, val) {
    if ( $(this).val() == 'session_1' || $(this).val() == 'session_2' ) {
      courses++;
    }
    if ( $(this).val() == 'full_session' ) {
      courses += 2;

    }
  });
  sessions_selected = courses;
  return courses;
}

function ValidateCourseCount() {

  courses = GetCourseCount();

  if( courses > 2 ) {
    return false;
  }

  return true;

}

function IsNumeric(input)
{
   return (input - 0) == input && input.length > 0;
}

var cs = <?php echo $_SESSION['ncjhs_student'] == 'ncjhs' ? 'true' : 'false'; ?>;
var cs_d_applied = false;
var cs_d_v = 100;
var cs_d_m = 600;
function UpdateTotalCost() {
    //alert('UpdateTotalCost()');
  var sum = 0;
  $(":input.price").each(function(i, val) {
    var val = $(this).val();
    if( IsNumeric(val) ) {
      sum += val*1;
    }
  });
  cs_d_applied = sum>=cs_d_m&&cs;
  $("#sumtotal").attr('value',sum);
  if( cs_d_applied ) {
    $("#sum_cs_discount_total").html(sum-cs_d_v);
    $(".sum_cs_discount").show();
    $("#sumtotal2").attr('value',sum-cs_d_v);
    //$("tr.sum_cs_discount td").css({'background-color': '#ffff00'});
  } else {
    $(".sum_cs_discount").hide();
    $("#sumtotal2").attr('value',sum);
  }

}

$('.course_session_selection').change(function() {
    var rel = $(this).attr('rel');

    if ( $(this).val() == '- Session -' ) { 
        $('#'+rel+'_checkbox').attr('checked','');
        ToggleCourse($('#'+rel+'_checkbox'),GetCourseCount(), 2);
        UpdateCourseAvailability($(':checkbox[id$=checkbox]:checked').length);
    } else {
        //SessionCapCheck($('#'+rel+'_checkbox'), rel); //verify this
        GetCourseCount();
        UpdateCourseAvailability($(':checkbox[id$=checkbox]:checked').length);
    }
});


function ToggleCourse(obj, current_course_count, num_sessions) {
    var checkbox_rel = $(obj).attr('rel');

    if($(obj).is(':checked')) {
            // If checkbox is checked, enable selection
            $('#' + checkbox_rel + '_selection').attr('disabled', '');

            if ( obj.checked && $('#'+checkbox_rel+'_selection option').length == 2) {
                $('#'+checkbox_rel+'_selection option').eq(1).attr('selected', 'selected');
                showUser(checkbox_rel,$('#'+checkbox_rel+'_selection').val());
            };

            var additional_sessions = 0;
            //alert('-' +$('#' + checkbox_rel + '_selection').val() + '-');
            switch ( $('#' + checkbox_rel + '_selection').val()) {
                case 'session_1':
                case 'session_2':
                    additional_sessions = 1;
                    break;
                case 'full_session':
                    additional_sessions = 2;
                    break;
                default:
                     break;
            }

            //alert(current_course_count + ' -- ' + additional_sessions);
            if( current_course_count == 2 || (current_course_count + additional_sessions) > 2 ) {
                alert('You can only select one full session course or two single session courses.\n\nYou must remove one of your current selections before you can add another one.');
                ResetCourse(checkbox_rel);
                UpdateTotalCost();
                return false;
            }
        } else {
            // If checkbox is not checked/un-checked, disable selection, reset value of selector, disable dollar amount and set value to 0.00
            $('#' + checkbox_rel + '_selection').attr('disabled', 'disabled');
            $('#' + checkbox_rel + '_selection').val('- Session -');
            $('#' + checkbox_rel + '_selectionresult').attr('disabled', 'disabled');
            $('#' + checkbox_rel + '_selectionresult').val('');
            sessions_selected -= num_sessions;
        }

        return sessions_selected;
}

function ResetCourse(checkbox_rel) {
    $('#' + checkbox_rel + '_checkbox').attr('checked', '');
    $('#' + checkbox_rel + '_selection').attr('disabled', 'disabled');
    $('#' + checkbox_rel + '_selection').val('- Session -');
    $('#' + checkbox_rel + '_selectionresult').attr('disabled', 'disabled');
    $('#' + checkbox_rel + '_selectionresult').val(''); 
}

function SessionCapCheck(obj, checkbox_rel) {
    var additional_sessions = 0;
    var current_course_count = GetCourseCount();

            switch ($('#' + checkbox_rel + '_selection').val()) {
                case 'Session 1':
                case 'Session 2':
                    additional_sessions = 1;
                    break;
                case 'Full Session':
                    additional_sessions = 2;
                    break;
                default:
                     break;
            }

            //alert(current_course_count + ' - ' +additional_sessions);
            if( current_course_count == 2 || (current_course_count + additional_sessions) > 2 ) {
                alert('You can only select one full session course or two single session courses.\n\nYou must remove one of your current selections before you can add another one.');
                $(obj).attr('checked', false);
                return false;
            }
}

// On checkbox click
$('input:checkbox').change(function() {

    //alert('checkbox value changed');

    // Set variable to rel value
    var checkbox_rel = $(this).attr('rel');

    current_course_count = GetCourseCount();

    // Check for qty of checkboxes
    var number_checked = $(':checkbox[id$=checkbox]:checked').length;

    if(number_checked >2) {
        alert('You can only check 2 items');
        $(this).attr('checked', false);
        return false;
    } else {

      // Get session type of checkbox
      var session_type = $('#'+checkbox_rel+'_selection').val();
      var num_sessions = 0;
      if( session_type == 'full_session' ) {
        num_sessions = 2;
      } else if ( session_type == 'session_1' || session_type == 'session_2' ) {
        num_sessions = 1;
      } 

      if( ToggleCourse(this, current_course_count, num_sessions) === false ) {
        return false;
      }

        UpdateCourseAvailability(number_checked);

        UpdateTotalCost();

    }
});

function UpdateCourseAvailability(number_checked) {
    if( GetCourseCount() >= 2 || number_checked == 2 ) {
          $('input:checkbox:not(:checked)').attr('disabled','disabled'); 
          //$('select[id$=selection]').attr('disabled','disabled'); 
        } else {
          $('input:checkbox').attr('disabled','');
           //$('select[id$=selection]').attr('disabled','');  
        }
}

// On select value change
$('select[id$=selection]').change(function() {

  var select_rel = $(this).attr('rel');

  // Get number of session 1 selections
    var session1 = $('select[id$=_selection] option:selected[value="session_1"]').length;
    // Get number of session 2 selections
    var session2 = $('select[id$=_selection] option:selected[value="session_2"]').length;
    // Set alerts
    if(session1 > 1 || session2 > 1) {
        alert('You can only choose one course per session.');
        $('#' + select_rel + '_selection').val('- Session -');
        $('#' + select_rel + '_selectionresult').val('');
        UpdateTotalCost();
        return false;
    }   

  var course_count = GetCourseCount();

  if( course_count == 2 ) {
      $('input:checkbox:not(:checked)').attr('disabled','disabled'); 
      //$('select[id$=selection]').attr('disabled','disabled'); 
    } else if( course_count > 2) {
      alert('A full session course cannot be selected along with single session courses.');
      $('#' + select_rel + '_selection').val('- Session -');
      $('#' + select_rel + '_selectionresult').val('');
    } else {
      //$('input:checkbox').attr('disabled','');
       //$('select[id$=selection]').attr('disabled','');  
    }

  var valid_course_count = ValidateCourseCount();

  if( !valid_course_count ) {
    $('#' + checkbox_rel + '_selection').val('- Session -');
  }

  UpdateTotalCost();

  return valid_course_count;




  // Set variable to rel value
  var select_rel = $(this).attr('rel');

    if($(this).val() == 'full_session') {

      if( sessions_selected > 0 ) {
        alert("You have other courses selected.  In order to selected a full session, please de-select the other courses first.");
        $('#' + checkbox_rel + '_selection').val('- Session -');
        return false;
      }

        // Un-check all checkboxes
        $('input[type="checkbox"]').attr('checked', false).attr('disabled', 'disabled');
        // Re-check the original selection
        $('#' + select_rel + '_checkbox').attr('checked', true).attr('disabled', '');

        sessions_selected = 2;
        //alert('!');

    } else if($(this).val() == 'session_1' || $(this).val() == 'session_2' ) {
      if( sessions_selected >= 2 ) {
        alert("You already have other courses selected.  In order to selected this course please de-select another course first.");
        $('#' + checkbox_rel + '_selection').val('- Session -');
        return false;
      }
        // Get number of session 1 selections
        var session1 = $('select[id$=_selection] option:selected[value="session_1"]').length;
        // Get number of session 2 selections
        var session2 = $('select[id$=_selection] option:selected[value="session_2"]').length;
        // Set alerts
        if(session1 > 1 || sessions2 > 1) {
            alert('You can only choose one course per session.');
            $('#' + checkbox_rel + '_selection').val('- Session -');
            $('#' + checkbox_rel + '_selectionresult').val('');
        } else {
          sessions_selected += 1;
        }

    }

      course_count = GetCourseCount();
      //alert(course_count);
        if( GetCourseCount() >= 2 ) {
          $(':input:not(:checked)').attr('disabled','disabled'); 
          //$('select[id$=selection]').attr('disabled','disabled'); 
        } else {
          $(':input').attr('disabled','');
           //$('select[id$=selection]').attr('disabled','');  
        }


});
</script>

<script type="text/javascript">



$(document).ready(function(){   

    $("#idTotalTextSum").click(function (){
         UpdateTotalCost();
    });

    $('button').click(function() {


        // get the sum of the elements
        var sum = $(".price").sum();

        if(sum == 0) {
            alert('You haven\'t selected any courses yet.');
            return false;
        } else {
            // update the total
            $("#sumtotal").attr('value',sum.toFixed(2));
        }

        // update the total
        $("#sumtotal").attr('value',sum.toFixed(2));
    });
});
</script>





        </div><!-- close inside content-->
        </div> <!-- close right column -->


<div style="clear:both"></div>
</div> <!-- close content wrapper -->

</div> <!-- close main wrapper  -->
<?php include_once("../../footer.php"); ?>

</body>
</html>