// JavaScript Document
function addEvent(elm, evType, fn, useCapture){
		if(elm.addEventListener){
			elm.addEventListener(evType, fn, useCapture);
			return true;
		}else if (elm.attachEvent){
			var r = elm.attachEvent('on' + evType, fn);
			return r;
		}else{
			elm['on' + evType] = fn;
		}
	}
	
	function showPlant(prodCode) {
		var h = (screen.availHeight - 650)/2;
		var w = ((screen.availWidth - 600)/2) - 10;
		window.open("productDisplay.cfm?product="+prodCode, "prodDisplay", "width=600,height=650,status=no,resizable=no,top="+h+",left="+w);
	}
	
	
	function doPopUp(e) {
		//look for parameters
		attribs = this.rel.split(",");
		if (attribs[1]!=null) {t = attribs[1];}
		//call the popup script
		showPlant(t);
		//cancel the default link action if pop-up activated
		if (window.event) {
			window.event.returnValue = false;
			window.event.cancelBubble = true;
		} else if (e) {
			e.stopPropagation();
			e.preventDefault();
		}
	}
	
	function buildPops() {
		var popups = document.getElementsByTagName("a");
		for (i=0;i<popups.length;i++) {
			if (popups[i].rel.indexOf("popup")!=-1) {
				popups[i].onclick = popups[i].onkeypress = doPopUp;
			}
		}
	}
	
	addEvent(window, 'load', buildPops, false);
