/* archive channel */
$('select[name="archive_model_id"]').change(function(){
	get_channel($(this).val());
	get_tpl($(this).val());
	get_parent_html_dir(0);
});
/* listen ac_parent_id change */
$('select[name="ac_parent_id"]').change(function(){
	get_model($(this).val());
	get_parent_html_dir($(this).val());
});
/* get archive model template */
function get_tpl(archive_model_id){
	$.getJSON(get_tpl_url+'&archive_model_id='+archive_model_id, function(result){
		if(1 == result.data){
			var k, s, tpls = result.info;
			for(k in tpls)
			{
				$('input[name="'+k+'"]').val(tpls[k]);
			}
		}
	});
}
/* get archive model channel list */
function get_channel(archive_model_id){
	$.getJSON(get_channel_url+'&archive_model_id='+archive_model_id, function(result){
		if(1 == result.data){
			$('select[name="ac_parent_id"]').html(result.info);
		}
	});
}
/* get archive model */
function get_model(archive_channel_id){
	$.getJSON(get_model_url+'&archive_channel_id='+archive_channel_id, function(result){
		if(1 == result.data){
			var archive_model_id = result.info;
			$('select[name="archive_model_id"] option[value="'+archive_model_id+'"]').attr('selected','selected');/* 选择模型 */
			get_tpl(archive_model_id);
		}
	});
}
/* get parent html dir */
function get_parent_html_dir(archive_channel_id){
	$.getJSON(get_html_dir_url+'&archive_channel_id='+archive_channel_id, function(result){
		if(1 == result.data){
			$('input[name="ac_parent_dir"]').val(result.info+'/');
			$('#ac_parent_dir').html(result.info+'/');
		}
	});
}

