function doctorInfoCtrl(Dobj,xthis){
	var bTxt = $(xthis).text();
	if( bTxt == '+展开简介' ){
		$(Dobj).css({height:'auto'});
		$(xthis).text('-收起简介');
	}else{
		$(Dobj).css({height:'75px'});
		$(xthis).text('+展开简介');
	}

}

jQuery(function($){
	$("#nav_ctrl>li").hoverIntent({
		sensitivity: 2, //敏感度,最少要設定為1
		interval: 20,
		over: makeTall,
		timeout: 300,
		out: makeShort
	});
});
function makeTall(){
	var obj = $(this).children('ul');
	obj.animate( {height: 'toggle', opacity: 'toggle'}, {duration:300} );
}
function makeShort(){
	var obj = $(this).children('ul');
	obj.animate( {height: 'toggle', opacity: 'toggle'}, {duration:'slow'} );
}


//留言
function messageAdd(message){
	if(message=="")
	{
		alert("你忘记填写建议了吧？~呵呵");
	}
	else
	{
		$("#newSuggestion input").attr("disabled","disabled");
		$("#newSuggestion textarea").attr("disabled","disabled");
		$("#newSuggestion h2").html("正在提交建议数据...");
		$.ajax({
			type: "POST",
			url: "ajax/message_add.php",
			data: "message="+message+"",
			success: function(data){
				$("#newSuggestion h2").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 h2").html("发表建议失败，请重试！");
				$("#newSuggestion input").removeAttr("disabled");
				$("#newSuggestion textarea").removeAttr("disabled");
			}
		});
	}
}
//评论
function commentAdd(comment,id){
	if(comment=="")
	{
		alert("你忘记写评论内容了吧？~呵呵");
	}
	else
	{
		$("#newSuggestion input").attr("disabled","disabled");
		$("#newSuggestion textarea").attr("disabled","disabled");
		$("#newSuggestion h2").html("正在提交评论数据...");
		$.ajax({
			type: "POST",
			url: "ajax/comment_add.php",
			data: "message="+comment+"&id="+id,
			success: function(data){
				$("#newSuggestion h2").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 h2").html("评论失败，请重试！");
				$("#newSuggestion input").removeAttr("disabled");
				$("#newSuggestion textarea").removeAttr("disabled");
			}
		});
	}
}
//搜索验证
function checkSearch()
{
	//tmp_val = $("#sugSearch input[type=text]").val();
	tmp_val = $("#sugSearch 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 addBookmark(title,url) {
	if (window.sidebar){
		window.sidebar.addPanel(title, url,"");
	}else if(document.all){
		window.external.AddFavorite( url, title);
	}else if(window.opera && window.print){
		return true;
	}
}
function setHomepage(url)
{
    if (document.all)    {
        document.body.style.behavior='url(#default#homepage)';
        document.body.setHomePage(url);
    }else if (window.sidebar){
        if(window.netscape){
            try{
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }catch(e){
                alert("this action was aviod by your browser，if you want to enable，please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true");
            }
         }
         var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
         prefs.setCharPref('browser.startup.homepage',url);
     }
}


//滚动专家照片
function startScroll(speed,li_width,liCount_fix){
	//var speed=2 //速度数值越大速度越慢
	//var li_width=83 //滚动元素LI占用的像素宽度
	//var liCount_fix=7 //一行同时能容纳的LI数
	var scrollWarp1=document.getElementById("scrollWarp1");
	var scrollWarp2=document.getElementById("scrollWarp2");
	var scrollWarp=document.getElementById("scrollWarp");
	var liCount = $("#scrollWarp2 dl").length;
	var scrollWarp1_width = (liCount*li_width)*2;
	var scrollWarp2_width = liCount*li_width;
	var scrollWarp_width = parseFloat(scrollWarp.style.width);
	scrollWarp1.style.width=scrollWarp1_width+"px";
	scrollWarp2.style.width=scrollWarp2_width+"px";
	if(liCount>liCount_fix){
		scrollWarp1.innerHTML+=scrollWarp1.innerHTML;
		scrollWarp.scrollLeft=0;
		function Marquee(){
			if(scrollWarp.scrollLeft>=(scrollWarp1_width-scrollWarp_width)){
				scrollWarp.scrollLeft=(scrollWarp2_width-scrollWarp_width);
			}
			scrollWarp.scrollLeft++;
		}
		var MyMar=setInterval(Marquee,speed)
		scrollWarp1.onmouseover=function() {clearInterval(MyMar)}
		scrollWarp1.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
	}
}
