function turnaround(objForm)
{
    if (objForm.turnaround_name.selectedIndex == 0) {
        document.getElementById("no_pages").innerHTML = "<select name='no_pages' class='small'><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option></select>";
    }

    if (objForm.turnaround_name.selectedIndex == 1) {
        document.getElementById("no_pages").innerHTML = "<select name='no_pages' class='small'><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='11'>11</option><option value='12'>12</option></select>";
    }

    if (objForm.turnaround_name.selectedIndex == 2) {
        document.getElementById("no_pages").innerHTML = "<select name='no_pages' class='small'><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='11'>11</option><option value='12'>12</option><option value='13'>13</option><option value='14'>14</option><option value='15'>15</option><option value='16'>16</option><option value='17'>17</option><option value='18'>18</option><option value='19'>19</option><option value='20'>20</option></select>";
    }

    if (objForm.turnaround_name.selectedIndex == 3) {
        document.getElementById("no_pages").innerHTML = "<select name='no_pages' class='small'><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='11'>11</option><option value='12'>12</option><option value='13'>13</option><option value='14'>14</option><option value='15'>15</option><option value='16'>16</option><option value='17'>17</option><option value='18'>18</option><option value='19'>19</option><option value='20'>20</option></select>";
    }

}

function turnaroundChanged(objForm)
{
    var selectedTurnAroundIndex = objForm.turnaround.selectedIndex;
    var selectedPages = parseInt(objForm.pages.value, 10);
    objForm.pages.options.length    = 0;
    maxPagesForSelectedturnAround   = aPricing.aPricingMarkup[selectedTurnAroundIndex].maxPages;
    for (var i = 1; i <= maxPagesForSelectedturnAround; i++) {
        selected = false;
        if (selectedPages == i) {
            selected = true;
        }
        oUIOption = new Option(i, i, selected, selected);
        objForm.pages.options[objForm.pages.options.length] = oUIOption;
    }
    recalculate(objForm);
}

function recalculate(objForm)
{
    var selectedTurnaroundIndex = objForm.turnaround.selectedIndex;
    var numPages = parseInt(objForm.pages.value, 10);
    numAdditionalPages = numPages - 1;
    totalPrice = aPricing.aPricingMarkup[selectedTurnaroundIndex].initialPageCost
        + (numAdditionalPages * aPricing.aPricingMarkup[selectedTurnaroundIndex].additionalPageCost);
    effectiveTurnaround = aPricing.aPricingMarkup[selectedTurnaroundIndex].turnaround;
    if (objForm.accessibility.checked) {
        totalPrice += numPages * aPricing.accessibilityCost;
        effectiveTurnaround++;
    }
    if (objForm.dropdown.checked) {
        totalPrice += numPages * aPricing.dropdownCost;
        effectiveTurnaround++;
    }
    if (objForm.liquidLayout.checked) {
        totalPrice += numPages * aPricing.liquidLayoutCost;
        effectiveTurnaround++;
    }
    if (objForm.sifar.checked) {
        totalPrice += numPages * aPricing.sifarCost;
        effectiveTurnaround++;
    }
    if (objForm.embased.checked) {
        totalPrice += numPages * aPricing.embasedCost;
        effectiveTurnaround++;
    }
    if (objForm.cms.selectedIndex == 1) {
        totalPrice += aPricing.cmsImplementationCost;
        effectiveTurnaround = effectiveTurnaround + 1.5;
    }
    if (objForm.cms.selectedIndex == 2) {
        totalPrice += aPricing.cmsImplementationCost;
        effectiveTurnaround = effectiveTurnaround + 3;
    }
    totalPrice = totalPrice.toFixed(2);
    document.getElementById('uiSelectedTurnaround').innerHTML =
            effectiveTurnaround
            + ' Business Day';
    document.getElementById('uiTotalPrice').innerHTML = totalPrice;
    objForm.effective_turnaround.value = effectiveTurnaround;
    objForm.price.value = totalPrice;
}

function validateSubmit(formName)
{
    // EMAIL VALIDATION
    if (formName.email.value == "" || formName.email.value == "Email") {
        formName.email.focus();
        alert("Please Enter Your Email Address!");
        return false;
    }
    // EMAIL ID FORMAT VALIDATION
    if (!formName.email.value
            .match(/^[\w\.-]+@(?:[A-Za-z0-9-]+\.)*[A-Za-z0-9-]{1,}\.[a-z]{2,9}$/)) {
        formName.email.select();
        alert("Please Enter a Valid Email Address!");
        return false;
    }
    return true;
}
