$(document).ready(function() {

    //All links
	$('.bodywrapper .component_standard-entry a, .bodywrapper .component_rich-text a, .bodywrapper .component_toggle-paragraph a, .bodywrapper .component_navigation-selection a').filter(function() {
            var myvar="";
            var myvar2="";

			if(this.previousSibling !=null) {
				if(this.previousSibling.nodeValue !=null) {
					myvar = this.previousSibling.nodeValue.replace(/^\s+|\s+$/g, '');
				}
            }

            if(this.nextSibling !=null) {
                if(this.nextSibling.nodeValue !=null)
                {
				    myvar2 = this.nextSibling.nodeValue.replace(/^\s+|\s+$/g, '');
                }
            }

			if($(this).find('img').html() == null && (this.previousSibling == null || this.previousSibling.nodeType == 1 || (this.previousSibling.nodeType == 3 && myvar.length ==0)) && (this.nextSibling == null || this.nextSibling.nodeType == 1 || (this.nextSibling.nodeType == 3 && myvar2.length ==0))) {
				if($(this).parent().prop('nodeName') == 'P' && $(this).prev().prop('nodeName') != "BR" && $(this).next().prop('nodeName') != "BR") return true;
                else return false;
			}

			return false;
    }).parent().addClass('arrow');

    //External Links
    $('#content a').filter(function() {
        if( this.hostname && this.hostname.indexOf("hepl.ch") == -1) {
             this.target="_blank";
            if($(this).find('img').html() == null)
            {
                $(this).addClass('ext-link');
            }
        }
     });
    $('#topheader a').filter(function() {
        if( this.hostname && this.hostname.indexOf("hepl.ch") == -1) {
             this.target="_blank";
            if($(this).find('img').html() == null)
            {
                $(this).addClass('ext-link');
            }
        }
     });
    $('#footer a').filter(function() {
        if( this.hostname && this.hostname.indexOf("hepl.ch") == -1) {
             this.target="_blank";
            if($(this).find('img').html() == null)
            {
                $(this).addClass('ext-link');
            }
        }
     });


});
