// JavaScript Document

		function pad(number, length) {
   		    var str = '' + number;
		    while (str.length < length) {
    	    	str = '0' + str;
		    }
   		    return str;
		}

		function setDivColor(what)
		{

			switch (what) {
				case "UPDATED"  : return "font-family: Verdana, Arial, Helvetica, sans-serif; \
										margin-right:3px; \
										padding:1px 2px 1px 2px; \
										font-size:.75em; \
										background-color:#CCCCCC; \
										color:#000000; \
										font-weight:bold;";
				case "NEW"  : return "font-family: Verdana, Arial, Helvetica, sans-serif; \
										margin-right:3px; \
										padding:1px 2px 1px 2px; \
										font-size:.75em; \
										background-color:#99CCFF; \
										color:#000000; \
										font-weight:bold;";
				case "BNEWS"  : return "font-family: Verdana, Arial, Helvetica, sans-serif; \
										margin-right:3px; \
										padding:1px 2px 1px 2px; \
										font-size:.75em; \
										background-color:#FF0000; \
										color:#FFFFFF; \
										font-weight:bold;";
				case "LVIDEO"  : return "font-family: Verdana, Arial, Helvetica, sans-serif; \
										margin-right:3px; \
										padding:1px 2px 1px 2px; \
										font-size:.75em; \
										background-color:#FFFFFF; \
										color:#FF0000; \
										font-weight:bold;";	
				case "LCHAT"  : return "font-family: Verdana, Arial, Helvetica, sans-serif; \
										margin-right:3px; \
										padding:1px 2px 1px 2px; \
										font-size:.75em; \
										background-color:#FFFFFF; \
										color:#FF0000; \
										font-weight:bold;";	
				default: return "";
			} // end switch
				
		}

		function execCalcDiff(date2,interval) 
		{
		    var second=1000, minute=second*60, hour=minute*60, day=hour*24, week=day*7;
			var date1 = new Date( );
			date2 = new Date(date2);
			var timediff = date1 - date2;
			
			if (isNaN(timediff)) return NaN;
			
			switch (interval) {
				case "years": return date2.getFullYear() - date1.getFullYear();
				case "months": return (
					( date2.getFullYear() * 12 + date2.getMonth() )
					-
					( date1.getFullYear() * 12 + date1.getMonth() )
				);
				case "weeks"  : return Math.floor(timediff / week);
				case "days"   : return Math.floor(timediff / day); 
				case "hours"  : return Math.floor(timediff / hour); 
				case "minutes": return Math.floor(timediff / minute);
				case "seconds": return Math.floor(timediff / second);
				default: return undefined;
			} // end switch
			
		} // end calcDiff

		function execCheckDiff(s,date2,interval,newStory) 
		{
			var timediff = execCalcDiff(date2,interval);
			var theDiv = "#st"+s;
			var theTim = "#tm"+s;
	
			if (timediff < 20 && newStory == "Y") 
			{
					$(theDiv).attr("style", setDivColor('NEW'));
					$(theDiv).html("NEW");
					//$(theTim).html("<br />"+ timediff + " mins. ago");
						
			} else if (timediff < 40 && newStory == "N") 
				{
							
					$(theDiv).attr("style", setDivColor('UPDATED'));
					$(theDiv).html("UPDATED");
					//$(theTim).html("<br />"+ timediff + " mins. ago");
				}

		} // end checkDiff

		function isBreakNews(s,date2,interval) 
		{
			var timediff = execCalcDiff(date2,interval);
			var theDiv = "#st"+s;
			var theTim = "#tm"+s;
	
			//if (timediff < 20) 
			//{
					$(theDiv).attr("style", setDivColor('BNEWS'));
					$(theDiv).html("BREAKING NEWS");
					//$(theTim).html("<br />"+ timediff + " mins. ago");
						
			//}
		} // end checkDiff

		function isLiveVideo(s,date2) 
		{
			var theDiv = "#st"+s;
			var theTim = "#tm"+s;
	
			$(theDiv).attr("style", setDivColor('LVIDEO'));
			$(theDiv).html("LIVE VIDEO");
			//$(theTim).html("<br />"+ timediff + " mins. ago");

		} // end checkDiff
		
		function isLiveChat(s,date2) 
		{
			var theDiv = "#st"+s;
			var theTim = "#tm"+s;
	
			$(theDiv).attr("style", setDivColor('LCHAT'));
			$(theDiv).html("LIVE CHAT");
			//$(theTim).html("<br />"+ timediff + " mins. ago");

		} // end checkDiff

