function changeCellBgr(cellRef, imgName, pageType) {
	cellObject = document.getElementById(cellRef);
	if(pageType == "sub") {
		cellObject.background = "../images/" + imgName;
	}
	else {
		cellObject.background = "images/" + imgName;
	}
}

function changeCellXY(cellRef) {
	cellObject = document.getElementById(cellRef);
	return cellObject;
}

function showNews(newsId, pageRef) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	sTop = (sHeight - 400) / 2;
	sLeft = (sWidth - 600) / 2;
	
	if(pageRef == "sub") {
		pageUrl = "0410full.asp";
	}
	else {
		pageUrl = "asp/0410full.asp";
	}
	window.open(pageUrl + "?newsId=" + newsId, "dashennews", "width=600,height=400,top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}

function closeWindow() {
	window.opener.focus();
	window.close();
}

function calculateEMI(rowNum) {
	minAmount = 10;
	maxAmount = 1000000000000;
	minRate = 1;
	maxRate = 99;
	minInstall = 1;
	maxInstall = 480;
	
	loanElement = eval("document.forms[0].loanAmount_" + rowNum);
	interestElement = eval("document.forms[0].interestRate_" + rowNum);
	installElement = eval("document.forms[0].installments_" + rowNum);
	resultElement = eval("document.forms[0].result_" + rowNum);
	
	loanAmount = trimSpaces(loanElement.value);
	interestRate = trimSpaces(interestElement.value);
	installments = trimSpaces(installElement.value);

	if(loanAmount.length > 0) {
		if(!checkAllowedChars(loanAmount, 'N.')) {
			alert("Only numbers are allowed for loan amount");
			loanElement.select();
			loanElement.focus();
			return;
		}
		loanAmount = parseFloat(loanAmount);
		
		if(loanAmount < minAmount || loanAmount > maxAmount) {
			alert("Loan amount should be between " + minAmount + " & " + maxAmount);
			loanElement.select();
			loanElement.focus();
			return;
		}
	}
	else {
		return;
	}
	if(interestRate.length > 0) {
		if(!checkAllowedChars(interestRate, 'N.')) {
			alert("Only numbers are allowed for interest rate");
			interestElement.select();
			interestElement.focus();
			return;
		}
		interestRate = parseFloat(interestRate);
		
		if(interestRate < minRate || interestRate > maxRate) {
			alert("Interest rate should be between " + minRate + " & " + maxRate);
			interestElement.select();
			interestElement.focus();
			return;
		}
	}
	else {
		return;
	}
	if(installments.length > 0) {
		if(!checkAllowedChars(installments, 'N.')) {
			alert("Only numbers are allowed for installments");
			installElement.select();
			installElement.focus();
			return;
		}
		installments = Math.round(installments);
		
		if(installments < minInstall || installments > maxInstall) {
			alert("Installments should be between " + minInstall + " & " + maxInstall);
			installElement.select();
			installElement.focus();
			return;
		}
	}
	else {
		return;
	}

/*	monthlyInterest = ((loanAmount * interestRate) / 1200);

	multValue = (400 + interestRate) / 400;
	multValue = Math.pow(multValue, installments);

	emiValue = monthlyInterest * multValue * (1 - (interestRate / 100));
	emiValue = Math.ceil(emiValue);
	resultElement.value = emiValue + ".00";*/

	interestRate = interestRate / 1200;
	topValue = loanAmount * interestRate;
	powValue = Math.pow((1 + interestRate), installments);
	botValue = 1 - (1 / powValue);
	
	emiValue = topValue / botValue;
	emiValue = new String(emiValue);
	if(emiValue.indexOf(".") > 0) {
		emiArray = emiValue.split(".");

		psVal = emiArray[1].substring(0, 2) + "." + emiArray[1].substring(2);
		psVal = Math.round(parseFloat(psVal));
		
		emiValue = emiArray[0] + "." + psVal;
	}
	else if(emiValue.indexOf(".") == 0) {
		psVal = emiValue.substring(1, 2) + "." + emiValue.substring(3);
		psVal = Math.round(parseFloat(psVal));
		
		emiValue = "0." + psVal;
	}
	else {
		emiValue = emiValue + ".00";
	}
	
	emiFinArray = emiValue.split(".");
	if(emiFinArray[1].length < 2) {
		emiValue = emiValue + "0";
	}
	resultElement.value = emiValue;
}

function resetEMI(rowNum) {
	loanElement = eval("document.forms[0].loanAmount_" + rowNum);
	interestElement = eval("document.forms[0].interestRate_" + rowNum);
	installElement = eval("document.forms[0].installments_" + rowNum);
	resultElement = eval("document.forms[0].result_" + rowNum);
	
	loanElement.value = "";
	interestElement.value = "";
	installElement.value = "";
	resultElement.value = "0.00";
}

function netBanking(pageName, pageType) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	if(pageType == "home") {
		pageType = "asp/";
	}
	else {
		pageType = "";
	}
	
	if(pageName == "CorpAdmin") {
		window.open(pageType + "corploginFrame.asp", "dashenbank", "width=" + sWidth + ",height=" + sHeight + ",top=1,left=1,toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	}
	else if(pageName == "Retail") {
		window.open(pageType + "retailFrame.asp", "dashenbank", "width=" + sWidth + ",height=" + sHeight + ",top=1,left=1,toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	}
	else if(pageName == "Corporate") {
		window.open(pageType + "corpFrame.asp", "dashenbank", "width=" + sWidth + ",height=" + sHeight + ",top=1,left=1,toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	}
	else if(pageName == "Biller") {
		window.open(pageType + "billerFrame.asp", "dashenbank", "width=" + sWidth + ",height=" + sHeight + ",top=1,left=1,toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	}
	return;
}