// Version 5.5.0 - Last modified 5/9/2005

function MM_findObj(n, d) { //v4.01
	var p,i,x;
	if(!d) d=document;
	if( (p=n.indexOf("?")) > 0 && parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n];
	for (i=0; !x && i<d.forms.length; i++) x=d.forms[i][n];
	for(i=0; !x && d.layers && i < d.layers.length; i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n);
	return x;
}


function MM_showHideLayers() { //v6.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) {
		v=args[i+2];
		if (obj.style) {
			obj=obj.style;
			v=(v=='show')?'visible':(v=='hide')?'hidden':v;
		}
		obj.visibility=v;
	}
}


function op_roll_change() {
	var args = op_roll_change.arguments;
	var op = args[0]; // 0 = hide all, 1 = show first
	var item;

	// Show/hide 1st ID
	item = document.getElementById(args[1]);
	if (op == 1) {
		item.style.display = 'block';
	} else {
		item.style.display = 'none';
	}

	for (i = 2; i < (args.length); i++) {
		// Hide all other IDs
		item = document.getElementById(args[i]);
		item.style.display = 'none';
	}
}


function MM_setTextOfTextfield(objName,x,newText) { //v3.0
	var obj = MM_findObj(objName);
	if (obj) obj.value = newText;
}


function MM_validateForm() { //v4.0
	var i, p, q, nm, test, num, min, max;
	var errors = '';
	var args = MM_validateForm.arguments;

	for (i = 0; i < (args.length-2); i += 3) {
		test = args[ i + 2 ];
		val = MM_findObj(args[i]);
		if (val) {
			nm=val.name;
			if ((val=val.value) != "") {
				if (test.indexOf('isEmail') != -1) {
					p = val.indexOf('@');
					if (p < 1 || p == (val.length-1)) errors += '- '+nm+' must contain an e-mail address.\n';
				} else if (test != 'R') {
					num = parseFloat(val);
					if (isNaN(val)) errors += '- '+nm+' must contain a number.\n';
					if (test.indexOf('inRange') != -1) {
						p = test.indexOf(':');
						min = test.substring(8, p);
						max = test.substring(p + 1);
						if (num < min || max < num) errors += '- '+nm+' must contain a number between '+min+' and '+max+'.\n';
					}
				}
			} else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n';
		}
	}

	if (errors) alert('The following error(s) occurred:\n' + errors);
	document.MM_returnValue = (errors == '');
}


// Wac: List of invalid chars for name/pass checking
function badChars(test) {
	var badsymbols = new Array('\'', '\"', '$', '#', '+', '&', '=','*', ':', ';', '/', '\\');

	for (var i = 0; i < badsymbols.length; i++) {
		if (test.indexOf(badsymbols[i]) != -1) {
			return badsymbols[i];
		}
	}
	return 0;
}


// Wac: Checks name for invalid chars
function checkName(name) {
	var n1 = document.getElementById(name);

	var result = badChars(n1.value);
	if (result == '\'' || result == '\"') {
		alert('Do not use double quotes or apostrophes in your name');
		return 0;
	}
	if (result) {
		alert('Do not use the following characters in your name: \' \" $ # & = * + : ; / \\');
		return 0;
	}
	return 1;
}


// Wac: Checks passwords
function checkPass(pass1, pass2) {
	var p1 = document.getElementById(pass1);
	var p2 = document.getElementById(pass2);

	var result = badChars(p1.value);
	if (result == '\'' || result == '\"') {
		alert('Do not use double quotes or apostrophes in your password');
		return 0;
	}
	if (result) {
		alert('Do not use the following characters in your password: \' \" $ # & = * + : ; / \\');
		return 0;
	}

	if (p1.value != '' && p2.value != '') {
		if (p1.value != p2.value) {
			alert('Passwords do not match');
			return 0;
		}
	}
	return 1;
}


function openWindow(url, w, h) {
	var options = "width=" + w + ",height=" + h + ",";
	options += "resizable=yes,scrollbars=yes,status=no,";
	options += "menubar=no,toolbar=no,location=no,directories=no";
	var newWin = window.open(url, 'newWin', options);
	newWin.focus();
}


function openOnline(url, w, h) {
	var options = "width=" + w + ",height=" + h + ",";
	options += "resizable=yes,scrollbars=yes,status=no,";
	options += "menubar=no,toolbar=no,location=no,directories=no";
	var newWin = window.open(url, 'newOl', options);
	newWin.focus();
}


function openChat(url, w, h) {
	var options = "width=" + w + ",height=" + h + ",";
	options += "resizable=yes,scrollbars=yes,status=no,";
	options += "menubar=no,toolbar=no,location=no,directories=no";
	var newWin = window.open(url, 'chatWin', options);
	newWin.focus();
}


function openProfile(url, w, h) {
	var options = "width=" + w + ",height=" + h + ",";
	options += "resizable=yes,scrollbars=yes,status=no,";
	options += "menubar=no,toolbar=no,location=no,directories=no";
	var newWin = window.open(url, 'tehprofile', options);
	newWin.focus();
}


function o(url) {
	window.open("profile.php?user="+url, 'profileWin', "width=300,height=400,resizable=yes,scrollbars=yes,status=no,menubar=no,toolbar=no,location=no");
	return false;
}