var MyBB = {
	popupWindow: function(url, name, width, height) {
		var settings = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes';
		if(width)  settings += ',width='+width;
		if(height) settings += ',height='+height;
		window.open(url, name, settings);
	},

	newPM: function() {
		if(!confirm("You have received a new private message. Click OK to view it, or Cancel to hide this prompt.")) return;

		window.open('private.php', 'pmPopup', 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=500');
	},

	reputation: function(uid, type) {
		MyBB.popupWindow('reputation.php?uid='+uid+'&type='+type, 'reputation', 400, 350);
	},

	whoPosted: function(tid) {
		MyBB.popupWindow('misc.php?action=whoposted&tid='+tid, 'whoPosted', 230, 300);
	},

	checkAll: function(eltForm, eltMaster) {
		for(var i=0; i < eltForm.elements.length; i++) {
			var elt = eltForm.elements[i];
			if(elt.tagName.toLowerCase() == 'input' && elt.type.toLowerCase() == 'checkbox' && elt.name != 'allbox') {
				elt.checked = eltMaster.checked;
			}
		}
	},

	addOnloadFunction: function(func) {
		if(typeof window.onload == 'function') {
			var oldOnload = window.onload;
			window.onload = function() {
				if(oldOnload) oldOnload();
				func();
			};
		} else {
			window.onload = func;
		}
	}
};

function confirmrs() { return confirm("Are you sure you want to reset the form?"); }
function imgResize(img,max) { if(max == null) { max = 150; } if(img.width && img.width > max) { img.width = max; } }

// Deprecated
function popupWin(url, window_name, window_width, window_height) {
	settings="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+window_width+",height="+window_height;
	NewWindow=window.open(url,window_name,settings);
}

// Deprecated
function whoPosted(tid) { popupWin("misc.php?action=whoposted&tid="+tid, "whoPosted", 230, 300); }
// Deprecated
function reputation(uid,type) { popupWin("reputation.php?uid="+uid+"&type="+type, "reputation", 400, 300); }

var agt = navigator.userAgent.toLowerCase();
var agt_ver = parseInt(navigator.appVersion);
var is_mozilla = (navigator.product == "Gecko");
var is_opera = (agt.indexOf("opera") != -1);
var is_konqueror = (agt.indexOf("konqueror") != -1);
var is_webtv = (agt.indexOf("webtv") != -1);
var is_ie = ((agt.indexOf("msie") != -1) && (!is_opera) && (!is_webtv));
var is_netscape = ((agt.indexOf("compatible") == -1) && (agt.indexOf("mozilla") != -1) && (!is_opera) && (!is_webtv));
var is_win = (agt.indexOf("win" != -1));
var is_mac = (agt.indexOf("mac") != -1);
