// JavaScript Document

Cufon.replace('#mainnav .L1_Active > a',{hover: true });
Cufon.replace('#mainnav .L2 > a',{hover: true });
Cufon.replace('#mainnav .L1 > a',{hover: true });

Cufon.replace('h1');
Cufon.replace('h2');
Cufon.replace('.forsideCenterRowColumn2 p');
Cufon.replace('.forsideCenterRowPerson');
Cufon.replace('#forsideBottomRow h3, .forsideCenterRowColumn2');
Cufon.replace('#educations h3');
Cufon.replace('#footerFindusbar ul li.findus');
Cufon.replace('.list .headline');
Cufon.replace('.midtvest .headline');





/*Cufon.replace('#bannerContent .text');*/

$(document).ready(function() {
 
   $("#breadcrumb span.Legend img").eq(0).css("display","none");
 	
	if ($('#subnav li li a').hasClass('L5_Active')) {
	    $('#subnav li a.L4_Active').addClass('hasChildren');
   }
   
   if ($('#subnav li li li a').hasClass('L6_Active')) {
	    $('#subnav li a.L4_Active').addClass('hasChildren');
        $('#subnav li li a.L5_Active').addClass('hasChildren');
   }
   
   if (!$('#subJsTjek ul').length) {
	     $("#subJsTjek").css("display","none");
   }
	
	
 
  var introheight = $("#introtext").height();
  var factsheight = $("#facts").height();
  
  if(introheight>0 && factsheight>0){
	  if(introheight>factsheight) {
		$('#outertext').css('height',introheight+"px");
		$('#introfactsContainer').css('height',introheight+"px");
		$('#rightWhiteOuter').css('height',introheight+80+"px");
		$('#rightWhiteOuterContainerContainer').css('height',introheight+80+"px");
		
	  }else{
		$('#outertext').css('height',factsheight+"px");
		$('#introfactsContainer').css('height',factsheight+"px"); 
		$('#rightWhiteOuter').css('height',factsheight+80+"px");
		$('#rightWhiteOuterContainerContainer').css('height',factsheight+80+"px");
	  }
  }
  
  var overskrift = $("#overskrift").height();
  
  if(overskrift>0){
	  $('#outertext').css('height',overskrift+"px");
	  $('#overskriftContainer').css('height',overskrift+"px");
	  $('#rightWhiteOuter').css('height',overskrift+66+"px");
	  $('#rightWhiteOuterContainerContainer').css('height',overskrift+66+"px");
  }

 var subnav = $("#subnav").height();
 
 if(subnav>0){
	 $('#subnavOuter').css('height',subnav+"px");
 }
 
	
  
 
  //Vis statement, kun EN!
  $( '.forsideCenterRowStatementContainer' ).eq( Math.floor(Math.random()*$( '.forsideCenterRowStatementContainer' ).length) ).show();
	
	
  //SLIDER
 // $("#forsidetop_slider").everyTime(10000, 'topstorytimer', function () {
	//  sliderpush('forsidetop_slider', 'forsidetop');  
  //});


    forsidetop_index = 0;
    forsidetop_count =  $(".banneritem").size();
    forsidetop_width = 1600;

      //navknapper
      ii=0;
      var navcontent ='<ul class="navitems">';
      while (ii < forsidetop_count) {

        if (ii == 0) {
        	var isAktiv = "active";
        } else {
        	var isAktiv = "";
        }

        var navcontent = navcontent + '<li class="'+isAktiv+'"><a href="#'+$(".banneritem").eq(ii).attr("id")+'" style="display: block;"></a></li>';
        ii++;

      }
	  var navcontent = navcontent + '</ul>';


      $("#forsidetop_nav").html(navcontent);
	  
     // $("#forsidetop_nav a").live("click", function() {
//
//        var rel = $(this).attr('rel');
//        forsidetop_index = rel;
//        sliderpush('forsidetop_slider', 'forsidetop', $(this));
//        $("#forsidetop_slider").stopTime();
//
//      });


	$("div.banneritem div.bannerdesc div.text a:eq(0)").addClass('firsta');
	$("div.banneritem div.bannerdesc div.text a:eq(1)").addClass('lasta');
	$("div.banneritem div.bannerdesc div.text a:eq(3)").addClass('lasta');
	$("div.banneritem div.bannerdesc div.text a:eq(5)").addClass('lasta');
	$("div.banneritem div.bannerdesc div.text a:eq(7)").addClass('lasta');
	$("div.banneritem div.bannerdesc div.text a:eq(9)").addClass('lasta');
	$("div.banneritem div.bannerdesc div.text a:eq(11)").addClass('lasta');

	$(".footerli").mouseenter(function() {
		$(this).addClass("activewhite");
		$(this).find(".onover").show();
		Cufon.replace('#endrow .navigation .header');

	}).mouseleave(function() {
		$(this).removeClass("activewhite");
		$(this).find(".onover").hide();
		Cufon.replace('#endrow .navigation .header');
	});


});

function sliderpush(sliderdiv, prefix, clickelement) {

				
	index = window[prefix+'_index'];
	var count = window[prefix+'_count'];
	var width = window[prefix+'_width'];

	if (clickelement) {
	
	var thisdirection = clickelement.attr('rel');
	

	if (thisdirection == 'zap_v') {

		index--;		

		if (index >= 0) {

			var forsidetopmoveto = width * index;
			$("#"+sliderdiv+"").animate({
				left: '-' + forsidetopmoveto +'px' 
				
			});			

		} else {
			index++;	
		}


	} else if (thisdirection == 'zap_h') {

		index++;	
		
		if (index < count) {

			var forsidetopmoveto = width * index;
									
			$("#"+sliderdiv+"").animate({
				left: '-' + forsidetopmoveto +'px' 
				
			});	
		

		} else {
			
			
			index = 0;
			var forsidetopmoveto = width * index;
									
			$("#"+sliderdiv+"").animate({
				left: '-' + forsidetopmoveto +'px' 
				
			});	
			
			
			
			//index--;	
		}					


	} else {
			
		var forsidetopmoveto = width * index;
		
		$("#"+sliderdiv+"").animate({
			left: '-' + forsidetopmoveto +'px' 
			
		});		
			
		
	}

	} else {

		index++;	
		
		if (index < count) {

			var forsidetopmoveto = width * index;
									
			$("#"+sliderdiv+"").animate({
				left: '-' + forsidetopmoveto +'px' 
				
			});			

		} else {
			index = 0;
			
			var forsidetopmoveto = width * index;
			
			$("#"+sliderdiv+"").animate({
				left: '-' + forsidetopmoveto +'px' 
				
			});		
		}	
		


	}

	$("#"+prefix+"_nav ul li").removeClass("active");
	$("#"+prefix+"_nav ul li").eq(index).addClass("active");

	window[prefix+'_index'] = index;

	//$("#debug").html(index + '-' + forsidetopmoveto);

}
