﻿$(function () {

    var opt = {
        descr_pos: "bottom"
    };
    $('a.picZoom1').HHPopUp(opt);
    $('a.picZoom2').HHPopUp(opt);
    $('a.picZoom3').HHPopUp(opt);
    $('a.picZoom4').HHPopUp(opt);
    $('a.picZoom5').HHPopUp(opt);
    $('a.picZoom6').HHPopUp(opt);
    $('a.picZoom7').HHPopUp(opt);
    $('a.picZoom8').HHPopUp(opt);
    $('a.picZoom9').HHPopUp(opt);


    //alle Elemente mit dem Class 'hhgal' selektieren
    $('.hhgal').each(function () {
        //jedes der 'hhgal' elemente durchlaufen

        //anzahl der Links ermitteln
        var linksCount = $(this).children('a').length;

        //wenn die anzahl > 0 ist
        if (linksCount > 0) {
            //das erste a-Element holen
            var firstLink = $(this).children('a:first-child')
            //...und diesem hinten den folgenden Inhalt ranhängen
            if (linksCount == 1) {
                firstLink.append('<div class="hhgallerycount">' + linksCount + ' Bild anschauen</div>');
            } else {
                firstLink.append('<div class="hhgallerycount">' + linksCount + ' Bilder anschauen</div>');
            }
        }
    });

    //link zu demofilmen suchen und HHPopUp behandeln
    var demofilme = $('a[href*="demofilme/"]');
    demofilme.each(function () {
        var href = new String($(this).attr('href'));

        var elems = href.split('/');
        if (elems.length > 0) {
            var doc = elems[elems.length - 1];
            doc = doc.replace(".htm", "");

            href = "http://" + window.location.hostname + "/demofilme/movie.cgi?ac=" + doc;

            $(this).attr('href', href);
        }

    });

    $('a[href*="demofilme/"]').HHPopUp({ descr_pos: "bottom", mediaCounterTxt1: "Lernvideo " });



    //link zu Infotexten suchen und HHPopUp behandeln
    var infotexte = $('a[href*="infos/"]');
    infotexte.each(function () {
        var href = new String($(this).attr('href'));

        var elems = href.split('/');
        if (elems.length > 0) {
            var doc = elems[elems.length - 1];
            doc = doc.replace(".htm", "");

            href = "http://" + window.location.hostname + "/infos/infos.cgi?ac=" + doc;

            $(this).attr('href', href);
        }

    });

    infotexte.HHPopUp({ mediaCounterTxt1: "Info " });


    //dieser Code sorgt dafür, dass beim Aufruf der lernvideo.htm (sowie -a und -d) und der Übermittlung eines Parameters mit dem Namen der Video Seite,
    //automatisch ein PopUp aufgeht. Bsp.: lernvideo.htm?praesentation_urlaub
    //Benötigt für die Link in der chm Hilfe
    if (window.location.toString().indexOf('lernvideo', 0) >= 0) {
        var param = window.location.search.toString().toLowerCase();
        param = param.replace(/\?/, "");
        if (param.length > 0) {

            var found = $('a[name="' + param + '"]');
            if (found.length > 0) {
                found.first().click();
            }
        }
    }



    $('.testversion').unbind('mouseenter').mouseenter(function () { $('.testversion').attr('src', 'styles/img/kostenlos-testen_hover.gif'); });
    $('.testversion').unbind('mouseleave').mouseleave(function () { $('.testversion').attr('src', 'styles/img/kostenlos-testen.gif'); });
    $('.testversion').unbind('click').click(function () { $('.testversion').attr('src', 'styles/img/kostenlos-testen.gif'); });



    $('.tour').unbind('mouseenter').mouseenter(function () { $('.tour').attr('src', 'styles/img/tour-starten_hover.gif'); });
    $('.tour').unbind('mouseleave').mouseleave(function () { $('.tour').attr('src', 'styles/img/tour-starten.gif'); });
    $('.tour').unbind('click').click(function () { $('.tour').attr('src', 'styles/img/tour-starten.gif'); });

    $('.logotext').click(function () {
        href = "http://" + window.location.hostname;
        window.location = href;
    });

});
