﻿var timeout = 1000;
var closetimer = 0;
var ddmenuitem = 0;

function mopen(id) {
    mcancelclosetime();
    if (ddmenuitem) ddmenuitem.style.visibility = 'hidden';
    ddmenuitem = document.getElementById(id);
    ddmenuitem.style.visibility = 'visible';
}

function mclose() {
    if (ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}


function mclosetime() {
    closetimer = window.setTimeout(mclose, timeout);
}


function mcancelclosetime() {
    if (closetimer) {
        window.clearTimeout(closetimer);
        closetimer = null;
    }
}


document.onclick = mclose;


function jsChangePointer() {
    document.body.style.cursor = 'pointer';
}

function jsChangeBack() {
    document.body.style.cursor = 'default';
}

function jsnoAlpha(obj) {
    reg = /[^0-9.,]/g;
    obj.value = obj.value.replace(reg, "");
}

function jsValidEmail(obj) {
    if (!obj.valueOf == '') {
        reg = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
        if (!reg.test(obj.value)) {
            alert('Please enter a valid Email address');
            obj.focus();
        }
    }
}

function jsValidPostCode(obj) {
    if (!obj.value == '') {
        reg = /^([A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]|[A-HK-Y][0-9]([0-9]|[ABEHMNPRV-Y]))|[0-9][A-HJKS-UW])\ [0-9][ABD-HJLNP-UW-Z]{2}|(GIR\ 0AA)|(SAN\ TA1)|(BFPO\ (C\/O\ )?[0-9]{1,4})|((ASCN|BBND|[BFS]IQQ|PCRN|STHL|TDCU|TKCA)\ 1ZZ))$/;
        if (!reg.test(obj.value)) {
            alert('Please enter a valid post code');
            obj.focus();
        }
    }
}

function jsHideContact() {
    document.getElementById('ContactUsLink').style.display = 'none';
}

// <div class="Item" onmouseover="mopen('m1')" onmouseout="mclosetime()">
//                        <a href="Business_Services/LoanForBusiness.aspx"  runat="server">Business Loans</a>
//                    </div>

//<div class="Item" onmouseout="mclose()">
//                        <a href="Loan_Calculator/Loan_Calc_Values.aspx" runat="server">Loan Calculator</a>
//                    </div>