jQuery(document).ready(function () {
    //Firefox, Chrome
    if (navigator.appName.toLowerCase() == "netscape") {
        jQuery(".content").keydown(function (event) {

            if (document.activeElement == "[object HTMLTextAreaElement]") {

            }
            else {

                if (jQuery(".content .alink.send").length > 0) {

                    var keycode = (event.keyCode ? event.keyCode : event.which);

                    if (keycode == '13') {

                        event.preventDefault();
                        //window.location.href = jQuery('.content .alink.send').attr('onClick');
                        jQuery(".content .alink.send").click();
                    }
                }

                if (jQuery(".content .hsuche").length > 0) {

                    var keycode = (event.keyCode ? event.keyCode : event.which);
                    if (keycode == '13') {

                        event.preventDefault();
                        jQuery(".content .hsuche").click();
                    }
                }

            }

        });
    }
    //IE
    if (navigator.appName.toLowerCase() == 'microsoft internet explorer') {

        if (document.activeElement == "[object HTMLTextAreaElement]") {

        }
        else {

            var idsearch = jQuery('.searchbox').children().next().attr('id');
            var objsearch = jQuery('.searchbox').children().next();

            jQuery(objsearch).attr('disabled', 'disabled');

            jQuery(".searchbox").focus(function () {
                jQuery(objsearch).attr('disabled', 'disabled');
            });
            jQuery(".content").focus(function () {
                jQuery(objsearch).attr('disabled', '');
            });
        }
    }





    jQuery("#tbl2 table tr:even").addClass("even");
    jQuery("#tbl1 table tr:even").addClass("even");

    if (jQuery("#tab1 table th").length == 0) {
        jQuery("#tbl1 table tr:first").addClass("theader");
    }
    if (jQuery("#tab2 table th").length == 0) {
        jQuery("#tbl2 table tr:first").addClass("theader");
    }
    jQuery("#tbl1 table").attr("border", 0);
    jQuery("#tbl2 table").attr("border", 0);

    jQuery('#tbl1 table tr').each(function () {
        jQuery('td:first', this).css('border-left', 'none');
        jQuery('th:first', this).css('border-left', 'none');
    });
    jQuery('#tbl2 table tr').each(function () {
        jQuery('td:first', this).css('border-left', 'none');
        jQuery('th:first', this).css('border-left', 'none');
    });


    if (jQuery(".contentcontainer .contentheader ul.contentheadernav").length > 0) {
        jQuery('.contentcontainer .contentheader ul.contentheadernav br').remove();
    }



    // Pretty Photo
    jQuery("a[rel^='prettyPhoto']").prettyPhoto({
        animationSpeed: 'normal',
        padding: 40,
        opacity: 0.35,
        show_title: false,
        counter_separator_label: ' von ',
        allow_resize: false,
        theme: 'light_square',
        hideflash: true,
        modal: false,
        overlay_gallery: false,
        markup: '<div class="pp_pic_holder"> \
						<div class="ppt">&nbsp;</div> \
						<div class="pp_top"> \
							<div class="pp_left"></div> \
							<div class="pp_middle"></div> \
							<div class="pp_right"></div> \
						</div> \
						<div class="pp_content_container"> \
							<div class="pp_left"> \
							<div class="pp_right"> \
								<div class="pp_content"> \
									<div class="pp_loaderIcon"></div> \
									<div class="pp_fade"> \
										<a href="#" class="pp_expand" title="Expand the image">Expand</a> \
										<div class="pp_hoverContainer"> \
											<a class="pp_next" href="#">ZURÜCK</a> \
											<a class="pp_previous" href="#">VOR</a> \
										</div> \
										<div id="pp_full_res"></div> \
										<div class="pp_details"><div style="float:left;"> \
											<div class="pp_nav"><span style="font-size:11px;float:left;">Bild </span> \
												<a href="#" class="pp_arrow_previous">Previous</a> \
												<p class="currentTextHolder">Bild 0 von 0</p> \
												<a href="#" class="pp_arrow_next">Next</a>\
											</div><div class="clear"></div> \
											<div class="pp_description" style="color:white;"></div></div><div style="float:right;"> \
											<a class="pp_close pp_closebig" href="#">Close</a></div> \
										</div> \
									</div> \
								</div> \
							</div> \
							</div> \
						</div> \
						<div class="pp_bottom"> \
							<div class="pp_left"></div> \
							<div class="pp_middle"></div> \
							<div class="pp_right"></div> \
						</div> \
					</div> \
					<div class="pp_overlay"></div>'
    });
    /* Glossar PrettyPhoto */
    jQuery("a[rel^='Glossar']").prettyPhoto({
        show_title: false,
        allow_resize: false,
        theme: 'light_square',
        hideflash: true,
        modal: false,
        markup: '<div class="pp_pic_holder"> \
						<div class="ppt">&nbsp;</div> \
						<div class="pp_top"> \
							<div class="pp_left"></div> \
							<div class="pp_middle"></div> \
							<div class="pp_right"></div> \
						</div> \
						<div class="pp_content_container"> \
							<div class="pp_left"> \
							<div class="pp_right"> \
								<div class="pp_content"> \
									<div class="pp_loaderIcon"></div> \
									<div class="pp_fade"> \
										<a href="#" class="pp_expand" title="Expand the image">Expand</a> \
										<div class="pp_hoverContainer"> \
											<a class="pp_next" href="#">next</a> \
											<a class="pp_previous" href="#">previous</a> \
										</div> \
										<div id="pp_full_res"></div> \
										<div class="pp_details clearfix"> \
										</div> \
									</div> \
								</div> \
							</div> \
							</div> \
						</div> \
						<div class="pp_bottom"> \
							<div class="pp_left"></div> \
							<div class="pp_middle"></div> \
							<div class="pp_right"></div> \
						</div> \
					</div> \
					<div class="pp_overlay"></div>',

        inline_markup: '<div class="pp_inline clearfix">{content}</div>'
    });



    /* Navigation */

    if (jQuery(".left .navigation .second .third").length > 0) {
        jQuery(".left .navigation .second").addClass("path");
    }
    if (jQuery(".left .navigation .second .third .fourth").length > 0) {
        jQuery(".left .navigation .second .third").addClass("path");
    }

    if (tabid == 1) {
        if ((jQuery('#newsticker').children().length) > 1) {
            jQuery('#newsticker').list_ticker({
                speed: 10000,
                effect: 'slide'
            })
        }
        jQuery("#Slider").xparoSlider({
            navi: false,
            pages: true,
            numbers: "image",
            interval: 11600,
            slide: true
        });
    }



    /* Produkttabellen: */

    if (jQuery("body.print").length == 0) {

        jQuery("#tbl2 table").addClass("hidden");
        jQuery(".tableheader a").click(function () {
            backgroundbool = jQuery(this).next().css('display');
            if (jQuery(this).nextAll().hasClass("hidden")) {
                jQuery(this).nextAll().removeClass("hidden");
                jQuery(this).css('background', 'transparent url("portaldata/1/resources/_intern/layout/pfeiltableunten.png") no-repeat 0% 50%');
            }
            else {
                jQuery(this).nextAll().addClass("hidden");
                jQuery(this).css('background', 'transparent url("portaldata/1/resources/_intern/layout/pfeiltablerechts.png") no-repeat 0% 50%');
            }

            return false;
        });

    }
    else {
        jQuery("#tbl2.tableheader span").css('background', 'transparent url("portaldata/1/resources/_intern/layout/pfeiltableunten.png") no-repeat 0% 50%');
    }

    /* Kalender, News und Glossar */
    //selectboxstylechange
    if (jQuery("select").length > 0) {
        jQuery("select").selectbox();
    }


    //Faq Content
    var backgroundbool = "";
    /*hovereffekt faqelements
    jQuery('.faqelements .index-header').mouseover(function () {
    jQuery(this).css('background', "#EBEBEB url(portaldata/1/resources/_intern/layout/pfeilmouseover.png) no-repeat 98% 50%");
    }).mouseout(function () {
    var inhalt = jQuery(this).attr('style');
    jQuery(this).css('background', 'none');

    if (inhalt != 'background: url("portaldata/1/resources/_intern/layout/pfeilmouseover.png") no-repeat scroll 98% 50% rgb(235, 235, 235);') {
    //jQuery(this).children().css('background', 'transparent url("portaldata/1/resources/_intern/layout/greenaufzaehlungszeichen.png") no-repeat 0px 50%');
    jQuery(this).css('background', 'none');
    jQuery(this).css('background', 'transparent url("portaldata/1/resources/_intern/layout/pfeilhoch.png") no-repeat 98% 50%');
    if (jQuery(this).next().hasClass('faqactive')) {
    jQuery(this).css('background', 'none');
    jQuery(this).css('background', "transparent url(portaldata/1/resources/_intern/layout/pfeilhoch.png) no-repeat 98% 50%");
    }
    else {
    //verhindert ?bergreifen
    jQuery(this).css('background', 'none');
    }
    }
    });*/
    /*faqcontent click event*/
    jQuery(".faqelements .index-header a").click(function () {
        backgroundbool = jQuery(this).parent().next().css('display');

        if (backgroundbool == 'none') {
            jQuery(this).parent().next().addClass('faqactive');
            jQuery(this).parent().addClass('headeractive');
            // jQuery(this).parent().css('border-bottom', 'none');
            // jQuery(this).parent().css('background', 'transparent url("portaldata/1/resources/_intern/layout/pfeilhoch.png") no-repeat 98% 50%');
            //  jQuery(this).parent().next().css('border-bottom', '1px solid #E3E3E3');
        }
        else {
            //    jQuery(this).parent().css('background', 'transparent url("portaldata/1/resources/_intern/layout/pfeilmouseover.png") no-repeat 98% 50%');
            jQuery(this).parent().next().removeClass('faqactive');
            jQuery(this).parent().removeClass('headeractive');
            //      jQuery(this).parent().css('border-bottom', '1px solid #E3E3E3');
            //    jQuery(this).parent().next().css('border-bottom', 'none');
        }
    });
    /*faqcontent click event end*/


    /*hovereffekt calendar
    jQuery('.overallcalendardiv .calendar .index-header').mouseover(function () {
    jQuery(this).css('background', "#EBEBEB url(portaldata/1/resources/_intern/layout/pfeilmouseover.png) no-repeat 98% 50%");
    }).mouseout(function () {
    var inhalt = jQuery(this).attr('style');
    jQuery(this).css('background', 'none');

    if (inhalt != 'background: url("portaldata/1/resources/_intern/layout/pfeilmouseover.png") no-repeat scroll 98% 50% rgb(235, 235, 235);') {
    //jQuery(this).children().css('background', 'transparent url("portaldata/1/resources/_intern/layout/greenaufzaehlungszeichen.png") no-repeat 0.755em 42.5%');
    jQuery(this).css('background', 'none');
    jQuery(this).css('background', 'transparent url("portaldata/1/resources/_intern/layout/pfeilhoch.png") no-repeat 98% 50%');
    if (jQuery(this).next().hasClass('faqactive')) {
    jQuery(this).css('background', 'none');
    jQuery(this).css('background', "transparent url(portaldata/1/resources/_intern/layout/pfeilhoch.png) no-repeat 98% 50%");
    }
    else {
    //verhindert übergreifen
    jQuery(this).css('background', 'none');
    }
    }
    });
    */
    /*calendar click event*/
    jQuery(".overallcalendardiv .calendar .index-header a").click(function () {
        backgroundbool = jQuery(this).parent().parent().next().css('display');

        if (backgroundbool == 'none') {
            jQuery(this).parent().parent().css('background', 'transparent url("portaldata/1/resources/_intern/layout/pfeilhoch.png") no-repeat 98% 50%');
            jQuery(this).parent().parent().next().addClass('faqactive');
        }
        else {
            jQuery(this).parent().parent().css('background', 'transparent url("portaldata/1/resources/_intern/layout/pfeilmouseover.png") no-repeat 98% 50%');
            jQuery(this).parent().parent().next().removeClass('faqactive');
        }
    });

    /*admaterial click event*/
    jQuery(".admaterial .index-header a").click(function () {
        backgroundbool = jQuery(this).parent().parent().next().css('display');

        if (backgroundbool == 'none') {
            //         jQuery(this).parent().parent().css('background', 'transparent url("portaldata/1/resources/_intern/layout/pfeilhoch.png") no-repeat 98% 50%');
            jQuery(this).parent().parent().next().addClass('faqactive');
        }
        else {
            //        jQuery(this).parent().parent().css('background', 'transparent url("portaldata/1/resources/_intern/layout/pfeilmouseover.png") no-repeat 98% 50%');
            jQuery(this).parent().parent().next().removeClass('faqactive');
        }
    });

    /*calendar click event end*/

    /*a-hovereffekt detailview*/
    jQuery('.listdetailview .news .index-header').mouseover(function () {
        jQuery(this).css('background-color', "#EBEBEB");
    }).mouseout(function () {
        var inhalt = jQuery(this).attr('style');
        jQuery(this).css('background', 'none');

        if (inhalt != 'background: url("portaldata/1/resources/_intern/layout/pfeilmouseover.png") no-repeat scroll 98% 50% rgb(235, 235, 235);') {
            jQuery(this).css('background', 'none');
        }
    });
    /*detailview a-click event*/
    //    jQuery(".listdetailview .calendar .index-header a").click(function () {
    //        backgroundbool = jQuery(this).parent().parent().next().css('display');

    //        if (backgroundbool == 'none') {
    //            jQuery(this).parent().parent().css('background', 'none');
    //            jQuery(this).parent().parent().next().addClass('faqactive');
    //        }
    //        else {
    //            jQuery(this).parent().parent().css('background', 'none');
    //            jQuery(this).parent().parent().next().removeClass('faqactive');
    //        }
    //    });
    /*detailview clickevent end*/

    /*detailview listview change click*/
    jQuery(".view.list").click(function () {

        jQuery(".listdetailview .news .index-content").removeClass('faqactive');

        jQuery(".view.list").removeClass('viewactive');
        jQuery(".view.detail").removeClass('viewactive');
        jQuery(".view.list").addClass('viewactive');
        //        jQuery(".view.list").css('background-color', '#E5E5E5');
        //        jQuery(".view.detail").css('background-color', '#F7F7F7');
    });
    jQuery(".view.detail").click(function () {
        jQuery(".listdetailview .news .index-content").addClass('faqactive');
        jQuery(".view.list").removeClass('viewactive');
        jQuery(".view.detail").addClass('viewactive');
        //        jQuery(".view.list").css('background-color', '#F7F7F7');
        //        jQuery(".view.detail").css('background-color', '#E5E5E5');
    });
    /*detailview listview change click end*/
    if (jQuery(".faq .index-letters").length > 0) {
        for (i = 1; i <= 26; i++) {
            if (jQuery(".faq .Letter" + String.fromCharCode(64 + i)).length == 0) {
                jQuery(".faq .index-letters .index" + String.fromCharCode(64 + i)).addClass("grey");
                jQuery(".faq .index-letters .index" + String.fromCharCode(64 + i)).removeAttr("onclick");
            }
        }

        var number = false;
        for (i = 0; i < 10; i++) {
            if (jQuery(".faq .Letter" + i).length > 0) {
                number = true;
            }
        }
        if (number == false) {
            jQuery(".faq .index-letters .indexNR").addClass("grey");
            jQuery(".faq .index-letters .indexNR").removeAttr("onclick");
        }

        if (jQuery(".faq .Letter" + String.fromCharCode(196)).length == 0) { // ?
            jQuery(".faq .index-letters .index" + String.fromCharCode(196)).addClass("grey");
            jQuery(".faq .index-letters .index" + String.fromCharCode(196)).removeAttr("onclick");
        }
        if (jQuery(".faq .Letter" + String.fromCharCode(214)).length == 0) { // ?
            jQuery(".faq .index-letters .index" + String.fromCharCode(214)).addClass("grey");
            jQuery(".faq .index-letters .index" + String.fromCharCode(214)).removeAttr("onclick");
        }
        if (jQuery(".faq .Letter" + String.fromCharCode(220)).length == 0) { // ?
            jQuery(".faq .index-letters .index" + String.fromCharCode(220)).addClass("grey");
            jQuery(".faq .index-letters .index" + String.fromCharCode(220)).removeAttr("onclick");
        }

    }

    /* Twitter */
    if (jQuery("#twitterbox").length > 0) {
        jQuery("#twitterbox").xparoTwitter({
            username: "IsoverGH",
            tweetcount: 3,
            image: false,
            template: "html",
            templateID: "ItemTemplate",
            mode: "standard"
        });
    }
});
/* Glossar Funktion */

/*Glossar Funktion - Buchstaben Links aktiv/inaktiv setzen */
function setLetter(Letter) {
    if (jQuery(".faqelements .headeractive").length > 0) {
        jQuery(".faqelements .headeractive").removeClass("headeractive");
        jQuery(".faqelements .faqactive").removeClass("faqactive");
    }

    jQuery(".faq .Letters").hide();


    jQuery(".faq .index-letters span").removeClass("lettersactive");
    if (Letter == "NR" || Letter == "All") {
        if (Letter == "NR") {
            for (i = 0; i < 10; i++) {
                if (jQuery(".faq .Letter" + i)) {
                    jQuery(".faq .Letter" + i).show();
                }
            }

            jQuery(".faq .index-letters .indexNR").addClass("lettersactive");
        } else if (Letter == "All") {
            jQuery(".faq .Letters").show();
            jQuery(".faq .index-letters .indexAll").addClass("lettersactive");
        }
    }
    else {

        jQuery(".faq div.Letter" + Letter).show();
        jQuery(".faq .index-letters .index" + Letter).addClass("lettersactive");
    }
}


function addItemToBasket(itemid, currentCount, obj) {
    if (!document.forms[0]) return;
    var tmp = obj;
    var count = null;
    count = parseInt(jQuery("#count" + itemid + " .jquery-selectbox-currentItem").html());

    obj.disabled = true;
    var field = document.createElement("input");
    field.type = "hidden";
    field.id = "additem" + itemid;
    field.name = "additem" + itemid;
    field.value = count + currentCount;
    document.forms[0].appendChild(field);
    document.forms[0].submit();
}
function addItemFromDetailToBasket(itemid, currentCount, obj) {
    if (!document.forms[0]) return;
    var tmp = obj;
    var count = null;
    count = parseInt(jQuery("#count" + itemid + " .jquery-selectbox-currentItem").html());
    jQuery(".shop_itemcount").val(count + currentCount);
    document.forms[0].submit();
}

function applyForEvent(showing) {
    if (jQuery("#eventdetail").length > 0 && jQuery("#eventapply").length > 0) {
        if (showing == 1) {
            jQuery("#eventdetail").show();
            jQuery("#eventapply").hide();
            jQuery(':text, :password, :file', '#eventapply').val('');
        }
        else if (showing == 2) {
            jQuery("#eventdetail").hide();
            jQuery("#eventapply").show();
            jQuery(".seminartitle").val(jQuery("#choosenEvent #seminartitle").html());
            jQuery(".seminarplace").val(jQuery("#choosenEvent #seminarplace").html());
            jQuery(".seminardate").val(jQuery("#choosenEvent #seminardate .full").html());
            jQuery(".seminarnumber").val(jQuery("#choosenEvent #seminarnumber").html());
            jQuery(".seminartitle").attr('readonly', true);
            jQuery(".seminarplace").attr('readonly', true);
            jQuery(".seminardate").attr('readonly', true);
            jQuery(".seminarnumber").attr('readonly', true);

            jQuery("#eventapply select").selectbox();


            /*
            jQuery(".seminardata").val(jQuery("#choosenEvent").html());
            */


        }
    }
    return false;
}

function showAttendant(id, obj) {
    jQuery(obj).hide();
    jQuery("#attendant" + id).show();

    jQuery(".alink.remove" + (id - 1) + "").hide();
    jQuery("#attendant" + id + " select").selectbox();
    return false;
}
function removeAttendant(id, obj) {
    if (id == 1) {

        jQuery(".mail .alink.add1").show();
    }
    else {
        jQuery("#attendant" + (id - 1) + " .alink.add" + id).show();

        jQuery("#attendant" + (id - 1) + " .alink.remove" + (id - 1)).show();
    }
    jQuery("#attendant" + id).hide();
    jQuery(":text", "#attendant" + id).val('');
    return false;
}

/* List Ticker by Alex Fish 
// www.alexefish.com
//
// options:
//
// effect: fade/slide
// speed: milliseconds
*/

(function ($) {
    $.fn.list_ticker = function (options) {

        var defaults = {
            speed: 4000,
            effect: 'slide'
        };

        var options = $.extend(defaults, options);

        return this.each(function () {

            var obj = $(this);
            var list = obj.children();
            list.not(':first').hide();

            setInterval(function () {

                list = obj.children();
                list.not(':first').hide();

                var first_li = list.eq(0)
                var second_li = list.eq(1)

                if (options.effect == 'slide') {
                    first_li.slideUp();
                    second_li.slideDown(function () {
                        first_li.remove().appendTo(obj);
                    });
                } else if (options.effect == 'fade') {
                    first_li.fadeOut(function () {
                        obj.css('height', second_li.height());
                        second_li.fadeIn();
                        first_li.remove().appendTo(obj);
                    });
                }
            }, options.speed)
        });
    };
})(jQuery);


