﻿function $(id){return (typeof(id) == "string") ? document.getElementById(id) : id;}
function zixun(param){
    if(param==null)
    {
        window.open("http://swt.ent120.com/LR/Chatpre.aspx?id=LPD31455319&p="+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")
    
    }
    else
    {
        window.open("http://swt.ent120.com/LR/Chatpre.aspx?id=LPD31455319&p="+document.location.href+"?"+param,"_blank","height=473,width=703,top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=no,scrollbars=no,location=no,titlebar=no")
    }
}
function qq()
{
    window.open('http://wpa.qq.com/msgrd?V=1&Uin=800030789&Exe=QQ&Site='+document.location.href+'&Menu=yes', '_blank', 'height=544, width=644,toolbar=no,scrollbars=no,menubar=no,status=no');
}
function tel()
{
    window.open("/tel/","_blank","height=267,width=300,top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=no,scrollbars=no,location=no,titlebar=no");
}

function Obj(id){ return document.getElementById(id);}
//隐藏窗口的方法 渐变
function heddenWindow(object){ 
    try{
        var filt=1;
        object.style.opacity=filt;
        object.style.MozOpacity=filt;
        object.style.filter="alpha(opacity="+(filt*100)+")";
        var mar=setInterval(function(){a()},1);
        function a()
        {
            try{
               filt=filt-0.1;
               object.style.opacity=filt;
               object.style.MozOpacity=filt;
               object.style.filter="alpha(opacity="+(filt*100)+")";
               if(filt<0){
                    object.style.opacity=0;
                    object.style.MozOpacity=0;
                    object.style.filter="alpha(opacity=0)";
                    document.body.removeChild(object);
                    clearInterval(mar);
               }
            }catch(e){}
        }
    }catch(e){}
}
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 changeBox(obj,w,h)
{
    obj.style.width="10px";
    obj.style.height="10px";//默认
    var mar=setInterval(function(){add_w()},1);
    function add_w()//加宽
    {
        obj.style.width=parseInt( obj.style.width.split('px')[0])+50+"px";
        if(parseInt(obj.style.width.split('px')[0])>=w)
        {
            clearInterval(mar);
            obj.style.width=w+"px";
        }
    }
    var mar2=setInterval(function(){add_h()},1);
    function add_h()//加高
    {
        obj.style.height=parseInt( obj.style.height.split('px')[0])+50+"px";
        if(parseInt(obj.style.height.split('px')[0])>=h)
        {
            clearInterval(mar2);
            obj.style.height=h+"px";
        }
    }
}

//商务通 修改左侧
function changeFloatLeft(){
  if($("LRfloater0").children[1]){
      if($("LRfloater0_if")){$("LRfloater0_if").style.display="none"; }
      $("LRfloater0").children[1].src="/images/leftent1.gif";
  }else{ setTimeout(function(){changeFloatLeft()},0);}
  
}


//增加底部 banner
function footBannerFloat()
{
    var pid="fot_banner_k";
    if($(pid)){
        document.write('<style type="text/css">#fot_banner_k{ width:980px; height:36px; margin:0 auto; *display:inline-block; position:relative/9;}#fot_banner{  width:980px; height:36px; background:url(/images/020footBanner.gif) no-repeat; z-index:999; margin:0 auto; position:fixed;_position:absolute;_top:expression(documentElement.scrollTop+documentElement.clientHeight-this.offsetHeight);  bottom:0; }#fot_banner h4{ float:left; width:190px; height:36px; text-indent:-9999px; }#fot_banner strong{ float:left; width:271px; height:36px; text-indent:-9999px;}#fot_banner button{ float:left; width:154px; height:25px; margin:7px 0 0 9px; display:inline; background:0; text-indent:-9999px; cursor:pointer;}</style>');
        
        var div2=document.createElement("div");
        div2.id="fot_banner";
        div2.innerHTML='<h4>服务通道</h4><strong>QQ:8000 30789</strong><button onclick="tel()">免费电话咨询</button><button onclick="zixun()">免费咨询专家</button><button onclick="zixun()">在线预约挂号</button>';
        for(var i=0;i<div2.getElementsByTagName("button").length;i++)
        {
            button_texiao(div2.getElementsByTagName("button")[i],0);
        }
        $(pid).appendChild(div2);
    }
}


 //商务通 修改中间邀请框
function changeFloatCenter()
{
    if($("LRfloater1") && $("LR_Tb2"))
    {
        if($("LR_Tb2")) $("LR_Tb2").style.display="none";
        
        //暑期青少年
        var htmlText = '<div style="background:url(/images/guangzhou020.gif); width:509px; height:337px; overflow:hidden;position:relative;">';
        htmlText += '       <span onclick="LR_HideInvite();LR_RefuseChat();return" style="float: left; margin-left:489px; margin-top:5px; cursor:pointer;">';
        htmlText += '           <img src="http://www.ent020.com/images/tmbj.gif"  style="width:13px; height:13px;"/>';
        htmlText += '       </span>';
        htmlText += '       <span style="width:98px;height:28px;position:absolute;right:50px;bottom:16px;cursor:pointer;" onclick="zixun()"></span>';
        htmlText += '       <ul style="font-size:12px;  width:657px; height:44px; left:30px; margin:0 0 0 0; padding:0;position:absolute;top:234px;">';
        htmlText += '           <li style="list-style:none; float:left; width:238px; height:17px; line-height:17px;"><span style="font-size:13px; color:#FF0000; font-weight:bold;">·搜狐：</span><a href="http://roll.sohu.com/20111018/n322580473.shtml"  target="_blank">保护耳朵，拯救健康”大型公益科普活动在广州盛大开启…</a></li>';
        htmlText += '           <li style="list-style:none; float:left; width:238px; height:17px;line-height:17px;"><span style="font-size:13px; color:#FF0000; font-weight:bold;">·sina：</span><a href="http://news.gd.sina.com.cn/news/20111018/1187913.html" target="_blank">广州地区重度耳聋高发…</a></li>';
        htmlText += '           <li style="list-style:none; float:left; width:238px; height:17px;line-height:17px; margin-top:10px;"><span style="font-size:13px; color:#FF0000; font-weight:bold;">·中国网：</span><a href="http://news.china.com.cn/rollnews/2011-10/21/content_10749767.htm" target="_blank">无论现代医学如何变幻 耳鼻喉诊疗始终与国际看起…</a></li>';
        htmlText += '           <li style="list-style:none; float:left; width:238px; height:17px;line-height:17px;margin-top:10px;"><span style="font-size:13px; color:#FF0000; font-weight:bold;">·网易：</span><a href="http://news.163.com/11/1021/17/7GTFPADQ0001125P.html" target="_blank">不要带着咽炎过完这个秋冬…</a></li>';
        htmlText += '       </ul>';
        htmlText += '   </div>';
        $("LRfloater1").innerHTML= htmlText;        
        
    }else{ setTimeout(function(){changeFloatCenter()},0);}
    
    function changie6_cntfloat()
    {
        $("LRfloater1").style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-$("LRfloater1").offsetHeight-36)+"px";
    }
}


//商务通 修改左侧 增加QQ咨询按钮  顺便移动到右侧
function folatLeft_qq()
{
if($("LRfloater0")){
  
    $("LRfloater0").children[1].src="/images/leftent1.gif";
    $("LRfloater0_if").style.display="none"; 
    
    //移动到右边
    $("LRfloater0").style.left="";
    $("LRfloater0").style.marginLeft="";
    $("LRfloater0").style.marginTop="";
    $("LRfloater0").style.right="0px";
    
  }else { setTimeout(function(){folatLeft_qq()},10)}
}




//标题、展示内容、宽、高
function openWindow(title,txt,w,h)
{
    //创建对象命名ID
    try{
        var window_frame=document.createElement("div");
        window_frame.id="window_frame";
        window_frame.style.height=document.body.clientHeight+"px";
        var window_main=document.createElement("div");
        window_main.id="window_main";
        var window_content=document.createElement("div");
        window_content.id="window_content";
        var content=document.createElement("div");
        content.id="content";
        content.innerHTML='<strong id="window_title">'+title+'</strong><span id="window_close">关闭</span><div style="float:left; width:100%; height:100%; padding:5px; line-height:25px;">'+txt+'</div>';
        //添加到body
        window_content.appendChild(content);
        window_main.appendChild(window_content);
        document.body.appendChild(window_frame);
        document.body.appendChild(window_main);
       Obj("window_close").onclick=function(){heddenWindow($("window_frame"));heddenWindow($("window_main"));}
       // setTimeout(function(){ heddenWindow($("window_frame"));heddenWindow($("window_main"));},1500);
        changeBox(window_content,w,h);
    }
    catch(e){}
}

//文章评论
function pl(id,fweb,type)
{
    var pid="pl_fot";
    if($(pid))
    {
            if($(pid).getElementsByTagName("textarea")[0].value==""){
                alert("提问内容不能为空。");
                $(pid).getElementsByTagName("textarea")[0].focus();
            }else{
                var ajax=newXMLHttpRequest();
                var pinglun=$(pid).getElementsByTagName("textarea")[0].value;
                pinglun=pinglun.replace(/ /g,"|nbsp|");
                pinglun=pinglun.replace(/\n/g,"|br|");
                var urlpost=id+"&fweb="+fweb+"&pinglun="+escape(pinglun);
                var url="/inc/ajax.ashx?id="+urlpost;
                var waiting="处理中...";
                ajax.open("get",url,true);
                //alert(url);
            //定义传输的文件HTTP头信息
            ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            ajax.send(urlpost);
                ajax.onreadystatechange=function()
                {
                
                    if(ajax.readyState==4 && ajax.status==200)
                    {
                    
                        if(ajax.responseText.substring(0,2)=="ok")
                        {
                            switch(type)
                            { 
                                case "1": openWindow("广州军区机关医院",waiting,300,80); break;
                                case "2":alert("感谢支持");break;
                            }
                            var mar=setInterval(function(){a()},1000);
                            var k=0;
                            function a(){ 
                                try{
                                    $("content").children[2].innerHTML+=".";
                                    k++;
                                    if(k>3){
                                        clearInterval(mar); k=0;
                                        $("content").children[2].innerHTML="您提问已经提交审核。";                                    
                                        setTimeout(function(){ heddenWindow($("window_frame"));heddenWindow($("window_main"));},3000);
                                        
                                    }
                                }catch(e){}
                            }
                          
                        }else{
                           switch(type)
                           {
                             case "1": openWindow("广州军区机关医院","您已经提交过问题，请稍后再试。",300,80);break;
                             case "2":alert("感谢支持");break; 
                           }
                        }
                    }
                }
            }
    }
}
function addHit(hitId,obj)
{ 
    if(document.cookie.indexOf("hitId"+hitId+"=") != -1)
    {
        alert("您已经支持过了."); 
    }
    else
    {
        var ajax=newXMLHttpRequest();
        var urlpost="plId="+hitId;
        var url="/DocInfo.aspx?"+urlpost;
        ajax.open("get",url,true);
        //定义传输的文件HTTP头信息
        ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8'");
        ajax.send(urlpost);
        ajax.onreadystatechange=function()
        {
            if(ajax.readyState==4 && ajax.status==200)
            {
                if(ajax.responseText.substring(0,2)=="NO")
                {
                    alert("您已经支持过了.");
                   
                }else{ 
                    alert("谢谢支持.");
                    obj.innerHTML="<span class='span_2'>支持["+parseInt(parseInt( obj.innerHTML.split('[')[1].split(']')[0])+1)+"]</span>";
                }
            }
        }
    }
}


function plunjump(url,pagecount)
{
    var pid="jump_nub";
    if($(pid))
    {
        var page=$(pid).value;
        if(page=="" || isNaN(page))
        {
           alert("请输入正确的页数！");
           $(pid).focus();
        }
        else if(parseInt(page)<1)
        {
            page=1;
        }
        else if(parseInt(page)>parseInt(pagecount))
        {
            page=pagecount;
        }
        else  window.location.href=url+page+".html#newinfo_plun";
    }
}

/*---------------------ajax----------------------*/
function fashx(str,act){
//alert(str);
 var req=newXMLHttpRequest();
 var callbackHandler=getReadyStateHandler(req,act);
 req.onreadystatechange=callbackHandler;
 req.open("get","/inc/ajax.ashx?"+str,true);
 req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
 req.send(str);
}


function getReadyStateHandler(req,act) {
 return function() {
  if(req.readyState==4) {//已经加载
    if(req.status==200) {//返回成功
        switch(act){
            case "wenda":{ returnComTan(req.responseText);break;}
        }
    }
  }
 }
}
function returnComTan(str){
    //alert(str);
    var info = str.split('|');
    if(info[0]=='no'){alert(info[1]);}
    if(info[0]=='ok'){alert(info[1]);}
}
/*---------------添加问答（此方法需要ajaxJS支持）---------------*/
function wenda()
{
//debugger;
    if(!$("txtTitle").value) {alert("请输入您的疑问");$("txtTitle").focus();return false;}
    if(!$("txtAge").value) {alert("请输入您的年龄");$("txtAge").focus();return false;}
    if(isNaN($("txtAge").value)||parseInt($("txtAge").value)<1||parseInt($("txtAge").value)>110){alert("请输入您的正确年龄");$("txtAge").focus();return false;}
    if(!$("txtContent").value) {alert("请对您的疑问进行描述");$("txtContent").focus();return false;}
    //alert($("txtContent").value);
    fashx("act=wenda&txtTitle="+escape($("txtTitle").value)+"&txtSex="+escape($("txtSex").value)+"&txtAge="+escape($("txtAge").value)+"&txtContent="+escape($("txtContent").value),"wenda");
}


function jryy(id){
  if(!id){id="jryy";}
  var dt=new Date();
  var num=dt.getHours();
  var min=dt.getMinutes();
  num=parseInt(num*15+min/4); 
  if($(id)) $(id).innerHTML=num;
}

function yynum(id){
  if(!id){id="jryy1";}
  var dt=new Date();
  var num=dt.getHours();
  var min=dt.getMinutes();
  num=parseInt(num*10+min/4); 
  if($(id)) $(id).innerHTML=num;
}


function showInviForm()
{
    Extend.addEvent(window, "onload", function(){
        setTimeout(function(){
            $("inviFormOuter").style.display = "block";
            var obj = $("newsForm");
            var left = Extend.getCurrentStyle(obj, "left");
            var top = Extend.getCurrentStyle(obj, "top");
            var height = obj.clientHeight;
            obj.style.top = height + "px";
            obj.style.display = "block";
            Extend.transform(obj, {top:0, defaultAlpha:0, opacity:1, noZIdx:true, duration:1});
            if($("LRfloater0")){$("LRfloater0").style.marginTop = "-40px";}
        }, 3000);
    });
    $("newsFormClose").onclick = function(){
        Extend.transform("newsForm", {defaultAlpha:1, opacity:0, top:173, noZIdx:true, hideEle:true});
        if($("LRfloater0")){$("LRfloater0").style.marginTop = "0px";}
    }
}
