﻿jQuery.fn.externallinks = function(p)
{
	return this.each(function(index){
	
		samedomain = new RegExp("^https://secure.wp3.rbsworldpay.com/wcc/purchase|^https://secure-test.wp3.rbsworldpay.com/wcc/purchase|^javascript:|^/|://" + document.domain);
		isdocument = new RegExp("(\.pdf|\.docx?|\.xls|DownloadAsset.aspx?id=(\d+))$");
        
        if (!samedomain.test(this.href) || isdocument.test(this.href))
        {
            $(this).attr("target","_blank");
		}
	});

};