/* Quick Reference */

/* global variables */
var w;
var validation = false;
var mip_allow = true;
var n = 4;
var q = new Array(n);
q[0] = "What type of property is to be purchased?";
q[1] = "Would the homebuyer occupy the property as his/her primary residence?";
q[2] = "What is the employment type of the homebuyer?";
q[3] = "What is the Loan-to-Value (LTV) ratio the homebuyer requested?";
var o = new Array(n);
o[0] = new Array('Private property for residential use', 'Village house (except "Tso", "Tong" and small village house with alienation restriction)');
o[1] = new Array('Yes', 'No');
o[2] = new Array('Regular salaried employee', 'Self-employed person', 'Non-regular salaried employee');
o[3] = new Array('85% or below', 'Between 85% and 90%', 'Between 90% and 95%');  // 2008/12/29, EN

var a = new Array(n);

var MSG_INVALID_MIP = 'Not eligible under the Mortgage Insurance Programme';

// 2008/12/29, EN
var MSG_HOMEBUYER_HEADER='Homebuyer';
var MSG_ELIGIBLITY_HEADER = 'Eligible under the Mortgage Insurance Programme';
var MSG_ELIGIBLE_PROPERTY_HEADER = 'Eligible Property';
var MSG_USE_OF_PROPERTY_HEADER = 'Use of Property';
var MSG_BORROWER_TYPE_HEADER = 'Borrower Type';
var MSG_MIN_LTV_THRESHOLD_HEADER = 'Min. LTV Threshold';
var MSG_MAX_LOAN_SIZE_HEADER = 'Max. Loan Size';
var MSG_MAX_DTI_HEADER = 'Max. Debt-to-Income Ratio';
var MSG_MAX_LOAN_TENOR_HEADER = 'Max. Loan Tenor';

var MSG_ELIGIBLE_PROP_W_EM = 'Completed properties, properties under construction and refinanced mortgages';
var MSG_ELIGIBLE_PROP_WO_EM = 'Completed properties and refinanced mortgages';
var MSG_OOC_PROP = 'Owner-occupied';
var MSG_NON_OOC_PROP = 'Non Owner-occupied';
var MSG_BORROWER_TYPE_PERSONAL = 'Personal Customers';
var MSG_BORROWER_TYPE_PERSONAL_COMPANY = 'Personal Customers and Shelf Companies';
var MSG_LTV_60 = '60%';
var MSG_LTV_70 = '70%';
var MSG_LOAN_SIZE_5M = 'HK$5 million';
var MSG_LOAN_SIZE_6M = 'HK$6 million';  // WWW0017
var MSG_LOAN_SIZE_8M = 'HK$8 million';
var MSG_LOAN_SIZE_6M_LTV60 = 'HK$6 million if LTV Threshold is lower than 70% of Value at Origination';  // WWW0017
var MSG_LOAN_SIZE_8M_LTV60 = 'HK$8 million if LTV Threshold is lower than 70% of Value at Origination';
var MSG_LOAN_SIZE_12M = 'HK$12 million';
var MSG_LOAN_SIZE_6M_COND = ' (may consider up to HK$6 million, on a case-by-case basis)';  // WWW0017
var MSG_LOAN_SIZE_8M_COND = ' (may consider up to HK$8 million, on a case-by-case basis)';
var MSG_LOAN_SIZE_6M_12M_COND = ' (may consider up to HK$12 million or up to HK$6 million if LTV Threshold is lower than 70% of Value at Origination, on a case-by-case basis)';  // WWW0017
var MSG_LOAN_SIZE_8M_20M_COND = ' (may consider up to HK$20 million or up to HK$8 million if LTV Threshold is lower than 70% of Value at Origination, on a case-by-case basis)';
var MSG_LOAN_SIZE_20M_COND = ' (may consider up to HK$20 million, on a case-by-case basis)';
var MSG_DTI_45 = '45%';
var MSG_DTI_50 = '50%';
var MSG_DTI_60 = '60%';
var MSG_DTI_HIGH_INCOME_EARNER_COND = ' (for high income earner)';
var MSG_DTI_60_COND = ' (for high income earner, may consider up to 60%, on a case-by-case basis)';
var MSG_LOAN_TENOR_30 = '30 years';
var MSG_LOAN_TENOR_40 = '40 years';

var MSG_LIST_OF_INCOME_PROOF = 'List of Required Income Proof';
var invalidMIP = false;    
// End 2008/12/29

function checkOption(q, o) {
    mips_allow = true;   /* 2007/12/03, EN */
    /* update by Joe Li, CL2 Limited, at 3 Mar 2006 */
    /* 2007/12/03, EN
    if (q == 1 && o != 0) {
        mip_allow = false;
        alert(MSG_INVALID_MIP);
    } else if (q == 0 || q == 1) {
        mip_allow = true;
    }
    */
    /*
    if ((q == 0 && o != 0) || (q == 1 && o != 0)) {
        mip_allow = false;
        alert(MSG_INVALID_MIP);
    } else if (q == 0 || q == 1) {
        mip_allow = true;
    }
    */
}

function freset(f) {
    mip_allow = true;
    f.reset();
}

function createQuestions() {
    var j;
    for (var i = 0; i < q.length; i++) {
        document.writeln('<tr valign="top" bgcolor="#F2F1F0">');
        document.writeln('<td width="2%" class="arial12boldred">' + (1 + i) + '.</td>');
        document.writeln('<td width="98%" class="arial12boldred">' + q[i] + '</td>');
        document.writeln('</tr>');
        document.writeln('<tr valign="top" bgcolor="#DEDDDC">');
        document.writeln('<td width="2%" class="arial12boldred">&nbsp;</td>');
        document.writeln('<td width="98%" class="arial12_just">');
        for (j = 0; j < o[i].length; j++) document.writeln('<input type="radio" name="q' + i + '" id="q' + i + '_' + j + '" value="' + j + '" onclick="checkOption(' + i + ',' + j + ');"> <label for="q' + i + '_' + j + '">' + o[i][j] + '</label><br />');
        document.writeln('</td>');
        document.writeln('</tr>');
    }
}

function reopen(name, features) {
    if (w.name != name) {
        w = window.open('', name, 'width=1,height=1,top=0,left=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0');
        w.close();
        w = window.open('', name, features);
    }
    if (!w) return null;
    if (!w.opener) w.opener = self;
    if (window.focus) w.focus();
    w.document.open('text/html');
    return w;
}

function validate(f) {
    if (!mip_allow) {
        alert(MSG_INVALID_MIP);
        validation = false;
        return;
    }
    var i, j, e;
    var clicked = false;
    for (i = 0; i < q.length; i++) {
        e = document.forms[f.name].elements['q' + i];
        clicked = false;
        for (j = 0; j < o[i].length; j++) {
            if (e[j].checked) {
                clicked = true;
                a[i] = j;
            }
        }
        if (!clicked) {
            e[0].focus();
            alert("Please select the most appropriate option at question " + (1 + i) + " !");
            validation = false;
            return;
        }
    }
    /* update by Joe Li, CL2 Limited, at 3 Mar 2006 */
    
	// WWW0017 begin
	// Ineligible for non-owner occupied property
	if (a[1] == 1) {
        alert(MSG_INVALID_MIP);                                  
        validation = false;
        return;
	}
	// WWW0017 end

	// if (a[0] == 1 && a[3] > 0) {                              /* 2007/12/03, EN */
    //  alert('Max. LTV ratio is 85% for village house');        /* 2007/12/03, EN */
    if ((a[0] == 1 && a[3] > 0) || 
        (a[0] == 0 && a[1] == 1 && a[3] > 0) ) {                 /* 2007/12/03, EN */
        alert(MSG_INVALID_MIP);                                  /* 2007/12/03, EN */
        validation = false;
        return;
    }
    
    validation = true;
}

// 2008/12/29, EN
function quiz(f) {
    /* update by Joe Li, CL2 Limited, at 3 Mar 2006 */
    if (!validation) return false;
    if (!mip_allow) {
        alert(MSG_INVALID_MIP);
        return false;
    }
    w = reopen('quickref_res', 'width=555,height=540,top=0,left=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1');
    var d = w.document;
    writeHeader(d);

    /* display inputs */
    d.writeln('<table width="500" border="0" cellspacing="1" cellpadding="5" class="framered">');
    d.writeln('<tr class="arial12" bgcolor="#8B2942"><td colspan="3" class="arial12"><font color="#FFFFFF"><b>' + MSG_HOMEBUYER_HEADER + '</b></font></td></tr>');
    for (var i = 0; i < q.length; i++) {
        d.writeln('<tr valign="top">');
        d.writeln('<td class="arial12" bgcolor="#E27F37"><font color="#FFFFFF"><b>' + (1 + i) + '</b></font></td>');
        d.writeln('<td class="arial12" bgcolor="#DEDDDC"><b>' + q[i] + '</b></td>');
        d.writeln('<td class="arial12" bgcolor="#F2F1F0">' + o[i][a[i]] + '</td>');
        d.writeln('</tr>');
    }
    d.writeln('</table>');
    d.writeln('<p></p><p></p>');

    /* perform checking */
    var eligibleProperty = "";
    var useOfProperty = "";
    var borrowerType = "";
    var minLtvThresholdHeader = "";
    var minLtvThreshold = "";
    var maxLoanSize = "";
    var maxLoanSize2 = "";
    var maxDTI = "";
    var maxDTI2 = "";
    var maxLoanTenor = "";        

    /* Private Property */ 
    if (a[0] == 0) {
        /* Owner-occupied */ 
        if (a[1] == 0) {
            /* Regular salaried or self-employed */ 
            if (a[2] != 2) {
                /* LTV <= 85% or LTV between 85% and 90% */ 
                if (a[3] != 2) {
                    /* point A */
                    eligibleProperty = MSG_ELIGIBLE_PROP_W_EM;
                    useOfProperty = MSG_OOC_PROP;
                    borrowerType = MSG_BORROWER_TYPE_PERSONAL;
                    minLtvThreshold = MSG_LTV_60;
                    maxLoanSize = MSG_LOAN_SIZE_12M;         // WWW0017
                    maxLoanSize2 = MSG_LOAN_SIZE_6M_LTV60;   // WWW0017
                    maxDTI = MSG_DTI_50 + MSG_DTI_60_COND;
                    maxDTI2 = "";
                    maxLoanTenor = MSG_LOAN_TENOR_40;                      
                /* LTV > 90% */ 
                } else {
                    /* point B */
                    eligibleProperty = MSG_ELIGIBLE_PROP_W_EM;
                    useOfProperty = MSG_OOC_PROP;
                    borrowerType = MSG_BORROWER_TYPE_PERSONAL;
                    minLtvThreshold = MSG_LTV_70;
                    maxLoanSize = MSG_LOAN_SIZE_6M;   // WWW0017
                    maxLoanSize2 = "";
                    maxDTI = MSG_DTI_45;
                    maxDTI2 = MSG_DTI_50 + MSG_DTI_HIGH_INCOME_EARNER_COND;
                    maxLoanTenor = MSG_LOAN_TENOR_30;                                    
                  }
            /* Non-regular salaried */ 
            } else {
                /* LTV <= 85% or LTV between 85% and 90% */ 
                if (a[3] != 2) {
                    /* point C */
                    eligibleProperty = MSG_ELIGIBLE_PROP_W_EM;
                    useOfProperty = MSG_OOC_PROP;
                    borrowerType = MSG_BORROWER_TYPE_PERSONAL;
                    minLtvThreshold = MSG_LTV_60;
                    maxLoanSize = MSG_LOAN_SIZE_5M + MSG_LOAN_SIZE_6M_12M_COND;   // WWW0017
                    maxLoanSize2 = "";
                    maxDTI = MSG_DTI_50 + MSG_DTI_60_COND;
                    maxDTI2 = "";
                    maxLoanTenor = MSG_LOAN_TENOR_40;                      
                /* LTV > 90% */ 
                } else {
                    /* point D */
                    eligibleProperty = MSG_ELIGIBLE_PROP_W_EM;
                    useOfProperty = MSG_OOC_PROP;
                    borrowerType = MSG_BORROWER_TYPE_PERSONAL;
                    minLtvThreshold = MSG_LTV_70;
                    maxLoanSize = MSG_LOAN_SIZE_5M + MSG_LOAN_SIZE_6M_COND;   // WWW0017
                    maxLoanSize2 = "";
                    maxDTI = MSG_DTI_45;
                    maxDTI2 = MSG_DTI_50 + MSG_DTI_HIGH_INCOME_EARNER_COND;
                    maxLoanTenor = MSG_LOAN_TENOR_30;                                    
                }
            }       
        /* Non Owner-occupied */ 
        } else {
			// WWW0017 begin
            invalidMIP = true;   
			/*
            // LTV <= 85% 
            if (a[3] == 0) {
                // Regular salaried or self-employed 
                if (a[2] != 2) {
                    // point F
                    eligibleProperty = MSG_ELIGIBLE_PROP_W_EM;
                    useOfProperty = MSG_NON_OOC_PROP;
                    borrowerType = MSG_BORROWER_TYPE_PERSONAL_COMPANY;
                    minLtvThreshold = MSG_LTV_70;
                    maxLoanSize = MSG_LOAN_SIZE_8M;
                    maxLoanSize2 = "";
                    maxDTI = MSG_DTI_50;
                    maxDTI2 = "";
                    maxLoanTenor = MSG_LOAN_TENOR_40;                      
                // irregular salaried 
                } else {
                    // point G
                    eligibleProperty = MSG_ELIGIBLE_PROP_W_EM;
                    useOfProperty = MSG_NON_OOC_PROP;
                    borrowerType = MSG_BORROWER_TYPE_PERSONAL_COMPANY;
                    minLtvThreshold = MSG_LTV_70;
                    maxLoanSize = MSG_LOAN_SIZE_5M + MSG_LOAN_SIZE_8M_COND;
                    maxLoanSize2 = "";
                    maxDTI = MSG_DTI_50;
                    maxDTI2 = "";
                    maxLoanTenor = MSG_LOAN_TENOR_40;                                    
                }
            // LTV between 85% and 90% or LTV > 90% 
            } else {
                invalidMIP = true;
            }
			*/
			// WWW0017 end
        }         
    /* Village House */         
    }  else {
        /* Owner-occupied */ 
        if (a[1] == 0) {
            /* LTV <= 85% */ 
            if (a[3] == 0) {
                /* point E */
                eligibleProperty = MSG_ELIGIBLE_PROP_WO_EM;
                useOfProperty = MSG_OOC_PROP;
                borrowerType = MSG_BORROWER_TYPE_PERSONAL;
                minLtvThreshold = MSG_LTV_60;
                maxLoanSize = MSG_LOAN_SIZE_5M;
                maxLoanSize2 = "";
                maxDTI = MSG_DTI_50 + MSG_DTI_60_COND;
                maxDTI2 = "";
                maxLoanTenor = MSG_LOAN_TENOR_40;                      
            /* LTV between 85% and 90% or LTV > 90% */ 
            } else {
                invalidMIP = true;
            }
        /* Non Owner-occupied */ 
        } else {
			// WWW0017 begin
            invalidMIP = true;   
			/*
            // LTV <= 85% 
            if (a[3] == 0) {
                // point H 
                eligibleProperty = MSG_ELIGIBLE_PROP_WO_EM;
                useOfProperty = MSG_NON_OOC_PROP;
                borrowerType = MSG_BORROWER_TYPE_PERSONAL_COMPANY;
                minLtvThreshold = MSG_LTV_70;
                maxLoanSize = MSG_LOAN_SIZE_5M;
                maxLoanSize2 = "";
                maxDTI = MSG_DTI_50;
                maxDTI2 = "";
                maxLoanTenor = MSG_LOAN_TENOR_40;                      
            // LTV between 85% and 90% or LTV > 90% 
            } else {
                invalidMIP = true;
            }  
			*/
			// WWW0017 end
        }
    }
    
    if (invalidMIP) {
        d.writeln('<div class="arial14" style="color:#8b2942;font-weight:bold;font-size:20px;">' + MSG_INVALID_MIP + '</div>');
    } else {
        d.writeln('<div class="arial14" style="color:#8b2942;font-weight:bold;">' + MSG_ELIGIBLITY_HEADER + '</div>');
        d.writeln('<table width="500" border="0" cellspacing="1" cellpadding="5" class="framered">');
        d.writeln('<tr valign="top">');
        d.writeln('<td class="arial12" bgcolor="#DEDDDC" width="35%"><b>' + MSG_ELIGIBLE_PROPERTY_HEADER + '</b></td>');
        d.writeln('<td class="arial12" bgcolor="#F2F1F0" width="65%">' + eligibleProperty + '</td>');
        d.writeln('</tr>');
        d.writeln('<tr valign="top">');
        d.writeln('<td class="arial12" bgcolor="#DEDDDC"><b>' + MSG_USE_OF_PROPERTY_HEADER + '</b></td>');
        d.writeln('<td class="arial12" bgcolor="#F2F1F0">' + useOfProperty + '</td>');
        d.writeln('</tr>');
        d.writeln('<tr valign="top">');
        d.writeln('<td class="arial12" bgcolor="#DEDDDC"><b>' + MSG_BORROWER_TYPE_HEADER + '</b></td>');
        d.writeln('<td class="arial12" bgcolor="#F2F1F0">' + borrowerType + '</td>');
        d.writeln('</tr>');
        d.writeln('<tr valign="top">');
        d.writeln('<td class="arial12" bgcolor="#DEDDDC"><b>' + MSG_MIN_LTV_THRESHOLD_HEADER + '</b></td>');
        d.writeln('<td class="arial12" bgcolor="#F2F1F0">' + minLtvThreshold + '</td>');
        d.writeln('</tr>');
        d.writeln('<tr valign="top">');
        d.writeln('<td class="arial12" bgcolor="#DEDDDC"><b>' + MSG_MAX_LOAN_SIZE_HEADER + '</b></td>');
        if (maxLoanSize2 == "") {
            d.writeln('<td class="arial12" bgcolor="#F2F1F0">' + maxLoanSize + '</td>');
        } else {
            d.writeln('<td class="arial12" bgcolor="#F2F1F0">' + maxLoanSize + '<br>' + maxLoanSize2 + '</td>');
        }
        d.writeln('</tr>');
        d.writeln('<tr valign="top">');
        d.writeln('<td class="arial12" bgcolor="#DEDDDC"><b>' + MSG_MAX_DTI_HEADER + '</b></td>');
        if (maxDTI2 == "") {
            d.writeln('<td class="arial12" bgcolor="#F2F1F0">' + maxDTI + '</td>');
        } else {
            d.writeln('<td class="arial12" bgcolor="#F2F1F0">' + maxDTI + '<br>' + maxDTI2 + '</td>');
        }
        d.writeln('</tr>');
        d.writeln('<tr valign="top">');
        d.writeln('<td class="arial12" bgcolor="#DEDDDC"><b>' + MSG_MAX_LOAN_TENOR_HEADER + '</b></td>');
        d.writeln('<td class="arial12" bgcolor="#F2F1F0">' + maxLoanTenor + '</td>');
        d.writeln('</tr>');
        d.writeln('</table>');

        if (a[0] == 0) {  // 2008/12/29, EN
            writeNote(d);
        }                 // 2008/12/29, EN

        writeRequireDocument(d);

        /* list of required income proof */
        d.writeln('<p></p>');
        d.writeln('<div style="padding:4px; width:500px; background-color: #f2f1f0; border:0px solid #8b2942;">');
        d.writeln('<div class="arial14"><b><font color="#8B2942">' + MSG_LIST_OF_INCOME_PROOF + '</font></b></div>');
        d.writeln('<p></p>');
        switch (a[2]) {
            /* for regular salaried employee */
            case 0: writeRegular(d); break;
            /* for self-employed person */
            case 1: writeSelfEmploy(d); break;
            /* for non-regular salaried employee */
            case 2: writeNonRegular(d); break;
            default: break;
        }
        d.writeln('</div>');
    }
    writeLinks(d);
    writeCopyright(d);
    writeFooter(d);
    validation = false;
}
// End 2008/12/29

function writeHeader(d) {
    /* update by Joe Li, CL2 Limited, at 3 Mar 2006 */
    /* header */
    with (d) {
        open('text/html', 'replace');
        writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
        writeln('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">');
        writeln('<head>');
        writeln('<meta http-equiv="Content-Language" content="iso-8859-1" />');
        writeln('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />');
        writeln('<meta http-equiv="imagetoolbar" content="false" />');
        writeln('<meta name="mssmarttagspreventparsing" content="true" />');
        writeln('<title>The Hong Kong Mortgage Corporation Limited</title>');
        writeln('<link rel="stylesheet" href="../../../hkmc.css" type="text/css" />');
        writeln('<style type="text/css">');
        writeln('<!--');
        writeln('a:visited { color : #555555; text-decoration : none; }');
        writeln('a:hover { color : #ff0000; text-decoration : underline; }');
        writeln('a:link { color : #b80e1a; text-decoration : none; }');
        writeln('-->');
        writeln('</style>');
        writeln('<script type="text/javascript">');
        writeln('function btn_click_ie() {');
        writeln('   if (event.button == 2) return false;');
        writeln('}');
        writeln('function btn_click_ns(e) {');
        writeln('   if (document.layers || document.getElementById && !document.all) {');
        writeln('       if (e.which == 2 || e.which == 3) return false;');
        writeln('   }');
        writeln('}');
        writeln('if (document.layers) {');
        writeln('   document.captureEvents(Event.MOUSEDOWN);');
        writeln('   document.captureEvents(Event.MOUSEUP);');
        writeln('   window.captureEvents(Event.MOUSEDOWN);');
        writeln('   window.captureEvents(Event.MOUSEUP);');
        writeln('   document.onmousedown = btn_click_ns;');
        writeln('   document.onmouseup = btn_click_ns;');
        writeln('   window.onmousedown = btn_click_ns;');
        writeln('   window.onmouseup = btn_click_ns;');
        writeln('} else if (document.all && !document.getElementById) {');
        writeln('   document.onmousedown = btn_click_ie;');
        writeln('   document.onmouseup = btn_click_ie;');
        writeln('   window.onmousedown = btn_click_ie;');
        writeln('   window.onmouseup = btn_click_ie;');
        writeln('}');
        writeln('document.oncontextmenu = new Function("return false;");');
        writeln('</script>');
        writeln('</head>');
        writeln('<body bgcolor="#ffffff" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
        writeln('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
        writeln('<tr bgcolor="#fedca2">');
        writeln('<td width="100%" bgcolor="#fedca2" height="83"><img src="../../../image/common/logo_hkmc.gif" width="371" height="83"></td>');
        writeln('</tr>');
        writeln('<tr bgcolor="#ffffff">');
        writeln('<td>&nbsp;</td>');
        writeln('</tr>');
        writeln('<tr bgcolor="#ffffff">');
        writeln('<td width="100%" align="right">');
        writeln('<a href="javascript:;" onclick="window.print();"><img src="../../../image/common/btn_print.gif" width="59" height="26" border="0" /></a> <a href="javascript:;" onClick="window.close();"><img src="../../../image/common/btn_close.gif" width="59" height="26" border="0" /></a>');
        writeln('</td>');
        writeln('</tr>');
        writeln('</table>');
        writeln('<div style="margin:0px 0px 0px 20px;">');
        writeln('<div class="arial14"><b><font color="#8B2942">MIP Quick Reference</font></b></div>');
    }
}

function writeFooter(d) {
    /* footer and buttons */
    with (d) {
        writeln('<p class="arial9">&copy; Copyright The Hong Kong Mortgage Corporation Limited<br />All rights reserved</p>');
        writeln('</div>');
        writeln('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
        writeln('<tr bgcolor="#ffffff">');
        writeln('<td width="100%" align="right">');
        writeln('<a href="javascript:;" onclick="window.print();"><img src="../../../image/common/btn_print.gif" width="59" height="26" border="0" /></a> <a href="javascript:;" onClick="window.close();"><img src="../../../image/common/btn_close.gif" width="59" height="26" border="0" /></a>');
        writeln('</td>');
        writeln('</tr>');
        writeln('</table>');
        writeln('</body>');
        writeln('</html>');
        close();
    }
}

function writeNote(d) {
    with (d) {
        writeln('<p></p><p></p>');
        writeln('<div style="padding:4px; width:500px; background-color: #f2f1f0; border:0px solid #8b2942;">');
        writeln('<div class="arial14"><b><font color="#8B2942">Note</font></b></div>');
        writeln('<ul>');
        /*EL on 2008/03/28: writeln('<li>The maximum loan size for deferred principal repayment loan is HK$ 5 million. (Not applicable to Non Owner-occupied Residential Properties)</li>');*/  /* 2007/12/03, EN */
        if (a[0] == 0) {   /* 2007/12/03, EN */
            writeln('<li>For properties under construction: -</li>');
            writeln('<ul>');
            writeln('   <li>The property development project must be covered by the Consent Scheme;</li>');
            writeln('   <li>The property development project must be scheduled for completion within 12 months from the Loan Drawdown Date, i.e. the Building Completion Date* must be within 12 months from the Loan Drawdown Date;</li>');
            writeln('   <li>The property <u>must not</u> be purchased from a confirmer in a sub-sale and purchase transaction; and</li>');
            writeln('   <li>The homebuyer must have paid on or before the Drawdown Date all stamp duty payable on such Formal Sale and Purchase Agreement.</li>');
            writeln('</ul>');
            writeln('</ul>');
            writeln('<div style="margin-left:20px;margin-right:10px;text-align:justify;font-size:11px;font-family:arial,helvetica">* Building Completion Date means the original date specified in the relevant Formal Sale and Purchase Agreement as the date on which construction of the building comprising the relevant residential property is to be completed in all respects in compliance with the conditions of the Government grant and the approved building plans, without regard to any extension of time by the Authorized Person.</div>');
        }                  /* 2007/12/03, EN */
        writeln('</ul>');  /* 2007/12/03, EN */
        writeln('</div>');
    }
}

function writeRequireDocument(d) {
    with (d) {
        writeln('<p></p><p></p>');
        writeln('<div style="padding:4px; width:500px; background-color: #f2f1f0; border:0px solid #8b2942;">');
        writeln('<div class="arial14"><b><font color="#8B2942">List of Required Documents</font></b></div>');
        writeln('<ul>');
        writeln('<li>A copy of Hong Kong Identity Card;</li>');
        writeln('<li>A copy of provisional sales and purchase agreement (if available);</li>');
        writeln('<li>Income Proof (see below)</li>');
        writeln('</ul>');
        writeln('<div style="font-size:11px;font-family:arial"><u>For refinancing case</u></div>');
        writeln('<ul>');
        writeln('<li>Repayment history for the last 6 months;</li>');
        writeln('<li>The most recent loan repayment statement showing outstanding principal balance;</li>');
        writeln('<li>Owner occupancy proof, as and when necessary</li>');
        writeln('</ul>');
        writeln('</div>');
    }
}

function writeRegular(d) {
    with (d) {
        writeln('<div style="font-size:11px;font-family:arial"><i>For Regular Salaried Employee</i></div>');
        writeln('<ul>');
        writeln('   <li>bank book / statement showing salary deposits clearly earmarked for the last 3 months; <b>plus</b></li>');
        writeln('   <li><b>Any</b> one of the following documents:</li>');
        writeln('   <ul>');
        writeln('       <li>the most recent tax demand note issued by the Inland Revenue Department;</li>');
        writeln('       <li>letter from the employer (issued on the company letterhead / bearing company chop and signed by the authorised person with his name and position stated) confirming job title and income details; and</li>');
        writeln('       <li>the most recent salary payroll slip with the employer&#39;s name and evidence of payment thereof into a bank  account of the Obligor.</li>');
        writeln('   </ul>');
        writeln('   </li>');
        writeln('</ul>');
        writeln('<p></p>');
    }
}

function writeSelfEmploy(d) {
    with (d) {
        writeln('<div style="font-size:11px;font-family:arial"><i>For Self-employed Person^</i></div>');
        writeln('<br>');        
        writeln('<div style="font-size:11px;font-family:arial"><b>All</b> the following documents:</div>');
        writeln('<ul>');
        writeln('   <li>a valid Business Registration Certificate;</li>');
        writeln('   <li>a valid practising certificate or similar document issued by the relevant professional body (in respect of <u>professional person</u> only); <b>plus</b></li>');
        writeln('   <p></p>');
        writeln('   <li>the following documents:');
        writeln('   <ul>');
        writeln('       <li>the latest tax demand note issued by the Inland Revenue Department;</li>');
        writeln('       <li>company and obligor&#39;s bank book / statement showing the average net cash-flow for the last 6 months; and</li>');
        writeln('       <li>the most recent audited financial statements of the business carried on by the Obligor. For Obligor who is a sole-proprietor, 100% of the profit before tax will be taken into account. For Obligor conducting the business through a partnership or a limited company, the amount of profit before tax to be taken into account will be apportioned in accordance with the Obligor&#39;s beneficial interest in such partnership / limited company.</li>');
        writeln('   </ul>');
        writeln('   </li>');
        writeln('</ul>');
        writeln('<div style="margin-left:20px;margin-right:10px;text-align:justify;font-size:11px;font-family:arial">^ For Obligor who is a self-employed and non-professional person, the audited financial statements (if applicable) and tax demand notes issued by the Inland Revenue Department for the last 2 years, as well as proof of the establishment of his business for a minimum period of 3 years, are required.</div>');
        writeln('<p></p>');
    }
}

function writeNonRegular(d) {
    with (d) {
        writeln('<div style="font-size:11px;font-family:arial"><i>For Non-regular Salaried Employee</i></div>');
        writeln('<ul>');
        writeln('   <li>bank book / statement showing salary deposits clearly earmarked for the last 6 months; <b>plus</b></li>');
        writeln('   <li><b>Any</b> one of the following documents:</li>');
        writeln('   <ul>');
        writeln('       <li>the most recent tax demand note issued by the Inland Revenue Department; and</li>');
        writeln('       <li>the most recent salary payroll slip with the employer&#39;s name and evidence of payment thereof into a bank account of the Obligor for the last 6 months. </li>');
        writeln('   </ul>');
        writeln('   </li>');
        writeln('</ul>');
        writeln('<p></p>');
    }
}

function writeLinks(d) {
    with (d) {
        writeln('<p></p>');
        writeln('<div style="padding:4px; width:500px; background-color: #f2f1f0; border:0px solid #8b2942;">');
        writeln('<div class="arial14"><b><font color="#8B2942">Links</font></b></div>');
        writeln('<p></p>');
        writeln('<div style="font-size:11px;font-family:arial"><u>General Information</u></div>');
        writeln('<ul>');
        writeln('<li><a href="../../ourbusiness/Annex-1-English.pdf" target="hkmc_pdf">Premium Rate Sheet</a></li>');
        writeln('<li><a href="../../ourbusiness/Annex-2-English.pdf" target="hkmc_pdf">List of Participating Banks</a></li>');
        writeln('</ul>');
        writeln('<p></p>');
        writeln('<div style="font-size:11px;font-family:arial"><u>Eligibility Criteria for Owner-occupied Residential Properties</u></div>');
        writeln('<ul>');
        writeln('<li><a href="../../ourbusiness/Annex-3-English.pdf" target="hkmc_pdf">Eligibility Criteria for 90% Mortgage Insurance Programme</a></li>');
        writeln('<li><a href="../../ourbusiness/Annex-4-English.pdf" target="hkmc_pdf">Eligibility Criteria for 95% Mortgage Insurance Programme</a></li>');
        writeln('<li><a href="../../ourbusiness/Annex-5-English.pdf" target="hkmc_pdf">Eligibility Criteria for 85% Mortgage Insurance Programme - Cash-out Refinancing</a></li>');
        writeln('<li><a href="../../ourbusiness/Annex-6-English.pdf" target="hkmc_pdf">Eligibility Criteria for 85% Mortgage Insurance Programme - Village House</a></li>');
        writeln('</ul>');
		// WWW0017 begin
		/*
        writeln('<p></p>');
        writeln('<div style="font-size:11px;font-family:arial"><u>Eligibility Criteria for Non Owner-occupied Residential Properties</u></div>');
        writeln('<ul>');
        writeln('<li><a href="../../ourbusiness/Annex-7-English.pdf" target="hkmc_pdf">Eligibility Criteria for 85% Mortgage Insurance Programme</a></li>');
        writeln('</ul>');
		*/
		// WWW0017 end
        writeln('</div>');
        writeln('<p></p>');
    }
}

function writeCopyright(d) {
    d.write('<p class="arial9" align="justify" style="width:500px;">This Quick Reference Guide is for reference purposes only. Please refer to Operational Manual of the HKMC&#39;s Mortgage Insurance Programme (MIP) for the full terms and requirements of the MIP. In the event of any conflict between the Operational Manual and this Guide, the Operational Manual shall prevail. In the event of any conflict between the English version of this Guide and the Chinese version, the English version shall prevail.</p>');
}
