<script type="text/javascript">
<!--
	var serverdate = -1;
	
	function setWorkingTime()
	{
		if (serverdate == -1) 
		{
			var n = new Date({YEAR}, {MONTHNOW}, {DAYNOW}, {HOURNOW}, {MINUTENOW}, {SECONDNOW});
			serverdate = n.getTime() / 1000;
		}
		else
		{
			serverdate++;
		}
		var startd = new Date({YEAR}, {MONTH}, {DAY}, {HOUR}, {MINUTE}, {SECOND});
		var ptime_m = {PTIME_M};
		var ptime_s = {PTIME_S};
		var minute = "{STRING_MINUTE}";
		var minutes = "{STRING_MINUTES}";
		var second = "{STRING_SECOND}";
		var seconds = "{STRING_SECONDS}";
		var timeleft = "{STRING_TIMELEFT}";
		var and = "{AND}";
		var now = serverdate;
		var then = startd.getTime() / 1000;
		// time since start in seconds
		var diff = Math.floor(now - then);
		// available time
		var avail = ptime_m * 60 + ptime_s - diff;
		if (avail < 0)
		{
			avail = 0;
		}
		var avail_m = Math.floor(avail / 60);
		var avail_s = avail - (avail_m * 60);
		var output = avail_m + " ";
		if (avail_m == 1)
		{
			output += minute;
		}
		else
		{
			output += minutes;
		}
		output += " " + and + " " + avail_s + " ";
		if (avail_m == 0)
		{
			output = avail_s + " ";
		}
		if (avail_s == 1)
		{
			output += second;
		}
		else
		{
			output += seconds;
		}
		var span = document.getElementById("timeleft");
		span.innerHTML = timeleft.replace(/%s/, output);
	}
//-->
</script>
