function fixIE6flicker(fix) {
	try {
		document.execCommand("BackgroundImageCache", false, fix);
	} catch(err) { }
}
fixIE6flicker(true);

var newWin = null;
function popUp(strURL, strType, strHeight, strWidth) {
 if (newWin != null && !newWin.closed)
   newWin.close();
 var strOptions="";
 if (strType=="console")
   strOptions="resizable,height="+
     strHeight+",width="+strWidth;
 if (strType=="fixed")
   strOptions="status,height="+
     strHeight+",width="+strWidth;
 if (strType=="elastic")
   strOptions="scrollbars,"+
     "resizable,location,height="+
     strHeight+",width="+strWidth;
 newWin = window.open(strURL, 'newWin', strOptions);
 newWin.focus();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

var win= null;
function NewWindow(mypage,myname,w,h,scroll,resize){
  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='+resize;
	  if (win){
		win.close();
		}
  win=window.open(mypage,myname,settings);
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

function intOnly(i) {
	var t;
	if(i.value.length>0) {
	i.value = i.value.replace(/[^.\d]+/g, ''); 
	}
}

function round(number,X) {
		// rounds number to X decimal places, defaults to 2
		X = (!X ? 2 : X);
		return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
	}
	
function sortnumber(number) {
	if(number.length>0) {
	number = number.replace(/[^.\d]+/g, '');
	}
	x = eval(number);	
	if (isNaN(x)) {
		return 0;}
	else {
		return(eval(x));
	};
}

function incomeTotal() {
    document.getElementById('frmTotalIncome').innerHTML = round(sortnumber(document.getElementById('frmSalary').value) + sortnumber(document.getElementById('frmRegularOT').value) + sortnumber(document.getElementById('frmCarallowance').value) + sortnumber(document.getElementById('frmOtherIncome').value), 2);
	//standardform.frmTotalIncome.value=round(sortnumber(standardform.frmSalary.value)+sortnumber(standardform.frmRegularOT.value)+sortnumber(standardform.frmCarallowance.value)+sortnumber(standardform.frmOtherIncome.value),2);
}

function expenditureTotal() {
    document.getElementById('frmTotalExpenditure').innerHTML = round(sortnumber(document.getElementById('frmMortgageRent').value) + sortnumber(document.getElementById('frmOtherLoans').value) + sortnumber(document.getElementById('frmUtilitybills').value) + sortnumber(document.getElementById('frmCreditcards').value) + sortnumber(document.getElementById('frmOtherExpenses').value) + sortnumber(document.getElementById('frmCarpayment').value), 2);
	//standardform.frmTotalExpenditure.value=round(sortnumber(standardform.frmMortgageRent.value)+sortnumber(standardform.frmOtherLoans.value)+sortnumber(standardform.frmUtilitybills.value)+sortnumber(standardform.frmCreditcards.value)+sortnumber(standardform.frmOtherExpenses.value)+sortnumber(standardform.frmCarpayment.value),2);
}


