﻿//最新预约
function GetRegt()
{
    var str="";       
    $.ajax({   
        url: 'regt.xml',   
        dataType: 'xml',   
        type: 'GET',     
        error: function(xml){   
            $("#regt").html("暂时还没预约信息");
        },   
        success: function(xml){  
            str+="<ul>"; 
            $(xml).find("regt").each(function(i){
                            
                //获取时间   
                var czrq = $(this).children("czrq").text();   
                //获取用户名
                var yhm=$(this).children("yhm").text();
                //医生姓名
                var ysxm=$(this).children("ysxm").text();
                //医院编号
                var hosp=$(this).children("hosp").text();
                //医生编号
                var ysbm=$(this).children("ysbm").text();  
                str+="<li> <font style=\"font-size:12px;color:#999999;\">"+czrq+"</font> <font style=\"font-size:12px;color:#2AA8E0;\">"+yhm+"</font> 成功预约<a target=\"_blank\" style=\"color:#FF7200;text-decoration: underline;\" href=\"doctor/doctor.aspx?hosp="+hosp+"&ysbm="+ysbm+"\">"+ysxm+"</a>医生</li>";  
                //str+="<div class=\"regtinfo\"><img align=\"absmiddle\" src=\"images/icon_regt.jpg\"> <font style=\"font-size:12px;color:#999999;\">"+czrq+"</font> <font style=\"font-size:12px;color:#2AA8E0;\">"+yhm+"</font> 成功预约<a target=\"_blank\" style=\"color:#FF7200;text-decoration: underline;\" href=\"doctor/doctor.aspx?hosp="+hosp+"&ysbm="+ysbm+"\">"+ysxm+"</a>医生</div>";  
            })
            str+="</ul>";
            $("#regt").html(str);
            new Marquee("regt",0,1,368,150,20,2000,0,25); 
        }                     
    });
}

//右下角弹窗JS代码
//var j = jQuery.noConflict();
var showbox = function(boxid, tipheight) {
        if(!boxid) boxid='floatbox';
        if(!tipheight) tipheight=190;

        var objclientheigth =document.getElementById(boxid).clientHeight;
        $('#'+boxid).height(objclientheigth+2);
        if(objclientheigth < tipheight) { 
                setTimeout(function(){showbox(boxid, tipheight)}, 5);
        }
}

var closebox = function(boxid) {
        if(!boxid) boxid='floatbox';
        var objclientheigth = document.getElementById(boxid).clientHeight;
        /*
        j('#'+boxid).height(objclientheigth-2);
        if(objclientheigth>1 && objclientheigth<=202) {
                setTimeout(function(){closead11adbox(boxid)},5);        
        }*/
        $('#'+boxid).height(1);
        if(objclientheigth<=1) {
                $('#'+boxid).hide();
        }        
}

var zoomInBox = function(boxid) {
        if(!boxid) boxid='floatbox';
        var objclientheigth = document.getElementById(boxid).clientHeight;
        $('#'+boxid).height(28);
        $('#'+boxid+" dt").css("background-img","url(images/floatbox_bg.jpg)");
        //$('#'+boxid).css({"top":$(document).scrollTop()+$(window).height()-30});
        /*
        if(objclientheigth>=30 && objclientheigth<=202) {
                setTimeout(function(){zoomad11InBox(boxid)},5);        
        }*/
}

var zoomOutBox = function(boxid, tipheight) {
        if(!boxid) boxid='floatbox';
        if(!tipheight) tipheight=190;

        var objclientheigth = document.getElementById(boxid).clientHeight;
        $('#'+boxid).height(objclientheigth+2);
        if(objclientheigth < tipheight) {
                setTimeout(function(){zoomOutBox(boxid, tipheight)},5);        
        }        
}

$(function(){
//        var fkbz=$('#fkbz').val();
//        if(fkbz==1)
//        {
            if($.browser.msie) { //对于不同浏览弹出高度的区别IE为210,其他194
                    var tipheight = $('#floatbox').height();
            } else {
                    var tipheight =$('#floatbox').height();// 150;
            }

            $('#floatbox').show();
            showbox('floatbox', tipheight);        

            $('#box_close').click(function(){
                $('#floatbox').hide();
            });
            $('#box_zoom').click(function(){
                    if(document.getElementById('floatbox').clientHeight >= tipheight) { 
                            zoomInBox('floatbox');                          
                            $("#tosmall").css({"display":"none"});
                            $("#tofull").css({"display":"block"});
                            //$('#box_zoom').attr("title", "点击展开");                            
						    //$('#box_zoom img').attr("src", "images/kai.jpg");
                    } else {
                            zoomOutBox('floatbox', tipheight);                            
                            $("#tosmall").css({"display":"block"});
                            $("#tofull").css({"display":"none"});
                            //$('#box_zoom').attr("title", "点击收缩");  
						    //$('#box_zoom img').attr("src", "images/xiao.jpg");
                    }
            });
//        }      
});

//漂浮窗口
//var OffLeft,OffTop,BodyHeight,BodyWidth,setfloatdiv,direction;
//$(document).ready(function(){
//    direction=3;
//    OffLeft=$("#floatdiv").attr("offsetLeft");
//    OffTop=$("#floatdiv").attr("offsetTop");
//    BoxHeight=$("#floatdiv").height();
//    BoxWidth=$("#floatdiv").width();
//    BodyHeight=$(document).height();//parseInt(document.documentElement.clientHeight);
//    BodyWidth=$(window).width();//parseInt(document.documentElement.clientWidth);   
//    FloatDiv();
//    
//});

function FloatDiv()
{
    var stopflag=false;
    setInterval(function()
    {
        if(stopflag) return;  
        if(direction==1)
        {
            OffLeft--;
            OffTop--;
            if(OffTop>0&&OffLeft>0)
                $("#floatdiv").css({"top":OffTop,"left":OffLeft});
            else
            {
                if(OffTop<=0)
                    direction=2;
                if(OffLeft<=0)
                    direction=4;    
            }                     
        }
        else if(direction==2)
        {
            OffLeft--;
            OffTop++;
            if(OffLeft>0&&(OffTop+BoxHeight)<BodyHeight)
                $("#floatdiv").css({"top":OffTop,"left":OffLeft});
            else
            {
                if(OffLeft<=0)
                    direction=3;
                if(OffTop+BoxHeight>=BodyHeight)
                {

                    direction=1;    
                }
            }         
        }
        else if(direction==3)
        {
            OffLeft++;
            OffTop++;
            if((OffTop+BoxHeight)<BodyHeight&&(OffLeft+BoxWidth+2)<BodyWidth)
                $("#floatdiv").css({"top":OffTop,"left":OffLeft});
            else
            {
                if(OffTop+BoxHeight>=BodyHeight)
                    direction=4;
                if(OffLeft+BoxWidth+2>=BodyWidth)
                    direction=2;        
            }         
        }
        else if(direction==4)
        {
            OffLeft++;
            OffTop--;
            if((OffLeft+BoxWidth+2)<BodyWidth&&OffTop>0)
                $("#floatdiv").css({"top":OffTop,"left":OffLeft});
            else
            {
                if(OffLeft+BoxWidth+2>=BodyWidth)
                    direction=1;
                if(OffTop<=0)
                    direction=3;    
            }         
        }
         //window.setTimeout("Flow()",11);
    },10);
    $("#floatdiv").mouseover(function(){stopflag=true;});
    $("#floatdiv").mouseout(function(){stopflag=false;});     
}

