﻿function $(id) {
  return (typeof(id) == "string") ? document.getElementById(id) : id
};
//列表添加事件隐藏与显示
var opnumb=0;
function Open(id){
    for(var j=1;j<=opnumb;j++){
        if(j==id) $("tr"+j).style.display="inline";
        else $("tr"+j).style.display="none";
    }
}

//判断列表跳转的页数
function jmps(adres,pagecount)
{
    var page=$("zhuan").value;  
    if(page<1 | page>pagecount){ alert("页数不在范围之内.");}
    else if(isNaN(page)){ $("zhuan").value=""; alert("请输入正确的页码,只能为数字.");}
    else{window.location.href=adres+$("zhuan").value+'/';}
}

function searchlistbypage(key,pagecount){
    var page=$("txtlistp").value;
    if(page<1 | page>pagecount){ alert("页数不在范围之内.");}
    else if(isNaN(page)){ $("txtlistp").value=""; alert("请输入正确的页码,只能为数字.");}
    else{window.location.href="?key="+escape(key)+"&page="+$("txtlistp").value;}
}
//给搜索框添加效果
function search(){
        $("SearchTXT").value="";
    $("SearchTXT").style.color="black";
}
//验证search
function checkSearch(){
    if($("SearchTXT").style.color=="#BDBDBD" | $("SearchTXT").value=="")
    {
        return false;
    }else{return true;}
}

//============================================================================================================================//
//搜索跳转
function search(text,button,defaultText,isKey,prefix,suffix)
{
	if(! text){text="txtKey";}
	if(! button){button="btnSearch";}
	if($(text) && $(button))
    {
		if(! defaultText){defaultText="请输入您所需了解的内容...";}
		if(! prefix){prefix="/search/";}
		if(suffix==undefined){suffix=".html";}
			
		var objText=$(text);
		var objButton=$(button);

		placeHolder(text,defaultText);  //设置文本框默认文本！
		objButton.onclick=function(){gotoSearch();}//点击按钮将进行跳转！
		objText.onkeypress=function(e){//输入文本框按回车键将进行跳转！
			e=(e)?e:event;
			if(e.keyCode==13){gotoSearch();return false;}
		}
	}

	function gotoSearch()
	{
        objText.value=objText.value.replace(/^\s*/,""); 
	    objText.value=objText.value.replace(/\s*$/,""); //去掉关键字输入框中的前尾空格！
    	
    	if((!isKey && objText.value==defaultText)|| objText.value=="") {
    	    alert("请输入您所需查询的内容...");
    	    objText.focus();
		}else{
    	    try{//IE6、Firefox等浏览器
                location.href=prefix+escape(objText.value)+suffix;
    	    }catch(e){//IE7、8浏览器
    	        location.href=prefix+encodeURI(objText.value)+suffix;
            }
        }
    }
}

//============================================================================================================================//
//设置输入框的占位文本
function placeHolder(id,holderText,holderColor)
{
	if($(id))    //如果存在目标对象
	{
		var txtBox=$(id);
		txtBox.oldColor=txtBox.style.color;
		if(holderColor){
			txtBox.holderColor=holderColor;
		}else{
			txtBox.holderColor="#AEAEAE";
		}
		txtBox.holderText=holderText;	

		txtBox.style.color=txtBox.holderColor;
		txtBox.value=txtBox.holderText;	

		txtBox.onfocus=function(){	
			if(this.value==this.holderText)
			{
				this.value="";
				this.style.color=this.oldColor;
			}
		}
		txtBox.onblur=function(){
			this.value=this.value.replace(/^\s*/,""); 
			this.value=this.value.replace(/\s*$/,"");  
			if(this.value=="")
			{
				this.value=this.holderText;
				this.style.color=this.holderColor;
			}
		}
	}
}

//设为首页
function SetHome(obj,vrl){
    try{obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);}
    catch(e){
       if(window.netscape){
       try{netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");}
       catch(e){alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");}
       var prefs=Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);prefs.setCharPref('browser.startup.homepage',vrl);}
    }
}

//加为收藏
function AddToFavorite(){
    if(document.all) window.external.addFavorite(document.URL,document.title);
    else if(window.sidebar) window.sidebar.addPanel(document.title,document.URL,"");
}

function zixun()
{
    window.open("http://chat.53kf.com/company.php?arg=sio001&style=2&refer="+document.location.href+"&keyword="+document.location.href,"_blank","height=473,width=703,top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=no,scrollbars=no,location=no,titlebar=no"); 
}

function tel()
{
    window.open("/telp.htm","_blank","height=267,width=300,top=100,left=200,status=yes,toolbar=no,menubar=no,resizable=no,scrollbars=no,location=no,titlebar=no");
}

function phone(){
    window.open("/message.aspx","_blank","height=320,width=300,top=100,left=200,status=yes,toolbar=no,menubar=no,resizable=no,scrollbars=no,location=no,titlebar=no");
}

function keysearch()
{
    if($("key").value=="请输入您想要查询的疾病"){alert("请输入搜索关键词");return;}
    if($("key").value)
    {
        location.href="/searchNews.aspx?key="+escape($("key").value);
    }else{alert("请输入搜索关键词");return;}
}
function keysearch2()
{
    if($("key2").value=="请输入您想要查询的疾病"){alert("请输入搜索关键词");return;}
    if($("key2").value)
    {
        location.href="/searchNews.aspx?key="+escape($("key2").value);
    }else{alert("请输入搜索关键词");return;}
}

function opensearch(seVal){
    if(seVal!="")window.open("/searchNews.aspx?key="+escape(seVal));
}

//需要途中加载的方法
function test(OpNumb){
//---这里是列表添加事件
var j=0;
opnumb=OpNumb;
    for(var i=0; i<OpNumb;i++){
        $("tbody").children[j].children[0].onmousemove=function(){Open(this.id.substring(2));}
        j=j+2;
    }

}

var callphone=0;
function sendyy()
{ 
    if(callphone!=0){alert("请不要重复发送");return;}
  	var txtName=$("txtName").value;
  	if (txtName=="")
	{
	    alert("请输入您的姓名！");
		$("txtName").style.border="1px #FF6600 solid";
		$("txtName").focus();
		return;
	}
	var txtPhone=$("txtPhone").value;
	if (txtPhone=="")
	{
	   alert("请输入您的联系方式！");
		$("txtPhone").style.border="1px #FF6600 solid";
		$("txtPhone").focus();
		return;
	}
	var txtTime=$("txtTime").value;
	if (txtTime=="")
	{
	   alert("请输入您想要预约的时间！");
		$("txtTime").style.border="1px #FF6600 solid";
		$("txtTime").focus();
		return;
	}
	var sex='男';
	for(var i=0;i<$$("sex").length;i++){
	    if($$("sex")[i].checked) sex=$$("sex")[i].value;
	}
	fashx("act=sendyy&txtName="+txtName+"&txtTime="+escape(txtTime)+"&txtPhone="+txtPhone+"&txtAdd="+$("txtAdd").value+"&txtBz="+$("txtBz").value+"&txtSex="+sex,"sendyy");
	
	callphone=1;
	setTimeout(function(){iform()},6000);
}

function sendPhone(){
    if(callphone!=0){alert("请不要重复申请");return;}

	if($("phone").value=="手机号码") $("phone").value="";
	if($("usename").value=="用户名称") $("usename").value="";
    var phone = $("phone").value;
	var usename = $("usename").value;
	var yytime=$("yytime").value;
    if (phone=="")
    {
        alert("请输入您的手机号！");
        $("phone").style.border="1px #FF6600 solid";
        $("phone").focus();
        return;
    }else{
        if(isNaN(phone)){
            alert("手机号由数字组成，请输入数字！");
            $("phone").style.border="1px #FF6600 solid";
            $("phone").value="";
            $("phone").focus();
            return;
        }
    }
	if (usename=="")
	{
     	alert("请输入您的用户名！");
		$("usename").style.border="1px #FF6600 solid";
		$("usename").focus();
		return;
	}
	if (yytime=="")
	{
	    alert("请输入您想要预约的时间！");
		$("yytime").style.border="1px #FF6600 solid";
		$("yytime").focus();
		return;
	}	
	fashx("act=sendPhone&phone="+phone+"&usename="+escape(usename)+"&yytime="+escape(yytime),"sendPhone");
	callphone=1;
	setTimeout(function(){iform()},6000);
}

function isDateTime(time){
    try{
        var isTime = new Date(time)
        alert(isTime.getDay());
    }catch(e){
        return false;
    }
    return true;
}

function iform()
{
    if(callphone==0) return;
    callphone=0;
}
function fashx(str,act){
 var req=newXMLHttpRequest();
 var callbackHandler=getReadyStateHandler(req,act);
 req.onreadystatechange=callbackHandler;
 req.open("post","/pagebase/yuyue.ashx",true);
 req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
 req.send(str);
}

function newXMLHttpRequest() {
 var xmlreq=false;
 if(window.XMLHttpRequest) {
  xmlreq=new XMLHttpRequest();
 } else if(window.ActiveXObject) {

  try {
   xmlreq=new ActiveXObject("Msxml2.XMLHTTP");
  } catch(e1) {

   try {
    xmlreq=new ActiveXObject("Microsoft.XMLHTTP");
   } catch(e2) {

   }
  }
 }

 return xmlreq;
}

function getReadyStateHandler(req,act) {
 return function() {
  if(req.readyState==4) {//已经加载
       
   if(req.status==200) {//返回成功
     switch(act){
        case "sendyy":{ returnComTan(req.responseText);break;}
        case "sendPhone":{ returnComTan(req.responseText);break;}
      }
   }
   else
   {
      alert("req.status:"+ req.status);
   }
  }
  else {
    
  }
 }
}
function returnComTan(str){
    var info = str.split('|');
    if(info[0]=='no'){alert(info[1]);}
    if(info[0]=='ok'){
        alert(info[1]);
        if(info[1].indexOf("短信")>=-1) window.close();
    }
}



//电话块
function _getId(a)
{
  return document.getElementById ? document.getElementById(a) : null;
}

var callzt=0;
function to_call()
{
  if(callzt!=0){alert("请不要重复呼叫");return;}
 // var qhao=_getId("uid1").value.Trim();
  var qhao=_getId("uid1").value;
	if(qhao=="")
	{
	  show_msg("请输入区号");
		_getId("uid1").style.border="1px #FF6600 solid";
		_getId("uid1").focus();
		return;
	}
	if(isNaN(qhao))
	{
	  show_msg("你输入的区号有误");
		_getId("uid1").style.border="1px #FF6600 solid";
		_getId("uid1").focus();
		return;
	}
	var dataType=_getId("uid1").title;
	if(dataType=="quhao")
	{
	  if (qhao.length!=4 && qhao.length!=3)
	  {
		  show_msg("你输入的区号有误");
			_getId("uid1").style.border="1px #FF6600 solid";
			_getId("uid1").focus();
			return;
	  }
	}
	_getId("uid1").style.border="1px #c9c7ba solid";
	//var haoma=_getId("uid2").value.Trim();
	var haoma=_getId("uid2").value;
	if (haoma=="")
	{
	  show_msg("请输入号码");
		_getId("uid2").style.border="1px #FF6600 solid";
		_getId("uid2").focus();
		return;
	}
	if (isNaN(haoma))
	{
	  show_msg("你输入的号码有误");
		_getId("uid2").style.border="1px #FF6600 solid";
		_getId("uid2").focus();
		return;
	}
	if (dataType=="quhao")
	{
	  if (haoma.length!=7 && haoma.length!=8)
	  {
		  show_msg("你输入的号码有误");
			_getId("uid2").style.border="1px #FF6600 solid";
			_getId("uid2").focus();
			return;
	  }
	}else
	{
	  if (haoma.length!=11)
	  {
		  show_msg("你输入的号码有误");
			_getId("uid2").style.border="1px #FF6600 solid";
			_getId("uid2").focus();
			return;
	  }
		if(/^13\d{9}$/g.test(haoma)||(/^15\d{9}$/g.test(haoma)) ||(/^18\d{9}$/g.test(haoma)))
		{
		}
		else
		{ 
			show_msg("你输入的号码有误");
			_getId("uid2").style.border="1px #FF6600 solid";
			_getId("uid2").focus();
			return;
		}
	}
	var caller=qhao+haoma;
	_getId("uid2").style.border="1px #c9c7ba solid";
	$("calltak").src="http://tel.kuaishang.cn/calld.php?sid="+sid+"&did="+did+"&tel="+caller+"&call_fromurl="+document.location.href;
	callzt=1; 
	setTimeout(function(){iform()},6000);
	//xajax_to_call(wiseid,ipaddr,caller);
}

function iform()
{
    if(callzt==0) return;
    callzt=0;
}

function show_msg(txt)
{
    alert(txt);
}

function click_munbertype1()
{
	//去除之前的错误信息
	_getId("uid1").style.border = "1px solid #C9C7BA";
	_getId("uid2").style.border = "1px solid #C9C7BA";
	_getId("uid1").style.color = 'gray';
	_getId("uid2").style.color = 'gray';
	_getId("uid1").value = "区号";
	_getId("uid2").value = "电话号码";
	_getId("uid1").disabled = false;
	_getId("uid1").title = "quhao";
	_getId("uid2").title = "ZuoJi";
}

function click_munbertype2()
{
	//去除之前的错误信息
	_getId("uid1").style.border = "1px solid #C9C7BA";
	_getId("uid2").style.border = "1px solid #C9C7BA";
	_getId("uid1").style.color = 'gray';
	_getId("uid2").style.color = 'gray';
	_getId("uid1").value = "0";
	_getId("uid2").value = "手机号码";
	_getId("uid1").disabled = true;
	_getId("uid1").title = "";
	_getId("uid2").title = "Mobile";
}

function DialInput1(obj) //拨号盘输入框onfocus响应事件
{
	obj.style.color = '';
	if (/区号/.test(obj.value))
	{
		obj.value=obj.value.replace('区号','');
	}
}


function DialInputBlur1(obj) //拨号盘输入框onfocus响应事件
{
	if (obj.value == '')
	{
		obj.style.color = 'gray';
		obj.value='区号';
	}
}

function DialInput2(obj) //拨号盘输入框onfocus响应事件
{
	obj.style.color = '';
	if (/电话号码/.test(obj.value))
	{
		obj.value=obj.value.replace('电话号码','');
	}
	if (/手机号码/.test(obj.value))
	{
		obj.value=obj.value.replace('手机号码','');
	}
	if (/请输入您的手机号码/.test(obj.value))
	{
		obj.value=obj.value.replace('请输入您的手机号码','');
	}
}

function DialInputBlur2(obj) //拨号盘输入框onfocus响应事件
{
	if (obj.value == '')
	{
		if (_getId("munbertype1").checked)
		{
			obj.style.color = 'gray';
			obj.value='电话号码';
		}
		else
		{
			obj.style.color = 'gray';
			obj.value='手机号码';
		}
	}
}




function changeFloatCenter()
{
  
    if($("kfivtwin") && $("acc_title"))
    {
          $("acc_title").style.display="none";
         
        var mydiv = document.createElement("DIV");
        mydiv.id="yqkDiv";
        mydiv.innerHTML="<span onclick=\"onliner_zdfq=3;hidden_ivt();\" class=\"span1\"><img src=\"http://www.ent020.com/images/tmbj.gif\"  style=\"width:13px; height:13px;\"/></span><span class=\"span3\"  onclick=\"zixun()\"></span><ul class=\"yqkDiv_pd\" ><li><span>·中国网：</span><a href=\"http://news.china.com.cn/rollnews/2011-10/18/content_10681086.htm\">解放军264医院加强自身建设，力抗耳鼻喉疾病</a></li><li ><span >·sina：</span><a href=\"http://news.gd.sina.com.cn/news/20111018/1187914.html\">“超微三联立体疗法”被列为咽炎重点推荐技术</a></li><li ><span >·搜狐网：</span><a href=\"http://roll.sohu.com/20110524/n308410936.shtml\">小儿腺样体肥大导致小儿听力下降</a></li><li ><span >·网易：</span><a href=\"http://news.163.com/11/1019/18/7GOEJ1190001125P.html\">耳鼻喉科学术交流会9日在太原召开</a></li></ul>";
        $("kfivtwin").appendChild(mydiv);

       
    }else{ setTimeout(function(){changeFloatCenter()},10);}
}


function closeY(obj){
    if(obj=="1"){ if($("kfivtwin")) $("kfivtwin").style.display="none";
       if($("iconDiv1")) $("iconDiv1").style.display="block";
    }
    else{if($("iconDiv1")) $("iconDiv1").style.display="none";
    if($("kfivtwin")) $("kfivtwin").style.display="block";
    }
}
changeFloatCenter();



