/*************************************************************************************************/

/* browser check
if (!document.getElementById) {
    window.location = 
	   "upgrade/"
}
*/

/*************************************************************************************************/

// popup window function

var win = null;
function popup(mypage,myname,w,h,scroll) {
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+scroll+',';
      settings +='resizable=yes';
  win=window.open(mypage,myname,settings);
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

// usage:
// onclick="popup('url','name','400','400','yes');return false"

/*************************************************************************************************/

// this rule will be hidden from non-javascript browsers
// this is necessary so that some content defaults to visible instead of hidden
document.write('<style type="text/css">');
document.write('.hidden{display:none;}');
document.write('</style>');

function show(id) {
	document.getElementById(id).style.display = "block";
}

function hide(id) {
	document.getElementById(id).style.display = "none";
}


/*************************************************************************************************/

function flipTab(old_tab, new_tab, path) {
	// hide the old tab and change it's class
	var ot    = document.getElementById(old_tab);
	var otBox = document.getElementById(old_tab + 'Box');
	var otImg = document.getElementById(old_tab + 'Img');

	// test to make sure they aren't clicking on the same box that is open
	var otCheck = new RegExp('\\bselected\\b').test(ot.className);

	if (!otCheck) {
		return;
	}

	// define the off image
	otOffImage = new Image(138,26);
	otOffImage.src = path + "/" + old_tab + ".gif";

	ot.className        = ot.className.replace('selected', '');
	otBox.style.display = "none";

	otImg.src = otOffImage.src; // flip the on image for the off

	// show the new tab
	var nt    = document.getElementById(new_tab);
	var ntBox = document.getElementById(new_tab + 'Box');
	var ntImg = document.getElementById(new_tab + 'Img');

	// define the on image
	ntOnImage = new Image(138,26);
	ntOnImage.src = path + "/" + new_tab + "Selected.gif";

	nt.className        = nt.className.replace('', 'selected');
	ntBox.style.display = "block";

	ntImg.src = ntOnImage.src;  // flip the off image for the on
}

function switchTab(old_tab, new_tab)
{
	var ot = document.getElementById(old_tab);
	var ot_selected = document.getElementById(old_tab + 'Selected');
	var ot_box = document.getElementById(old_tab + 'Box');
	
	var nt = document.getElementById(new_tab);
	var nt_selected = document.getElementById(new_tab + 'Selected');
	var nt_box = document.getElementById(new_tab + 'Box');
	
	//deselect old tab
	ot.style.display = "block";
	ot_selected.style.display = "none";
	ot_box.style.display = "none";
	
	//select new tab
	nt_selected.style.display = "block";
	nt.style.display = "none";
	nt_box.style.display = "block";
}

/*************************************************************************************************/
//this function will check or uncheck all checkboxes w/ a given field name
//form is the id of the form containing the checkboxes (in plain text)
//field is the name of the checkbox array (in plain text)
//value is true for check, false for uncheck
//there is extra code to handle checkbox arrays with [] in them.

function checkAll(form, field, value)
{
	var form = document.getElementById(form);
	var fields = form.getElementsByTagName('input');
	
	for (i = 0; i < fields.length; i++)
	{
		var regex = new RegExp(field, "i");
		if (regex.test(fields[i].getAttribute('name'))) 
		{
			fields[i].checked = value;
		}
	}
}
/*************************************************************************************************/