/**
     * @param  string $name        The element name
     * @param  string $value       The date displayed in this widget
     * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
     * @param  array  $errors      An array of errors for the field
     *
     * @return string An HTML tag string
     *
     * @see sfWidgetForm
     */
    public function render($name, $value = null, $attributes = array(), $errors = array())
    {
        $attributes = $this->getAttributes();
        $input = new sfWidgetFormInput(array(), $attributes);
        $date = new DateTime($value);
        $html = $input->render($name, $date->format('m/d/Y'));
        $id = $input->generateId($name);
        $culture = $this->getOption('culture');
        $cm = $this->getOption("change_month") ? "true" : "false";
        $cy = $this->getOption("change_year") ? "true" : "false";
        $nom = $this->getOption("number_of_months");
        $sbp = $this->getOption("show_button_panel") ? "true" : "false";
        $showOn = $this->getOption("show_on");
        $buttonImage = $this->getOption("button_image");
        $bio = $this->getOption("button_image_only") ? "true" : "false";
        if ($culture != 'en') {
            $html .= <<<EOHTML
<script type="text/javascript">
\t\$(function() {
    var params = \$.datepicker.regional['{$culture}'];
    params.dateFormat = 'mm/dd/yy';
    params.changeMonth = {$cm};
    params.changeYear = {$cy};
    params.numberOfMonths = {$nom};
    params.showButtonPanel = {$sbp};
    params.showOn = '{$showOn}';
    params.buttonImage = '{$buttonImage}';
\t\tparams.buttonImageOnly = {$bio};
    \$("#{$id}").datepicker(params);
\t});
</script>
EOHTML;
        } else {
            $html .= <<<EOHTML
<script type="text/javascript">
\t\$(function() {
    var params = {
      dateFormat: 'mm/dd/yy',
      changeMonth : {$cm},
      changeYear : {$cy},
      numberOfMonths : {$nom},
      showButtonPanel : {$sbp},
      showOn : '{$showOn}',
      buttonImage: '{$buttonImage}',
      buttonImageOnly: {$bio}
    };
    \$("#{$id}").datepicker(params);
\t});
</script>
EOHTML;
        }
        return $html;
    }
    /**
     * @param  string $name        The element name
     * @param  string $value       The date displayed in this widget
     * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
     * @param  array  $errors      An array of errors for the field
     *
     * @return string An HTML tag string
     *
     * @see sfWidgetForm
     */
    public function render($name, $value = null, $attributes = array(), $errors = array())
    {
        $attributes = $this->getAttributes();
        // Set date to requested format
        if ($this->getOption('date_format') && $value) {
            $value = date($this->getOption('date_format'), strtotime($value));
        }
        $input = new sfWidgetFormInput(array(), $attributes);
        $html = $input->render($name, $value);
        $id = $input->generateId($name);
        $culture = $this->getOption('culture');
        $cm = $this->getOption("change_month") ? "true" : "false";
        $cy = $this->getOption("change_year") ? "true" : "false";
        $nom = $this->getOption("number_of_months");
        $sbp = $this->getOption("show_button_panel") ? "true" : "false";
        if ($culture != 'en') {
            $html .= <<<EOHTML
<script type="text/javascript">
\t\$(function() {
    var params = \$.datepicker.regional['{$culture}'];
    params.changeMonth = {$cm};
    params.changeYear = {$cy};
    params.numberOfMonths = {$nom};
    params.showButtonPanel = {$sbp};
    \$("#{$id}").datepicker(params);
\t});
</script>
EOHTML;
        } else {
            $html .= <<<EOHTML
<script type="text/javascript">
\t\$(function() {
    var params = {
    changeMonth : {$cm},
    changeYear : {$cy},
    numberOfMonths : {$nom},
    showButtonPanel : {$sbp} };
    \$("#{$id}").datepicker(params);
\t});
</script>
EOHTML;
        }
        return $html;
    }
    /**
     * @param  string $name        The element name
     * @param  string $value       The date displayed in this widget
     * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
     * @param  array  $errors      An array of errors for the field
     *
     * @return string An HTML tag string
     *
     * @see sfWidgetFormInput
     */
    public function render($name, $value = null, $attributes = array(), $errors = array()) {
        $attributes = $this->getAttributes();

        $input = new sfWidgetFormInput(array(), $attributes);

        $html = $input->render($name, $value);

        $id = $input->generateId($name);
        $culture = $this->getOption('culture');
        $cm = $this->getOption("change_month") ? "true" : "false";
        $cy = $this->getOption("change_year") ? "true" : "false";
        $nom = $this->getOption("number_of_months");
        $sbp = $this->getOption("show_button_panel") ? "true" : "false";
        $altField = $this->getOption('altField');
        $dateFormat = $this->getOption('dateFormat');
        $minDate = $this->getOption('minDate');
        $maxDate = $this->getOption('maxDate');
        if($this->getOption('defaultDate') == null) {
            $defaultDate = $value;
        } else {
            $defaultDate = $this->getOption('defaultDate');
        }

        if ($culture != 'en') {
            $html .= <<<EOHTML
<script type="text/javascript">
	jQuery(function() {
            var params = {
            changeMonth : $cm,
            changeYear : $cy,
            numberOfMonths : $nom,
            showButtonPanel : $sbp,
            altField : '$altField',
            dateFormat : '$dateFormat',
            minDate : '$minDate',
            maxDate : '$maxDate',
            defaultDate : '$defaultDate'};
            jQuery("#$id").datepicker(params);
            jQuery( "#$id" ).datepicker( "option",
                             jQuery.datepicker.regional['$culture'] );
            jQuery( "#$id" ).datepicker( "option", 'dateFormat', '$dateFormat');
	});
</script>
EOHTML;
        } else {
            $html .= <<<EOHTML
<script type="text/javascript">
	jQuery(document).ready(function() {
            jQuery.datepicker.setDefaults(jQuery.datepicker.regional['']);
            var params = {
            changeMonth : $cm,
            changeYear : $cy,
            numberOfMonths : $nom,
            showButtonPanel : $sbp,
            altField : '$altField',
            dateFormat : '$dateFormat',
            minDate : '$minDate',
            maxDate : '$maxDate',
            defaultDate : '$defaultDate'};
            jQuery("#$id").datepicker(params);
	});
</script>
EOHTML;
        }

        return $html;
    }