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 toggle () { //v6.0
	var
		i,
		p,
		v,
		obj,
		args = toggle.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 sortBy (key, table, mode) {
	if (mode == 'ASC') mode = 'DESC';
	else mode = 'ASC';
	window.location.href = '?sortTable=' + table +  '&sortField=' + key + '&sortMode=' + mode;
}

function delId (id, table) {
	if (confirm ('Are you sure?')) window.location.href='?delId=' + id + '&table=' + table;
}
function sendText (id) {
	if (confirm ('Are you sure?')) window.location.href='?sendTextId=' + id;
}
function checkAll (object) {
	var elems = object.form.elements;
	for (var i = 0; i < elems.length; i++) {
		var elem = elems[ i ];
		if (elem.type == 'checkbox' && elem != this) {
			elem.checked = object.checked;
		}
	}
}

function debugElement(elem) {
	str = "";
	j = 0;
	for (i in elem) {
		//str+="<center><big>" + i + "</big></center><br/>\n";
		str+=i + "\n";
		j++;
		if (j==40) {
			//document.write(str);
			alert(str);
			str="";
			j = 0;
		}
	}
}

function xwin(url, name, width, height, features){
  var l = (window.screen.availWidth) ? (window.screen.availWidth - width)/2 : 0;
  var t = (window.screen.availHeight) ? (window.screen.availHeight - height)/2 : 0;
  if (typeof(features) == 'string')
     features = ',' + features;

  var w = window.open(url, name, 'top=' + t + ',left=' + l + ',height=' + height + ',width=' + width + features);
  if (!w){
     return;
  }
  w.resizeTo(width, height);
  return w;
}
