//===============================================================================//
// Gets the elements of an object with a certain id by tag name (only those tags)

function getElementsByTagNames(list,obj) {
	if (!obj) var obj = document;
	var tagNames = list.split(',');
	var resultArray = new Array();
	for (var i=0;i<tagNames.length;i++) {
		var tags = obj.getElementsByTagName(tagNames[i]);
		for (var j=0;j<tags.length;j++) {
			resultArray.push(tags[j]);
		}
	}
	var testNode = resultArray[0];
	if (!testNode) return [];
	if (testNode.sourceIndex) {
		resultArray.sort(function (a,b) {
				return a.sourceIndex - b.sourceIndex;
		});
	}
	else if (testNode.compareDocumentPosition) {
		resultArray.sort(function (a,b) {
				return 3 - (a.compareDocumentPosition(b) & 6);
		});
	}
	return resultArray;
}


//===============================================================================//
//Listens to certain events (ie: mouseover, mouseout) and changes the background and
// foreground color of certain tags in an object with a certain id (using the
// function declared above)

function getEvent(e){  if(window.event != null) {    return event;  }  return e;}

function setMYColor(e){
//for my link format: <li><a><img>text</a><li>

 e = getEvent(e);
 var src =  e.srcElement || e.target;

 var new_background_color = '#f90';
 var new_foreground_color = '#fff';

 if(src != null && src.nodeName == 'LI' ) {
	src.style.bkColor = src.style.backgroundColor;
	src.style.backgroundColor = new_background_color;
	src.style.frColor = src.style.color;
	src.style.color = new_foreground_color;

	src.firstChild.style.fchbkColor = src.firstChild.style.backgroundColor;
	src.firstChild.style.backgroundColor = new_background_color;  
	src.firstChild.style.fchfrColor = src.firstChild.style.color;
	src.firstChild.style.color = new_foreground_color;
 	}
if(src != null && src.nodeName == 'A' ) {
	src.style.bkColor = src.style.backgroundColor;
   	src.style.backgroundColor = new_background_color;   
   	src.style.frColor = src.style.color;
  	src.style.color = new_foreground_color;

   	src.parentNode.style.fchbkColor = src.parentNode.style.backgroundColor;
   	src.parentNode.style.backgroundColor = new_background_color;   
   	src.parentNode.style.fchfrColor = src.parentNode.style.color;
   	src.parentNode.style.color = new_foreground_color;
	}
if(src != null && src.nodeName == 'IMG' ) {
	src.parentNode.style.fchbkColor = src.parentNode.style.backgroundColor;
   	src.parentNode.style.backgroundColor = new_background_color;   
   	src.parentNode.style.fchfrColor = src.parentNode.style.color;
   	src.parentNode.style.color = new_foreground_color;

   	src.parentNode.parentNode.style.fchbkColor = src.parentNode.parentNode.style.backgroundColor;
   	src.parentNode.parentNode.style.backgroundColor = new_background_color;   
   	src.parentNode.parentNode.style.fchfrColor = src.parentNode.parentNode.style.color;
   	src.parentNode.parentNode.style.color = new_foreground_color;
	}
}

function reSetMYColor(e){

 e = getEvent(e);
 var src =  e.srcElement || e.target;

if(src != null && src.nodeName == 'LI' ) {
   src.style.backgroundColor = src.style.bkColor;   
   src.style.color = src.style.frColor;

   src.firstChild.style.backgroundColor = src.firstChild.style.fchbkColor;   
   src.firstChild.style.color = src.firstChild.style.fchfrColor;
 }
if(src != null && src.nodeName == 'A' ) {
	src.style.backgroundColor = src.style.bkColor;   
   	src.style.color = src.style.frColor;

   	src.parentNode.style.backgroundColor = src.parentNode.style.fchbkColor;   
   	src.parentNode.style.color = src.parentNode.style.fchfrColor;
	}
if(src != null && src.nodeName == 'IMG' ) {
	src.parentNode.style.backgroundColor = src.parentNode.style.fchbkColor;   
   	src.parentNode.style.color = src.parentNode.style.fchfrColor;

   	src.parentNode.parentNode.style.backgroundColor = src.parentNode.parentNode.style.fchbkColor;   
   	src.parentNode.parentNode.style.color = src.parentNode.parentNode.style.fchfrColor;
	}
}

function attachEvent(name,element,callBack) {
    if (element.addEventListener) {
      element.addEventListener(name, callBack,false);
    } else if (element.attachEvent) {
      element.attachEvent('on' + name, callBack);
    }
  }

function setListner(eve,func) {
	if (document.getElementById('listgames') != null) {
		var myelement = document.getElementById('listgames');
		//this was for multiple tags: var ele = getElementsByTagNames('li',myelement);
		var ele = myelement.getElementsByTagName("li");
		for(var i = 0; i <ele.length;i++) { 
			element = ele[i];
    			attachEvent(eve,element,func);
			}
	}
}

//===============================================================================//
