function showimage(s){
		document.getElementById(s).style.display = 'block';
	}
	function hideimage(s){
		document.getElementById(s).style.display = 'none';
	}
function Countdown(elm, options) {
  this.elm = (typeof elm == 'string') ? document.getElementById(elm) : elm;
	if(!this.elm) return;
	this.options = this.extend({
		year: 1970,
		month:01,
		day:01,
		hour:00,
		minute:00,
		second:00,
		interval : 1,
		format : this.elm.innerHTML || '{d} : {h} : {m} : {s}',
		autoStart : true
	}, options || {});
	this.timer = false;
	if(this.options.autoStart) this.start();
}


Countdown.prototype.update = function() {
	var now = new Date();
	var end = new Date(
		this.options.year,
		this.options.month - 1,
		this.options.day,
		this.options.hour,
		this.options.minute,
		this.options.second
	);
	var diff = end - now;
	var days    = this._gN(parseInt(diff / 86400000));
	var hours   = this._gN(parseInt((diff % 86400000) / 3600000));
	var minutes = this._gN(parseInt((diff % 3600000) / 60000));
	var seconds = this._gN(parseInt((diff % 60000) / 1000));
	var html = this.options.format;
	html = html.replace(/\{d\}/, days);
	html = html.replace(/\{h\}/, hours);
	html = html.replace(/\{m\}/, minutes);
	html = html.replace(/\{s\}/, seconds);
	//console.log(html);
	this.elm.innerHTML = html;
	if(this.options.interval > 0) this.timer = setTimeout(this.update.bind(this), this.options.interval * 1000);
}
Countdown.prototype.start = function() {
	this.update();
}
Countdown.prototype.stop = function() {
	if(this.timer) clearTimeout(this.timer);
}
Countdown.prototype.extend = function(o, s) {
 	for (var p in s) {
  	o[p] = s[p];
	}
 	return o;
}
Countdown.prototype._gN = function(n) {
	n = Math.max(n,0) + '';
	if (n.length == 1) n = '0' + n;
	return n;
}
//http:// prototype.conio.net
var $A = Array.from = function(iterable) {
	if (!iterable) return [];
	if (iterable.toArray) {
		return iterable.toArray();
	} else {
		var results = [];
		for (var i = 0; i < iterable.length; i++)
			results.push(iterable[i]);
		return results;
	}
}

Function.prototype.bind = function() {
	var __method = this, args = $A(arguments), object = args.shift();
	return function() {
		return __method.apply(object, args.concat($A(arguments)));
	}
}
