function toggle(obj, $this, title0, title1) {
	var el = theObject(obj);
	if (el) {
		el.style.display = (el.style.display != 'none') ? 'none' : '';
		if (title0 && (el.style.display != 'none')) {
			$this.innerHTML = title0;
		}
		if (title1 && (el.style.display == 'none')) {
			$this.innerHTML = title1;
		}
	}

	return false;
}

function myToggle($on, $off) {
	$on[0]	= document.getElementById($on[0]);
	$off[0]	= document.getElementById($off[0]);
	$on[1]	= document.getElementById($on[1]);
	$off[1]	= document.getElementById($off[1]);
	if ($on[0] && $off[0]) {
		$on[1].className		= $on[2];
		$off[1].className		= $off[2];

		$off[0].style.display	= 'none'
		$on[0].style.display	= '';
	}
	return false;
}

function mySwap($id1, $id2) {
	var $t1	= document.getElementById($id1).cloneNode(true);
	var $t2	= document.getElementById($id2).cloneNode(true);
	var $p1 = document.getElementById($id1).parentNode;
	var $p2 = document.getElementById($id2).parentNode;

	$p1.replaceChild($t2, document.getElementById($id1));
	$p2.replaceChild($t1, document.getElementById($id2));
}

function _o($id) {
	return theObject($id);
}
function theObject($id) {
	return document.getElementById($id);
}

function theNames($name) {
	return document.getElementsByName($name);
}

function trimString(str) {
	while (str.charAt(0) == ' ')  str = str.substring(1);
	while (str.charAt(str.length - 1) == ' ')  str = str.substring(0, str.length - 1);
	return str;
}

function addClass($this, $class) {
	var $temp	= $this.className.split(" ");
	$temp.push($class);
	$this.className	= $temp.join(" ");
}

function removeClass($this, $class) {
	var $temp	= $this.className.split(" ");
	var $n	= $temp.length;
	while($n--) {
		if ($temp[$n] == $class) { $temp[$n]= ""; }
	}
	$this.className	= $temp.join(" ");
}

function clearField($this) {
	if (trimString($this.value) == trimString($this.title)) {
		$this.parentNode.style.background	= "#fff";
		$this.className	= "text edit";
		$this.value 	= '';
	}
}

function restoreField($this) {
	$this.value	= trimString($this.value);
	if (!$this.value) {
		$this.parentNode.style.background	= "#fbfbfb";
		$this.className	= "text";
		$this.value 	= trimString($this.title);
	}
}

function openerUrl($url) {
//	if (opener && !opener.closed) {
//		opener.location.href = $url;
//	} else {
		$form			= document.createElement('FORM');
		$form.target	= '_blank';
		$form.action	= $url;
		$form.method	= 'post';
		document.body.appendChild($form);
		$form.submit();
//	}
	return false;
}

function doSubmit($form, $input, $value, $submit) {
	$submit	= $submit ? $submit : false;
	if (document.forms[$form]) {
		if (document.forms[$form].elements[$input]) {
			document.forms[$form].elements[$input].value	= $value;
			if ($submit) {
				document.forms[$form].submit();
			}
		}
	}
	return false;
}
