if ($.browser.msie && top != self) {
	top.location = self.location;
}


$(document).ready(function() {


	/**
	 * main nav js - simulate hover
	 */
	/*$(".mainnav > ul > li").hover(
		function () {
			$(this).addClass("hover");
		},
		function () {
			$(this).removeClass("hover");
		}
	);*/
	$(".combinav > ul > li").hover(
		function () {
			$(this).addClass("hover");
		},
		function () {
			$(this).removeClass("hover");
		}
	);

	/*min-height fix ie6 - set #col1 min-height to 400px */
	if (jQuery.browser.version <= 6 && jQuery.browser.msie){
		if ($("#col1").height() < 370){
			$("#col1").height(370);
		}
	}


	/**
	 * Feature elements (interactive box)
	 */
	$('.feature').gmcFeatureBox({
		activeClass: 'active',
		navClass: 'feature-nav'
	});


	/**
	 * Configure language selector
	 */
	$('#countryAnchor').click(function() {
			$('#langSelector').slideToggle(200);
			//$('#langSelector').toggle();
			$('#langSelector').css({ top:"0", backgroundColor:"transparent" });
			return false;
	});

	$('#langSelector').hover(
		function () {
			//do nothing
		},
		function () {
			if ($('#langSelector').css("display") == "block"){
				$('#langSelector').slideToggle(200);
				//$('#langSelector').toggle();
			}
		}
	);


	/**
	 * Print
	 */
	$('a.print').click(function() {
		//$('link[media=screen]').attr('disabled', 'disabled');
		//$('link[title="Print Preview"]').attr('disabled', '');
		window.print();
		return false;
	});


	/**
	 * Enable and configure lightbox
	 */
	$('ul.gallery').each(function () {
		$('a', $(this)).lightBox({
			imageLoading:  ZF_BASEURL + '/images/jquery/lightbox/lightbox-ico-loading.gif',
			imageBtnPrev:  ZF_BASEURL + '/images/jquery/lightbox/lightbox-btn-prev.gif',
			imageBtnNext:  ZF_BASEURL + '/images/jquery/lightbox/lightbox-btn-next.gif',
			imageBtnClose: ZF_BASEURL + '/images/jquery/lightbox/lightbox-btn-close.gif',
			imageBlank:	   ZF_BASEURL + '/images/jquery/lightbox/lightbox-blank.gif'
		});
	});
	$('.galleryMore').click(function() {
		$(this).nextAll('li').removeClass('hidden');
		$(this).nextAll('.galleryLess').show().css('display', 'inline');
		$(this).hide();
	});
	$('.galleryLess').click(function() {
		$(this).prevAll('.galleryMore').show().css('display', 'inline');
		$(this).prevAll('.galleryMore').nextAll('li').addClass('hidden');
		$(this).hide();
	});


	/**
	 * IE6 PNG Transparency fix
	 */
	if ($.browser.msie && ($.browser.version == '6.0')) {
		try {
		  document.execCommand("BackgroundImageCache", false, true);
		} catch(err) {}
		$.ifixpng(ZF_BASEURL + '/images/pixel.gif');
		$('.print, #col2 .vh_result_content ul li, .teaser_roundedwhitecorner_link span, .teaser_roundedwhitecorner_link, .header_content, .headerimage_overlay, .main_bottomcorners, .header_bottomcorners, .header_topcorners, .main_topcorners, .header_nav, .tagcloud_top, .tagcloud_bottom, .mainnav a.backtohome, .Tablist ul li .label_left, .Tablist ul li .label_right, ul.paging').ifixpng(ZF_BASEURL + '/images/pixel.gif');
	}


	/**
	 * Form help bubble
	 */
	$(".formline input, .formline select").focus(function(){
	 	$(this).parents('.formline').find('.helptext').show();	//fadeIn(400);
	});
	$(".formline input, .formline select").blur(function(){
	 	$(this).parents('.formline').find('.helptext').hide();	//fadeOut(200);
	});
	/**
	 * Open all external links in a new window
	 */
	$("a[@href^=http]").each(
		function() {
			if (this.href.indexOf(location.hostname) == -1) { 
				//$(this).attr('target', '_blank');
			}
		}
	);

});
	/**
	 * Avatar - funktioniert nicht im document ready ...
	 */
	globalcontroltypewriter = 0;
	globalmesg = '';
	
    function sendToJSAvatar(mesg,stat,overwrite)
    {
    if (mesg != '')
      {
         var stat = (typeof(stat) != 'undefined') ? stat : "info" ;
          stat = 'avatar_'+stat;
         var el = document.getElementById('avatar_body');
         //el.innerHTML = mesg;
         var l = mesg.length;
         var p = 0; 
         var ms = 30;
         if ((!overwrite) && (globalmesg == mesg)) return false; //mesg schon angezeigt ... nicht nochmal schreiben
         globalmesg = mesg;
         var localcontroltypewriter = ++globalcontroltypewriter; //nicht 2 typewriter gleichzeitig
         function typewriter()
         {     
             if ((globalcontroltypewriter == localcontroltypewriter) && (p++ < l)) {
               var padding = '<span style="visibility:hidden">' + mesg.substring(p, l+1) + '</span>';
               el.innerHTML = mesg.substring(0, p) + padding;
               setTimeout(typewriter, ms);
             }
         }
         el.parentNode.setAttribute('id', stat);
         setTimeout(typewriter, ms); 
      }
    }
