$(document).ready(function(){
	
	// Open lightbox if class "lightbox"
	jQuery("a.lightbox").each(
		function(){
			var paramValue = "?&type=67";
			var lightboxLink = jQuery(this).attr('href') + paramValue;
			jQuery(this).attr('href', lightboxLink);
			jQuery(this).attr('rel', 'shadowbox[0];width=500');
		}
	);
	
	
	// Open login in lightbox 
	jQuery("a[target=login]").each(
		function(){
			var paramValue = "?&type=67";
			var lightboxLink = jQuery(this).attr('href') + paramValue;
			jQuery(this).attr('href', lightboxLink);
			jQuery(this).attr('rel', 'shadowbox;height=480;width=320');
		}
	);
	// Open login in lightbox 
	jQuery("a.login").each(
		function(){
			var paramValue = "?&type=67";
			var lightboxLink = jQuery(this).attr('href') + paramValue;
			jQuery(this).attr('href', lightboxLink);
			jQuery(this).attr('rel', 'shadowbox;height=480;width=320');
		}
	);
	

	
	// Open print in lightbox 
	jQuery("a[target=print]").each(
		function(){
			var paramValue = "?&type=98";
			var lightboxLink = jQuery(this).attr('href') + paramValue;
			jQuery(this).attr('href', lightboxLink);
			jQuery(this).attr('rel', 'shadowbox[0];width=800');
		}
	);
	
	// Open lightbox if href contains "id=323" or "id=712" or "id=707" or "id=751"
	jQuery("a[href*=id=323], a[href*=id=707], a[href*=id=751], a[href*=id=721]").each(
		function(){
			var paramValue = "?&type=67";
			var lightboxLink = jQuery(this).attr('href') + paramValue;
			jQuery(this).attr('href', lightboxLink);
			jQuery(this).attr('rel', 'shadowbox;width=500');
		}
	);

	// RGgooglemaps HIDE Company Category
	jQuery('input#rggm-cat-1').hide();
	jQuery('label[for=rggm-cat-1]').hide();
	
	jQuery('.loadingLogo img').effect('pulsate', { times: 1 }, 1000);
	
	// FORMAT TABLE
	jQuery('table tr:odd').addClass('odd');
	jQuery('table tr:even').addClass('even');
	jQuery('table tr:first').addClass('first');
	
	// FADE IMAGES
	$(".selectYourCountry .link").find("img").fadeTo("slow", 0.3); // START OPACITY
	$(".selectYourCountry .link").hover(function(){
		$(this).find("img").fadeTo("slow", 1.0); 
	},function(){
		$(this).find("img").fadeTo("slow", 0.3); 
	});
	
	$("#close").click(function () {
      $("#extensions").remove();
  });
    
  $('#rggmsearch2').submit(function() {
		// alert('Handler for .submit() called.');
		return false;
	});


	
	jQuery('.mapAll').click(function(){
      jQuery('#searchFormResult').load('/index.php?id=59&type=500');
 
      return false;
  });

	
	
	
	
});


/*  LAYER NAVIGATION  */
	jQuery(function(){ 
		jQuery('#menu li').mouseenter(function () {
			jQuery(this).find('ul')
				.eq(0).addClass('open')
				.animate({ height: 'show', opacity: 'show' }, 'fast').parent("li").addClass('act');
		});
		jQuery('#menu li').mouseleave(function () {
			jQuery(this).find('ul')
				.eq(0).removeClass('open')
				.animate({ height: 'hide', opacity: 'hide' }, 'fast').parent("li").removeClass('act');
		});
		jQuery("a.showClone").click(function () {
			jQuery('#content2').load('index.php?id=59&type=500&no_cache=1&tx_rggooglemap_pi1[detail]=9&tx_rggooglemap_pi1[table]=tt_address'); 
		});
	});

/* FANCY LOADING ANIMATION */
if (document.location.href.indexOf('zoom=1') > 0) {
	var loader = jQuery('<div id="loadingdiv"><div class="loadingLogo"><img style="margin-bottom: 10px" src="fileadmin/templates/images/logo/logo_kardex_group_opt.png" width="171" height="28" /></div><div><img src="fileadmin/templates/images/icons/loader.gif" width="32" height="32" /></div></div>');
	var aniTime = 1000;
	var showContent = aniTime - 500;

	jQuery(document).ready(function(){
	    $('body').hide();
	    loader.appendTo('html');
	});
	
	// WAIT UNTIL EVERYTHING IS LOADED (DOM, IMAGES, SCRIPTS)
	jQuery(window).load(function(){
    	loader.remove();
	    $('body').show();
		if($(":animated")) {
			jQuery('#site').addClass("noBackground");		
		} else {
			jQuery('#site').removeClass("noBackground");
		};
    	$('#site').removeClass('noJS').addClass("small");
		$('.small div').fadeOut();
		$('.small').addClass("zoom", aniTime);
		$('.small div').animate({opacity: '+=0'}, showContent).fadeIn(400);
	});
	
}


	$(document).ready(function() {
 var inhalt = $("#content").html();
 inhalt = inhalt.replace(/target="_self"/gi,'');

 $("#content").html(inhalt);
 
});
