var clicked_ud = false; // 用户下拉快捷
function switchRD(id, max){
    for(var i = 1; i <= max; i++){
        var rdli = ge("rdli" + i);
        rdli.className = "fleft mside2 ps6";
        
        var rdul = ge("rdul" + i);
        rdul.className = "ulist lh24 blue none";
    }
    var li = ge("rdli" + id);
    li.className = "fleft mside2 ps6 bg_green";
    
    var ul = ge("rdul" + id);
    ul.className = "ulist lh24 blue block";
}

/****************************登录 开始*****************************/
function login_f(url,uc_path)
{   
    $.post('/uc_app/index.php',{
        act:'login',
        uid:document.getElementById("uid").value,
        pwd:document.getElementById("pwd").value,
        url:url,
        uc_path:uc_path
    },login_complete);
//ThinkAjax.send("/uc_app/index.php",'act=login&uid=' + document.getElementById("uid").value + "&pwd=" + document.getElementById("pwd").value + "&url=" + url,login_complete,'');
}

function login_complete(str)
{
    ret=eval('(' + str + ')');
    data = ret.data;
	 
    if(ret.status==true)
    {
        document.getElementById("d_login").style.display = 'none';
        document.getElementById("userInfo").innerHTML = data;
        $(ret.reserve1).appendTo('body');
       
        $("#userpanel").bind("click",{
            id:"up_cnt"
        }, simple_tip_handler);
    }
    else
    {
        document.getElementById("d_warnning").innerHTML = data;
    }
}

function logout_f(url,uc_path)
{
    $.post('/uc_app/index.php',{
        act:'logout',
        url:url,
        uc_path:uc_path
    },logout_complete);
}

function logout_complete(str)
{
    ret=eval('(' + str + ')');
    data = ret.data;
    if(ret.status==true)
    {
        $("#userInfo").html(data);
    }
}

function close_login(){
    document.getElementById('d_login').style.display='none';
}

function chk_login() {
    $.post("/uc_app/index.php", {
        act:'chklogin'
    }, chk_login_comp);
}
function chk_login_comp(str)
{
    ret=eval('(' + str + ')');
    data = ret.data;
    if(ret.status==true)
    {
        $(ret.reserve1).appendTo('body');
        document.getElementById("userInfo").innerHTML = data;
        $("#userpanel").bind("click",{
            id:"up_cnt"
        }, simple_tip_handler);
    }
}

function show_login()
{
    document.getElementById("d_warnning").innerHTML = "";
   

    var bi = new BrowserInfo();
    document.getElementById("d_login").style.top = (bi.screenHeight /2 - 150) + "px";
    document.getElementById("d_login").style.left = (bi.screenWidth /2 - 150) + "px";
    document.getElementById("d_login").style.display="block";
    document.getElementById("uid").focus();
}

function BrowserInfo()
{
    this.screenWidth = window.screen.width;
    this.screenHeight = window.screen.height;
    this.bodyWidth = document.body.clientWidth;
    this.bodyHeight = document.body.clientHeight;
    this.scrollWidth = document.body.scrollWidth;
    this.scrollHeight = document.body.scrollHeight;
}
/****************************登录 结束*****************************/

function show_line_d()
{
    var bi = new BrowserInfo();
    document.getElementById("line_d").style.top = (bi.screenHeight /2 - 250) + "px";
    document.getElementById("line_d").style.left = (bi.screenWidth /2 - 250) + "px";
    document.getElementById("line_d").style.display="block";
    document.getElementById("dc").focus();
}
function line_d_check()
{
    if(document.getElementById("lid").value=="" || document.getElementById("dc").value==""|| document.getElementById("dt").value=="" || document.getElementById("dl").value=="")
    {
        alert("信息填写不完整!");
        return false;
    }
    else	
    {
        $.post('/TravelLine_scheduled',{
            lc:document.getElementById("lc").value,
            dd:document.getElementById("dd").value,
            dr:document.getElementById("dr").value,
            lid:document.getElementById("lid").value,
            dc:document.getElementById("dc").value,
            dt:document.getElementById("dt").value,
            dl:document.getElementById("dl").value,
            dtq:document.getElementById("dtq").value
        },add_line_comp);
        return false;
    }
}
function add_line_comp(str)
{     
    ret=eval('(' + str + ')');
    data = ret.data;
    if(ret.status==0)
    {
        alert("预定成功");
        document.getElementById("line_d").style.display = 'none';
    }
    else
        alert("预定失败!请稍候再试");
}
/****************************Tip 开始*****************************/
function tip_handler(e) {
    var showid=e.data.id;
    var width = e.data.width;
    if($('#'+showid).css('display')=='block'){
        $('#'+showid).css({
            display:'none'
        });
        if ($.browser.msie) {
            if(showid=='more_spots'){
                $('#mask').css({
                    display:'none'
                });
            }
        }
    }else{
        var a=e.srcElement || e.target;
        var off=$(a).offset();
        var h=a.offsetHeight;
        var div_show=document.getElementById(showid);
		
        // 一般情况下tip是在连接的右边显示，但如果右边的宽度不够显示的时候，就要显示在连接的左国
        $('#'+showid).css({
            display:'block'
        });
        if((off.left+width+$(a).width())<$(document).width())
        {
            div_show.className="tip1_r";
            $('#'+showid).css({
                top:off.top+'px',
                left:off.left+$(a).width()+'px',
                position:'absolute'
            });
        }
        else
        {
            div_show.className="tip1_l";
            $('#'+showid).css({
                top:off.top+'px',
                left:off.left-width-10+'px',
                position:'absolute'
            });
        }
    }
}

/****************************Tip 结束*****************************/
/****************************简单Tip 开始*****************************/
function simple_tip_handler(e) {
    var showid=e.data.id;
    var width = e.data.width;
    if($('#'+showid).css('display')=='block'){
        $('#'+showid).css({
            display:'none'
        });
        clicked_ud = false;
    }else{
        var a=e.srcElement || e.target;
        var off=$(a).offset();
        var h=a.offsetHeight;
        var div_show=document.getElementById(showid);
		
        $('#'+showid).css({
            top:off.top+15+'px',
            left:off.left+'px',
            position:'absolute',
            display:'block'
        });
        clicked_ud = true;
        //增加收藏提示
        $("#sfav").bind('mouseover',{
            id:'myfav'
        },simple_tip_fav_handler);
    }
}

function simple_tip_fav_handler(e) {
    var showid=e.data.id;
    if($('#'+showid).css('display')=='block'){
        $('#'+showid).css({
            display:'none'
        });
    }else{
        var a=e.srcElement || e.target;
        var off=$(a).offset();
        var h=a.offsetHeight;
        var div_show=document.getElementById(showid);
		
        $('#'+showid).css({
            top:off.top+7+'px',
            left:off.left+15+'px',
            position:'absolute',
            display:'block'
        });
    }
	
}
/****************************简单Tip 结束*****************************/

function clearpop(e)
{
    if(clicked_ud) clicked_ud = false; else $("#up_cnt").css({
        display:'none'
    });
    $("#myfav").css({
        display:'none'
    });
}
/****************************Tip 结束*****************************/

/****************************加入收藏夹**************************/
function addFavorites(uid,url,name,groupid)
{
    $.post('/userCenter_addFavorites',{
        uid:uid,
        url:url,
        name:name,
        groupid:groupid
    },addf_complete);
}
function addf_complete(retdata)
{
    ret=eval('(' + retdata + ')');
    data = ret.data;
    alert("已加到您的收藏夹中!");
}
