<script>
	$(document).ready(function(){
		$("#imapAll").click(function () {
		    $(".chkImapClass").prop('checked', $(this).prop('checked'));
		    $("#dbAll").prop('checked', !$(this).prop('checked'));
		    $(".chkDbClass").prop('checked', !$(this).prop('checked'));
		});
		$("#dbAll").click(function () {
		    $(".chkDbClass").prop('checked', $(this).prop('checked'));
		    $("#imapAll").prop('checked', !$(this).prop('checked'));
		    $(".chkImapClass").prop('checked', !$(this).prop('checked'));
		});
		$("input:checkbox").click(function() {
		    if ($(this).is(":checked")) {
		        var group = "input:checkbox[name='" + $(this).attr("name") + "']";
		        $(group).prop("checked", false);
		        $(this).prop("checked", true);
		    } else {
		        $(this).prop("checked", false);
		    }
		});
	});	
</script>
<?php
	//$this->beginForm();	
	echo CHtml::beginForm();	

	$this->widget('zii.widgets.grid.CGridView',array(
				'dataProvider'=>$model,
				//'filter'=>$model,
				'enableSorting'=>false,
				'columns'=>array(
					'username',
					'password',
					'email',
					array('header'=>'Login Type','value'=>'$data->login_type==0?"IMAP":"DB"'),	
					array('header'=>CHtml::checkBox("IMAPAll",'',array('id'=>'imapAll'))." IMAP",'value'=>'CHtml::checkBox("loginType[".$data->username."]","",array("class"=>"chkImapClass","value"=>0))','type'=>'raw'),
					array('header'=>CHtml::checkBox("DBAll",'',array('id'=>'dbAll')).'DB','value'=>'CHtml::checkBox("loginType[".$data->username."]","",array("class"=>"chkDbClass","value"=>1))','type'=>'raw'),
				),
			));

	?>
	<div class="row buttons">
			<?php echo CHtml::submitButton('Submit'); ?>
	</div>
	
<?php 	
	echo CHtml::endForm();		
?>