// Functions for MailChimp Subscriber in Header
var subscribe = {
	showForm: function(){
		subscribe.step.eq(0).fadeOut(800).end().eq(1).fadeIn(800);
		return false;
	},
	validate: function(){
		g = subscribe.step.eq(1).find("input[type=text]").val();
		if( !g || !/^([a-zA-Z0-9])+([a-zA-Z0-9\.\\+=_-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+\.[a-zA-Z.]{2,5}$/.test( g ) ){
			subscribe.step.eq(1).find(".errMsg").fadeIn(500, function(){
				setTimeout('subscribe.step.eq(1).find(".errMsg").fadeOut(500)',1000);
			});
			return false;
		} else return true;
	}
}

$(function () {
    // Set objects for MailChimp Subscriber in Header
    subscribe.container = $("#header").find(".emailSubscribe");
    subscribe.step = subscribe.container.find(".step");

    $("table .decimalAlign").each(function () {
        var t = ($(this).text().replace(/^\s*|\s*$/g, '')).split(".");
        $(this).html('<span class="dcmLeft">' + t[0] + '.</span><span class="dcmRight">' + t[1] + '</span>');
    })

    var loc = location.hostname;
    var lstExclusions = [loc, "server33.cey-ebanking.com", "www.tpars.com", "norrybank.mortgagewebcenter.com", "www.cey-ebanking.com"];

    var oAllLinks = $('a');
    $(oAllLinks).filter(function () {
        return this.hostname && jQuery.inArray(this.hostname, lstExclusions) == -1;
    }).click(function () { return confirm('You are about to leave Northumberland National Bank. This is presented as a courtesy to our customers and is not affiliated with our institution.') });

    // Remove all hrefs on tel URIs used on mobiles since we can't unwrap() in jQuery 1.3.2
    $(oAllLinks).filter(function () {
        return this.href.match(/tel:*/);
    }).removeAttr("href").addClass("mobileTel");

});
