$(function(){
    $('.package_ul > li').hover(function(){
        $(this).children('div.float_div').show();
        $(this).removeClass('normal').addClass('active');
        var obj = $(this).offset();
        var child_obj = $(this).children('div.float_div');
        //child_obj.css({top:obj.top-215});
    },function(){
        $(this).removeClass('active').addClass('normal');
        $(this).children('div.float_div').hide();
    });
    $('.float_content li').hover(function(){
        $(this).addClass('activechild');
    },function(){
        $(this).removeClass('activechild');
    });
});

/*切换选项*/
$(document).ready(function(){
var stime = $("a.ads").attr("data-time");
var showr = $("a.ads").attr("data-add");
countdown(stime, showr);
$("a.ads").click(function (){
$(".abutton").removeClass("abutton");
$(this).addClass("abutton");

$(".index_ad_info").slideUp();

var content_show = $(this).attr("data-label");
var stime        = $(this).attr("data-time");
var showr        = $(this).attr("data-add");
countdown(stime, showr);
$("#"+content_show).slideDown();
});
});

/* 倒计时 */
function countdown(stime,showr)
{
  var starttime = parseInt(stime);   //这里获取倒计时的起始时间 
  var andtime = window.setInterval(SetRemainTime, 1000); //间隔函数，1秒执行   
        
  //将时间减去1秒，计算天、时、分、秒   
  function SetRemainTime() {   
  if (starttime > 0) {   
   starttime = starttime - 1;   
   var second = Math.floor(starttime % 60);              // 计算秒       
   var minite = Math.floor((starttime / 60) % 60);       //计算分   
   var hour = Math.floor((starttime / 3600) % 24);       //计算小时   
   var day = Math.floor((starttime / 3600) / 24);        //计算天   
  
   $("#"+showr).html(day + " 天 " + hour + " 小时 " + minite + " 分 " + second + " 秒 ");   
   }
   else
   { 
     window.clearInterval(andtime);
	 $("#"+showr).html("已结束");  
   }
  }
}
