function cartPop(theForm) {
	paypalWin = "";
	
	if ((!paypalWin.closed) && (paypalWin.location)) {
		theForm.target = "paypal";
		paypalWin.focus();
	} else {
		paypalWin = window.open('','paypal','width=900,height=555,scrollbars=1');
		theForm.target = "paypal";
		paypalWin.focus();
	}
}

function initPaypalWindow() {
	var allForms = document.getElementsByTagName('form');
	
	for (var i=0; i < allForms.length; i++) {
		formTarget = allForms[i].getAttribute("target");
		if (formTarget == "paypal") {
			allForms[i].onsubmit = function() {
				if (this.id != "mc-embedded-subscribe-form") {
					return cartPop(this);
				};
			};
		}
	}
}
addLoadEvent(initPaypalWindow);
                             

function addLoadEvent(func) {
	var oldOnLoad = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldOnLoad();
			func();
		}
	}
}

function setNewWindow() {
	// make sure the browser has what we need
	if (!document.getElementsByTagName) return false;
	// get the elements
	var links = document.getElementsByTagName("a");
	// make sure there are any
	if (links.length < 1) return false;
	for (a=0; a < links.length; a++) {
		var link = links[a];
		if ((link.getAttribute("href")) && (link.getAttribute("rel") == "external")) {
			link.onclick = function() {
				var location = this.getAttribute("href");
				window.open(location, "newWindow");				
				return false;
			}
		}
	}
}
addLoadEvent(setNewWindow);
