/* === FLASH VERSION REQUIREMENTS: === */

    var requiredVersion = 7;   // Version the user needs to view site (max 9, min 2)
    var jsVersion = 1.0;       // Do not change or delete.


function getElementsByClassName(node, classname) {
    var a = [];
    var re = new RegExp('(^| )'+classname+'( |$)');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}

function popUpWindow(cPopUrl, cPopName, iPopWidth, iPopHeight, bScrollBars) {
	var iPopLeft, iPopTop;
	var oPopWindow = null;
	if (!oPopWindow || oPopWindow.closed){
		iPopLeft = (window.screen.width/2) - ((iPopWidth/2) + 10);
		iPopTop = (window.screen.height/2) - ((iPopHeight/2) + 50);
		oPopWindow=open(cPopUrl, cPopName,"height="+ iPopHeight +",width="+ iPopWidth +",left=" + iPopLeft + ",top=" + iPopTop + ",screenX=" + iPopLeft + ",screenY=" + iPopTop + ",scrollbars=" + bScrollBars + ", status=yes");
		oPopWindow.location.href = cPopUrl;
		oPopWindow.focus()
    } else {
    	oPopWindow.focus()
	}
}

function showProduct(id) {
    popUpWindow("http://www.grahampackaging.com/markets/viewProduct.asp?id=" + id, "GrahamProductWindow", 540, 520, "yes");
}

/* === OPEN EXTERNAL LINKS IN NEW BROWSER WINDOW === */

    onLoadFuncs = new Array();
    function addOnLoad(func){
    	onLoadFuncs[onLoadFuncs.length] = func;
    }
    function runOnLoad(){
    	for(i in onLoadFuncs){
    		eval(onLoadFuncs[i]+"()");
    	}
    }
    window.onload = runOnLoad;

    function handleExternalLinks() {
    	var anchors = document.getElementsByTagName("a");
    	var i, href;
    	for(i=0; i < anchors.length; i++){
    		if(!anchors[i].href) continue;
    		href = anchors[i].href;

    		if(href.indexOf("grahampackaging") == -1 && href.indexOf("localhost") == -1) { // Href is not a file on my server
    			if(href.indexOf("javascript:") == -1){ // Href is not a javascript call
    				if(!anchors[i].onclick){ // Href does not have an onclick event
    					if(href.indexOf("mailto:") == -1){ // Href is not a mailto:
    						if(href.indexOf("http://") != -1 || href.indexOf("https://") != -1) { // Href is not relative (for Safari)
    							anchors[i].setAttribute("target","_blank");
    						}
    					}
    				}
    			}
    		}

    		// things that must open in a new browser window.
    		if (href.indexOf(".pdf") > 0 && href.indexOf("download.php?file") <= 0) anchors[i].setAttribute("target","_blank");

    	}
    }

    if(document.getElementsByTagName){
    	// addOnLoad("handleExternalLinks");
    }
