﻿
var tempLink = '';
var disabledLink = "javascript:alert('Please complete all required fields.')";
var dPassPrice = 0;
var oPassPrice = 0;
function getPassPrices() {
    if (dPassPrice == 0) {
        dPassPrice = $get('ctl00_ContentPlaceHolder1_RegistrationWiz_dancePassCostlb').firstChild.nodeValue;
        oPassPrice = $get('ctl00_ContentPlaceHolder1_RegistrationWiz_obsPassCostlb').firstChild.nodeValue;
    }
}
function disableLink(el) {
    if ((el!=null)&&(disabledLink!=el.getAttribute('href'))) {
        tempLink=el.getAttribute('href');
        el.setAttribute('href',disabledLink);
    }
}
function enableLink(el) {
    if (el.getAttribute('href')==disabledLink){
    el.setAttribute('href',tempLink);
    }
}
function page1key(el) {
    if (($get('ctl00_ContentPlaceHolder1_RegistrationWiz_fName').value.length<1)||
        ($get('ctl00_ContentPlaceHolder1_RegistrationWiz_lName').value.length<1)||
        ($get('ctl00_ContentPlaceHolder1_RegistrationWiz_eMail').value.length<1)||
        ($get('ctl00_ContentPlaceHolder1_RegistrationWiz_HomePhone').value.length<1)||
        ($get('ctl00_ContentPlaceHolder1_RegistrationWiz_streetAddress').value.length<1)||
        ($get('ctl00_ContentPlaceHolder1_RegistrationWiz_citySuburb').value.length<1)||
        ($get('ctl00_ContentPlaceHolder1_RegistrationWiz_pCode').value.length<1)
        ) {
            disableLink(el);
        }else{
            enableLink(el);
        }
}
function page2key(el) {
    if (($get('tcAgree').checked==true)&&((oCount+dCount+tCount)>0))
    {
        enableLink(el);
    }else
    {
        disableLink(el);
    }
}
var dCount=0;
var oCount=0;
var tCount=0;
function addCount(el) {
var ja = parseInt(el.value.charAt(el.value.length-1));
    if (ja>=0){
        if (el.id=="ctl00_ContentPlaceHolder1_RegistrationWiz_dCount")
        {
            dCount = parseInt(el.value);
        }else{
            oCount = parseInt(el.value);
        }
        evalVars();
    }
    else
    {
        el.value='';
        if (el.id=="ctl00_ContentPlaceHolder1_RegistrationWiz_dCount")
        {
            dCount = 0;
        }else{
            oCount = 0;
        }
        evalVars();
    };
}
function addTee(el) {
    var ja = parseInt(el.value.charAt(el.value.length-1));
    if (!(ja>=0)) {
        el.value='';
    }
    var sT = parseInt($get('ctl00_ContentPlaceHolder1_RegistrationWiz_sCount').value);
    var mT = parseInt($get('ctl00_ContentPlaceHolder1_RegistrationWiz_mCount').value);
    var lT = parseInt($get('ctl00_ContentPlaceHolder1_RegistrationWiz_lCount').value);
    var xsT = parseInt($get('ctl00_ContentPlaceHolder1_RegistrationWiz_xsCount').value);

    if (!(sT>=0)) {sT=0;};
    if (!(mT>=0)) {mT=0;};
    if (!(lT >= 0)) { lT = 0; };
    if (!(xsT >= 0)) { xsT = 0; };
    tCount = sT + mT + lT + xsT;
    $get('teeTotal').firstChild.nodeValue = "$" + (tCount * 25);
    $get('teeCount').firstChild.nodeValue=tCount;
    calcTotal();
}
function evalVars() {
    getPassPrices();
    var dTotal = dCount*dPassPrice;
    var oTotal = oCount*oPassPrice;
    var extras=0;
    var exob=0;
    $get('DancepassTotal').firstChild.nodeValue = "$" + dTotal;
    $get('ObserverpassTotal').firstChild.nodeValue = "$" + oTotal;
    if (dCount >= 5) {
        if (dCount >= 10) { //dcount is more than 10
            extras = dCount / 10;
            if (extras < Math.round(extras)) {
                extras = Math.round(extras) - 1;
            } else {
                extras = Math.round(extras);
            }

            exob = dCount / 5;
            if (exob < Math.round(exob)) {
                exob = Math.round(exob) - 1;
            } else {
                exob = Math.round(exob);
            }
        } else { //dcount is less than 10 but gt 5
            exob = 1
        }
    }
    $get('dcountDance').firstChild.nodeValue = extras;
    $get('dcountObserver').firstChild.nodeValue = exob;
   
    var i=1;
    for(i=1;i<=50;i++){
        if (i<=dCount+extras){
            $get('dr'+i).style.display="table-row";
        }else{
            $get('dr'+i).style.display="none";
        }
        if (i<=oCount+exob){
            $get('ob'+i).style.display="table-row";
        }else{
            $get('ob'+i).style.display="none";
        }
    }
    calcTotal();
 }
 function calcTotal() {
     getPassPrices();
    $get('gTotal').firstChild.nodeValue='$'+((dCount*dPassPrice)+(oCount*oPassPrice)+(tCount*25))+'.00';
 }