//准备函数
$(function(){
	//键盘输入：用户名写入URL演示地址
	$('#user_id').keyup(function(){
		showWebUrl($(this).val());	
	});
	//失去焦点：用户名唯一性检测
	$('#user_id').blur(function(){
		check_user($(this).val());	
	});
	//选择证件类型
	$('#selectDoctorCheck label').click(function(){
        $(this).parent().find('label').removeClass();
		$(this).addClass('df_tab_title_currently');
		tmp_id = $(this).attr('for');
		$('#contentDoctorCheck').children().hide();
		$('#'+tmp_id+'_cont').show();
	});
	
	//添加一个附件
	$('a[class=addAttachment]').click(function(){
		mark = $(this).attr('id');
		tmp = addOneAttachment(mark);
		$(this).parent().after(tmp);
        $(this).remove();
	})
})
//验证用户名是否存在
function check_user(user_id){
	$('#is_isset').remove();
	tmp = ' <span id="is_isset" style="color:red;font-size:12px">正在检测...</span>';
	$('#user_id').after(tmp);
	$.ajax({
		type: "GET",
		url: "/account/?c=check_user&a=true",
		data: "user_id="+user_id,
		success: function(data){
			$("#is_isset").html(data);
		},
		error: function(data){
		}
	});
}

//城市
function city_op(id){
	$.ajax({
		type: "GET",
		url: "/account/?c=city_change&a=true",
		data: "id="+id+"",
		success: function(data){
			$("#city_ch").html(data);
		},
		error: function(data){
		}
	});
}

function getAllHos(){
	$("#all_dpt").fadeOut();
	$("#all_hos").fadeIn();
	city_id = document.account_form.city_id.value;
	$.ajax({
		type: "GET",
		url: '/account/?c=gethospital&a=true',
		data: "city_id="+city_id+"",
		success: function(data){
			$("#all_hos").html(data);
		},
		error: function(data){
		}
	});
}

function getAllDpt(){
	$("#all_hos").fadeOut();
	$("#all_dpt").fadeIn();
	city_id = document.account_form.city_id.value;
	hos_name = document.account_form.hospital_name.value;
	$.ajax({
		type: "GET",
		url: '/account/?c=getdepartment&a=true',
		data: "city_id="+city_id+"&hos_name="+hos_name,
		success: function(data){
			$("#all_dpt").html(data);
		},
		error: function(data){
		}
	});
}

function sKey(s,o){
	if(s!=''){
		tmp = $(o+' span').hide().filter(':contains('+ s +')').show();
	}else{
		$(o+' span').show();
	}
}

//输入用户名时，显示URL地址
//v输入的值
//id在某一个ID上显示出来，默认为id = web_url
function showWebUrl(v,id){
	if(id == undefined) id = 'web_url';
	$('#'+id).html(v);
}

function addOneAttachment(o){
	tmp = '<div><input name="'+o+'2" type="file" check="file_safe" canBeNull="true" warning="文件类型只能为 gif,jpg,jpeg,png,bmp,tiff,pdf,doc"/></div>';
	return tmp;
}

