var adult = 0;
var primary = 0;
var toddler = 0;
var highschool = 0;


function calcCost(cost, field) {

var total = field.value * cost;

if (total >= 0)
{
document.getElementById('cost'+field.id).innerHTML = '$'+total;
calcTotal(field.id, total);
}
else
document.getElementById('cost'+field.id).innerHTML = 'please enter a number';

}

function calcTotal(id, cost) {

var subtotal;
var totalcost;

if (id == 'q12563_q1')
{
adult = cost;
}
if (id == 'q12563_q2')
{
primary = cost;
}
if (id == 'q12563_q3')
{
toddler = cost;
}
if (id == 'q12563_q5')
{
highschool = cost;
}

subtotal = adult + primary + toddler;

if (adult > 240 && toddler == 0 && primary == 0)
{
}
else if (subtotal > 410 && adult < 241)
{
subtotal = 410;
}
else if (subtotal > 410 && adult > 240)
{
var checktot = 240 + primary + toddler;
if (checktot > 410)
subtotal = 410 + adult - 240;
}


document.getElementById('q12563_q6').value = subtotal;

totalcost = subtotal + highschool;

document.getElementById('q12563_q7').value = totalcost ;

}

function showdetails(field) {

if (field.value == 2)
{
document.getElementById('bankdetails').style.display = "block";

}
else
{
document.getElementById('bankdetails').style.display = "none";
}
}

function deleteAsset(assetid, assetname, type) 
{
   if(confirm('Are you sure you want to delete '+assetname+'?')==true)
   {
        var url = this.location.href = this.location.href+'?a='+assetid+'&delete=yes';
        url2 = uca_replaceChars(url, '_edit', '');
        this.location.href = url2+'?a='+assetid+'&delete=yes';
        

if (type == 'page')
{
this.location.href = url2;
}
else
{
refreshPage();
}
        
   }     
   
}

function refreshPage() 
{
   this.location.href = currenturl;

}