function numimg(mynum) {
 var numstring = '';
  for(i = 0; i < mynum.length; i++) {
    numstring = numstring +  '<img src=\'common/images/' + mynum.charAt(i) + 'sm.png\' alt=\'' + mynum.charAt(i) + '\'>';  
  }
  return numstring;
}


function smnumimg(mynum) {
 var numstring = '';
  for(i = 0; i < mynum.length; i++) {
    numstring = numstring +  '<img src=\'common/images/' + mynum.charAt(i) + 'sm.png\' alt=\'' + mynum.charAt(i) + '\'>';  
  }
  return numstring;
}

function updateseconds() {
  var now = new Date();
  var s=now.getSeconds();
  if (s < 10 ) s = '0' + s;
  if (s == 0) clock();
  var mys  = s.toString();
  mys =  numimg(mys);  
  document.getElementById('seconds').innerHTML=mys
  sectimer = setTimeout('updateseconds()', 1000);
	
}

function clock() {
  var now = new Date();

  var month=now.getMonth() +1;
  var myday = now.getDate();

  var h=now.getHours();
  var m=now.getMinutes();
  var s=now.getSeconds();

  if (h > 12 ) h = h - 12; 
  if (h == 0) h = 12;
  var myh = h.toString();
  var myh = numimg(myh);

  var mym = m.toString()
  if (mym.toString().length <2) mym = '0' + mym;
  var mym = numimg(mym);

  if (s < 10 ) s = '0' + s;
  var mys  = s.toString();
  mys = numimg(mys); 

  var mydate = smnumimg(myday.toString());
  
  var mytime = '<br /><br /><img src=\'common/images/' + month + 'month.png\' alt=\'' + month + '/\'> ' + mydate + '<br />'
  mytime = mytime + myh + '<img src=\'common/images/colon.png\' alt=\':\'>' + mym + '<img src=\'common/images/colon.png\' alt=\':\'>'; 
  document.getElementById('myclocktime').innerHTML=mytime

if (msieversion() > 5 )  correctPNG();

//  timerID = setTimeout('clock()', 60000);
}

function msieversion()
// return Microsoft Internet Explorer (major) version number, or 0 for others
// This function works by finding the "MSIE " string and extracting the version number
// following the space, up to the decimal point for the minor version which is ignored.
{
	var ua = window.navigator.userAgent
	var msie = ua.indexOf ( "MSIE " )
	if ( msie > 0 )		// is Microsoft Internet Explorer; return version number
		return parseInt ( ua.substring ( msie+5, ua.indexOf ( ".", msie ) ) )
	else
		return 0	// is other browser
}
