function checkedAll(ref)
{var chkAll=document.getElementById('checkAll');var checks=document.getElementsByName('list[]');var boxLength=checks.length;var allChecked=false;var totalChecked=0;if(ref==1)
{if(chkAll.checked==true)
{for(i=0;i<boxLength;i++)
checks[i].checked=true;}
else
{for(i=0;i<boxLength;i++)
checks[i].checked=false;}}
else
{for(i=0;i<boxLength;i++)
{if(checks[i].checked==true)
{allChecked=true;continue;}
else
{allChecked=false;break;}}
if(allChecked==true)
chkAll.checked=true;else
chkAll.checked=false;}
for(j=0;j<boxLength;j++)
{if(checks[j].checked==true)
totalChecked++;}
}