var clockID = 0;

function UpdateClock() {
   if(clockID) {
      clearTimeout(clockID);
      clockID  = 0;
   }

   var tDate = new Date();
   var tHour = tDate.getHours();
   var tMinute = tDate.getMinutes();
   var tSecond = tDate.getSeconds();
   
   if (tMinute < 10) {
	   tMinute = "0" + tMinute
	   }
	   
	if (tSecond < 10) {
	   tSecond = "0" + tSecond
	   }

   document.getElementById("timer").innerHTML = "" 
                                   + tHour + ":" 
                                   + tMinute + ":" 
                                   + tSecond;
   
   clockID = setTimeout("UpdateClock()", 1000);
}

function StartClock() {
   clockID = setTimeout("UpdateClock()", 0);
}

function KillClock() {
   if(clockID) {
      clearTimeout(clockID);
      clockID  = 0;
   }
}

function getWeekday() {
    var now = new Date();
    var output
    var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
    var monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November", "December");
    output = dayNames[now.getDay()] +", "+ now.getDate() +" "+ monthNames[now.getMonth()] +", "+ now.getFullYear();
   
    document.getElementById("dater").innerHTML = output;
}

/* This function takes on 2 parameters and matches the first parameter with a hastable */
/* The hastable is created in pairs like this '2':40 where the first parameter is the categoryid and the second parameter is the pageid*/
function showArticle(sCatId,sNewsId) {
    //var catPageIDRelation = {'178':42,'7':38,'17':38,'16':33,'2':40,'19':41};
    //var catPageIDRelation = {'178':71,'7':38,'17':38,'16':33,'2':40,'19':71};
    //var link = '/default.aspx?ID='+catPageIDRelation[sCatId]+'&amp;Action=1&amp;NewsId='+sNewsId;
    var link = '/default.aspx?ID=71&Action=1&NewsId='+sNewsId;
    document.location = link;
}