//alert('common');

function enlarge(product,width,height) {
	//alert(product+';'+width+';'+height);
	var url='/product_popup.php?product='+product;
	battles_product_popup=window.open(url,'battles_product_popup','width='+width+',height='+height+',resizable=1');
	// in case the window swas already open and a different size, resize it
	battles_product_popup.focus();
	return false;
	}

function getElementsByClassName(className, tag, elm){
	// http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/
	// "Revised version May 11th 2007" version
	var testClass = new RegExp("(^|\\\\s)" + className + "(\\\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
} // end function getElementsByClassName

function addListenerToEvent(obj,evtName,fnCall) {
	// can't remember where this came from
	// doesn't appear to be able to take parameters in fnCall, which seems odd

 evtName=evtName.toLowerCase();
 doCapture=false;

 if (obj.addEventListener){
  //obj.addEventListener(evtName.replace('on',''),fnCall,doCapture);
  obj.addEventListener(evtName.replace('on',''),
  function(){eval(fnCall);},false);
 }
 else if(obj.attachEvent){
  obj.attachEvent(evtName,function(){eval(fnCall);});
  //also do detachEvent later
 }
 else{
  eval(obj+"."+evtName +"="+ fnCall);
 }
}

//Used to display Terms and Conditions
function popup(windowName, location, height, width) {
	width = width + 20;
	height = height + 20;
	window.open(location, "'" + windowName + "'", "resizable,scrollbars=yes,width=" + width + ",height=" + height);
	return false;
}

function show(divid, id) {
	var imgdiv = document.getElementById(id);
	var alt = imgdiv.alt;
	var div=document.getElementById(divid);
	div.style.display='block';
	imgdiv.alt='';
	//imgdiv.attributes['onmouseout'].value = hide(divid, id, alt);
	imgdiv.onmouseout = function() {hide(divid, id, alt)}
	} // end function show(divid)
	
function hide(divid, id, alt) {
	var imgdiv = document.getElementById(id);
	imgdiv.alt = alt;
	var div=document.getElementById(divid);
	div.style.display='none';
	} // end function show(divid)

