//关于时间的倒计时用于列表显示
var minute = 1000 * 60;
var hour = minute * 60;
var day = hour * 24;
var halfamonth = day * 15;
var month = day * 30;
 
function getDateDiff(dateTimeStamp,element){
var now = new Date().getTime()/1000;
var diffValue = now - Date.parse(dateTimeStamp.replace('-', "/"))/1000;
 
if(diffValue < 0){
 //非法操作
 //alert("结束日期不能小于开始日期！");
 } 
var monthC =diffValue/month;
var weekC =diffValue/(7*day);
var dayC =diffValue/day;
var hourC =diffValue/hour;
var minC =diffValue/minute; 
if(monthC>=1){
 result="发表于" + parseInt(monthC) + "个月前";
 }
 else if(weekC>=1){
 result="发表于" + parseInt(weekC) + "个星期前";
 }
 else if(dayC>=1){
 result="发表于"+ parseInt(dayC) +"天前";
 }
 else if(hourC>=1){
 result="发表于"+ parseInt(hourC) +"个小时前";
 }
 else if(minC>=1){
 result="发表于"+ parseInt(minC) +"分钟前";
 }
 else
 {
 result="刚刚发表";
 }

 document.getElementById(element).innerHTML = result;

}



//用于商品倒计时
function show_date_time(time, element)    {
        window.setTimeout("show_date_time('"+time+"','"+element+"')", 1000);       
        BirthDay = new Date(time);
today=new Date(); 
timeold=(BirthDay.getTime()-today.getTime()); 
sectimeold=timeold/1000 
secondsold=Math.floor(sectimeold); 
msPerDay=24*60*60*1000 
e_daysold=timeold/msPerDay 
daysold=Math.floor(e_daysold); 
e_hrsold=(e_daysold-daysold)*24; 
hrsold=Math.floor(e_hrsold); 
e_minsold=(e_hrsold-hrsold)*60; 
minsold=Math.floor((e_hrsold-hrsold)*60); 
seconds=Math.floor((e_minsold-minsold)*60);
if(daysold<0)
{
 document.getElementById(element).innerHTML="活动已结束";
} 
document.getElementById(element).innerHTML=hrsold+"小时"+minsold+"分"+seconds+"秒" ;
}


//用于商品倒计时(有样式了)
function show_date_timeStyle(time, element)    {
window.setTimeout("show_date_timeStyle('"+time+"','"+element+"')", 1000);       
BirthDay = new Date(time);
today=new Date(); 
timeold=(BirthDay.getTime()-today.getTime()); 
sectimeold=timeold/1000 
secondsold=Math.floor(sectimeold); 
msPerDay=24*60*60*1000 
e_daysold=timeold/msPerDay 
daysold=Math.floor(e_daysold); 
e_hrsold=(e_daysold-daysold)*24; 
hrsold=Math.floor(e_hrsold); 
e_minsold=(e_hrsold-hrsold)*60; 
minsold=Math.floor((e_hrsold-hrsold)*60); 
seconds=Math.floor((e_minsold-minsold)*60);
hrsold=(hrsold+(daysold*24));
if(hrsold<100)
{
  hrsold="&nbsp;"+hrsold;
}
if(minsold>=10)
{
 
}else(minsold<10)
{
 minsold="&nbsp;"+minsold;
}
if(seconds>=10)
{
 
}else(seconds<10)
{
 seconds="&nbsp;"+seconds;
}
document.getElementById(element).innerHTML="<div class=\"time1\" ><div class=\"time1_left\"><h2>剩余时间<\/h2><ul style=\"width:100px\" ><li><b>"+hrsold+"</b><span >小时</span><\/li><li><b>"+minsold+"</b><span >分钟</span><\/li><li><b>"+seconds+"</b><span >秒</span><\/li><\/ul><\/div><div class=\"time1_right\"><img src=\"Themes\/Skin_Default\/Images\/bg-deal-open.gif\" \/><\/div><\/div>";
}