//****************************************************
// IsMac
//****************************************************
function IsMac()
{
  if(navigator.appVersion.indexOf("Win") != -1)
  {
    return false;
  }
  else if(navigator.appVersion.indexOf("Mac") != -1)
  {
    return true;
  }
  else return false;
}
//****************************************************
// FilterKeyPressNumeric
// Allows digits, comma and period.
// Call format: onKeyPress="FilterKeyPressNumeric(this)"
//****************************************************
function FilterKeyPressNumeric(obj)
{
	var sString = obj.value;
	if (sString.length==0)
	{
		return;
	}
	var ch = sString.charAt(sString.length-1);
	switch(ch)
	{
		case '0': return;
		case '1': return;
		case '2': return;
		case '3': return;
		case '4': return;
		case '5': return;
		case '6': return;
		case '7': return;
		case '8': return;
		case '9': return;
		case '0': return;
		case '.': return;
		case ',': return;
	}
	
	// otherwise bad value
	sString = obj.value.substr(0,obj.value.length-1);
	obj.value = sString;
}

//****************************************************
// FilterNumeric
// Allows digits, comma and period.
// Call format: onKeyDown="FilterNumeric()"
//****************************************************
function FilterNumeric()
{
	var NS = (document.layers) ? 1 : 0;
	var Key;
	Key = (NS) ? event.which : event.keyCode;

	// allow 0 thru 9, ',' or '.' or DEL
	// Also allow TAB
	if (((Key>=48) && (Key<=57)) || (Key==188) || (Key==190) || (Key==46) || (Key==9) || (Key==16))
	{
		return;
	}
	
	//alert(Key.toString());
	
	// otherwise DEL the key
	if (NS)
	{
		event.which=46;  
	}
	else
	{
		event.keyCode=46;
	}
}
//****************************************************
// IsNumberInt
//****************************************************
function IsNumberInt(inputString)
{
  return (!isNaN(parseInt(inputString))) ? true : false;
}	
//****************************************************
// IsNumberFloat
//****************************************************
function IsNumberFloat(inputString)
{
  return (!isNaN(parseFloat(inputString))) ? true : false;
}	

//****************************************************
// popUpLinkWindow
//****************************************************
var popUpLinkWin=0;
function popUpLinkWindow(url)
{
  	if(popUpLinkWin)
  	{
    	if(!popUpLinkWin.closed) popUpLinkWin.close();
  	}
	
	popUpLinkWin = open(url, 'link', 'height=400,width=600,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,location=yes,directories=yes,status=yes');
	popUpLinkWin.focus();
}
//****************************************************
// popUpImgWindow
//****************************************************
var popUpImgWin=0;
function popUpImgWindow(url)
{
  	if(popUpImgWin)
  	{
    	if(!popUpImgWin.closed) popUpImgWin.close();
  	}
	
	popUpImgWin = open(url, 'img', 'top=3000,left=3000,height=1,width=1,toolbar=no,menubar=no,scrollbars=no,resizable=yes,location=yes,directories=no,status=no,dependent=yes');
	popUpImgWin.resizeTo(1,1);
	popUpImgWin.moveTo(2000,2000);
	popUpImgWin.blur();
	//popUpImgWin.close();
}

var popUpWin=0;
function popUpWorkWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

//****************************************************
// ConvertHTML
// Converts the opening and closing HTML tags to parens
//****************************************************
function ConvertHTML(sInput)
{
	var sOutput = sInput;
    sOutput=sOutput.replace(/</g,"(");
    sOutput=sOutput.replace(/>/g,")");
	return sOutput;
}
//****************************************************
// JSTrim
// Removes leading and trailing characters from a string
//****************************************************
function JSTrim (inputString, removeChar) 
{
	var returnString = inputString;
	if (removeChar.length)
	{
	  while(''+returnString.charAt(0)==removeChar)
		{
		  returnString=returnString.substring(1,returnString.length);
		}
		while(''+returnString.charAt(returnString.length-1)==removeChar)
	  {
	    returnString=returnString.substring(0,returnString.length-1);
	  }
	}
	return ConvertHTML(returnString);
}
//****************************************************
// JSTrimSpace
// Removes leading and trailing spaces from a string
//****************************************************
function JSTrimSpace(inputString)
{
	return JSTrim(inputString,' ');
}

