//复制URL地址
function setCopy(_sTxt){
	if(navigator.userAgent.toLowerCase().indexOf('ie') > -1) {
		clipboardData.setData('Text',_sTxt);
		alert ("医院网址“"+_sTxt+"”\n已经复制到您的剪贴板中\n您可以使用Ctrl+V快捷键粘贴到需要的地方");
	} else {
		prompt("请复制医院网址:",_sTxt);
	}
}
//加入收藏
function addBookmark(site, url){
	if(navigator.userAgent.toLowerCase().indexOf('ie') > -1) {
		window.external.addFavorite(url,site)
	} else if (navigator.userAgent.toLowerCase().indexOf('opera') > -1) {
		alert ("请使用Ctrl+T将本页加入收藏夹");
	} else {
		alert ("请使用Ctrl+D将本页加入收藏夹");
	}
}

//更改分类显示状态
function messageAdd(message){
	if(message=="")
	{
		alert("你忘记写留言内容了吧？~呵呵");
	}
	else
	{
		$("#newSuggestion input").attr("disabled","disabled");
		$("#newSuggestion textarea").attr("disabled","disabled");
		$("#newSuggestion h4").html("正在提交留言数据...");
		$.ajax({
			type: "POST",
			url: "ajax/message_add.php",
			data: "message="+message+"",
			success: function(data){
				$("#newSuggestion h4").fadeIn(1000).html("留言成功！你可以再写一条留言~");
				$("#newSuggestion input").removeAttr("disabled");
				$("#newSuggestion textarea").removeAttr("disabled").val("");
				tmp_html = $("#suggestionList ol").html();
				$("#suggestionList ol").html(data).append(tmp_html);
			},
			error: function(){
				$("#newSuggestion h4").html("留言失败，请重试！");
				$("#newSuggestion input").removeAttr("disabled");
				$("#newSuggestion textarea").removeAttr("disabled");
			}
		});
	}
}
//搜索验证
function checkSearch()
{
	tmp_val = $("#globalSearch input[@type=text]").val();
	if(tmp_val == "" || tmp_val == "请输入搜索关键字")
	{
		alert("请输入搜索关键字");
		return false;
	}
}


//交通位置图 最大宽度设定
function set_image_width(fix_width)
{
	var image=new Image();
	image.src=$(".traffic_image img").attr("src");
	if( image.width > fix_width )
	{
		$(".traffic_image").html("<a href=\""+image.src+"\" target=\"_blank\"><img width=\""+fix_width+"\" src=\""+image.src+"\" title=\"点击查看完整交通位置图\" alt=\"点击查看完整交通位置图\" \/><\/a>");	
	}
}
$(function(){
	//点击搜索框，清空之
	$("#globalSearch input[@type=text]").click(function(){
		if($(this).val() == "请输入搜索关键字") $(this).val('');
	})
	
	//搜索ACTION跳转
	$("#globalSearch input[@type=radio]").click(function(){
		var current_radio_val = $("#globalSearch input[@type=radio][@checked]").val();
		var search_action = '';
		switch (current_radio_val){
			case 'doc':
				search_action = '/doctors.php';
				break;
			case 'news':
				search_action = '/news_search.php';
				break;
			case 'ask':
				search_action = '/ask.php';
				break;
			default:
				search_action = '/doctors.php'
		}
		$("#globalSearch").attr('action',search_action);
	})
})