function did(id) {
    return document.getElementById(id);
}
function ShowHide(id) {
	obj = document.getElementById(id);
	if (obj.style.display == 'block'){
	obj.style.display = 'none';
	}
	else {
	obj.style.display = 'block';
	}
}

function setColor1(cell) {
	cell.style.backgroundColor = '#FFE7A6';
}
function resetColor1(cell) {
	cell.style.backgroundColor = '#FFFFFF';
}
function setColor2(cell) {
	cell.style.backgroundColor = '#FFE7A6';
}
function resetColor2(cell) {
	cell.style.backgroundColor = '#F1F5FA';
}

function setRowHover(cell) {
	cell.className = 'list_row_hover';
}
function resetRow1(cell) {
	cell.className = 'list_row1';
}

function resetRow2(cell) {
	cell.className = 'list_row2';
}

function handySelectAll(id) {
	_select_opt_list = document.getElementById(id);
	for (var i = _select_opt_list.length - 1; i >= 0; i--) {
       _select_opt_list.options[i].selected = true;
    }
}

function handyDeselectAll(id) {
	_select_opt_list = document.getElementById(id);
	for (var i = _select_opt_list.length - 1; i >= 0; i--) {
       _select_opt_list.options[i].selected = false;
    }
}

function doRBC(elem, id) {
	elem.style.color='#FF0000'; 
	elem.style.fontWeight='bold'; 
	
	if (id > 0 && document.getElementById('res_data[' + id + '][update]')) {
		document.getElementById('res_data[' + id + '][update]').checked = true;
	}
}

function URLEncode(mystr) {
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" + // Numeric
	"ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic
	"abcdefghijklmnopqrstuvwxyz" +
	"-_.!~*'()"; // RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";
	
	var plaintext = mystr;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
		if (ch == " ") {
			encoded += "+"; // x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
			encoded += ch;
		} else {
			var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for
	return encoded;
};
