<tmpl_if name="config_error_msg">
<div style="background: #ffdfdf; border: 1px solid #df7d7d; border-width: 1px 0; margin: 1.5em 0 1.5em 0; padding: 7px;">
                <p style="font-face:bold">{tmpl_var name='configuration_error_txt'}</p>
				<div>
				<div style="float:left;width:150px;">{tmpl_var name='config_error_tstamp'} :&nbsp;</div><div style="padding-left:150px;">{tmpl_var name='config_error_msg'}</div>
				</div>
</div>
</tmpl_if>


        {tmpl_hook name="begin_form"}
		<tmpl_if name="vhostdomain_type" value="domain">
            <tmpl_if name="is_admin">
                <div class="form-group">
                    <tmpl_if name="edit_disabled">
                        <label for="server_id_disabled" class="col-sm-3 control-label">{tmpl_var name='server_id_txt'}</label>
                        <div class="col-sm-9"><select name="server_id_disabled" id="server_id_disabled" class="form-control" disabled="disabled">
                            {tmpl_var name='server_id'}
                        </select></div>
                        <input type="hidden" name="server_id" value="{tmpl_var name='server_id_value'}" />
                        <tmpl_else>
                            <label for="server_id" class="col-sm-3 control-label">{tmpl_var name='server_id_txt'}</label>
                            <div class="col-sm-9"><select name="server_id" id="server_id" class="form-control">
                                {tmpl_var name='server_id'}
                            </select></div>
                    </tmpl_if>
                </div>
                <tmpl_unless name="domain_option">
                    <div class="form-group">
                        <label for="client_group_id" class="col-sm-3 control-label">{tmpl_var name='client_group_id_txt'}</label>
                        <div class="col-sm-9"><select name="client_group_id" id="client_group_id" class="form-control">
                            {tmpl_var name='client_group_id'}
                        </select></div>
                    </div>
                </tmpl_unless>
            <tmpl_else>
                <tmpl_if name="only_one_server">
                    <input type="hidden" id="server_id" name="server_id" value="{tmpl_var name='server_id_value'}" />
                <tmpl_else>
                    <div class="form-group">
                        <tmpl_if name="edit_disabled">
                            <label for="server_id_disabled" class="col-sm-3 control-label">{tmpl_var name='server_id_txt'}</label>
                            <div class="col-sm-9"><select name="server_id_disabled" id="server_id_disabled" class="form-control" disabled="disabled">
                                {tmpl_var name='server_id'}
                            </select></div>
                            <input type="hidden" name="server_id" value="{tmpl_var name='server_id_value'}" />
                        <tmpl_else>
                            <label for="server_id" class="col-sm-3 control-label">{tmpl_var name='server_id_txt'}</label>
                            <div class="col-sm-9"><select name="server_id" id="server_id" class="form-control">
                                {tmpl_var name='server_id'}
                            </select></div>
                        </tmpl_if>
                    </div>
                </tmpl_if>
            </tmpl_if>
            <tmpl_if name="is_reseller">
                <tmpl_unless name="domain_option">
                    <div class="form-group">
                        <label for="client_group_id" class="col-sm-3 control-label">{tmpl_var name='client_group_id_txt'}</label>
                        <div class="col-sm-9"><select name="client_group_id" id="client_group_id" class="form-control">
                            {tmpl_var name='client_group_id'}
                        </select></div>
                    </div>
                </tmpl_unless>
            </tmpl_if>
            <div class="form-group">
                <label for="ip_address" class="col-sm-3 control-label">{tmpl_var name='ip_address_txt'}</label>
                <div class="col-sm-9"><select name="ip_address" id="ip_address" class="form-control">
                    {tmpl_var name='ip_address'}
                </select></div>
            </div>
            <div class="form-group">
                <label for="ipv6_address" class="col-sm-3 control-label">{tmpl_var name='ipv6_address_txt'}</label>
                <div class="col-sm-9"><select name="ipv6_address" id="ipv6_address" class="form-control">
                    {tmpl_var name='ipv6_address'}
                </select></div>
            </div>
            <div class="form-group">
                <label for="domain" class="col-sm-3 control-label">{tmpl_var name='domain_txt'}</label>
                <tmpl_if name="domain_option">
                    <div class="col-sm-9"><select name="domain" id="domain" class="form-control">
                        {tmpl_var name='domain_option'}
                    </select></div>
                    <tmpl_else>
                        <div class="col-sm-9"><input type="text" name="domain" id="domain" value="{tmpl_var name='domain'}" class="form-control" /></div></tmpl_if>
            </div>
			<tmpl_if name="edit_disabled">
				<div class="form-group">
					<label for="document_root" class="col-sm-3 control-label" readonly >{tmpl_var name='document_root_txt'}</label>
					<div class="col-sm-9">
                        <div class="checkbox">{tmpl_var name='document_root'}</div>
                    </div>
				</div>
			</tmpl_if>
            <div class="form-group">
                <label for="hd_quota" class="col-sm-3 control-label">{tmpl_var name='hd_quota_txt'}</label>
                <div class="col-sm-9"><div class="input-group"><input type="text" name="hd_quota" id="hd_quota" value="{tmpl_var name='hd_quota'}" class="form-control" /><span class="input-group-addon" id="quota-desc">MB</span></div></div>
			</div>
		</tmpl_if>
		<tmpl_if name="vhostdomain_type" value="subdomain">
            <input type="hidden" name="server_id" id="server_id" value="{tmpl_var name='server_id_value'}" />
            <tmpl_if name="domain_option">
            <div class="form-group">
                <label for="parent_domain_id" class="col-sm-3 control-label">{tmpl_var name='parent_domain_id_txt'}</label>
                <div class="col-sm-9"><select id="parent_domain_id" name="parent_domain_id" class="form-control">{tmpl_var name='parent_domain_id'}</select></div>
            </div>
            </tmpl_if>
            <div class="form-group">
                <label for="domain" class="col-sm-3 control-label">{tmpl_var name='host_txt'}</label>
                <div class="col-sm-9"><input type="text" name="domain" id="domain" value="{tmpl_var name='domain'}" class="form-control" /></div></div>
            <tmpl_if name="domain_option">
            <div class="form-group">
                <label for="sel_domain" class="col-sm-3 control-label">{tmpl_var name='domain_txt'}</label>
                    <div class="col-sm-9"><select name="sel_domain" id="sel_domain" class="form-control">
                        {tmpl_var name='domain_option'}
                    </select></div>
            </div>
            <tmpl_else>
            <div class="form-group">
                <label for="parent_domain_id" class="col-sm-3 control-label">{tmpl_var name='domain_txt'}</label>
                <div class="col-sm-9"><select id="parent_domain_id" name="parent_domain_id" class="form-control">{tmpl_var name='parent_domain_id'}</select></div>
            </div>
            </tmpl_if>
            <div class="form-group">
                <label for="web_folder" class="col-sm-3 control-label">{tmpl_var name='web_folder_txt'}</label>
                <div class="col-sm-9"><input type="text" name="web_folder" id="web_folder" value="{tmpl_var name='web_folder'}" class="form-control"<tmpl_if name='fixed_folder' op='==' value='y'>readonly="readonly"</tmpl_if> /></div>
            </div>
		</tmpl_if>
		<tmpl_if name="vhostdomain_type" value="aliasdomain">
            <input type="hidden" name="server_id" id="server_id" value="{tmpl_var name='server_id_value'}" />
            <div class="form-group">
                <label for="domain" class="col-sm-3 control-label">{tmpl_var name='domain_txt'}</label>
                <tmpl_if name="domain_option">
                    <div class="col-sm-9"><select name="domain" id="domain" class="form-control">
                        {tmpl_var name='domain_option'}
                    </select></div>
                    <tmpl_else>
                        <div class="col-sm-9"><input type="text" name="domain" id="domain" value="{tmpl_var name='domain'}" class="form-control" /></div></tmpl_if>
            </div>
            <div class="form-group">
                <label for="parent_domain_id" class="col-sm-3 control-label">{tmpl_var name='parent_domain_id_txt'}</label>
                <div class="col-sm-9"><select name="parent_domain_id" id="parent_domain_id" class="form-control">
                    {tmpl_var name='parent_domain_id'}
                </select></div>
            </div>
            <div class="form-group">
                <label for="web_folder" class="col-sm-3 control-label">{tmpl_var name='web_folder_txt'}</label>
                <div class="col-sm-9"><input type="text" name="web_folder" id="web_folder" value="{tmpl_var name='web_folder'}" class="form-control"<tmpl_if name='fixed_folder' op='==' value='y'> readonly="readonly"</tmpl_if> /></div>
            </div>
		</tmpl_if>
            <div class="form-group">
                <label for="traffic_quota" class="col-sm-3 control-label">{tmpl_var name='traffic_quota_txt'}</label>
                <div class="col-sm-9"><div class="input-group"><input type="text" name="traffic_quota" id="traffic_quota" value="{tmpl_var name='traffic_quota'}" class="form-control" /><span class="input-group-addon" id="quota-desc">MB</span></div></div><tmpl_var name='traffic_quota_exceeded_txt'>
            </div>
            <tmpl_if name="limit_cgi" op="==" value="y"><div class="form-group">
                <label class="col-sm-3 control-label">{tmpl_var name='cgi_txt'}</label>
                <div class="col-sm-9">
                    {tmpl_var name='cgi'}
                </div>
            </div></tmpl_if>
            <tmpl_if name="limit_ssi" op="==" value="y"><div class="form-group">
                <label class="col-sm-3 control-label">{tmpl_var name='ssi_txt'}</label>
                <div class="col-sm-9">
                    {tmpl_var name='ssi'}
                </div>
            </div></tmpl_if>
            <tmpl_if name="limit_perl" op="==" value="y"><div class="form-group apache">
                <label class="col-sm-3 control-label">{tmpl_var name='perl_txt'}</label>
                <div class="col-sm-9">
                    {tmpl_var name='perl'}
                </div>
            </div></tmpl_if>
            <tmpl_if name="limit_ruby" op="==" value="y"><div class="form-group apache">
                <label class="col-sm-3 control-label">{tmpl_var name='ruby_txt'}</label>
                <div class="col-sm-9">
                    {tmpl_var name='ruby'}
                </div>
            </div></tmpl_if>
            <tmpl_if name="limit_python" op="==" value="y"><div class="form-group apache">
                <label class="col-sm-3 control-label">{tmpl_var name='python_txt'}</label>
                <div class="col-sm-9">
                    {tmpl_var name='python'}
                </div>
            </div></tmpl_if>
            <tmpl_if name="force_suexec" op="==" value="n"><div class="form-group apache">
                <label class="col-sm-3 control-label">{tmpl_var name='suexec_txt'}</label>
                <div class="col-sm-9">
                    {tmpl_var name='suexec'}
                </div>
            </div></tmpl_if>
            <tmpl_if name="limit_hterror" op="==" value="y"><div class="form-group">
                <label class="col-sm-3 control-label">{tmpl_var name='errordocs_txt'}</label>
                <div class="col-sm-9">
                    {tmpl_var name='errordocs'}
                </div>
            </div></tmpl_if>

            <div class="form-group">
                <label for="subdomain" class="col-sm-3 control-label">{tmpl_var name='subdomain_txt'}</label>
                <div class="col-sm-9"><select name="subdomain" id="subdomain" class="form-control">
                    {tmpl_var name='subdomain'}
                </select></div>
            </div>
            <tmpl_if name="limit_ssl" op="==" value="y"><div class="form-group">
                <label class="col-sm-3 control-label">{tmpl_var name='ssl_txt'}</label>
                <div class="col-sm-9" data-uncheck-fields="ssl_letsencrypt">
                    {tmpl_var name='ssl'}
                </div>
            </div>
            <tmpl_if name="limit_ssl_letsencrypt" op="==" value="y">
            <div class="form-group">
                <label class="col-sm-3 control-label">{tmpl_var name='ssl_letsencrypt_txt'}</label>
                <div class="col-sm-9" data-check-fields="ssl">
                    {tmpl_var name='ssl_letsencrypt'}
                </div>
            </div></tmpl_if>
            </tmpl_if>
            <div class="form-group">
                <label for="php" class="col-sm-3 control-label">{tmpl_var name='php_txt'}</label>
                <div class="col-sm-9"><select name="php" id="php" class="form-control">
                    {tmpl_var name='php'}
                </select></div>
            </div>
            {tmpl_hook name="field_fastcgi_php_version"}
            <div class="form-group fastcgi_php_version">
                <label for="fastcgi_php_version" class="col-sm-3 control-label">{tmpl_var name='fastcgi_php_version_txt'}</label>
                <div class="col-sm-9"><select name="fastcgi_php_version" id="fastcgi_php_version" class="form-control">
                    {tmpl_var name='fastcgi_php_version'}
                </select></div>
                <tmpl_if name="fastcgi_php_version_default_hidden_warning_confirmed">
                    <input type="hidden" id="fastcgi_php_version_default_hidden_warning_confirmed" name="fastcgi_php_version_default_hidden_warning_confirmed" value="{tmpl_var name='fastcgi_php_version_default_hidden_warning_confirmed'}" />
                </tmpl_if>
            </div>
            <tmpl_if name="limit_directive_snippets" op="==" value="y"><div class="form-group">
				<label for="directive_snippets_id" class="col-sm-3 control-label">{tmpl_var name='directive_snippets_id_txt'}</label>
				<div class="col-sm-9"><select name="directive_snippets_id" id="directive_snippets_id" class="form-control">
					{tmpl_var name='directive_snippets_id'}
				</select></div>
			</div></tmpl_if>
			<tmpl_if name="is_pagespeed_enabled" op="==" value="y">
				<div class="form-group nginx pagespeed">
					<label class="col-sm-3 control-label">{tmpl_var name='enable_pagespeed_txt'}</label>
					<div class="col-sm-9">{tmpl_var name="enable_pagespeed"}</div>
				</div>
			</tmpl_if>
<!--
			{tmpl_hook name="field_enable_pagespeed"}
			<div class="form-group nginx pagespeed">
				<label class="col-sm-3 control-label">{tmpl_var name='enable_pagespeed_txt'}</label>
				<div class="col-sm-9">
					{tmpl_var name="enable_pagespeed"}
				</div>
			</div>
-->
            {tmpl_hook name="field_active"}
            <div class="form-group">
                <label class="col-sm-3 control-label">{tmpl_var name='active_txt'}</label>
                <div class="col-sm-9">
                    {tmpl_var name='active'}
                </div>
            </div>
			{tmpl_hook name="end_form"}

        <input type="hidden" name="id" value="{tmpl_var name='id'}">

        <div class="clear"><div class="right">
            <button id="dom-edit-submit" class="btn btn-default formbutton-success" type="button" value="{tmpl_var name='btn_save_txt'}">{tmpl_var name='btn_save_txt'}</button>
            <button class="btn btn-default formbutton-default" type="button" value="{tmpl_var name='btn_cancel_txt'}" data-load-content="sites/web_vhost_domain_list.php">{tmpl_var name='btn_cancel_txt'}</button>
        </div></div>
<script language="JavaScript" type="text/javascript">
    var serverId;
    var clientGroupId = jQuery('#client_group_id').val();
    var serverIdDisabled = jQuery('#server_id_disabled').val();
	var serverType;
    if(serverIdDisabled > 0){
        serverId = serverIdDisabled;
    } else {
        serverId = jQuery('#server_id').val();
        jQuery('#server_id').change(function(){
            serverId = $(this).val();
            adjustForm();
            reloadWebIP();
            reloadFastcgiPHPVersions();
			reloadDirectiveSnippets();
        });
    }
    adjustForm(true);
    reloadFastcgiPHPVersions(true);

    jQuery('#client_group_id').change(function(){
        clientGroupId = $(this).val();
        reloadWebIP();
		reloadFastcgiPHPVersions();
    });

    if(jQuery('#php').val() == 'fast-cgi' || jQuery('#php').val() == 'php-fpm' || (jQuery('#php').val() == 'hhvm' && serverType == 'nginx')){
        jQuery('.fastcgi_php_version:hidden').show();
		if(jQuery('#php').val() == 'hhvm'){
			jQuery('#fastcgi_php_version_txt').hide();
			jQuery('#fastcgi_php_fallback_version_txt').show();
		} else {
			jQuery('#fastcgi_php_version_txt').show();
			jQuery('#fastcgi_php_fallback_version_txt').hide();
		}
    } else {
        jQuery('.fastcgi_php_version:visible').hide();
    }
    //ISPConfig.resetFormChanged();

    jQuery('#php').change(function(){
        reloadFastcgiPHPVersions();
        if(jQuery(this).val() == 'fast-cgi' || jQuery(this).val() == 'php-fpm' || (jQuery(this).val() == 'hhvm' && serverType == 'nginx')){
            jQuery('.fastcgi_php_version:hidden').show();
			if(jQuery(this).val() == 'hhvm'){
				jQuery('#fastcgi_php_version_txt').hide();
				jQuery('#fastcgi_php_fallback_version_txt').show();
			} else {
				jQuery('#fastcgi_php_version_txt').show();
				jQuery('#fastcgi_php_fallback_version_txt').hide();
			}
        } else {
            jQuery('.fastcgi_php_version:visible').hide();
        }
    });
    jQuery('#parent_domain_id').change(function() {
        reloadServerId(false);
    });
	// new Vhostsubdomains/Vhostaliasdomains
	if(serverId == '') jQuery('#parent_domain_id').trigger('change');

/*
	if(jQuery('#directive_snippets_id').val() > 0){
		jQuery('.pagespeed').show();
	} else {
		jQuery('.pagespeed').hide();
	}
	jQuery('#directive_snippets_id').change(function(){
		if(jQuery(this).val() > 0){
			jQuery('.pagespeed').show();
		} else {
			jQuery('.pagespeed').hide();
		}
	});
*/

    function reloadServerId(noFormChange) {
        var parentWebId = jQuery('#parent_domain_id').val();
        jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {web_id : parentWebId, type : "getserverid"}, function(data) {
            if(data.serverid) serverId = data.serverid;
            adjustForm(noFormChange);
            if(noFormChange) reloadFastcgiPHPVersions(noFormChange);
        });
    }

    function adjustForm(noFormChange){
        jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, type : "getservertype"}, function(data) {
            if(data.servertype == "nginx"){
				serverType = 'nginx';
                var selected = jQuery('#php').val();
                jQuery('.apache').hide();
				jQuery('.nginx').show();
/*
				if(jQuery('#directive_snippets_id').val() > 0){
					jQuery('.pagespeed').show();
				} else {
					jQuery('.pagespeed').hide();
				}
				jQuery('#directive_snippets_id').change(function(){
					if(jQuery(this).val() > 0){
						jQuery('.pagespeed').show();
					} else {
						jQuery('.pagespeed').hide();
					}
				});
*/
                if(selected != "no" && selected != "php-fpm" && selected != "hhvm") {
                    jQuery('#php option[value="php-fpm"]').attr('selected', 'selected').val('php-fpm');
                }
                jQuery('#php option[value="fast-cgi"]').hide();
                jQuery('#php option[value="cgi"]').hide();
                jQuery('#php option[value="mod"]').hide();
                jQuery('#php option[value="suphp"]').hide();
            } else {
				serverType = 'apache';
				jQuery('.nginx').hide();
                jQuery('.apache').show();
                jQuery('#php option[value="fast-cgi"]').show();
                jQuery('#php option[value="cgi"]').show();
                jQuery('#php option[value="mod"]').show();
                jQuery('#php option[value="suphp"]').show();
            }
            if(noFormChange) {
                ISPConfig.resetFormChanged();
            }
        });
    }

	function reloadDirectiveSnippets() {
        jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, type : "getdirectivesnippet"}, function(data) {
            var options = '<option value="0">-</option>';
			options += "<optgroup label=\"{tmpl_var name='select_master_directive_snippet_txt'}\">";
			for (var i = 0, len = data['m_snippets'].length; i < len; i++) {
				var isSelected = '';

				 if ($('#directive_snippets_id').val() == i + 1) {
					 isSelected = 'selected="selected"';
				 }

				 options += '<option ' + isSelected + ' value="' + data['m_snippets'][i]['directive_snippets_id'] + '">' + data['m_snippets'][i]['name'] + '</option>';
			}
			options += '</optgroup>';

			options += "<optgroup label=\"{tmpl_var name='select_directive_snippet_txt'}\">";
			for (var i = 0, len = data['snippets'].length; i < len; i++) {
				var isSelected = '';

				 if ($('#directive_snippets_id').val() == i + 1) {
					 isSelected = 'selected="selected"';
				 }

				 options += '<option ' + isSelected + ' value="' + data['snippets'][i]['directive_snippets_id'] + '">' + data['snippets'][i]['name'] + '</option>';
			}
			options += '</optgroup>';

			$('#directive_snippets_id').html(options).change();
		});
	}

    function reloadWebIP() {
        ISPConfig.loadOptionInto('ip_address','sites/ajax_get_ip.php?ip_type=IPv4&server_id='+serverId+'&client_group_id='+clientGroupId<tmpl_if name="use_combobox" value="y">, rerenderSelect2</tmpl_if>);
        ISPConfig.loadOptionInto('ipv6_address','sites/ajax_get_ip.php?ip_type=IPv6&server_id='+serverId+'&client_group_id='+clientGroupId<tmpl_if name="use_combobox" value="y">, rerenderSelect2</tmpl_if>);
		<tmpl_if name="use_combobox" value="y">
		//$('#ip_address').add('#ipv6_address').select2();
		</tmpl_if>
    }

	function rerenderSelect2(elem) {
		$('#'+elem).select2();
	}

    function reloadFastcgiPHPVersions(noFormChange) {
        jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, php_type : jQuery('#php').val(), type : "getphpfastcgi", client_group_id : clientGroupId}, function(data) {
            //var options = '<option value="">Default</option>';
			var options = '';
            var phpfastcgiselected = '';
            $.each(data, function(key, val) {
				<tmpl_if name="id">
                if($('#fastcgi_php_version').val() == key){
                    phpfastcgiselected = ' selected="selected"';
                } else {
                    phpfastcgiselected = '';
                }
				</tmpl_else>
					phpfastcgiselected = '';
				</tmpl_if>
                options += '<option value="'+key+'"'+phpfastcgiselected+'>'+val+'</option>';
            });
			<tmpl_if name="id">
			if($('#fastcgi_php_version').val() == ''){
                phpfastcgiselected = ' selected="selected"';
            } else {
                phpfastcgiselected = '';
            }
			</tmpl_else>
				phpfastcgiselected = '';
			</tmpl_if>
			//options += '<option value=""'+phpfastcgiselected+'>{tmpl_var name="default_php_txt"}</option>';
            $('#fastcgi_php_version').html(options).change();
            if(noFormChange) ISPConfig.resetFormChanged();
        });
    }

    <tmpl_if name="readonly_tab">
        jQuery('div.panel_web_domain').find('fieldset').find('input,select,button').not('#directive_snippets_id').bind('click mousedown', function(e) { e.preventDefault(); }).focus(function() { $(this).blur(); });
        jQuery('#dom-edit-submit').click(function() {
			ISPConfig.submitForm('pageForm','sites/web_vhost_domain_edit.php');
        });
    <tmpl_else>
        jQuery('#dom-edit-submit').click(function() {
            ISPConfig.submitForm('pageForm','sites/web_vhost_domain_edit.php');
        });
    </tmpl_if>

	if($('#domain').val() == ''){
		$('#web_folder_domain').text('[DOMAIN]');
	} else {
		$('#web_folder_domain').text($('#domain').val());
	}
	$('#domain').bind('change keyup', function(){
		if($(this).val() == ''){
			$('#web_folder_domain').text('[DOMAIN]');
		} else {
			$('#web_folder_domain').text($('#domain').val());
		}
	});

	$('#more_folder_directive_snippets').click(function(){
		$('.folder_directive_snippets:hidden:first').removeClass('hidden');
	});

</script>
