function getObj(name) {
  if (document.getElementById) {
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
  } else if (document.all) {
		this.obj = document.all[name];
		this.style = document.all[name].style;
  } else if (document.layers) {
		this.obj = document.layers[name];
		this.style = document.layers[name];
  }
}

function resetTextFieldValue(fieldID, newValue) {
   field = new getObj(fieldID);
   field.obj.value = newValue;
}

function hideTableRow(rowID) {
   row = new getObj(rowID);
   row.style.display = 'none';
}

function showTableRow(rowID) {
   row = new getObj(rowID);
   row.style.display = "";
}

function switchTableRowDisplay(rowID) {
   row = new getObj(rowID);
   if(row.style.display == 'none') {
      showTableRow(rowID);
   } else {
      hideTableRow(rowID);
   }
}

function scrollBottom() {
   window.scrollTo(0,document.body.scrollHeight)
}

function confirmEntry(theLink) {
   input_box=confirm("Are you sure you want to delete the item?");
   if(input_box==true) {
      window.location = theLink;
   }
}

function confirmEntryWithPrompt(theLink, thePrompt) {
   input_box=confirm(thePrompt);
   if(input_box==true) {
      window.location = theLink;
   }
}

var gAutoPrint = false; // Flag for whether or not to automatically call the print function

function printSpecial()
{
	if (document.getElementById != null)
	{
		var html = '<HTML>\n<HEAD>\n';

		if (document.getElementsByTagName != null)
		{
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
				html += headTags[0].innerHTML;
		}
		
		html += '\n</HE' + 'AD>\n<BODY style="background-color:#FFFFFF;">\n';
		
		var printReadyElem = document.getElementById("printReady");
		
		if (printReadyElem != null)
		{
				html += printReadyElem.innerHTML;
		}
		else
		{
			alert("Could not find the printReady section in the HTML");
			return;
		}
			
		html += '\n</BO' + 'DY>\n</HT' + 'ML>';

		var printWin = window.open("","printSpecial");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();

	}
	else
	{
		alert("Sorry, the print ready feature is only available in modern browsers.");
	}
}

function PrintThisPage() 
{ 
   var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,resizable=yes,"; 
       sOption+="scrollbars=yes,width=750,height=600,left=100,top=25"; 

   var sWinHTML = document.getElementById('printReady').innerHTML; 
   
   var winprint=window.open("","",sOption); 
       winprint.document.open(); 
       winprint.document.write('<html><LINK href=print_styles.css rel=Stylesheet><body style="background-color:#FFFFFF;>'); 
       winprint.document.write(sWinHTML);          
       winprint.document.write('</body></html>'); 
       winprint.document.close(); 
       winprint.focus(); 
}

function numbersonly(e, decimal) {
	var key;
	var keychar;
	
	if (window.event) {
	   key = window.event.keyCode;
	}
	else if (e) {
	   key = e.which;
	}
	else {
	   return true;
	}
	keychar = String.fromCharCode(key);
	
	if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) ) {
	   return true;
	}
	else if ((("0123456789").indexOf(keychar) > -1)) {
	   return true;
	}
	else if (decimal && (keychar == ".")) { 
	  return true;
	}
	else
	   return false;
 }

//-------------------------------------
// Get the HTTP Object
function getHTTPObject() {
   if (window.ActiveXObject)
      return new ActiveXObject("Microsoft.XMLHTTP");
   else if (window.XMLHttpRequest)
      return new XMLHttpRequest();
   else {
      alert("Your browser does not support AJAX.");
      return null;
   }
}