function resizeIframe(height) {
    $('#tipafriend').height(height + 60);
    $('#lightbox-container-image-box').height(height + 70);
}
$(document).ready(function () {
    $('.WeiterempfehlenLink').click(function () {
        var appendhtml = ' \
		<div id="jquery-overlay" class="OverlayWeiterempfehlen"></div> \
		<div id="jquery-lightbox" class="LightBoxWeiterempfehlen" style="top:5%;"> \
			<div id="lightbox-container-image-box" style="width: 566px; display: block; ">  \
				<div id="lightbox-secNav" style="">  \
					<div style="padding: 30px 0 10px 0;float:left;width: auto;"><h2 style="clear: both;display: inline;background: #E2007A;font-size: 18px;color: white;margin: 20px 16px 20px 16px;">&nbsp;Seite empfehlen&nbsp;</h2></div>  \
					<a href="#" id="lightbox-secNav-btnClose"><img src="/fileadmin/images/schliessen_x_off.png"></a>  \
				</div>  \
				<iframe src="/index.php?id=171&tipUrl=' + encodeURIComponent(document.URL) + '&eID=tipafriend" width="566" height="200" name="tipafriend" id="tipafriend" frameborder="0" style="overflow-y:hidden;"></iframe> \
			</div>  \
		</div> \
		';
        $('body').append(appendhtml).each(function () {
            $('#tipafriend').load(function () {
                //$('#tipafriend').height(document.getElementById('tipafriend').contentWindow.document.body.scrollHeight);
                //$('#lightbox-container-image-box').height(document.getElementById('tipafriend').contentWindow.document.body.scrollHeight);
            });
            $('input,text,textarea').clearField();
            $('.BtnEmpfehlen').click(function () {
                $("#jquery-lightbox .TextField ").each(function (i) {
                    if (this.text != "") {}
                });
                return false;
            });
            $('#lightbox-secNav-btnClose').click(function () {
                $('#jquery-overlay, #jquery-lightbox, .iframegeneratedContent').remove();
                return false;
            });
        });
        return false;
    });
	// Block Marginal letzten Abstand entfernen
	$('.BlockMarginal:last').css("margin-bottom","0");
    $('.infolbopen').click(function () {
        $('#jquery-overlay, #jquery-lightbox, .iframegeneratedContent').show();
        $('#lightbox-secNav-btnClose').click(function () {
            $('#jquery-overlay, #jquery-lightbox, .iframegeneratedContent').hide();
            return false;
        });
        return false;
    });
    $("a.topnav").bind("mouseenter", function () {
        if ($("a.topnav.acti").length == 0) { // && !$(this).hasClass("actv")
            var curract = $(this);
            $(this).parent().children("ul.topnav").stop(true, true);
            curract.addClass("acti");
            curract.css("display", "block");
            if ($.browser.msie) {
                $(this).parent().append('<div class="TopNavigShadow" style="position: absolute;z-index: 1000;width:' + ($(this).parent().children("ul.topnav").width() - 8) + 'px"></div>');
            } else {
                $(this).parent().append('<div class="TopNavigShadow" style="position: absolute;z-index: 1000;width:' + ($(this).parent().children("ul.topnav").width() + 1) + 'px">		</div>');
            }
            $(this).parent().children("ul.topnav").css("z-index", "1")
            $(this).parent().children("ul.topnav").slideDown("slow");
            $("a.topnav.acti").parent("li").one("mouseleave", function () {
                curract.stop(true, true);
                curract.removeClass("acti");
                $("ul.topnav").hide();
                $(".MetaNavig .TopNavigShadow").remove();
            })
        }
    })
    //$("ul.topnav li a").hover($(this).addClass("active"),$(this).removeClass("active"));
    $("ul.topnav li a").hover(

    function () {
        $(this).addClass("active");
    }, function () {
        $(this).removeClass("active");
    });
    $(".SubNavig").hide();
    if ($(".MainNavig ul li a.progress").length > 0) {
        if ($(".SubNavig." + $(".MainNavig ul li a.progress").attr("subnav")).html().length != 0) {
            $(".SubNavig." + $(".MainNavig ul li a.progress").attr("subnav")).show();
            $(".SubNavig." + $(".MainNavig ul li a.progress").attr("subnav")).animate({
                height: "24px"
            }, 500);
        }
    }
    if ($(".MainNavig ul li a.Actv").length > 0 && $(".SubNavig." + $(".MainNavig ul li a.Actv").attr("subnav")).html().length != 0) {
        $(".SubNavig." + $(".MainNavig ul li a.Actv").attr("subnav")).show();
        $(".SubNavig." + $(".MainNavig ul li a.Actv").attr("subnav")).height(24);
    }
/*$(".MainNavig ul li a").each(function (i) {
		if (!$(this).hasClass("Actv"))
		{
			$(".SubNavig." + $(this).attr("subnav")).animate({
        		height: "24px"
    		}, 500);		
		}
		else 
		{
			//$(".SubNavig." + $(this).attr("subnav")).height(24)	
		}
	});*/
/*$(".MainNavig ul li a").click(function () {
		if (!$(this).hasClass("Actv")) {
			if (!$(".MainNavig ul li a.Actv").length == 0) {
				$(".SubNavig").animate({
					height: "0px"
				}, 500);
				$(".MainNavig ul li a.Actv").removeClass("Actv");
			}
			$(this).addClass("Actv");
			$(".SubNavig." + $(this).attr("subnav")).animate({
			   height: "24px"
			}, 500);
		}
	});*/
    $(".SubNavig #jsddm li.firstLi").bind("mouseenter", function () {
        if (!$(this).children("a").hasClass("subActv")) {
            curract = $(this)
            if (!$(".SubNavig #jsddm li.firstLi.act").length == 0) {
                $(".SubNavig #jsddm li.act a").removeClass("Actv");
                $(".SubNavig #jsddm li.act ul").stop(true, true).hide().removeClass("act");
            }
            curract.addClass("act");
            curract.children("a").addClass("Actv");
            curract.children("ul").slideDown("slow");
            $(curract).one("mouseleave", function () {
                $(this).children("ul").hide();
                $(".SubNavig #jsddm li.act a").removeClass("Actv");
            })
        }
    });
    $(".SubNavig #jsddm li.firstLi ul li a").hover(

    function () {
        $(this).addClass("active");
    }, function () {
        $(this).removeClass("active");
    });
    $(".SubNavig #SonderNavig li").bind("mouseenter", function () {
        curract = $(this)
        curract.children("a").addClass("Actv");
        curract.children("ul").slideDown("slow");
        $(".SubNavig #SonderNavig li").bind("mouseleave", function () {
            $(this).children("ul").stop(true, true);
            $(this).children("ul").slideUp("slow");
            $(this).children("a").removeClass("Actv");
        })
    });
    $(".imgContainer .imgOverlay").bind("mouseenter", function () {
        $(this).stop();
        $(this).animate({
            height: '102px'
        }, "slow");
    }).bind("mouseleave", function () {
        $(this).stop();
        $(this).animate({
            height: '25px'
        }, "slow");
    });
    // init lightBox
    $(function () {
        $('#gallery a:not(.nolightbox)').lightBox();
        $('tr.gallery a:not(.nolightbox)').lightBox();
    });
    $('.TBList th').each(function () {
        $(this).text($(this).text().replace('\u0084', '"').replace('\u0093', '"').replace('\u2019', "'").replace('\x92', "'").replace('\u0092', "'").replace('\u0096', '-').replace('\x96', "-"));
        //.replace('\u0084', '"').replace('\u0093', '"').replace('\u2019', "'").replace('\x92', "'").replace('\u0092', "'")
        //this.innerHTML = this.innerHTML;
    });
});
(function ($) {
    $.fn.clearField = function (settings) {
        settings = jQuery.extend({
            blurClass: 'clearFieldBlurred',
            activeClass: 'clearFieldActive',
            attribute: 'rel',
            value: ''
        }, settings);
        return $(this).each(function () {
            var el = $(this);
            settings.value = el.val();
            if (el.attr(settings.attribute) == undefined) {
                el.attr(settings.attribute, el.val()).addClass(settings.blurClass);
            } else {
                settings.value = el.attr(settings.attribute);
            }
            el.focus(function () {
                if (el.val() == el.attr(settings.attribute)) {
                    el.val('').removeClass(settings.blurClass).addClass(settings.activeClass);
                }
            });
            el.blur(function () {
                if (el.val() == '') {
                    el.val(el.attr(settings.attribute)).removeClass(settings.activeClass).addClass(settings.blurClass);
                }
            });
        });
    };
})(jQuery);

function showMessage(html) {
    var htmlMessage = '<div id="Layer" style="display:none"></div>\
                  <div id="LightBox" display:none;">\
					  <div class="LightBoxTop">\
						<img src="images/lb_info.png" class="lbinfo" alt="" border="0">\
						<img src="images/lb_close.png" class="lbclose" alt="" border="0">\
					  </div>\
					  <div class="LightBoxText">\
						' + html + '\
					  </div>\
                  </div>';
    $("body #Container").prepend(htmlMessage);
    $("#Layer").height($("#Container").height());
    $("#Layer").fadeTo("500", 0.8)
    $("#LightBox").fadeIn(500);
    $("#LightBox .lbclose, #Layer").click(function () {
        $("#Layer, #LightBox").fadeOut(500, function () {
            $("#Layer, #LightBox").show()
        });
        return false;
    });
}

function slideToggle(el, bShow) {
    var $el = $(el),
        height = $el.data("originalHeight"),
        visible = $el.is(":visible");
    if (arguments.length == 1) bShow = !visible;
    if (bShow == visible) return false;
    if (!height) {
        height = $el.show().height();
        $el.data("originalHeight", height);
        if (!visible) $el.hide().css({
            height: 0
        });
    }
    if (bShow) {
        $el.show().animate({
            height: height
        }, {
            duration: 250
        });
    } else {
        $el.animate({
            height: 0
        }, {
            duration: 250,
            complete: function () {
                $el.hide();
            }
        });
    }
}

function openLightWindowiFrame(iFrameSource) {
    var appendlightboxString = ' \
		<div id="jquery-overlay" style="background-color: rgb(0, 0, 0); opacity: 0.5; width: 1903px; height: 969px;position:fixed; "></div> \
		<div id="jquery-lightbox" style="top: 5%; left: 0px;position:fixed; "> \
			<div id="lightbox-container-image-box" style="width: 598px; height: 688px; display: block; "> \
				<div id="lightbox-secNav" class="DLine" style="height:31px"> \
					<a href="#" id="lightbox-secNav-btnClose" onClick="$(\'#jquery-overlay, #jquery-lightbox, .iframegeneratedContent\').remove();return false;"><img src="/fileadmin/images/schliessen_x_off.png"></a> \
				</div> \
					<iframe id="lightwindowIframe" src="' + iFrameSource + '" width="593" height="650" frameborder="0"> \
				</iframe> \
			</div> \
		</div>';
    $("body").append(appendlightboxString);
}
