function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		mission_over = newImage("/images/mission-over.gif");
		riders_over = newImage("/images/riders-over.gif");
		products_over = newImage("/images/products-over.gif");
		who_over = newImage("/images/who-over.gif");
		book_over = newImage("/images/book-over.gif");
		press_over = newImage("/images/press-over.gif");
		news_over = newImage("/images/news-over.gif");
		events_over = newImage("/images/events-over.gif");
		links_over = newImage("/images/links-over.gif");
		forum_over = newImage("/images/forum-over.gif");
		contact_over = newImage("/images/contact-over.gif");
		buy_over = newImage("/images/buynow-over.gif");
		preloadFlag = true;
	}
}

function popThisBitch(what, thingieid, groupid, groupid2) {
	window.open('/popthisbitch.php?popwhat='+what+'&thingieid='+thingieid+'&groupid='+groupid+'&groupid2='+groupid2,'popupwindow','toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,menubar=no,resizable=yes,copyhistory=no,width=400,height=400');
}

function newWindow(url, w, h) {
	window.open(url,"tum"+w,"width="+w+",height="+h+",status=yes,scrollbars=yes,resizable=yes");
}

// This function opens links in an external window in a standards compliant way.
// To use it, code the link like this:
// 		<a href="document.html" rel="external">external link</a>
function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i < anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
	     	anchor.target = "_blank";
		}
 	}
}

// Set a form target to a new target.  Use this to open a form in a new window, like this:
// <form action="whatever.php" method="post" onsubmit="return setFormTarget(this, '_blank');">
function setFormTarget(formname, new_target) {
	formname.target = new_target;
}

// Function to allow multiple onload functions to be called
function multipleOnload() {
  preloadImages();
  externalLinks();
}
window.onload = multipleOnload;
