function addFavorite(){
    if (document.all){
        try{
            window.external.addFavorite(window.location.href,document.title);
        }catch(e){
            alert( "加入收藏失败，请使用Ctrl+D进行添加" );
        }

    }else if (window.sidebar){
        window.sidebar.addPanel(document.title, window.location.href, "");
     }else{
        alert( "加入收藏失败，请使用Ctrl+D进行添加" );
    }
}
function setHomepage(){
    if (document.all){
        document.body.style.behavior='url(#default#homepage)';
          document.body.setHomePage(window.location.href);
    }else if (window.sidebar){
        if(window.netscape){
            try{
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }catch (e){
                alert( "该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true" );
            }
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage',window.location.href);
    }else{
        alert('您的浏览器不支持自动自动设置首页, 请使用浏览器菜单手动设置!');
    }
}

function reloadImage(url)
{
   var img = document.getElementById("authcode");
    img.src = url +"?" + Math.random();

}

function countDown(){
	var all = $("input[id^='item_ids_']");
	for (i=0; i< all.length; i++)
	{
		var id = all[i].value;
		var lasttime = $("#lasttime_" + id).val();
		var nowtime = Date.parse(new Date())/1000;
		var time = lasttime - nowtime;
		if (Math.floor(time) <= 0)
		{
			$("#item_time_display_" + id).html('团购已结束');
		}
		else
		{
			var tday=Math.floor(time/86400);
			var thour=Math.floor(time/(3600))%24;
			var tminute=Math.floor(time/60)%60;
			var tsecond=Math.floor(time)%60;
			str= tday+"天"+thour+"小时"+tminute+"分"+tsecond+"秒";
			$("#item_time_display_" + id).empty();
			$("#item_time_display_" + id).html(str);
		}
	}
	setTimeout('countDown()',1000);
}


