// JavaScript Document
if ('undefined'!=typeof(jQuery)){
	jQuery.noConflict();
	jQuery(document).ready(function(){
		jQuery('a.navLinkLevel0').each(function(){
			var connectedSubNavigation=jQuery(this).parent().find('ul');
			var href=jQuery(this).attr('href');
			if (connectedSubNavigation.length==1){
				jQuery(this).attr('href','javascript:;');
				connectedSubNavigation.appendTo(jQuery('#navigation'));
				jQuery(this).click(function(){
					if (jQuery(this).hasClass('active'))return(false);
					jQuery('a.navLinkLevel0').removeClass('active');
					jQuery(this).addClass('active');
					jQuery('ul.navigationLevel1').fadeOut(150);
					connectedSubNavigation.stop(true,true).fadeIn(150).addClass('active');
					return(false);
				});
			}
			
			if ('undefined'!=typeof(currentNavLevel0) && currentNavLevel0==jQuery(this).text()){
				jQuery(this).addClass('active');
				if (connectedSubNavigation.length==1){
					connectedSubNavigation.find('a').each(function(){
						if(jQuery(this).text()==currentNavLevel1)jQuery(this).addClass('active');
					});
				}
			}
		});
		
		jQuery('a.externalLink').click(function(){
			window.open(jQuery(this).attr('href'),'externalLink');
			return(false);
		});
		
		//init google maps
		if (jQuery('#googleMapsNoScript').length==1){
			var googleMapsCode=jQuery('<iframe width="350" height="490" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=de&amp;geocode=&amp;q=M%C3%BCller+-+Bremer+GmbH,+Maarstra%C3%9Fe,+Bonn,+Deutschland&amp;aq=0&amp;oq=M%C3%BCller&amp;sll=50.73924,7.14348&amp;sspn=0.014802,0.038109&amp;vpsrc=6&amp;ie=UTF8&amp;hq=M%C3%BCller+-+Bremer+GmbH,&amp;hnear=Maarstra%C3%9Fe,+53227+Bonn,+Nordrhein-Westfalen,+Deutschland&amp;t=m&amp;cid=1722792272141562285&amp;ll=50.745797,7.147293&amp;spn=0.026612,0.030041&amp;z=14&amp;iwloc=A&amp;output=embed"></iframe>');
			jQuery('a#googleMapsNoScript').before(googleMapsCode).remove();
		}
		
		//init mobile devices		
		if (isMobileDevice()){
			function hideURLbar(){
				window.scrollTo(0,0.9)
			}
			hideURLbar();
		}
	});
	
	//detection functions
	//mobile devices
	function isMobileDevice(){
		return((navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPod/i)||(navigator.userAgent.match(/iPad/i))||(navigator.userAgent.match(/Android/i))))
	}
	//touch devices
	function isTouchDevice(){  
		try{  
			document.createEvent("TouchEvent");  
			return(true);  
		}catch(e){
			return(false);  
		}  
	}
}
