<?php
Yii::app()->clientScript->registerScript('selectPageDialog', <<<EOT
        function selectPageDialog(sender)
        {
            $('#sender_id').val($(sender).parents('form').attr('id'));
            $("#select-page-dialog").dialog("open"); 
            return true;
        }
EOT
        ,  CClientScript::POS_HEAD
);
?>
<div class="pull-left col-md-12 well well-sm">
    <div class="row relative">
        <div class="col-md-3">
            <?php
            if($model->type=='image'){
            $path = Yii::app()->params['uploadUrl'] . get_class($model) . '/';
//	    echo CHtml::link('X', array('sliderImages/delete', 'id' => $model->id), array('class' => 'delete-link'));
            echo '<img src="' . $path . $model->image . '" />';
            }elseif($model->type=='video'){
             echo  '<iframe width="250" height="200" src="https://www.youtube.com/embed/'.$model->link.'" ></iframe>';
            }
             elseif($model->type=='flash'){
                 $path = Yii::app()->params['uploadUrl'] . get_class($model) . '/';
                //  echo ' <object width="250" height="300" data="'.$path.$model->image.'"></object> ';
                echo  '<embed width="250" height="300" src="'.$path.$model->image.'">'; 
            }
            ?>
        </div>

        <?php
        $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
            'id' => "slider-images-form-{$model->id}",
            'layout' => TbHtml::FORM_LAYOUT_HORIZONTAL,
            'controlGroupCssClass' => 'col-xs-9',
            'action' => $this->createUrl('sliderImages/update', array('id' => $model->id, 'slider_id' => $model->slider_id)),
            // Please note: When you enable ajax validation, make sure the corresponding
            // controller action is handling ajax validation correctly.
            // There is a call to performAjaxValidation() commented in generated controller code.
            // See class documentation of CActiveForm for details on this.
            'enableAjaxValidation' => false,
        ));
        ?>
        <div class="col-md-4">


            <?php
            // echo $form->textFieldControlGroup($model, 'link', array(
            //     'maxlength' => 250,
            //     'class' => 'col-md-12 SliderImages_link',
            //     'append' => CHtml::link(Yii::t('admin', 'Select'), '#', array('onclick' => 'selectPageDialog(this);return false;'))
            //         )
            // );
            ?>

            <?php //echo $form->textFieldControlGroup($model, 'title', array('maxlength' => 200)); ?>

        </div>
        <div class="col-md-4">

            <?php //echo $form->textAreaControlGroup($model, 'description', array('rows' => 4)); ?>

        </div>
        <div class="col-md-1">
            <div class="space-4"></div>
            <?php //echo TbHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array('color' => TbHtml::BUTTON_COLOR_PRIMARY, 'size' => 'sm')); ?>
            <div class="space-4"></div>
            
            <?php echo CHtml::button('Delete', array('submit' => array('SliderImages/delete','id'=>$model->id),'class' => 'deletebutton','confirm'=>'Are you sure you want to delete this item?')); ?>
           
        </div>


        <?php $this->endWidget(); ?>
    </div>
</div>