// jQuery conflict mode
$.noConflict();

// jQuery starts here

// jQuery document.ready
jQuery(document).ready(function() {


    // Start Flackern IE6 abstellen
    if (jQuery.browser.msie) {
        try {
            document.execCommand("BackgroundImageCache", false, true);
        } catch (err) { }
    }; // End Flackern IE6 abstellen


    // Start toggle box
    //Hide the tooglebox on pageload
    jQuery(".togglebox").hide();
    //Switch the "Open" and "Close" state per click
    jQuery(".toggle").toggle(function() {
        jQuery(this).addClass("toggledown");
    }, function() {
        jQuery(this).removeClass("toggledown");
    });
    //slide up and down on click
    jQuery(".toggle").click(function() {
        jQuery(this).next(".togglebox").slideToggle("slow");
        return true;
    }); // end toggle box


    // Start document icons
    var iconPath = '/images/FileManager/Icons/';

    var fileTypes = {
        doc: 'doc.gif',
        docx: 'doc.gif',
        xls: 'xls.gif',
        xlsx: 'xls.gif',
        ppt: 'ppt.gif',
        pptx: 'ppt.gif',
        pdf: 'pdf.gif',
        jpg: 'jpg.gif',
        tif: 'tif.gif',
        tiff: 'tif.gif'
    };
    // All but not article images
    jQuery('.article a').not('.article-image a').each(function() {
        var $a = jQuery(this);
        var href = $a.attr('href');
        if (
(href.match(/^http/)) &&
(!href.match(document.domain))
) {
            // use a special image for external links
            var image = 'link-external.gif';
        }
        // mailto link
        else if (
(href.match(/^mailto:/))
) {
            // use a special image for external links
            var image = 'link-email.gif';
        }
        else {
            // get the extension from the href
            var hrefArray = href.split('.');
            var extension = hrefArray[hrefArray.length - 1];
            var image = fileTypes[extension];
        }
        if (image) {
            $a.css({
                paddingLeft: '20px',
                background: 'transparent url("' + iconPath + image + '") no-repeat center left'
            }).attr("target", "_blank");
        }
    }); // End document icons

//Empty News and Termine
jQuery("div.teaser-items").each(function(i) {
if (jQuery(this).children().size() <= 0) {
    if (jQuery(".language-de").length) jQuery(this).text("Z.Zt. keine Einträge vorhanden");
    if (jQuery(".language-en").length) jQuery(this).text("No entries at the moment");
    }
});


});// Close document.ready
