﻿// JScript File
function ToggleAcc(ID) {
    var n = document.getElementById(ID);
    if (n.className == 'divAccess')
        n.className='divAccessOn';
    else
        n.className='divAccess';
}
function updateselected(warrantySelected) 
{
    var f=document.forms['aspnetForm']; if (!f) {f = document.aspnetForm;}
    var msg='', n=0, i=0, c=0, s1=document.getElementById('totSelWarr'), s2=document.getElementById('totSelInstServ'), s3=document.getElementById('totSelAcc');
    for (c=0; c<f.length; c++) {if (f[c].type == 'checkbox') {if (f[c].checked) n += 1;}}
    n += warrantySelected;
    
    document.getElementById('SquareTradeSelected').value = warrantySelected;
    
    if(document.getElementById(document.getElementById('MembershipClientID').value).value == 'true')
        n += 1;
    
    msg=n.toString() + ' Item'; if (n!=1) msg += 's';
    if (s1!=null) s1.innerHTML=msg; 
    if (s2!=null) s2.innerHTML=msg; 
    if (s3!=null) s3.innerHTML=msg;
}

function getSelectedAccessories()
{
    var f=document.forms['aspnetForm']; if (!f) {f = document.aspnetForm;}
    var msg='', n=0, i=0, c=0;
    for (c=0; c<f.length; c++) {if (f[c].type == 'checkbox') {if (f[c].checked) n += 1;}}
    return n;
}

function updateMembership(isAdded)
{
    var n=getSelectedAccessories(),msg='',s1=document.getElementById('totSelWarr'), s2=document.getElementById('totSelInstServ'), s3=document.getElementById('totSelAcc');
    n += isAdded;
    
    if(document.getElementById('SquareTradeSelected').value == '1')
        n += 1;
        
    msg=n.toString() + ' Item'; if (n!=1) msg += 's';
    if (s1!=null) s1.innerHTML=msg; 
    if (s2!=null) s2.innerHTML=msg; 
    if (s3!=null) s3.innerHTML=msg;
}
