global = {
allLinks: [], // the set of question mark (now) help icons next to the options label
helpPopUpClass: 'helpPopUp', // class name used in html as hook
largePopUpWindowClass: 'largePopUp',
smallPopUpWindowClass: 'smallPopUp',
emailFriendClass: 'emailFriendLink',
init:function() {
	if (!document.getElementsByTagName || !document.getElementById) { return false; }
	/*--- Help icon boxes ---*/
	global.allLinks = document.getElementsByTagName("a");
	for(var i=0; i<global.allLinks.length; i++) {
		if (DOMhelp.cssjs('check', global.allLinks[i], global.helpPopUpClass)) {
			DOMhelp.addEvent(global.allLinks[i], 'click', global.helpPopUp, false);
		}
		if (DOMhelp.cssjs('check', global.allLinks[i], global.emailFriendClass)) {
			DOMhelp.addEvent(global.allLinks[i], 'click', global.showReferal, false);
		}
	}
},
helpPopUp:function(e) {
	var obj = DOMhelp.getTarget(e);
	/* iterate up parent node until we reach a then grab the href value */
	while(obj.nodeName.toLowerCase() != 'a') {
		obj = obj.parentNode;
	}
	URL = obj.getAttribute("href");
	var page;
	if (DOMhelp.cssjs('check', obj, global.largePopUpWindowClass)) {
		w = 740 
		h = 520
	}
	else if (DOMhelp.cssjs('check', obj, global.smallPopUpWindowClass)) {
		w = 220
		h = 200
	}
	else {
		w = 400 
		h = 300
	}		
	eval("page = window.open(URL, 'Help', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=" + w + ",height=" + h + "');");
	page.focus();
	DOMhelp.cancelClick(e);
	return false;
},
showReferal:function(e){
	var obj = DOMhelp.getTarget(e);
	var leftPos = 20;
	var topPos = 40;
	/* iterate up parent node until we reach a then grab the href value */
	while(obj.nodeName.toLowerCase() != 'a') {
		obj = obj.parentNode;
	}
	URL = obj.getAttribute("href");
	if (screen) {
		leftPos = (screen.width - 600) / 2;
		topPos = (screen.height - 400) / 2;
	}
	var page;
	eval("page = window.open('http://www.edgetechcorp.com/store/EmailAFriend.aspx?url=' + URL, 'referAfriend', 'fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,left=' + leftPos + ',top=' + topPos + ',width=600,height=400');");
	page.focus();
	DOMhelp.cancelClick(e);
	return false;
}
}
DOMhelp.addEvent(window, 'load', global.init, false);


function AddBundle(cartPath, product, bundleProduct, bundleQty, index, category) {
    var loc = cartPath;
    var qtyObj = document.getElementById("qty" + index);
    if (qtyObj && qtyObj.value) {
        loc += "product_id=" + product + "|" + qtyObj.value + "," + bundleProduct + "|" + bundleQty + "&category_id=" + category;
    } else {
        loc += "product_id=" + product + "," + bundleProduct + "&category_id=" + category;
    }
    window.location = loc;
}

function UpsellSelectChange() {
    var sel = document.getElementById("upsellSelect");
    var link = document.getElementById("submitLink");
    if (link && link.href && !window["ORIGINAL_LINK"]) {
        window["ORIGINAL_LINK"] = link.href;
        window["ORIGINAL_CLICKER"] = link.onclick;
    }
    if (sel && sel.selectedValue) {
        if (sel.selectedValue == "0") {
            link.href = window["ORIGINAL_LINK"];
            link.onclick = window["ORIGINAL_CLICKER"];
        }
        else {
            link.onclick = null;
            sel
        }
    }
}