	$.getScript('http://www.google-analytics.com/ga.js',
		function() {
		var pageTracker = _gat._getTracker("UA-15951351-1");
		pageTracker._setDomainName(".gross-partner.de");
		pageTracker._trackPageview();
	});
jQuery.fn.sameLevel = function(){
	return $(this).nextAll().add($(this).prevAll());
}
function html_entity_decode(str){
	var tarea=$('<textarea />');
	tarea.html(str);
	str = tarea.val()
	tarea.remove();
	return str;
}
jQuery.fn.prepare = function(){
	//Cufon.refresh();
	if($('#slideshow').length>0){
		$('#slideshow img:not(:last)').hide();
		$('#slideshow img').css({width:459,height:550})
		if($.browser.msie){
			$('#slideshow img').css({width:435,height:526})
		}
		var doslide = function(){
			$('#slideshow').append($('#slideshow img:first')
			.fadeIn(1000,function(){
				$('#slideshow img:not(:last)').hide();
				$('#slideshow img:last').animate({opacity:1},{complete:function(){
				doslide();
				},duration:5000});
			}));	
		}
		doslide();
	}
	
	$('.angebote .further').hide();
	$('a.toggle-further').each(function(i,e){
		$(e).data('textclosed',$(e).html());
		$(e).data('textopen',$(e).attr('name'));
	});
	$('a.toggle-further').click(function(){
		if(!$(this).hasClass('open')){
			$(this).addClass('open');
			$(this).parent().nextAll('.angebote .further').slideDown();
			$(this).html($(this).data('textopen'));
		} else {
			$(this).removeClass('open');
			$(this).parent().nextAll('.angebote .further').slideUp();
			$(this).html($(this).data('textclosed'));
		}
		return false;
	});
	
	
	
	$('.results').hide();
	$('.results .result').hide();
	
	if($('.angebote form').length){
		var divboxes = [];
		$('#content .richtext').each(function(i,e){
			divboxes.push(e);
			if(i>0)	$(e).hide();
		});
	}
	
	$('.angebote form').submit(function(){
			$(divboxes[0]).hide();
			$(divboxes[1]).show();
			$(divboxes[2]).hide();	
		$('.results').hide();
		$('.results .result').hide();
		var classesactive = [];
		if($('#select1').val()!=0){
			classesactive.push('.'+$('#select1').val());
		}
		if($('#select2').val()!=0){
			classesactive.push('.'+$('#select2').val());
		}
		if($('#select1').val()==0 && $('#select2').val()){
			classesactive.push('.result');
		}
		
		if(classesactive.length){
			var classes = classesactive.join('');
		}else{
			var classes = '.absolutenonesense';	
		}
		if($(classes).length){
			$(classes).show();
			$('.results').fadeIn();
		}else{
			$(divboxes[2]).fadeIn();	
		}
        return false;
    });
    $('.angebote form').submit();
	$(this).find('a.arrowed:last').after($('<span class="clearer"> </span>'));
	$(this).find('a').click(function(){
		$(this).blur();
	});
	$(this).find('a[href^="http://"]:not(.insider)').attr('target','_blank');
	$(this).find('a[href$=".pdf"]').attr('target','_blank');
	$(this).find('a:not([href^="/media"]):not([href^="http://"]):not([href^=mailto:]):not([href^=skype:]):not([href^=#]):not(.toggle-further):not([href^=/download]):not([href$=.swf]):not([href^=javascript]):not(#fancybox-close):not(.smallbox):not(.bigbox)')
		.click(function(){
		$.historyLoad($(this).attr('href'));
		//loadPage($(this).attr('href'));
		return false;
	});
	
	
	$(this).find('a.bigbox:not(href^=jpeg):not(href^=jpg)').css({fontWeight:'normal'}).fancybox({'overlayShow':false,'width':900,'height':540,'autoDimensions':false,'onComplete':function(){
		if($('#fancybox-inner .popup').height()<$('#fancybox-inner').height()){
			$('#fancybox-inner .popup').css({height:$('#fancybox-inner').height()-20});
		}
}});
	$(this).find('a.smallbox:not(href^=jpeg):not(href^=jpg)').css({fontWeight:'normal'}).fancybox({'overlayShow':false,'width':450,'height':300,'autoDimensions':false,'onComplete':function(){
		if($('#fancybox-inner .popup').height()<$('#fancybox-inner').height()){
			$('#fancybox-inner .popup').css({height:$('#fancybox-inner').height()-20});
		}
}});
	
	$(this).find('.image a').fancybox({'overlayShow':false,'titlePosition':'outside','cyclic':false,'hideOnContentClick':true,'onStart':function(){
		showonstart = setTimeout(function(){
			$('#fancybox-left, #fancybox-right').removeClass('hover');
		},4000);
		$('#fancybox-right')
		.addClass('hover')
		$('#fancybox-left, #fancybox-right')
		.mouseover(function(){
			clearTimeout(showonstart);
			$(this).addClass('hover');	
		})
		.mouseout(function(){
			clearTimeout(showonstart);
			$('#fancybox-left, #fancybox-right').removeClass('hover');	
		});
	}});
	var wm = 'transparent';
	$(this).find('a.video').each(function(i,e){
		var size = $(e).attr('rel').split('-');
		
if (swfobject.hasFlashPlayerVersion("9.0.18")) {
		$(e).fancybox({
			'overlayShow':false,
			'type'  : 'swf',
			'width':parseInt(size[1]),
			'height':parseInt(size[2]),
			'swf':{'flashvars':'v='+size[3]+'&playIcon=#000000&controlsAutoHide=true&autoPlay=true&controlsBg=#666666&controlsBgAlpha=1&fullscreen=false','wmode': wm,'allowfullscreen':false,'width':'100%','height':'100%'},
			'onComplete':function(){
				setTimeout(function(){
					$('#fancybox-inner object,#fancybox-inner embed').attr({height:1,width:1})
						.attr({width:$('#fancybox-outer').width()-18,height:$('#fancybox-outer').height()-18})
				}
				,200);
			}
		});
		}else{
			$(e).hide();
		}
	});

	
	$(this).find('input:not([type=submit])').each(function(i,e){
		$(e).data('oval',$(e).val());
		$(e).focus(function(){
			if($(this).val()==$(this).data('oval'))
				$(this).val('');	
		});
		$(e).blur(function(){
			if($(this).val()=='')
				$(this).val($(this).data('oval'));	
		});
	});
	$(this).find('.accordion li:not(.open)>div').hide();
	$(this).find('.accordion li .trigger').click(function(){
		if($(this).parent().hasClass('open')){
			$(this).parent().removeClass('open');
			$(this).next('div').slideUp();
		}else{
			$(this).parent().addClass('open');
			$(this).next('div').slideDown();
		}
		$(this).parent().sameLevel().removeClass('open').children('div').slideUp();
		return false;	
	});
	if($(this).find('ul#history li').length){
		hismaygo = true;
		function showYear(year){
			if($('#history .year-'+year).length && hismaygo){
				$('#history li').hide();
				$('#history .year-'+year).fadeIn();
				$('#history_navi li').removeClass('active');


				if($('#history_navi .year-'+year).position().left>=Math.abs(parseInt($('#history_navi').css('margin-left')))+$('#history_navi').parent().width() && $('#history_navi .year-'+year).position().left>0){
					hismaygo = false;
					$('#history_navi').animate({marginLeft:-$('#history_navi .year-'+year).position().left},{queue:false,complete:function(){
						hismaygo = true;
					}});	
				}
				if($('#history_navi .year-'+year).position().left<Math.abs(parseInt($('#history_navi').css('margin-left'))) && $('#history_navi .year-'+year).position().left>0){
					hismaygo = false;
					$('#history_navi').animate({marginLeft:-(($('#history_navi .year-'+year).position().left+$('#history_navi .year-'+year).width())-$('#history_navi').parent().width())},{queue:false,complete:function(){
						hismaygo = true;
					}});
				}



				$('#history_navi .year-'+year).addClass('active');
				curryear = year;
				if(year==$('#history_navi li:last').html())
					clearInterval(slideTimer);
			}
		}
		function showNextYear(){
			clearInterval(slideTimer);
			showYear($('#history_navi li.active:first').next('li').find('a').html());	
		}
		function showNextYearInterval(){
			showYear($('#history_navi li.active:first').next('li').find('a').html());	
		}
		function showPrevYear(){
			clearInterval(slideTimer);
			showYear($('#history_navi li.active:first').prev('li').find('a').html());	
		}
		var mh = 0;
		var history_navi = $('<ul />')
				.attr('id','history_navi');
		history_navi.data('i',0);
		var history_navi_holder = $('<div />')
			.attr('id','history_navi_holder')
			.append(history_navi);
		$('ul#history').before(history_navi_holder);
		history_navi_holder.after(
			$('<a href="#" class="bt_rt" />')
				.css('float','left')
				.click(function(){
					$(this).blur();
					clearInterval(slideTimer);
					showNextYear();
					return false;	
				})
		);
		history_navi_holder.before(
			$('<a href="#" class="bt_lt" />')
				.css('float','left')
				.click(function(){
					$(this).blur();			
					clearInterval(slideTimer);
					showPrevYear();
					return false;		
				})
		);
		$('ul#history li').each(function(i,e){
			var year = $(e).children('h5:first').html();
			var cls = 'year-'+year;
			if($('li a:contains('+year+')').length==0){
				history_navi
					.append(
					$('<li />')
						.addClass(cls)
						.html('<a href="#">'+year+'</a>')
						.click(function(){
							clearInterval(slideTimer);
							showYear(year);	
							return false;
						})
				);
			}
			$(e).children('h5').remove();
			$(e).addClass(cls);
				$(e).hide();	
			if($(e).height()>mh)
				mh = $(e).height();	
		});
		$('ul#history').children('li').css('height',mh);
		$('ul#history').css('height',mh+40);
		$('#history_navi').css({width:$('#history_navi>li').length*$('#history_navi>li:first').width()});
		var curryear = $('ul#history_navi li:first').find('a').html();
		var minyear = curryear;
		showYear(curryear);
		var slideTimer = setInterval(showNextYearInterval,6000);
	}
}

function loadPage(url,type){	
		var pageTracker = _gat._getTracker("UA-15951351-1");
		pageTracker._setDomainName(".gross-partner.de");
		pageTracker._trackPageview(url);
	//window.location.hash='#'+url;
	$.fancybox.close();
	$('#header ul ul').hide();
	$('#header *').removeClass('active');
	$('a.active').removeClass('active');
	
	$('a[href='+url+']').parents('ul').show();
	$('a[href='+url+']').parents('li').addClass('active');
	$('a[href='+url+']').parent('li').parent('ul').prev('a').addClass('active');
	
	$('a[href='+url+']').addClass('active');
	$('a[href='+url+']').next('ul').css({top:$('#header ul ul').data('t')}).fadeIn();
	if($('a[href='+url+']').parents('ul ul').length>0){
		$('a[href='+url+']').parents('ul ul').animate({top:-($('a[href='+url+']').parent('li').position().top-$('#header ul ul').data('t'))});
	}
	$('#content').html('');
	$('#pageheading h1').hide();
	//$('body').css({overflow:'hidden'});
	$('#holder').css({height:'95%'});
	$('#content').addClass('loading');
	jQuery.ajax({
		url: url,
		type:"GET",
		dataType: "html",
		complete: function(res, status){
			$('#holder').css({height:''})
			//$('body').css({overflow:''});
			$('a[href='+url+']').parents('ul ul').animate({top:-($('a[href='+url+']').parent('li').position().top-$('#header ul ul').data('t'))});
			var tit = $.trim(res.responseText.replace( /([\s\S]+)<title>/, '' ).replace(/<\/title>([\s\S]+)/, '' ));
			var helper = $('<div />').append(res.responseText.replace(/<script(.|\s)*?\/script>/g, ""));
			document.title = html_entity_decode(tit);
			$('*').scrollTop(0);
			if(helper.find('#pageheading h1').html()!=''){
				$('#content').css('margin-top',$('#content').data('mt'));
				$('#pageheading').css({display:'block'});
				$('#pageheading h1').html(helper.find('#pageheading h1').html())
					.fadeIn();
			}else{
				$('#content').css('margin-top',parseInt($('#content').data('mt'))-26);
			}
			$('#pageheading h1').html(html_entity_decode(tit).split('|')[0]);
			$('#content')
				.hide()
				.html(helper.find('#content').html())
				.fadeIn()
				.prepare();
			/*$('#lngswitcher')
				.attr('href',helper.find('#lngswitcher').attr('href'))
				.innerHTML = helper.find('#lngswitcher').innerHTML;*/
			$('*').removeClass('loading');
		}
	});
}


$('document').ready(function(){
	$.historyInit(loadPage,"/");
	$('#content').css({display:'block'});
	if(window.location.pathname!='/' && window.location.pathname!='/newsletter'){
		window.location = '/#'+window.location.pathname;
		return;
	}
	$('#content').data('mt',parseInt($('#content').css('margin-top')));
	$('#header ul ul').data('t',6);
	$('body').prepare();
	/*var reloc = window.location.hash.substr(1);
	if(reloc=='') reloc = '/';
	if(reloc!='/'){
		loadPage(reloc);
	}*/
	
	

});


$(document).ready(function(){
// Flashintro
/*swfobject.embedSWF($('#flashdiv>a').attr('href'), "flashdiv", "459", "540", "8,0,0", null, {wmode:"transparent"});
var flashvars = {wmode:"transparent"};
var params = {
  menu: "false"
};
var attributes = {
  style: "z-index:-1"
};

//swfobject.embedSWF($('#flashdiv>a').attr('href'), "flashdiv", "459", "540", "8,0,0",null, flashvars, params, attributes);
$('embed, object').css({zIndex:1});
$('#content').css({zIndex:1});*/

//Cufon.replace('h1,#header a',{hover: true});
});