var linkClicked = false;

function linkClick(loc) {
  if (!linkClicked) {
    linkClicked = true;
    
    // MJF - changed for two reasons - document.location is "deprecated" (apparently?? - should check into further) and location.replace keeps the user rom hitting "back button"
    
    location.replace(loc);
    //          document.location = loc;
  }           
}

function confirmLinkClick(loc, confirmText) {
  if (confirm(confirmText)) {
    if (!linkClicked) {
      linkClicked = true;
      
      // MJF - changed for two reasons - document.location is "deprecated" (apparently?? - should check into further) and location.replace keeps the user rom hitting "back button"
      location.replace(loc);
      //            document.location = loc;
    }           
  }
  
  //        return 0;
}

var formSubmitted = false;

function buttonClick(name) 
{
  if (!formSubmitted) {
    formSubmitted = true;
    
    //document.getElementByName(name).style.border="3px white";
    document.forms[name].submit();
    return 1;
  }
  
  return 0;
}

function confirmButtonClick(name, confirmText) 
{
  if (confirm(confirmText)) { 
    if (!formSubmitted) {
      formSubmitted = true;
      
      //document.getElementByName(name).style.border="3px white";
      document.forms[name].submit();
      return 1;
    }
  }
  
  return 0;
}

function confirmDelete(itemName, formName)
{
  var answer = confirm("Are you sure you really want to delete this " + itemName + "?");
  
  if (answer){
    buttonClick(formName);
  }
}

function isNumberKey(evt)
{
  var charCode = (evt.which) ? evt.which : event.keyCode
  if (charCode > 31 && (charCode < 48 || charCode > 57))
    return false;
  
  return true;
}

function FormatNumber(num,decimalNum)
{ 
  if (isNaN(parseInt(num))) return "NaN";
  
  var tmpNum = num;
  var iSign = num < 0 ? -1 : 1;		// Get sign of number
  var bolLeadingZero = false;
  var bolParens = false;
  var bolCommas = true;
  
  // Adjust number so only the specified number of numbers after
  // the decimal point are shown.
  tmpNum *= Math.pow(10,decimalNum);
  tmpNum = Math.round(Math.abs(tmpNum))
  tmpNum /= Math.pow(10,decimalNum);
  tmpNum *= iSign;					// Readjust for sign
  
  
  // Create a string object to do our formatting on
  var tmpNumStr = new String(tmpNum);
  
  // See if we need to strip out the leading zero or not.
  if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
    if (num > 0)
      tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
    else
      tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length);
  
  // See if we need to put in the commas
  if (bolCommas && (num >= 1000 || num <= -1000)) {
    var iStart = tmpNumStr.indexOf(".");
    if (iStart < 0)
      iStart = tmpNumStr.length;
    
    iStart -= 3;
    while (iStart >= 1) {
      tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart,tmpNumStr.length)
      iStart -= 3;
    }		
  }
  
  // See if we need to use parenthesis
  if (bolParens && num < 0)
    tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";
  
  return tmpNumStr;		// Return our formatted string!
}

var hidden = true;

function notImplemented(feature) {
  alert('Sorry, ' + feature + ' has not yet been implemented...Check back soon and check the ' +
        'News/Updates page for all the latest features!');
  //          window.stop();
  
  //        mywindow = window.open ("","mywindow",
  //        "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,width=500,height=100");
  //        mywindow.document.write('Sorry, ' + feature + ' has not yet been implemented...' +
  //        'Check back soon and check the News/Updates page for all the latest features!');
  return false;
}

function minimize(id) {
  //if (hidden == true) {
  if (document.getElementById(id).style.display == 'none') {
    document.getElementById(id).style.display='block';
    //hidden = false;
  }
  else {
    document.getElementById(id).style.display='none';
    //hidden = true;
  }
}

//  function alphaNumericOnly(e) {
//    var keynum;
//
//    if (window.event) // IE
//    {
//      keynum = e.keyCode;
//    } else if(e.which) // Netscape/Firefox/Opera
//    {
//      keynum = e.which;
//    }
//
//    if (keynum > 96 && keynum < 123) return true;			// Lowercase letters
//    if (keynum > 64 && keynum < 91)  return true;			// Uppercase letters
//    if (keynum > 47 && keynum < 58)  return true;			// Numbers
//    if (keynum == 32) return true;					// Space
//    if (keynum == 46) return true;					// Period
//    if (keynum == 95 || keynum == 8 || keynum == 45) return true;	// Underscore, BS, Dash
//    return false;
//  }

//function alphanumeric(alphane)
//{
//	var numaric = alphane;
//	for(var j=0; j<numaric.length; j++)
//		{
//		  var alphaa = numaric.charAt(j);
//		  var hh = alphaa.charCodeAt(0);
//		  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
//		  {
//		  }
//		else	{
//                         alert("Your Alpha Numeric Test Failed");
//			 return false;
//		  }
// 		}
// alert("Your Alpha Numeric Test Passed");
// return true;
//}



