<div class='page-header'>
	<h1><tmpl_var name="list_head_txt"></h1>
</div>
<p><tmpl_var name="list_desc_txt"></p>


        
			<tmpl_if name="childdomain_type" value="subdomain">
            <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>
			<tmpl_else>
            <div class="form-group">
                <tmpl_if name="domain_option">
                    <label for="domain" class="col-sm-3 control-label">{tmpl_var name='domain_txt'}</label>
                    <div class="col-sm-9"><select name="domain" id="domain" class="form-control">
                        {tmpl_var name='domain_option'}
                    </select></div>
                <tmpl_else>
                    <label for="domain" class="col-sm-3 control-label">{tmpl_var name='domain_txt'}</label>
                    <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 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="redirect_type" class="col-sm-3 control-label">{tmpl_var name='redirect_type_txt'}</label>
                <div class="col-sm-9"><select name="redirect_type" id="redirect_type" class="form-control">
                    {tmpl_var name='redirect_type'}
                </select></div>
            </div>
            <div class="form-group">
                <label for="redirect_path" class="col-sm-3 control-label">{tmpl_var name='redirect_path_txt'}</label>
                <div class="col-sm-9"><input type="text" name="redirect_path" id="redirect_path" value="{tmpl_var name='redirect_path'}" class="form-control" /></div></div>
			<tmpl_if name="childdomain_type" value="aliasdomain">
            <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>
			<div class="form-group">
                <label for="seo_redirect" class="col-sm-3 control-label">{tmpl_var name='seo_redirect_txt'}</label>
                <div class="col-sm-9"><select name="seo_redirect" id="seo_redirect" class="form-control">
                    {tmpl_var name='seo_redirect'}
                </select></div>
            </div>
			</tmpl_if>
			<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_exclude_txt'}</label>
                <div class="col-sm-9">
                    {tmpl_var name='ssl_letsencrypt_exclude'}
                </div>
            </div>
			</tmpl_if>
            <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>
        

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

        <div class="clear"><div class="right">
            <button class="btn btn-default formbutton-success" type="button" value="{tmpl_var name='btn_save_txt'}" data-submit-form="pageForm" data-form-action="sites/web_childdomain_edit.php">{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_childdomain_list.php">{tmpl_var name='btn_cancel_txt'}</button>
        </div></div>
<script language="JavaScript" type="text/javascript">
    var webId = jQuery('#parent_domain_id').val();
    var serverId;
    getServerId(webId);
	
    jQuery('#parent_domain_id').change(function(){
        webId = $(this).val();
        getServerId(webId);
    });
	
	if(jQuery('#redirect_type').val() == 'proxy'){
        jQuery('.tabbox_tabs ul li:last').show();
    } else {
        jQuery('.tabbox_tabs ul li:last').hide();
    }
    jQuery('#redirect_type').change(function(){
        if(jQuery(this).val() == 'proxy'){
            jQuery('.tabbox_tabs ul li:last').show();
        } else {
            jQuery('.tabbox_tabs ul li:last').hide();
        }
    });
	
    function getServerId(webId){
        jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {web_id : webId, type : "getserverid"}, function(data) {
            serverId = data.serverid;
            adjustForm(serverId);
        });
    }
		
    function adjustForm(serverId){
        jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, type : "getservertype"}, function(data) {
            var selected = jQuery('#redirect_type').val();
            if(data.servertype == "nginx"){
                jQuery("#redirect_type option[value='R']").attr('disabled','disabled');
                jQuery('#redirect_type option[value="L"]').attr('disabled','disabled');
                jQuery('#redirect_type option[value="R,L"]').attr('disabled','disabled');
                jQuery('#redirect_type option[value="R=301,L"]').attr('disabled','disabled');
					
                jQuery("#redirect_type option[value='R']").hide();
                jQuery('#redirect_type option[value="L"]').hide();
                jQuery('#redirect_type option[value="R,L"]').hide();
                jQuery('#redirect_type option[value="R=301,L"]').hide();
					
                jQuery('#redirect_type option[value="last"]').show();
                jQuery('#redirect_type option[value="break"]').show();
                jQuery('#redirect_type option[value="redirect"]').show();
                jQuery('#redirect_type option[value="permanent"]').show();
				jQuery('#redirect_type option[value="proxy"]').show();
					
                jQuery('#redirect_type option[value="last"]').attr('disabled',false);
                jQuery('#redirect_type option[value="break"]').attr('disabled',false);
                jQuery('#redirect_type option[value="redirect"]').attr('disabled',false);
                jQuery('#redirect_type option[value="permanent"]').attr('disabled',false);
				jQuery('#redirect_type option[value="proxy"]').attr('disabled',false);
					
                if(selected != "no" && selected != "" && selected != "last" && selected != "break" && selected != "redirect" && selected != "permanent" && selected != "proxy") jQuery('#redirect_type option[value="no"]').attr('selected', 'selected');
            } else {
                jQuery('#redirect_type option[value="last"]').attr('disabled','disabled');
                jQuery('#redirect_type option[value="break"]').attr('disabled','disabled');
                jQuery('#redirect_type option[value="redirect"]').attr('disabled','disabled');
                jQuery('#redirect_type option[value="permanent"]').attr('disabled','disabled');
				jQuery('#redirect_type option[value="proxy"]').attr('disabled','disabled');
					
                jQuery('#redirect_type option[value="last"]').hide();
                jQuery('#redirect_type option[value="break"]').hide();
                jQuery('#redirect_type option[value="redirect"]').hide();
                jQuery('#redirect_type option[value="permanent"]').hide();
				jQuery('#redirect_type option[value="proxy"]').hide();
					
                jQuery('#redirect_type option[value="R"]').show();
                jQuery('#redirect_type option[value="L"]').show();
                jQuery('#redirect_type option[value="R,L"]').show();
                jQuery('#redirect_type option[value="R=301,L"]').show();
					
                jQuery('#redirect_type option[value="R"]').attr('disabled',false);
                jQuery('#redirect_type option[value="L"]').attr('disabled',false);
                jQuery('#redirect_type option[value="R,L"]').attr('disabled',false);
                jQuery('#redirect_type option[value="R=301,L"]').attr('disabled',false);
					
                if(selected != "no" && selected != "" && selected != "R" && selected != "L" && selected != "R,L" && selected != "R=301,L") jQuery('#redirect_type option[value="no"]').attr('selected', 'selected');
            }
        });
    }
</script>