if(enableCustomFont=false){
	
	// activate hover satte for links wrapped into paragraphs
	Cufon.replace('p a',{hover:true} );
	
	// hover states on start page
	Cufon.set( {color:'#000000'} )
		('.mod_newslist h2 a')('.solutions td')('.descr_box span.title');
	Cufon.set( {color:'#FFFFFF'} )
		('.mod_newslist h2 a.hovered')('.solutions td.hovered')('.descr_box span.title.hovered');

	// link font mapping
	Cufon.replace('a:not(.item_link)',{hover:true} );
		
	// normal weight font mapping
	Cufon.set( {
		fontFamily: 'Univers',
		fontWeight: '400'
	})('td')('h2' )('span' )('p')('.mod_catalogreader .field');
	
	// bold weight font mapping
	Cufon.set( {
		fontFamily: 'Univers',
		fontWeight: '700'	
	})('h1')('strong')('.bold')('label');
	
}







(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)


// general props 

//featuring box
var descr,
	currBoxIndex = 0,
	box_bottomwidth_col = 50,
	box_bottomwidth_exp = 535,
	boxSideWidth=89,
	cubeOverlapX = 87,
	cubeExpWidth = 513,
	cubeHeight = 262,
	cubeFrontHeight = 176,
	cubeFrontWidth = 446,
	cubeColWidth = 154;//685;
	
// slide show box
var currSlideShowBoxIndex = 0

$(document).ready( function(){
	
	$(".solutions a.hyperlink_txt").attr("title","Mehr zu unserem Angebot");
	
	$("#metaNav .pageSearch").focus(function(){ $(this).attr("value",""); });
	
	$.preLoadImages( 
		"tl_files/images/greenarrow_right_hover.png",
		"tl_files/images/greenarrow_right_hover.png",
		"tl_files/images/footer_mailbtn_bg_hover.png",
		"tl_files/images/footer_map_bg_hover.png",
		"tl_files/images/button_bg_hover.png"
	);
	
	if( $(".mod_catalogfeatured").size() )
	{
		initProjectFeatureBoxes();
	}	
	
	if( $(".mod_catalogreader").size() )
	{
		initSlideShowBox();
	}
	
	if( $(".mod_cataloglist").size() )
	{
		$(".mod_cataloglist .year_teaser").addClass("active")
			.click( 
			function(){
				
				$(this).toggleClass("active").next().slideToggle();
				
			} );
	}
	
	
	// solution text hover
	$(".solutions .solutionTable p").wrap("<div class='p'/>");
	$(".solutions .solutionTable h1").wrap("<div class='h1'/>");
	$(".solutions a.hyperlink_txt").bind('mouseover mouseout', function(){
		if( $(".solutions .solutionTable p").add(".solutions .solutionTable h1").toggleClass("hovered").hasClass("hovered") )
			Cufon.refresh('.solutions .solutionTable *');
		else
			Cufon.refresh('.solutions .solutionTable *');
	} );
	
	// news teaser hover
	$(".mod_newslist .layout_latest").bind('mouseover mouseout', function(){
		if( $(this).find("a").toggleClass("hovered").hasClass("hovered") )
			Cufon.refresh('.mod_newslist h2 a.hovered');
		else
			Cufon.refresh('.mod_newslist h2 a');
	} );
	
	Cufon.refresh();
	
	$(".mod_catalogfilter .checkbox_container>div.filter_item").click(function(event){
		if( $(this).index() == 0 )
		{
			return;
		}
		event.preventDefault();
		$(this).toggleClass("active").next().slideToggle(300);
	}).next().hide();
	var checked = $(".mod_catalogfilter input[checked=checked]");
	checked.parent().parent().parent().show().prev().addClass("active");
	// 	if( checked.size()==0 ){
	// 		$(".mod_catalogfilter .checkbox_container>div.filter_item").show();
	// 	}
	
	$("ul li input.checkbox").hide().after("<span class='checkbox'/>").change(function(){
		$(this).siblings("span.checkbox").toggleClass("checked");
	})
	$("ul li span.checkbox").click(function(){
		$(this).siblings("input.checkbox").trigger('change');
	});
	$("ul li input.checkbox[checked=checked]").siblings("span.checkbox").addClass("checked");
} );


function initSlideShowBox() {
	
	
	var num = showTargetSlide( currSlideShowBoxIndex );
	$.preLoadImages( "tl_files/images/detailview_nav_hoverleft.png","tl_files/images/detailview_nav_hoverright.png" );
	
	if(num>1){
		
		// enable click through
		$(".mod_catalogreader div.field.image .image img").click( function(){ showTargetSlide( currSlideShowBoxIndex+1 ) } )
			.attr("title","Nächstes Bild anzeigen...");
		
		// initialize navigation
		var nav = $("<div class='nav_arrows' />").appendTo(".mod_catalogreader div.field.image");
		$( "<a href='javascript:void()' class='prev' />" ).appendTo( nav )
			.click( function(){ showTargetSlide( currSlideShowBoxIndex-1 ) } )
			.bind("mouseover mouseout",function(){ $(this).parent().toggleClass("lefthovered") });
		$( "<a href='javascript:void()' class='next' />" ).appendTo( nav )
			.click( function(){ showTargetSlide( currSlideShowBoxIndex+1 ) } )
			.bind("mouseover mouseout",function(){ $(this).parent().toggleClass("righthovered") });
	}
	
	
	
}

function showTargetSlide( index ) {
	var imgs = $(".mod_catalogreader div.field.image .image");
	
	if( index >= imgs.size() ){
		currSlideShowBoxIndex = 0;
	}else if( index < 0 ){
		currSlideShowBoxIndex = imgs.size()-1;
	}else{
		currSlideShowBoxIndex = index;
	}
	imgs.hide().eq(currSlideShowBoxIndex).show();
	return imgs.size();
}



function initProjectFeatureBoxes() {
	
	var w,
		total_w = 0;
	
	$(".mod_catalogfeatured .item").each( function(index){
		
		var span = $(this).find(".description"),
			h1 = $(this).find("h1");
		
		$(this).addClass("collapsed");
		$(this).css( { left:0 } );
		$("<div class='shadow'/>").appendTo( $(this) );
		$("<div class='overlaySide'/>").appendTo( $(this) );
		var img = $(this).find("img");
		var contBottom = $("<div class='imgContainerBottom'><img/></div>").insertAfter(img);
		contBottom.append( span );
		img.wrap("<div class='imgContainerTop'/>");
		contBottom.find("img").attr({ src:img.attr("src") })
		
		if( index==0 ){	
			$("<div class='underlaySide'/>").insertBefore( $(this).find(".imgContainerTop") );
		}
		
	} ).click( toggleBoxView );
	
	
	//$(".mod_catalogfeatured").css({ width:0, left:0 });
	$(".mod_catalogfeatured .imgContainerTop").css({ width:0, opacity:0, height:cubeHeight-cubeFrontHeight });
	$(".mod_catalogfeatured .imgContainerBottom").css({ width:0, opacity:0, height:cubeHeight });
	$(".mod_catalogfeatured .shadow").css({ opacity:0 });
	$(".mod_catalogfeatured span.description").css({ top:187 })
	$(".mod_catalogfeatured .item").eq(currBoxIndex).addClass("expanded");
	
	
	// initialize bar and navigation
	initTextTeaserNav();
	//initIndicationBar();
	
	// initialize description box
	descr = $("<div class='descr_box' />").appendTo( ".mod_catalogfeatured" );	
	descr.css({ width:box_bottomwidth_exp-boxSideWidth, top:cubeHeight+$(".mod_catalogfeatured .layout_full").position().top })
	descr.append("<span class='title' />");
	descr.append("<a class='more_link'>&nbsp;</a>");
	$(".mod_catalogfeatured .descr_box > *").wrapAll("<div class='detail_info' />")
		.bind('mouseover mouseout', function(event){
			if( $(this).parent().find("span.title").toggleClass("hovered").hasClass("hovered") ){
				Cufon.refresh( '.descr_box span.title.hovered' )
			}else{
				Cufon.refresh( '.descr_box span.title' )
			}
			$(this).parent().find("a.more_link").toggleClass("hovered");
		})
		.click(function(){
			location.href = $(this).parent().find("a.more_link").attr("href"); 
		});
	$(".mod_catalogfeatured .descr_box").append("<a class='project_overview_link' href='portfolio.html'>Zur Portfolioübersicht</a>");
	
	// start automation and animations
	updateRow( 1400 );
	setAutoSlideTimer();
	
}

function initIndicationBar() {
	var bar = $("<div class='indicationBar'/>").appendTo(".mod_catalogfeatured");
	$("<a class='navLeft' />").appendTo(bar).click( showPrevSlide );
	$( ".mod_catalogfeatured .item" ).each(function(index){
		bar.append( "<div class='box'><a /></div>" );
	});
	
	bar.find(".box:first").addClass("active");
	bar.find(".box").click( toggleBoxView ).wrapAll("<div class='box_group' />");
	$("<a class='navRight' />").appendTo(bar).click( showNextSlide );
	bar.children().wrapAll("<div class='icon_group' />");
	
}

function initTextTeaserNav() {
	var nav = $("<div class='textTeaserNav'/>").insertBefore(".mod_catalogfeatured .layout_full");
	$( ".mod_catalogfeatured .item" ).each(function(index){
		var content = "<strong>"+$(this).find(".client").text()+"</strong><br />"+$(this).find(".solution").text() ;
		$( "<div class='teaser'><a /></div>" ).appendTo(nav)
			.find("a").html( content );
	});
	
	nav.find(".teaser:first").addClass("active");
	nav.find(".teaser").click( toggleBoxView );
	
	$(".mod_catalogfeatured .layout_full").css({ top:Math.round(nav.height()+nav.position().top-5) })
}

function showNextSlide() {
	expandTargetSlide( currBoxIndex + 1 );
}

function showPrevSlide() {
	expandTargetSlide( currBoxIndex - 1 );
}

function toggleBoxView() {
	expandTargetSlide( $(this).index() );
}

function updateRow( duration, options ) {
	
	var row,
		left,
		w,
		onComplete,
		exp, 
		duration = duration || 400,
		delay = delay || 600,
		opts = options || {queue:false, duration:duration},
		opacity,
		moreBtn,
		v_gap = 1;
	$(".mod_catalogfeatured").each(function(index){
		left = 0;
		row = $(this);
		row.find(".item").each(function(index)
		{
				
			exp = $(this).hasClass("expanded");
			opacity = { opacity:1 };
			var box_topwidth_col = box_bottomwidth_col+boxSideWidth;
			var box_topwidth_exp = box_bottomwidth_exp+boxSideWidth;
			
			w = exp?box_bottomwidth_exp:box_topwidth_col;
			w-=v_gap;
			
			// animation
			$(this).animate({ width:w, left:left },opts );			
			$(this).find(".shadow").animate( opacity,opts );
			$(this).find(".imgContainerTop").animate( $.extend({width:box_bottomwidth_exp},opacity), {queue:false, duration:duration} );
			$(this).find(".imgContainerBottom").animate( $.extend({width:exp?box_bottomwidth_exp+v_gap-boxSideWidth:box_bottomwidth_col},opacity), {queue:false, duration:duration} );

			if( exp ){
				descr.animate({left:left},opts);
				descr.find("span").text( $(".mod_catalogfeatured .item").eq(currBoxIndex).find("h1").text() );
				descr.find("a.more_link").attr("href", $(".mod_catalogfeatured .item").eq(currBoxIndex).find("a").attr("href"));
				Cufon.refresh('span');
			}
			
			left += w-cubeOverlapX;
		});
	});
	
}

function setAutoSlideTimer() {
	$(window).stopTime();
	$(window).oneTime(5000, function(i) {
		currBoxIndex++;
		expandTargetSlide( currBoxIndex );
	} );
	
}

function expandTargetSlide( index ) {
	currBoxIndex = index;
	
	if( currBoxIndex >= 4 ){
		currBoxIndex = 0;
	}else if( currBoxIndex < 0 ){
		currBoxIndex = 3;
	}
	$(".indicationBar .box").removeClass("active")
		.eq(currBoxIndex).addClass("active");	
	
	$(".textTeaserNav .teaser").removeClass("active")
		.eq(currBoxIndex).addClass("active");	
		
	$(".mod_catalogfeatured .item").addClass("collapsed").removeClass("expanded")
		.eq(currBoxIndex).addClass("expanded").removeClass("collapsed");  
	updateRow();
	setAutoSlideTimer();
}




