function SetFocus() {
	if (document.forms.length > 0) {
		var field = document.forms[0];
		for (i=0; i<field.length; i++) {
			if ( (field.elements[i].type != "image") &&
			(field.elements[i].type != "hidden") &&
			(field.elements[i].type != "reset") &&
			(field.elements[i].type != "submit") ) {

				document.forms[0].elements[i].focus();

				if ( (field.elements[i].type == "text") ||
				(field.elements[i].type == "password") )
				document.forms[0].elements[i].select();

				break;
			}
		}
	}
}

function rowOverEffect(object) {
	if (object.className == 'dataTableRow') object.className = 'dataTableRowOver';
}

function rowOutEffect(object) {
	if (object.className == 'dataTableRowOver') object.className = 'dataTableRow';
}

var newWin=null;
function popUp(theURL,width,height)
{
	if ((newWin!=null) && ! newWin.closed)
	{
		newWin.location= theURL ;
		newWin.focus();
	}
	else
	{
		newWin= window.open(theURL,"popUpWin", 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+'');
		newWin.opener=self;
		newWin.focus();
	}
}

function toggle_visibility(id){

	if (document.all)	{
		if (document.all[id].style.display == 'none')	{
			document.all[id].style.display = '' ;
		} else {
			document.all[id].style.display = 'none';
		}
	}
	else if (document.getElementById)	{
		if(document.getElementById(id).style.display == 'none'){
			document.getElementById(id).style.display = '' ;
		} else	{
			document.getElementById(id).style.display = 'none';
		}
	}
}

function uncheck_checkbox(id){

	if (document.all)	{
		document.all[id].checked = false
	}
	else if (document.getElementById)	{
		document.getElementById(id).checked = false
	}
}


//var checkflag = "false";
function check_all(field, checkflag) {
	if (checkflag == true)
	{
		for (i = 0; i < field.length; i++)
		{
			field[i].checked = true;
		}
		checkflag = "true";
		return "Uncheck All";
	}
	else {
		for (i = 0; i < field.length; i++)
		{
			field[i].checked = false;
		}
		checkflag = "false";
		return "Check All";
	}
}

function count_checkboxes(field)
{
	var counter=0;

	for (i = 0; i < field.length; i++)
	{
		if (field[i].checked == true) counter++;
	}

	return counter;
}

function swap_contents(id1, id2)
{
  var content = document.getElementById(id1).innerHTML;
  document.getElementById(id1).innerHTML = document.getElementById(id2).innerHTML;
  document.getElementById(id2).innerHTML = content;
}