window.status = 'OUTTV – jouw gay lifestyle televisiezender';

$.fn.countdown = function(c) {
	var cstamp, tstamp, difstamp, cyears, cmonths, cdays, chours, cmins, csecs, output, obj, format;
	// reset effects
	
	c.date	 	= (c.date===undefined) ? '2010/02/21 06:00:00' : c.date ;
	c.format	= (c.format===undefined) ? '%y years %m months %d days %h hours %i minutes %s seconds' : c.format ;
	c.finish	= (c.finish===undefined) ? 'Timer has finished' : c.finish ;
	c.effect	= (c.effect===undefined) ? false : c.effect ;
	obj = $(this);
	cstamp = Math.floor( new Date().getTime()/1000 );
	tstamp = Math.floor( new Date(c.date).getTime()/1000 );

	difstamp = (tstamp-cstamp);

	if (difstamp<=0) { obj.html( c.finish ); return false; }

	// calculate time
	if (c.format.indexOf('%y')!=-1) {
		cyears = Math.floor(difstamp / 31536000);
		difstamp -= (cyears*31536000);
	}
	if (c.format.indexOf('%m')!=-1) {
		cmonths = Math.floor(difstamp / 2678400);
		difstamp -= (cmonths*2678400);
	}
	if (c.format.indexOf('%d')!=-1) {
		cdays = Math.floor(difstamp / 86400);
		difstamp -= (cdays*86400);
	}
	if (c.format.indexOf('%h')!=-1) {
		chours = Math.floor(difstamp / 3600);
		difstamp -= (chours*3600);
	}
	if (c.format.indexOf('%i')!=-1) {
		cmins = Math.floor(difstamp / 60);
		difstamp -= (cmins*60);
	}
	csecs = Math.floor(difstamp);

	// output
	format = c.format.replace('%y',cyears).replace('%m',cmonths).replace('%d',cdays).replace('%h',chours).replace('%i',cmins).replace('%s',csecs);

	obj.html( format );
	
	setTimeout(function(){ obj.countdown(c); }, 1000 );
};