
function checkvoteform(obj) {
	if ((obj.disease.value == "") || (obj.disease.value == "请填入正确的疾病名称")) {
		alert("请输入疾病名称!");
		obj.disease.focus();
		return false;
	}
	if (obj.disease.value.length > 100) {
		alert("疾病名称不能大于50字！");
		obj.disease.focus();
		return false;
	}
	if (obj.skill.value == -2) {
		alert("请选择疗效！");
		obj.skill.focus();
		return false;
	}
	if (obj.attitude.value == -2) {
		alert("请选择态度！");
		obj.attitude.focus();
		return false;
	}
	if (obj.registerrate.value == -2) {
		alert("请选择挂号难度！");
		obj.registerrate.focus();
		return false;
	}
	return true;
}

function focusVoteInputBox(e){
	e.value = "";
}

function blurVoteInputBox(e){
	if(e.value == ""){
		e.value="请填入正确的疾病名称";
	}
}

function showPopDiv(el, show){
	$('#el_reply_template').css('display', 'none');
	$('#el_goods_case').css('display', 'none');
	$('#'+show).css('top', $(el).offset().top + $(el).height());
	$('#'+show).css('left', $(el).offset().left);
	$('#'+show).css('display', 'block');
}

function add2content(txt, el, pp){
	var otxt = $('#'+el).val() == '' ? '' : $('#'+el).val() + "\n";
	$('#'+el).val(otxt + txt);
	$('#'+pp).css('display', 'none');
	document.getElementById('content').className='none';
}

function idx_open_patient_list(patient_category_id, self){
	var el = $('#el_patient_list_'+patient_category_id);
	el.css({
		'top': $(self).offset().top - 10,
		'left': $(self).offset().left  + $(self).width(),
		'visibility': 'visible'
	});
}

function idx_patient_list_init(){
	$(function(){
		$.each($('.patient_list'), function(){
			$(this).mouseout(function(){
				// $(this).css('visibility', 'hidden');
			});
		});
	});
}

//////////////////////////////////////////////////////////////////////////
var SPACE_POP_WIN_TIME = 256;
var SPACE_POP_WIN_BG_ID = 'space_pop_windows_bg';

function space_pop_windows(fromel, windowsId, tourl, params){
	var params = params == undefined ? {} : params;
	
	function laji_aoyou(fromel){
		$('#'+windowsId).find('*[tag=win_ext]').css('visibility', 'hidden');
		
		var nowWidth = $('#'+windowsId).width();
		var nowHeight = $('#'+windowsId).height();
		var winWidth = $(window).width();
		var winHeight = $(window).height();

		$('#'+windowsId).css({
			left: (winWidth - nowWidth)/2,
			top: $(window).scrollTop() + (winHeight - nowHeight)/2,
			visibility: 'visible'
		});
		$('#'+windowsId+'_ifm').width(nowWidth);
		$('#'+windowsId+'_ifm').height(nowHeight);
		$('#'+windowsId+'_ifm').css({
			left: (winWidth - nowWidth)/2,
			top: $(window).scrollTop() + (winHeight - nowHeight)/2,
			visibility: 'visible'
		});
	}

	if ($('#'+windowsId).get(0) == undefined || params.every_refresh != false) {
		var wwtitle = params.title == undefined ? 'title' : params.title;
		if (params.icon != undefined) { icon_url = params.icon; }
		var wtitle = '<div class="head"><div class="title">' + wwtitle + '</div><div class="close"><a href="javascript:" onclick="space_pop_windows_close(\''+windowsId+'\')">关闭窗口</a></div></div>';
		
		if ($('#'+windowsId).get(0) == undefined) {
			var makeHtml = '<div class="haodf_windows" id="'+windowsId+'">'+wtitle+'<div class="content" id="'+windowsId+'_content"></div></div>';
			makeHtml += '<iframe border="0" frameborder="0" id="'+windowsId+'_ifm" class="haodf_windows_ifm"></iframe>';
			$(document.body).append(makeHtml);
		}
		$('#'+windowsId+'_content').html('<div style="width:300px;">载入中，请稍候...</div>');
		laji_aoyou(fromel);
		$.get(tourl + "&ref=" + (new Date()), function(data){
			$('#'+windowsId+'_content').html(data);
			laji_aoyou(fromel);
		});
	}
}

function space_pop_windows_close(windowsId, callcack){
	var callcack = callcack == undefined ? function(){} : callcack;
	$('#'+windowsId).find('*[tag=win_ext]').css('visibility', 'hidden');
	$('#'+windowsId).css({
		visibility: 'hidden'
	});
	$('#'+windowsId+'_ifm').css({
		visibility: 'hidden'
	});
	callcack();
}

function space_pop_windows_pop_alert(windowsId, msg, callback){
	var callback = (callback == undefined ? function(){} : callback);
	var popalert = $('#'+windowsId+'_pop_alert');
	var icon_src = 'http://hdfimg.com/space/doctor/global/icon_yes.gif';
	if (popalert.get(0) == undefined) {
		var makeHtml = '<div tag="win_ext" class="haodf_windows small" id="'+windowsId+'_pop_alert"><div id="'+windowsId+'_pop_alert_content" class="content"></div></div>';
		makeHtml += '<iframe tag="win_ext" border="0" frameborder="0" id="'+windowsId+'_pop_alert_ifm" class="haodf_windows_ifm"></iframe>';
		$('#'+windowsId).append(makeHtml);
		popalert = $('#'+windowsId+'_pop_alert');
	}
	$('#'+windowsId+'_pop_alert_content').html('<div style="padding-left:32px; margin-right:40px; text-align:left; font-size:14px; line-height:25px; background:url('+icon_src+') left no-repeat; ">'+msg+'</div>');
	
	popalert.css({
		visibility: 'visible',
		top: ($('#'+windowsId).height() - popalert.height())/2 - 10,
		left: ($('#'+windowsId).width() - popalert.width())/2
	});
	$('#'+windowsId+'_pop_alert_ifm').css({
		width: popalert.width(),
		height: popalert.height(),
		visibility: 'visible',
		top: ($('#'+windowsId).height() - popalert.height())/2 - 10,
		left: ($('#'+windowsId).width() - popalert.width())/2
	});
	setTimeout(function(){
		popalert.css('visibility', 'hidden');
		$('#'+windowsId+'_pop_alert_ifm').css('visibility', 'hidden');
		callback();
	}, 1600);
}

function space_pop_windows_pop_confirm(windowsId, msg, callback){
	var popalert = $('#'+windowsId+'_pop_confirm');
	var icon_src = 'http://hdfimg.com/space/doctor/global/icon_confirm.gif';
	if (popalert.get(0) == undefined) {
		var makeHtml = '<div tag="win_ext" class="haodf_windows small2" id="'+windowsId+'_pop_confirm"><div id="'+windowsId+'_pop_confirm_content" class="content"></div></div>';
		makeHtml += '<iframe border="0" tag="win_ext" frameborder="0" id="'+windowsId+'_pop_confirm_ifm" class="haodf_windows_ifm"></iframe>';
		$('#'+windowsId).append(makeHtml);
		popalert = $('#'+windowsId+'_pop_confirm');
	}
	var button_html = '<div style="margin-top:15px; padding-right:5px; text-align:right;"><button onclick="space_pop_windows_pop_confirm_close(\''+windowsId+'\');'+callback+';">确定</button>&nbsp;<button onclick="space_pop_windows_pop_confirm_close(\''+windowsId+'\');">取消</button></div>';
	$('#'+windowsId+'_pop_confirm_content').html('<div style="margin-left:5px; padding-left:28px; width:200px; height:24px; font-size:14px; line-height:28px; background:url('+icon_src+') left no-repeat; ">'+msg+'</div>' + button_html);
	popalert.css({
		visibility: 'visible',
		top: ($('#'+windowsId).height() - popalert.height())/2 - 10,
		left: ($('#'+windowsId).width() - popalert.width())/2
	});
	$('#'+windowsId+'_pop_confirm_ifm').css({
		width: popalert.width(),
		height: popalert.height(),
		visibility: 'visible',
		top: ($('#'+windowsId).height() - popalert.height())/2 - 10,
		left: ($('#'+windowsId).width() - popalert.width())/2
	});
}

function space_pop_windows_pop_confirm_close(windowsId){
	var popalert = $('#'+windowsId+'_pop_confirm');
	popalert.css('visibility', 'hidden');
	$('#'+windowsId+'_pop_confirm_ifm').css('visibility', 'hidden');
}


function space_pop_windows_reload(windowsId, tourl){
	$('#'+windowsId).find('*[tag=win_ext]').css('visibility', 'hidden');
	$.get(tourl + "&ref=" + (new Date()), function(data){
		$('#'+windowsId+'_content').html(data);
		var nowWidth = $('#'+windowsId).width();
		var nowHeight = $('#'+windowsId).height();
		var winWidth = $(window).width();
		var winHeight = $(window).height();
		$('#'+windowsId).css({
			left: (winWidth - nowWidth)/2,
			top: $(window).scrollTop() + (winHeight - nowHeight)/2
		});
	});
}


function moo_disable_btn(el, act){
	$(el).attr('disabled', act);
}

//////////////////////////////////////////////////////////////////////////////////

function space_edit_case_note(el){
	space_pop_windows(el, 'index_case_note', '/?oa=Admin_Case,AjaxNote&window_id=index_case_note', {title: '设置患者提问要求'});
}

function space_edit_case_disease(el){
	space_pop_windows(el, 'index_case_disease', '/?oa=Admin_Case,AjaxDisease&window_id=index_case_disease', {title: '设置咨询疾病范围'});
}

function space_edit_case_new_max_number(el){
	space_pop_windows(el, 'index_case_new_max_number', '/?oa=Admin_Case,AjaxNewMaxNumber&window_id=index_case_new_max_number', {title: '设置最多新问题数'});
}

function space_edit_case_setup(el){
	space_pop_windows(el, 'index_case_setup', '/?oa=Admin_Case,AjaxSetup&window_id=index_case_setup', {title: '设置咨询模块开关'});
}

function space_edit_reply_template(el){
	space_pop_windows(el, 'index_case_reply_template', '/cross_domain_agent.php?url='+DOCTOR_HOST+'%2F%3Foa%3DAdmin_ReplyTemplate%2CAjaxIndex%26window_id%3Dindex_case_reply_template', {title: '设置常用回复模板'});
}

function index_update_doctor_offline(el){
	space_pop_windows(el, 'index_update_doctor_offline', '/?oa=Admin_Doctor,Offline&is_ajax=1&window_id=index_update_doctor_offline', {title: '更新停诊公告'});
}

function index_upload_photo(el){
	space_pop_windows(el, 'index_announce_photo', '/?oa=Admin_Doctor,AjaxPhoto&window_id=index_announce_photo', {title: '上传头像'});
}
function index_update_announce(el){
	space_pop_windows(el, 'index_update_announce', '/?oa=Admin_Setup,AjaxAnnounce&window_id=index_update_announce', {title: '编辑欢迎词'});
}

function index_update_doctor_info(el){
	space_pop_windows(el, 'index_update_doctor_info', '/?oa=Admin_Doctor,Update&is_ajax=1&window_id=index_update_doctor_info', {title: '修改信息'});
}

function space_doctor_addSign(el,caseId){
	space_pop_windows(el, 'doctorAddSign', '/cross_domain_agent.php?url='+DOCTOR_HOST+'%2F%3Foa%3DAdmin_Doctor%2CAddSign%26is_ajax%3D1%26window_id%3DdoctorAddSign%26caseId%3D'+caseId, {title: '给患者加号(预约号)'});
}

function space_doctor_Update_addSign(el,signId){
	space_pop_windows(el, 'doctorUpdateAddSign', '/cross_domain_agent.php?url='+DOCTOR_HOST+'%2F%3Foa%3DAdmin_Doctor%2CUpdateAddSign%26is_ajax%3D1%26window_id%3DdoctorUpdateAddSign%26signId%3D'+signId, {title: '更新加号'});
}

function space_doctor_Stop_addSign(el){
	space_pop_windows(el, 'doctorStopAddSign', '/?oa=Admin_Doctor,StopAddSign&is_ajax=1&window_id=doctorStopAddSign', {title: '停诊通知'});
}

function index_show_schedule(el){
	space_pop_windows(el, 'pop_index_show_schedule', '/?oa=Index,AjaxSchedule&is_ajax=1&window_id=pop_index_show_schedule', {title: '门诊时间表'});
}

function API_space_show_schedule(el){
	index_show_schedule(el);
}

function space_patient_callof_addSign(el,signId,caseId){
	space_pop_windows(el, 'patientCallofAddSign', '/cross_domain_agent.php?url='+DOCTOR_HOST+'%2F%3Foa%3DCase%2CCallOffSign%26is_ajax%3D1%26window_id%3DpatientCallofAddSign%26signId%3D'+signId+'%26caseId%3D'+caseId, {title: '取消加号'});
}

function spaceEditorInit(pid){
	KE.show({
	    id : pid,
	    resizeMode : 1,
	    cssPath : 'http://hdfimg.com/space/editor/index.css',
	    skinType: 'tinymce',
	    items : ['undo', 'redo', 'textcolor', 'bold', 'italic', 'underline', 'removeformat'],
		htmlTags: {
	    	'font' : ['color', 'size', 'face', '.background-color'],
	        'span' : ['.color', '.background-color', '.font-size', '.font-family', '.font-weight', '.font-style', '.text-decoration', '.vertical-align'],
	        'a' : ['href', 'target','class'],
	        'hr' : ['/'],
	        'br' : ['/'],
	        'p' : ['align', '.text-align', '.color', '.background-color', '.font-size', '.font-family', '.font-weight', '.font-style', '.text-decoration', '.vertical-align'],
	        'strong': [],
	        'b': [],
	        'em': [],
	        'u': [],
	        'strike': []
	    },
	    filterMode: true
	});
}

//////////////// fix old popwindows //////////////////////////////////////////////////////////



