/*
	$Revision: $

	r2 preDisplay
*/

/*
	r2 clock
*/
function arrayOfMonthNames() {
        this[0] = "January";
        this[1] = "February";
        this[2] = "March";
        this[3] = "April";
        this[4] = "May";
        this[5] = "June";
        this[6] = "July";
        this[7] = "August";
        this[8] = "September";
        this[9] = "October";
        this[10] ="November";
        this[11] ="December";
}

function getMonthName(m) {
        var monthNames = new arrayOfMonthNames();
        return monthNames[m];
}

function updateClock (dateFormat)
{
  var currentTime = new Date ( );

  var currentHours = currentTime.getHours ( );
  var currentMinutes = currentTime.getMinutes ( );
  var currentTimeString = "";
 
  // Pad the minutes with leading zeros, if required
  currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
 
  // Choose either "AM" or "PM" as appropriate
  var timeOfDay = ( currentHours < 12 ) ? "am" : "pm";

  // Convert the hours component to 12-hour format if needed
  currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

  // Convert an hours component of "0" to "12"
  currentHours = ( currentHours == 0 ) ? 12 : currentHours;

  var currentDayOfMonth = currentTime.getDate()
  var currentMonth = getMonthName(currentTime.getMonth());
  var currentYear =  currentTime.getYear();
  if (currentYear < 1000) currentYear += 1900;
  
  // Compose the string for display
  if(dateFormat && dateFormat == "HH:MM:tt dd MMM YYYY") {
  	currentTimeString = "updated " + currentHours + ":" + currentMinutes + timeOfDay + ' ' + currentDayOfMonth + ' ' + currentMonth + ' ' + currentYear;
  	
  }
  else {
  	currentTimeString = currentDayOfMonth + ' ' + currentMonth + ' ' + currentYear + ': ' +currentHours + ":" + currentMinutes + timeOfDay;
  }

  // Update the time display
  var clk = document.getElementById("clock");
  if ( clk != undefined ) 
  	clk.firstChild.nodeValue = currentTimeString;
}

/*
xp:135337 fix top ad slot
*/

(function (){
	var adclass = function() {
		if (!document.getElementById || !document.getElementsByTagName) return;
		var adContainer = document.getElementById('top-search-ad-wrapper');
		if (!adContainer) return;
		var c = adContainer.className;
		//  look for child elt over 700px wide
		var elTypes = ['A','OBJECT', 'DIV', 'IMG', 'IFRAME'];
		for (var i=0; i < elTypes.length; i++ ) {
			var els = adContainer.getElementsByTagName(elTypes[i]);
			for (var j=0; j < els.length; j++ ) {
				w = els[j].offsetWidth;
				if (typeof w == 'undefined') return;
				if (w > 700) {
					adContainer.className = c + ' ' + 'top-leaderboard'; 
					return;
				}
			}
		}
		adContainer.className = c + ' ' + 'top-banner'; 
	}
	if (window.addEventListener) { // Moz etc
		window.addEventListener('load', adclass, false);
	} else if (window.attachEvent) { // IE
		window.attachEvent('onload', adclass);
	}
})()


