var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

var yr=2010
var m=01
var d=12

var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy
var paststring=montharray[m-1]+" "+d+", "+yr
var difference=(Math.round((Date.parse(todaystring)-Date.parse(paststring))/(24*60*60*1000))*1)
var poundspast=(2712329+(difference*30240))

	var myfont_face = "Arial";
	var myfont_size = "9";
	var myfont_color = "#ffffcc";
	var myback_color = "";
	var mywidth = 80;

	var dn = ""; var old = "";

	 if (document.all||document.getElementById) { document.write('<span id="LiveClockIE" style="width:'+mywidth+'px; background-color:'+myback_color+'"></span>');  }
	 else 
	if (document.layers) { document.write('<ilayer bgColor="'+myback_color+'" id="ClockPosNS"><layer width="'+mywidth+'" id="LiveClockNS"></layer></ilayer>'); }
	else { old = "true"; show_clock(); }


	function show_clock() {

		//show clock in NS 4
		if (document.layers)
                document.ClockPosNS.visibility="show"
		if (old == "die") { return; }

		var Digital = new Date();
		var hours = Digital.getHours();
		var minutes = Digital.getMinutes();
		var seconds = Digital.getSeconds();

		if (minutes <= 9) { minutes = "0"+minutes; }
		if (seconds <= 9) { seconds = "0"+seconds; }

		seconds=seconds*0.35;
		minutes=minutes*21;
		hours=hours*1260;

		poundstoday=hours+minutes+seconds;
		
		

		myclock = '';
		myclock += '<center>Oregon Natural Meats has <strong>upcycled</strong> an estimated <br /><strong style="font-size:1.6em;">';
		total=Math.round((poundspast+poundstoday)*10)/10;
		total=addCommas(total);
		myclock += total;
		myclock += '</strong><br />pounds of brewer\'s grain since October 15, 2009.</center>';

		if (old == "true") {
			document.write(myclock);
			old = "die"; return;
		}

		if (document.layers) {
			clockpos = document.ClockPosNS;
			liveclock = clockpos.document.LiveClockNS;
			liveclock.document.write(myclock);
			liveclock.document.close();
		} else if (document.all) {
			LiveClockIE.innerHTML = myclock;
		} else if (document.getElementById) {
			document.getElementById("LiveClockIE").innerHTML = myclock;
		}

		setTimeout("show_clock()",1000);
}


function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

