﻿// JavaScript File

popupwin = new Array;
function ShowPopup(page,name,options)
{
popupwin[popupwin.length] = window.open(page,name,options);
}


function popupWin(URL,width,height)
{ NewWin = window.open(URL,"window","width="+width+",height="+height+",status=no,scrollbars=yes,resize=yes,menubar=no"); }

function clickButton(e,buttonid)
{ 
debugger;
var bt=document.getElementById(buttonid);
if(typeof bt=='object')
{
if(navigator.appName.indexOf("Netscape")>(-1))
{
if(e.keyCode == 13)
{
if (bt && typeof(bt.click) == 'undefined')
{
bt.click = addClickFunction1(bt);
return false;
} 
}
}

if(navigator.appName.indexOf("Microsoft Internet Explorer")>(-1) | navigator.appName.indexOf("Opera")>(-1))
{
if(event.keyCode == 13)
{
bt.click();
return false;
}
}
}
} 

function addClickFunction1(bt)
{
debugger;
var result = true;
if (bt.onclick) result = bt.onclick();
if (typeof(result) == 'undefined' || result)
{
eval(bt.href); 
}
}

// Function to format totals to 2 decimal places
	function checkDecimals(fieldName, fieldValue) {

	    decallowed = 2;  // how many decimals are allowed?

   	    if (isNaN(fieldValue) || fieldValue == "" || (fieldName!= "bonus_deduction" && fieldValue<0)) {
	        alert("Please enter a valid value.");
	        eval("document.aspnetForm." + fieldName + ".select()");
	        eval("document.aspnetForm." + fieldName + ".value='0'");
	        eval("document.aspnetForm." + fieldName + ".focus()");
	        return 0;
	    }
	    else {
	    if (fieldValue.indexOf('.') == -1) fieldValue += ".";
	        dectext = fieldValue.substring(fieldValue.indexOf('.')+1, fieldValue.length);

	        if (dectext.length > decallowed)
	        {
	            alert ("Please enter a value with up to 2 decimal places only.");
	            eval("document.aspnetForm." + fieldName + ".select()");
	            eval("document.aspnetForm." + fieldName + ".focus()");
	            return 0
            }
	        else {
	            var TwoDecValue = eval(fieldValue).toFixed(2);
	            eval("document.aspnetForm." + fieldName + ".value='" + TwoDecValue + "'");
	            return 1;
            }
  	    } 
	}





