<?php $controller = Yii::app()->getController(); ?>
<div id="newsletter-subscribe">
    <div class="form-inner">
        <?php
        $form = $controller->beginWidget('CActiveForm', array(
            'id' => 'newsletter-subscriber-form',
            'enableAjaxValidation' => false,
                )
        );
        echo CHtml::hiddenField('returnUrl', Yii::app()->request->url);
        ?>


        <div class="row">
            <?php
            echo $form->label($model, 'email', array('label' => Yii::t('site', 'Subscribe to our mailing list')));
            echo $form->textField($model, 'email', array('class' => 'email-field', 'maxlength' => 50));
            echo $form->error($model, 'email');
            ?>
        </div>
        <?php
//        echo CHtml::ajaxSubmitButton(Yii::t('site', 'Subscribe'), array('site/newsletter.Subscribe'), array(
//            'dataType' => 'json',
//            'success' => 'function(data) {
//                         $("#ajax-loader").hide();  
//                         $("#status-message").html(data.message);
//                         
//                         if(data.status=="success")
//                        {
//                            $step2 = $("#newsletter-subscribe-step2");
//                            $("#NewsletterSubscriber_id",$step2).val(data.id);
//                            $step2.fadeIn("slow");
//                        }
//                       
//                    }',
//            'beforeSend' => 'function(){$("#ajax-loader").show();}'
//                ), array('class' => 'button'));
//    <?php echo CHtml::htmlButton(Yii::t('site', 'Subscribe'), array('type' => 'submit'));
        ?>
        <?php $controller->endWidget(); ?>
    </div>

</div>


<div id="newsletter-subscribe-step2" class="hide">
    <?php
    $form = $controller->beginWidget('CActiveForm', array(
        'id' => 'newsletter-subscriber-form-2',
        'enableAjaxValidation' => false,
            )
    );
    echo CHtml::hiddenField('returnUrl', Yii::app()->request->url);
    ?>
    <?php echo $form->hiddenField($model, 'id'); ?>


    <div class="row">
        <?php echo $form->labelEx($model, 'fullname'); ?>
        <div class="clear"></div>
        <?php echo $form->textField($model, 'fullname', array('maxlength' => 50)); ?>
        <div id="error-fullname"></div>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'phonenumber'); ?>
        <div class="clear"></div>
        <?php echo $form->textField($model, 'phonenumber', array('maxlength' => 45)); ?>
        <div id="error-phonenumber"></div>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'have_previous_experience'); ?>
        <?php echo $form->checkBox($model, 'have_previous_experience'); ?>
        <div id="error-have_previous_experience"></div>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'previous_experience_role'); ?>
        <?php echo $form->textArea($model, 'previous_experience_role', array('maxlength' => 300)); ?>
        <div id="error-previous_experience_role"></div>
    </div>



    <?php
    echo CHtml::ajaxSubmitButton(Yii::t('site', 'Complete Subscription'), array('site/newsletter.CompleteSubscription'), array(
        'dataType' => 'json',
        'success' => 'function(data) {
                        $("#step2-ajax-loader").hide();  
                        $("#status-message").html(data.message);
                        if(data.status=="success")
                        {
                            $("#newsletter-subscribe").html(data.message);
                            $("#newsletter-subscribe-step2").fadeOut();
                        }
                        else{
                            
                        }
                    }',
        'beforeSend' => 'function(){$("#step2-ajax-loader").show();}'
            ), array('class' => 'button'));
//    <?php echo CHtml::htmlButton(Yii::t('site', 'Subscribe'), array('type' => 'submit'));
    ?>
    <?php $controller->endWidget(); ?>
</div>