//fix for IE
//use browser sniffing to determine if IE or Opera (ugly, but required)
var isOpera, isIE = false;
if(typeof(window.opera) != 'undefined'){isOpera = true;}
if(!isOpera && navigator.userAgent.indexOf('Internet Explorer')){isIE = true;}

//fix both IE and Opera (adjust when they implement this method properly)
if(isOpera || isIE){
  document.nativeGetElementById = document.getElementById;
  //redefine it!
  document.getElementById = function(id){
    var elem = document.nativeGetElementById(id);
    if(elem){
      //verify it is a valid match!
      if(elem.attributes['id'] && elem.attributes['id'].value == id){
        //valid match!
        return elem;
      } else {
        //not a valid match!
        //the non-standard, document.all array has keys for all name'd, and id'd elements
        //start at one, because we know the first match, is wrong!
        for(var i=1;i<document.all[id].length;i++){
          if(document.all[id][i].attributes['id'] && document.all[id][i].attributes['id'].value == id){
            return document.all[id][i];
          }
        }
      }
    }
    return null;
  };
}

// JavaScript Document

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function switchElement(element) { 
	turn_on=document.getElementById(element);
	where=document.getElementById('banner_left');
	the_others=getElementsByClass('changeable',where,'div');
	othersLen=the_others.length;

	shows=getElementsByClass('show',where,'div');
	show_length=shows.length;
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	var devel = 0;
	if(sPage=='index2.php') {
		devel = 1;
	}
//	if(devel) alert('to turn on: ' + element + ' turn_on.id: ' + turn_on.className);
//	if(devel) alert('number shown: ' + show_length + ' hidden: ' + othersLen);
	if(show_length > 0) {
		for(i=0;i<show_length;i++) {
			the_others[othersLen + i] = shows[i];
////			if(devel) alert('added ' + shows[i].id + ' position ' + othersLen + '+' + i);
////			for(j=0;j<the_others.length;j++) {
////				alert(j + ' ' + the_others[j].id);
////			}
		}
	}
	othersLen=the_others.length;
////	if(devel) alert('to hide: ' + othersLen + ' to show: ' + element);
	for(i=0; i < othersLen; i++) { 
		the_others[i].className='changeable';
////		if(devel) alert(the_others[i].id + ' off');
////		the_others[i].style.display='none';
	}
	turn_on.className='show';
//	if(devel) alert(turn_on.id + ' on');
//	if(devel) alert(turn_on.className);
////	turn_on.style.display='block';
}

function hoveron(my_element,what) { 
	for (x in off_array) { 
		document[x].src=off_array[x];
	}
	my_element.className='hoveron';
	document[what].src=on_array[what];
}

function timedCount2() { 
	clearTimeout(t);
	t=setTimeout("timedCount()",5000);

}

function timedCount()
{
switchElement(count_info[c].id);
hoveron(left_side[c],left_side[c].name);
if (c < (count_length - 1) ) 
	c=c+1;
else 
	c=0;
t=setTimeout("timedCount()",10000);
}

function stopCount()
{
clearTimeout(t);
}
