// jQuery conflict mode
$.noConflict();

// jQuery starts here

// jQuery document.ready
jQuery(document).ready(function() {


// 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, ul 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:/) || href.match(/^javascript:location.href='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

// Remove line
jQuery('#dnn_ContentPane .article').last().css('background', 'none');
jQuery('#dnn_Produkt .article').last().css('background', 'none');
jQuery('#dnn_Grundfunktionen .article').last().css('background', 'none');
jQuery('#dnn_Optionen .article').last().css('background', 'none');
jQuery('#dnn_Downloads .article').last().css('background', 'none');
jQuery('#dnn_OutputPane .article').last().css('background', 'none');
jQuery('#dnn_ContentPane .teaserlist .teaser').last().css('background', 'none');
jQuery('#dnn_RightPane .teaserlist .teaser').last().css('background', 'none');
jQuery('#dnn_LeftPane .teaserlist .teaser').last().css('background', 'none');
jQuery('#dnn_OutputPane .teaserlist .teaser').last().css('background', 'none');
jQuery('#dnn_TagcloudPane .article').css('background', 'none');
jQuery('#dnn_ContactPane .article').css('background', 'none');
jQuery('#dnn_Footerbox1 .article ul li').last().css('border-bottom', 'none');
jQuery('#dnn_Footerbox2 .article ul li').last().css('border-bottom', 'none');
jQuery('#dnn_Footerbox3 .article ul li').last().css('border-bottom', 'none');
jQuery('#dnn_Footerbox4 .article ul li').last().css('border-bottom', 'none');

//News h2
jQuery('.language-de h2.news-start-h2').append('Aktuelles');
jQuery('.language-en h2.news-start-h2').append('News');

// Vertical Menu
jQuery('.nav-vertical ul.level1:last-child').css({ padding: '0 0 20px 0' });

// Article List Float Fix
jQuery('.article ul').next('p').css('clear', 'both');
jQuery('.article ol').next('p').css('clear', 'both');

//Search Watermark
jQuery('.language-de .input-search').watermark('Suche');
jQuery('.language-en .input-search').watermark('Search');

//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");
    }
});

// Zebra Stripe List
jQuery('#dnn_ContentPane .article li:nth-child(odd)').addClass('odd');
jQuery('#dnn_LeftPane .article li:nth-child(odd)').addClass('odd');

// FAQ

//Hide (Collapse) the toggle containers on load
jQuery(".toggle-container").hide(); 

//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
jQuery("h2.trigger").click(function(){
	jQuery(this).toggleClass("active").next().slideToggle("slow");
	return false; //Prevent the browser jump to the link anchor
});

}); // Close document.ready
