function gwAddLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		};
	}
}

function gwIncludeScript() {
	var gwbbcode_dynamic_root = 'gwbbcode';
	var gwbbcode_skin = 'pvxwiki';

	/* Include the send iframe for the pickup feature */
	var send_frame = document.createElement('iframe');
	send_frame.id = 'send';
	send_frame.style.display = 'none';
	send_frame.src = 'about:blank';
	document.body.insertBefore(send_frame, document.body.firstChild);

	/* Include the gwbbcode.css */
	var headID = document.getElementsByTagName("head")[0];
	var cssNode = document.createElement('link');
	cssNode.type = 'text/css';
	cssNode.rel = 'stylesheet';
	cssNode.href = gwbbcode_dynamic_root + '/templates/' + gwbbcode_skin + '/gwbbcode.css';
	cssNode.media = 'screen';
	headID.appendChild(cssNode);

	/* Include wz_tooltip.js */
	var include_wz_tooltip = document.createElement('script');
	include_wz_tooltip.type = 'text/javascript';
	include_wz_tooltip.src = gwbbcode_dynamic_root + '/js/wz_tooltip.js';
	document.body.insertBefore(include_wz_tooltip, document.body.firstChild);

	/* Include gwbbcode.js */
	var include_gwbbcode = document.createElement('script');
	include_gwbbcode.type = 'text/javascript';
	include_gwbbcode.src = gwbbcode_dynamic_root + '/js/gwbbcode.js';
	document.body.insertBefore(include_gwbbcode, document.body.firstChild);

	/* Preload images */
	if (document.images) {
		var pic1 = new Image(220, 19); 
		pic1.src = gwbbcode_dynamic_root + '/templates/' + gwbbcode_skin + '/images/interface/rating_loading.gif'; 
		var pic2 = new Image(16, 48); 
		pic2.src = gwbbcode_dynamic_root + '/templates/' + gwbbcode_skin + '/images/interface/star.png'; 
		var pic3 = new Image(25, 75); 
		pic3.src = gwbbcode_dynamic_root + '/templates/' + gwbbcode_skin + '/images/interface/star2.png'; 
		var pic4 = new Image(16, 13); 
		pic4.src = gwbbcode_dynamic_root + '/templates/' + gwbbcode_skin + '/images/interface/rating_tick.gif';
		var pic5 = new Image(14, 14); 
		pic5.src = gwbbcode_dynamic_root + '/templates/' + gwbbcode_skin + '/images/interface/rating_warning.gif';
	}
}

gwAddLoadEvent(gwIncludeScript);