// BEHAVIOR LAYER

// create print page link on the fly if key items are supported
var hasPrintFeature = (window.print) ? true : false;
var supportsW3CDOM = ((document.createElementNS || document.createElement) && document.createTextNode && document.insertBefore && document.appendChild);

if (hasPrintFeature && supportsW3CDOM) {
    if (typeof PRINT_PAGE_TEXT == 'string') {
        var li = (document.createElementNS) ? document.createElementNS(XHTML_NS_URI, 'li') : document.createElement('li');
        li.setAttribute('id', 'navFunctionsPrint');
        var a = (document.createElementNS) ? document.createElementNS(XHTML_NS_URI, 'a') : document.createElement('a');
        a.setAttribute('href', '#');
        a.setAttribute('title', 'Seite drucken (öffnet Dialog)');
        a.onclick = function() {
            window.print();
            return false;
        }
        a.appendChild(document.createTextNode(PRINT_PAGE_TEXT));
        li.appendChild(a);
        var refNode = document.getElementById('navFunctionsRecommend');
        if (refNode) {
            refNode.parentNode.insertBefore(li, refNode);
        } else {
            var parentRefNode = document.getElementById('siteInfo');
            if (parentRefNode) {
                var ul = (document.createElementNS) ? document.createElementNS(XHTML_NS_URI, 'ul') : document.createElement('ul');
                ul.appendChild(li);
                refNode = (parentRefNode.getElementsByTagName('p').length > 0) ? parentRefNode.getElementsByTagName('p')[0] : null;
                if (refNode) {
                    refNode.parentNode.insertBefore(ul, refNode);
                }
            }
        }
    }
}

// attach events to search form input
attachToField('f2376d624');
attachToField('f620d26');
attachToField('f620d28');
attachToField('f2378d2380');
attachToField('f2382d2384');
attachToField('f2382d2386');