﻿/*DW RSS-link workaround START*/
var url=location.href;
if(url.indexOf("&M=NewsV2")>-1) location.replace(url.replace("&M=NewsV2",""));
/*DW RSS-link workaround SLUT*/
/*SlideNyheder START*/
var timeBetweenSlides = 4000;
var timeAnimation = 500;
var rowHeight = 0;
function initFrontPageNewsScroll() {
  var newslists = jQuery(".FrontPageSetup div.paragraph div").children("ul.newsList");
  newslists.each(function(){
    var ulen=jQuery(this);
    slideNewsList(ulen);
  });
}
function slideNewsList(ul) {
  ul.prepend(ul.children(":last"));
  if(rowHeight==0) rowHeight = jQuery(".FrontPageSetup div.paragraph div").height();
  ul.css("top", -rowHeight);
  setTimeout(function(){slideNewsList(ul);}, timeBetweenSlides+timeAnimation);
  ul.animate({
    top: parseInt(ul.css("top")) + rowHeight
  }, timeAnimation);
}
/*SlideNyheder SLUT*/
/*SlideBoxes START*/
var listBoxes;
var SlidingBoxesNudge = 25;
var SlidingBoxesIsScrolling = false;
function initFrontPageBoxSlide(){
  listBoxes = jQuery(".SlidingBoxes div ul");
  var boxItems = listBoxes.children("li");
  if(boxItems.length>4){
    listBoxes.css("width",boxItems.length*boxItems.outerWidth()+"px");
    jQuery("#arrowLeft").click(function(){
      if(jQuery(this).css("opacity")!="1") return;
      var nudge=SlidingBoxesNudge*-1;
      var left=listBoxes.position().left+listBoxes.parent().width();
      slideTheBoxes(nudge,left);
    }).css("display","block");
    jQuery("#arrowRight").click(function(){
      if(jQuery(this).css("opacity")!="1") return;
      var nudge=SlidingBoxesNudge;
      var left=listBoxes.position().left+(listBoxes.parent().width()*-1);
      slideTheBoxes(nudge,left);
    }).css("display","block");
    handleArrows();
  }
}
function slideTheBoxes(nudge,left){
  if(SlidingBoxesIsScrolling) return;
  toggleIsScrolling();
  listBoxes.animate({
    left: listBoxes.position().left+nudge+"px"
    }, 200,
    function(){listBoxes.animate({
      left: left+"px"
      }, 1000,
      function(){toggleIsScrolling();handleArrows();}
      );
    }
  );
}
function handleArrows(){
  var left=listBoxes.position().left;
  if(left>=0){ jQuery("#arrowLeft").animate({opacity:0.1},100); }
  else{ jQuery("#arrowLeft").animate({opacity:1},200); }
  if(left*-1>=listBoxes.width()-listBoxes.parent().width()){ jQuery("#arrowRight").animate({opacity:0.1},100); }
  else{ jQuery("#arrowRight").animate({opacity:1},200); }
}
function toggleIsScrolling() {
  SlidingBoxesIsScrolling = !SlidingBoxesIsScrolling;
}
/*SlideBoxes SLUT*/
/*BilledGallery START*/
function initCo3Gallery() {
  var imageList = jQuery(".imageGallery");
  if (imageList.length > 0) {
    var settings = {
    Play: 'http://jscripts.s3.co3.dk/Co3Gallery/btn_play.png',
    Stop: 'http://jscripts.s3.co3.dk/Co3Gallery/btn_stop.png',
    BlankImage: 'http://jscripts.s3.co3.dk/Co3Gallery/x.gif',
    PlacePlayInside: true,
    PaddingBottom:26,
    ImageMarginTop: 2,
    ImageMarginBottom: 2,
    playSpeed: 4000,
    showImageList: true,
    imageListHeight: 60,
    imageInformationHeight: 15,
    imageInformationTemplate: '<a href="/admin/public/getimage.aspx?Image=[href]&Width=10000&Resolution=300&Compression=100&ForceDownload=True">Download billedet</a>',
    TempThumb: null
    };
    var co3Gallery = jQuery(".imageGallery img").CreateGallery(settings);
  }
}
/*BilledGallery SLUT*/
jQuery(document).ready(function(){
  initFrontPageNewsScroll() ;
  initFrontPageBoxSlide()
  initCo3Gallery();
});
