function calculateByInvestition(){
	var investition=$('#investition').val();
	investition=parseFloat(investition.replace(",","."));
	if(investition=="" || isNaN(investition)){investition=0;}
	
	
	var dachflaeche=investition/312.5;
	$('#dachflaeche').val(dachflaeche.toFixed(2).replace(".",","));
	
	var nennleistung=dachflaeche/8;
	$('#nennleistung').text(nennleistung.toFixed(2).replace(".",","));

	var ertragPAkwh=dachflaeche*106.25;
	$('#ertragPAkwh').text(ertragPAkwh.toFixed(0).replace(".",","));
	var ertragPAeur=dachflaeche*30.625;
	$('#ertragPAeur').text(ertragPAeur.toFixed(2).replace(".",","));

	var ertragP20Akwh=dachflaeche*2125;
	$('#ertragP20Akwh').text(ertragP20Akwh.toFixed(0).replace(".",","));
	var ertragP20Aeur=dachflaeche*610;
	$('#ertragP20Aeur').text(ertragP20Aeur.toFixed(2).replace(".",","));
}

function calculateByDachflaeche(){
	var dachflaeche=$('#dachflaeche').val();
	dachflaeche=parseFloat(dachflaeche.replace(",","."));
	if(dachflaeche=="" || isNaN(dachflaeche)){dachflaeche=0;}
	
	
	var investition=dachflaeche*312.5;
	$('#investition').val(investition.toFixed(2).replace(".",","));
	
	var nennleistung=dachflaeche/8;
	$('#nennleistung').text(nennleistung.toFixed(2).replace(".",","));

	var ertragPAkwh=dachflaeche*106.25;
	$('#ertragPAkwh').text(ertragPAkwh.toFixed(0).replace(".",","));
	var ertragPAeur=dachflaeche*30.625;
	$('#ertragPAeur').text(ertragPAeur.toFixed(2).replace(".",","));

	var ertragP20Akwh=dachflaeche*2125;
	$('#ertragP20Akwh').text(ertragP20Akwh.toFixed(0).replace(".",","));
	var ertragP20Aeur=dachflaeche*610;
	$('#ertragP20Aeur').text(ertragP20Aeur.toFixed(2).replace(".",","));
}

function dom_init() {

if ($('#calculator').length) {

	$('#investition').keyup(calculateByInvestition);
	$('#dachflaeche').keyup(calculateByDachflaeche);

	if($('#investition').val()!=""){
		calculateByInvestition();
	} else if($('#dachflaeche').val()!=""){
		calculateByDachflaeche();
	}

}

  slideshowInit();
  
  $(".tab_content").hide();
  $("ul.tabs li").first().addClass("active").show();
  $(".tab_content").first().show();
  $("ul.tabs li").click(function() {
    $("ul.tabs li").removeClass("active");
    $(this).addClass("active");
    $(".tab_content").hide();
    var activeTab = $(this).find("a").attr("href");
    $(activeTab).fadeIn();
    return false;
  });
  
  $('.boxgrid.thecombo').hover(function(){
    $(".cover", this).stop().animate({top:'0px', left:'0px'},{queue:false,duration:300});
  }, function() {
    $(".cover", this).stop().animate({top:'150px', left:'200px'},{queue:false,duration:300});
  });
  
  $('#navigation li').hover(function(){
    $(this).addClass('hovered');
  }, function(){
    $(this).removeClass('hovered');
  });
  
  
  $('.refNav a').click(function(){
    var sortClass=$(this).attr('rel');
    $('.refNav .current').removeClass('current');
    $(this).parent().addClass('current');
    if(sortClass=='all'){
      $('.reflist li').fadeIn();
      return false;
    } else {
      $('.reflist li:not(.'+sortClass+')').fadeOut();
      $('.reflist li[class*="'+sortClass+'"]').fadeIn();
      return false;
    }
  });
  
  var myFile = document.location.toString();
  if (myFile.match('#')) { // the URL contains an anchor
    var myAnchor = '#' + myFile.split('#')[1];
    myAnchor = myAnchor.substring(1);
    
    myAnchor=decodeURI(myAnchor);
    if (myAnchor != "") {
      $('.refNav a[rel="' + myAnchor + '"]').click();
    }
  }
  
  
}
function slideshowInit(){
  var timer = setInterval(autoplaySlideshow, 5000);
}
function autoplaySlideshow(){
  $('.logoSlide').last().clone().prependTo('#partnerSlider');
  $('#partnerSlider .logoSlide').last().animate({opacity:'0'},'slow',function(){
    $('.logoSlide').last().remove();
  });
}




