function toggleCityView(){
	$(".layer").toggle();
}

//time counter
function CountDown(a){
    if (a.startTime == null) 
        throw "args:startTime is null";
    if (a.endTime == null) 
        throw "args:endTime is null";
    this.startTime = a.startTime.constructor == Date ? a.startTime.getTime() : a.startTime;
    this.endTime = a.endTime.constructor == Date ? a.endTime.getTime() : a.endTime;
    this.callback = a.callback || new Function;
    this.startCount()
}

CountDown.prototype = {
    startCount: function(){
        var a = new Date().getTime(), c = this.endTime, d = this.callback, f = setInterval(function(){
            a += 1E3;
            if (a > c) 
                clearInterval(f);
            else {
                var b = (c - a) / 1E3, e = parseInt(b / 3600 / 24), g = parseInt((b - e * 24 * 3600) / 3600), h = parseInt((b - e * 24 * 3600 - g * 3600) / 60);
                b = parseInt(b - e * 24 * 3600 - g * 3600 - h * 60);
                d(e, g, h, b)
            }
        }, 1E3)
    }
};

function calculateTime(container, startTime, endTime){
	var str = '';
	new CountDown({
		startTime: startTime,
		endTime: endTime,
		callback: function(day, hour, minute, second){
			str = (day != 0 ? '<span class="size18">'+ day + '</span>' + '天' : '') + '<span class="size18">' + formatNum(hour) + '</span>' + '时' + '<span class="size18">' + formatNum(minute) + '</span>' + '分' + (day == 0 ? '<span class="size18">' + formatNum(second) + '</span>' + '秒' : '') ;
			if (day == 0 && hour == 0 && minute == 0 && second == 0) {
				str = "<span class=\"size18\">交易结束</span>";
			}
			container.html(str);
		}
	});
}
function formatNum(n){
	return n < 10 ? '0' + n : n;
}
function addCount(siteId){
	//alert(siteId);
	//location.href ="/index.php/site/siteCount?subSiteId="+siteId;
	$.ajax({
		type: "POST",
		url: '/index.php/site/siteCount',
		cache: false,
		data: "subSiteId="+siteId,
		success: function(data) {
			//alert(data);
		}
	});
}

