﻿
function createLoan() {

	myLoan = createDiv('absolute');
	myLoan.style.visibility = 'hidden';
//	myLoan.style.backgroundColor = "red";

	var txtContent = ['<b>HOUSING LOAN PROGRAM</b>', '<b>LOAN ENTITLEMENT BASED IN Pag-IBIG CONTRIBUTIONS</b>',
					'A member\'s loan entitlement shall be proportionate to his Pag-IBIG contributions (inclusive of the employer counterpart contributions), which shall be based on the following schedule:'];

	loanDiv = createDiv('absolute');
//	loanDiv.style.overflowY = "auto";
//	loanDiv.style.overflowX = "hidden";
	myLoan.appendChild(loanDiv);

	myLoanTxt = new Array();

	for(c=0; c<txtContent.length; c++) {
		myLoanTxt[c] = createP(txtContent[c]);
		myLoanTxt[c].style.visibility = 'hidden';
		myLoanTxt[c].style.position = "absolute";
		if(c>0) myLoanTxt[c].style.width = "80%";
		clearMargins(myLoanTxt[c]);
		loanDiv.appendChild(myLoanTxt[c]);
	}

	loanTable = document.createElement('table');
	loanTable.style.position = "absolute";
	loanTable.style.visibility = "hidden";
	loanDiv.appendChild(loanTable);
	
	loanTable.appendChild(tbody = document.createElement("tbody"));

	tbody.appendChild(tr = document.createElement("tr"));

	var tableContent = new Array();
	i=0;
	tableContent[i] = ['<b>Pag-IBIG Membership<br>Contributions</b>', '<b>Loan Amount</b>']; i++;
	tableContent[i] = ['<b>POP</b>', '<b>Pag-IBIG I & II</b>']; i++;
	tableContent[i] = ['US $5', 'P200', 'Up to 500,000']; i++;
	tableContent[i] = ['US $ equivalent<br>at point of<br>availment', '250', 'Over 500,000 - 600,000']; i++;
	tableContent[i] = ['300', 'Over 600,000 - 700,000']; i++;
	tableContent[i] = ['350', 'Over 700,000 - 800,000']; i++;
	tableContent[i] = ['400', 'Over 800,000 - 900,000']; i++;
	tableContent[i] = ['450', 'Over 900,000 - 1,000,000']; i++;
	tableContent[i] = ['500', 'Over 1,000,000 - 1,100,000']; i++;
	tableContent[i] = ['550', 'Over 1,100,000 - 1,200,000']; i++;
	tableContent[i] = ['600', 'Over 1,200,000 - 1,300,000']; i++;
	tableContent[i] = ['650', 'Over 1,300,000 - 1,400,000']; i++;
	tableContent[i] = ['700', 'Over 1,400,000 - 1,500,000']; i++;
	tableContent[i] = ['750', 'Over 1,500,000 - 1,600,000']; i++;
	tableContent[i] = ['800', 'Over 1,600,000 - 1,700,000']; i++;
	tableContent[i] = ['850', 'Over 1,700,000 - 1,800,000']; i++;
	tableContent[i] = ['900', 'Over 1,800,000 - 1,900,000']; i++;
	tableContent[i] = ['950', 'Over 1,900,000 - 2,000,000']; i++;

	for(x=0; x<tableContent.length; x++) {
		tbody.appendChild(tr = document.createElement("tr"));
		for(y=0; y<tableContent[x].length; y++) {
			tr.appendChild(td = document.createElement("td"));
			if(x==0) {
				if(y==0) {
					td.colSpan = 2;
					td.rowSpan =1;
				} else {
					td.colSpan = 1;
					td.rowSpan =2;
				}
			} else if(x==3) {
				if(y==0) {
					td.colSpan = 1;
					td.rowSpan = tableContent.length-1;
				}
			}
			td.innerHTML = "<center>" + tableContent[x][y] + "</center>";
			td.style.border = "1px solid black";
		}
	}

	loanInterestTxt = createP("<b>INTEREST RATE</b>");
	loanInterestTxt.style.visibility = "hidden";
	loanInterestTxt.style.position = "absolute";
	loanDiv.appendChild(loanInterestTxt);

	interContent = new Array();
	
	interContent[0] = ['<b>Loan Amount</b>', '<b>Interest rate</b>'];
	interContent[1] = ['Up to P300,000', '6%'];
	interContent[2] = ['Up to P300,000 to<br>750,000', '7%'];
	interContent[3] = ['Up to P750,000 to<br>2,000,000', '10.5%'];
	
	interTable = createBlankTable(interContent.length,interContent[0].length);
	interTable.style.position = "absolute";
	for(i=0; i<interContent.length; i++) {
		for(j=0; j<interContent[i].length; j++) {
			interTable.rows[i].cells[j].innerHTML = "<center>" + interContent[i][j] + "</center>";
			interTable.rows[i].cells[j].style.border = "1px solid black";
			if(i==0) interTable.rows[i].cells[j].style.textDecoration = "underline";
		}
	}
	loanDiv.appendChild(interTable);

	myLoan.aaa = "good";
	myLoan.resize = resizeLoan;
return myLoan;
}

function resizeLoan() {

	fontSize=Math.round(bodyDiv.offsetWidth/65) + "px";
	fontSize1=Math.round(bodyDiv.offsetWidth/82) + "px";

	loanDiv.style.width = Math.round(myLoan.offsetWidth) + "px";
	loanDiv.style.height = Math.round(myLoan.offsetHeight) + "px";

	for(c=0; c<myLoanTxt.length; c++) {
		if(c==0) {
			myLoanTxt[c].style.fontSize = fontSize;
			myLoanTxt[c].style.top = Math.round(siteHeader.offsetHeight*0.1) + "px";
			myLoanTxt[c].style.left = Math.round((myLoan.offsetWidth - myLoanTxt[c].offsetWidth)/2) + "px";
			myLoanTxt[c].style.visibility = 'visible';
		} else {
			myLoanTxt[c].style.fontSize = fontSize1;
			myLoanTxt[c].style.top = Math.round(myLoanTxt[c-1].offsetTop + myLoanTxt[c-1].offsetHeight + siteHeader.offsetHeight*0.05) + "px";
			myLoanTxt[c].style.left = Math.round(myLoan.offsetWidth*0.1) + "px";
			myLoanTxt[c].style.visibility = 'visible';
		}
	}

	loanTable.style.fontSize = fontSize1;
	loanTable.style.top = Math.round(myLoanTxt[myLoanTxt.length-1].offsetTop + myLoanTxt[myLoanTxt.length-1].offsetHeight + siteHeader.offsetHeight*0.1) + "px";
	loanTable.style.width = Math.round(myLoan.offsetWidth*0.8) + "px";
	loanTable.style.left = Math.round((myLoan.offsetWidth-loanTable.offsetWidth)/2) + "px";
	loanTable.style.visibility = "visible";

	loanInterestTxt.style.fontSize = fontSize;
	loanInterestTxt.style.top = Math.round(loanTable.offsetTop + loanTable.offsetHeight + siteHeader.offsetHeight*0.1) + "px";
	loanInterestTxt.style.left = Math.round((myLoan.offsetWidth-loanInterestTxt.offsetWidth)/2) + "px";
	loanInterestTxt.style.visibility = "visible";

	interTable.style.fontSize = fontSize1;
	interTable.style.top = Math.round(loanInterestTxt.offsetTop + loanInterestTxt.offsetHeight + siteHeader.offsetHeight*0.1) + "px";
	interTable.style.width = Math.round(myLoan.offsetWidth*0.4) + "px";
	interTable.style.left = Math.round((myLoan.offsetWidth-interTable.offsetWidth)/2) + "px";

	myLoan.style.height = Math.round(interTable.offsetTop + interTable.offsetHeight) + "px";
//	myLoan.style.height = Math.round(mainDiv.offsetHeight) + "px";


return true;
}
