﻿/**************************************************************
* Copyright Cares Corporation. All rights reserved.
* 
* Author:guitao(guitao@cares.sh.cn) 
* Create Date: 07/15/2010
* Description:
*          
* Revision History:
*      Date         Author               Description
*              
***************************************************************/

$(document).ready(function() {
    Cares.Ecommerce.Flights.BizSepcialFlightTicket.RenewSpecialFlightTicket($("#CheapTicket-title .cur").attr("name"));
});

usingNamespace("Cares.Ecommerce.Flights")["BizSepcialFlightTicket"] = {
    //查找特价机票
    SearchSpecialFlightTicket: function(cityCode, obj) {
        $.ajax({
            type: "post",
            url: $Url.BuildCurrentUrlByName("SearchSpecialFlightTicketAjaxPage"),
            dataType: "html",
            async: false,
            timeout: 30000,
            data: { ShowCityCode: cityCode },
            beforeSend: function() { },
            error: function(XMLHttpRequest, textStatus, errorThrown) { },
            success: function(data, textStatus) {
                var dataObj = $(data);
                $.each(dataObj, function(index, item) {
                    if (typeof (item) != 'undefined') {
                        if (item.id == 'CheapTicket-content') {
                            $("#CheapTicket-content").empty();
                            $("#CheapTicket-content").html(item.innerHTML);
                        }
                    }
                })
            },
            complete: function(XMLHttpRequest, textStatus) {
                Cares.Ecommerce.Flights.BizSepcialFlightTicket.ChangeShowCityCss(obj);
            }
        })
    },
    ChangeShowCityCss: function(obj) {
        $("#CheapTicket-title dl>dt").removeClass("cur");
        $(obj).parent("dt").addClass("cur");
    },
    //定时更新特价机票
    RenewSpecialFlightTicket: function() {
    var interval = setInterval(
        'Cares.Ecommerce.Flights.BizSepcialFlightTicket.SearchSpecialFlightTicket($("#CheapTicket-title .cur a").attr("name"), $("#CheapTicket-title .cur a"))'
        , 1800000);
        $("#CheapTicket #CheapTicket-title dl dt").bind("mouseenter", function() { clearInterval(interval); })
        $("#CheapTicket #CheapTicket-title dl dt").bind("mouseleave"
                                                        , function() {
                                                                        interval = setInterval(
        'Cares.Ecommerce.Flights.BizSepcialFlightTicket.SearchSpecialFlightTicket($("#CheapTicket-title .cur a").attr("name"),$("#CheapTicket-title .cur a"))'
        , 1800000); })
    },
    //抽奖
    Lottery: function(rid,action) {
            $.ajax({
                url: $Url.BuildCurrentUrlByName("LotteryAjaxPage")+"?rid="+rid+"&action="+action,
                data:{},
                beforeSend: function() {$("#imgLogo").src="../WebResources/Images/Lottery/gif_cj.gif";},
                success: function(data) {
                    if (!$String.IsNullOrEmpty(data))
                    {
                        $("#divContent").empty();
                        $("#divContent").html(data);
                    }
                },
                complete: function() {}
            });
        },
        
        MyLottery: function(rid,action,cardno) {
            $.ajax({
                url: $Url.BuildCurrentUrlByName("MyLotteryAjaxPage")+"?rid="+rid+"&action="+action+"&cardno="+cardno,
                data:{},
                beforeSend: function() {$("#imgLogo").src="../WebResources/Images/Lottery/gif_cj.gif";},
                success: function(data) {                
                    if (!$String.IsNullOrEmpty(data))
                    {
                        alert(data);                        
                        var url="MyLottery.aspx?rid="+rid;
                        window.location.href=url;
                    }
                },
                complete: function() {}
            });
        }
};
