$(function() {
    $('a').filter(function() { return this.hostname && this.hostname !== location.hostname && this.hostname !== 'www.cumberlandbusiness.co.uk' && this.hostname !== 'banking.cumberland.co.uk' && this.hostname !== 'pdf.cumberland.co.uk' && this.hostname !== 'www.cumberland.co.uk' && this.hostname !== 'www.cumberlandestateagents.co.uk' && this.hostname !== 'www.cumberlandfinancialplanning.co.uk' && this.hostname !== '213.120.211.7'; })
        .click(function() { 
            //alert(location);
            if(this.hostname.match(/(.*?)www.cumberland.aviva.co.uk(.*?)/i)) {
                return confirm("You are now being taken to an Aviva website operated in conjunction with Cumberland Financial Planning. Please select 'OK' to continue.");
            } else {
                return confirm("You are now leaving the current website. Are you sure you wish to continue?"); 
            }
        })
    .add('a[href$="pdf"]')
        .attr('target', '_blank')
    .filter(':not(:has(img))').addClass('linkAway');
});

function linkAway(url) {
    if(confirm("You are now being taken to an Aviva website operated in conjunction with Cumberland Financial Planning. Please select 'OK' to continue.")) {
        window.location.href = url;
    }
}