<script>
    jQuery(document).ready(function(){                                              
        jQuery("#operation").change(function () {                                        
                                                    
            var len = jQuery("#group:checked").length;
            if (len < 1) {
                alert("لم تقم باختيار أى عنصر");
                jQuery(".defaultOpt").attr("selected", "selected");
                return false;
            } else {
                if (jQuery("option.delete").is(":selected")) {
                    var answer = confirm('هل أنت متأكد من حذف هذه العناصر؟');
                    if (answer == false) {
                        jQuery(".defaultOpt").attr("selected", "selected");                        
                        return false;
                    }
                }
                jQuery("#form").submit();
            }                                            
        });     
    });     
</script>
<!-- Data Grid Start -->
<div class="block">
    <div class="title lightTextShadow"><?php echo $this->lang->line('contactus_list'); ?></div>
    <div class="content">
        <!-- Notification boxes -->
        <?php echo $this->template->flash_msg(); ?>
        <?php if ($contactus == FALSE) : ?>
            <br/>            
            <p class="block boxStyle notice attention"><a href="javascript:void(0)" class="close"></a><b>تنبيه!</b>لا توجد رسائل<p>
        <?php else : ?>
            <form method="post" action="<?= base_url() ?>contactus/admin_contactus/operation/" id="form">                            
                <table class="dataGrid tableSorter boxStyle" cellspacing="0" cellpadding="0" border="0">
                    <thead>
                        <tr>
                            <th><input type="checkbox" name="check_nf2" id="selectall" /></th>
                            <th>مسلسل</th>
                            <th>الحالة</th>
                            <th>عنوان الرسالة</th>
                            <th>اسم الراسل</th>
                            <th>الدولة</th>
                            <th>البريد الإلكتروني</th>
                            <th>تاريخ الرسالة</th>
                            <th><?php echo $this->lang->line('operation'); ?></th>
                        </tr>
                    </thead>
                    <tbody>


                        <?php
                        $counter = $row + 1;;
                        foreach ($contactus as $p) :
                            if ($p['co_Readed'] == 1) {
                                $ImgUser = "msg_open";
                                $Reded = "قرأت";
                            } else {
                                $ImgUser = "msg_close";
                                $Reded = "لم تقرأ";
                            }
                            ?>
                            <tr <?php if($counter %2 ==1){echo "class='odd'";}?>>
                                <td><input type="checkbox" name="check_nf[]" value="<?= $p['co_id'] ?>" id="group"/></td>
                                <td class="align-center"><?php echo $counter; ?></td>
                                <td class="align-center"><img title="<?= $Reded ?>" src="<?= base_url() ?>global/modules/admin/images/<?= $ImgUser ?>.png"  /></td>
                                <td><?php echo $p['co_Title']; ?>    </td>        
                                <td><?= $p['co_Name'] ?></td>
                                <td><?= $p['co_Country'] ?></td>
                                <td><?= $p['co_Email'] ?></td>
                                <td><?= date('d-m-Y', $p['co_Date']) ?></td>
                                <td class="align-center">                                    
                                    <a href="<?= base_url() ?>contactus/admin_contactus/showmsg/<?= $p['co_id'] ?>"> <img title="قراءة محتوى الرسالة" src="<?= base_url() ?>global/modules/admin/images/balloon.gif"  /></a>&nbsp;&nbsp; | &nbsp;&nbsp;
                                    <a href="<?= base_url() ?>contactus/admin_contactus/remove/<?= $p['co_id']; ?>" onclick="return confirm('هل تريد حذف هذا العنصر؟');"><img src="<?= base_url() ?>global/modules/admin/images/del.png" width="16" height="16" title="حذف" alt="حذف"  /></a>
                                </td>
                            </tr>
                            <?php
                            $counter++;
                        endforeach;
                        ?>

                    </tbody>
                </table>
                <div class="pager">
                    <div class="resultsCount"><b><?php echo $row + 1 ?></b> - <b><?php echo $row + 10 ?></b> / <em><?php echo $total_rows; ?></em></div>
                <?php echo $links;?>
                    <fieldset class="formList inlineBlock">
                        <p align="center"><?php echo $this->lang->line('choose_operation'); ?>:
                            <select class="select rnd5" id="operation" name="operation" onchange="" >
                                <option class="defaultOpt" value=""  >--<?php echo $this->lang->line('choose'); ?>--</option>                                
                                <option class="oButton delete" value="delete" ><?php echo $this->lang->line('delete'); ?></option>
                            </select>
                        </p>
                    </fieldset>  
                </div>
            </form>
        <?php endif; ?>
    </div>
</div><!-- Data Grid End -->

