Cufon.replace(".btn_blue, .btn_blue_dark, h1, h2, h3, h4, h5, h6");
Cufon.replace("#navigation a, .spf", { hover: true });
Cufon.replace("#content .column_container .column span.board .txt");
Cufon.replace("#content .column_container .column span.board-net .txt a");
Cufon.replace("#bumperpage .boards .board .content a", {hover: true});
Cufon.replace("bumperpage .boards .board .content a.active", {hover: true});


$(document).ready(function() {	
	
	$(window).resize(resizeHandler);
	$(window).trigger("resize");
		
	$('#mediabar .slideshow').cycle({
		fx: 'fade',
		timeout: 5000,
		speed: 1000
	});

	$('#infowindow .slider').cycle({
		fx: 'blindX',
		timeout: 5000,
		speed: 1000,
		cleartype: true,
		cleartypeNoBg: true
	});
	
	$('#board-text-net .netitems').cycle({
		fx: 'scrollLeft',
		timeout: 5000,
		speed: 1000,
		cleartype: true,
		cleartypeNoBg: true
	});

	if($("#columnbook div").length == 2 || $("#columnbook").hasClass("width_626")) {
		$("#column1").css("margin-right", "10px");
		$("#column3").remove();
		
		if($("#columnbook div").length == 2) {
			PlaceImageInColumn(2);
		}
	}
	if($("#columnbook div").length == 3) {
		$("#column1").css("margin-right", "11px");
		$("#column3").css("margin-left", "10px");
		PlaceImageInColumn(3);
	}

	if($("a.fancybox").length > 0) {
		$("a.fancybox").fancybox({
			'titleShow'	: false	
		});
	}	

	$("a[href$=.jpg],a[href$=.png],a[href$=.gif]").each(function(){
		if(!$(this).parent().parent().hasClass("file")) {
			$(this).fancybox();
			$(this).css("border","0px solid #ffffff");
		}
	});  
  
  $(".newsletter_subscribe").fancybox({
    'type'      : 'iframe',
    'width'      : 380,
    'height'    : 350,
    'titleShow'  : false
  });
	
	$("a[href^='http://www.youtube.com/watch?v=']").click(function(){
		$.fancybox({
			'padding'		    : 0,
			'autoScale'	 	  : false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			    : this.title,
			'width'		      : 680,
			'height'		    : 495,
			'href'			    : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			    : 'swf',
			'swf'			      : {
			   	 								'wmode'						: 'transparent',
													'allowfullscreen'	: 'true'
												}
		});
		return false;
	});
  
  $(".list-toggle .item").each(function() {
    $(this).find(".category_name").click(function() {      
      // set settings for current item
      $(this).css("background-image", "url(/pics/bg_li_a_down.gif)");
      $(this).addClass("current");
      
      $(this).next("div:first").stop(true,true).slideToggle(function() {
        if($(this).css("display") == "none") {
          $(this).prev(".category_name").css("background", "url(/pics/bg_li_a.gif) 0px 15px no-repeat");  
          $(this).prev(".category_name").removeClass("current");
        } else {
          $(this).prev(".category_name").css("background", "url(/pics/bg_li_a_down.gif) 0px 15px no-repeat");
          $(this).prev(".category_name").addClass("current");  
        }
      });

    });
  });
	

});




function resizeHandler() {
	var WindowHeight = parseInt($(window).height());
	var BodyHeight   = parseInt($("body").css("height"));

	$("body").css("height", WindowHeight + "px");
	
	return;
}

function PlaceImageInColumn(ColumnCount) 
{
	var objImg = $("img.position");
	var objContainer = null;
	
	if(objImg.parent().hasClass("fancybox")) {
		objContainer = objImg.parent();	
	} 
	
	if(objContainer == null) {
		objContainer = objImg;		
	}
	
	if(objContainer.length == 1) 
	{
		switch(ColumnCount) 
		{
			case 2 : 
			{
				if(objImg.hasClass("left") || objImg.hasClass("center")) {
					objContainer.clone().prependTo("#column1").show();		
					objContainer.remove();		
				}	
				if(objImg.hasClass("right")) {
					objContainer.clone().prependTo("#column2").show();		
					objContainer.remove();		
				}
			} break;
			
			case 3 : 
			{
				if(objImg.hasClass("left")) {
					objContainer.clone().prependTo("#column1").show();		
					objContainer.remove();		
				}	
				if(objImg.hasClass("center")) {
					objContainer.clone().prependTo("#column2").show();		
					objContainer.remove();		
				}
				if(objImg.hasClass("right")) {
					objContainer.clone().prependTo("#column3").show();		
					objContainer.remove();		
				}
			} break;
			
			default : { } break;
		}	
	}
}

if($("#newsslider li").length > 0) { 
	setInterval(function() {
		
		$("#newsslider li:first").animate({
			opacity: 0
		}, 1000, function() {
			var Li_Element = $(this);
			
			//$("#newsslider li").removeClass("last");
			//$("#newsslider li:eq(1)").addClass("last");	
			
			Li_Element.css("display", "block");
			Li_Element.animate({ height: "0px" }, 1000, function() {
				
				Li_Element.clone().appendTo('#newsslider').show();
				Li_Element.remove();
				
				$("#newsslider li").removeAttr("style");
			});		
		});
	}, 3500);
}

var PreviousTag = 0;

function AddTag(){
  var TagDiv = $('.tags');
  if(PreviousTag >= 9){
    alert('Het maximaal aantal tags is bereikt.')
    return false;
  }
  $('.tag',TagDiv).eq(PreviousTag).css('display','block');
  $('.tag',TagDiv).eq(PreviousTag).find('input').focus();
  PreviousTag = PreviousTag + 1;
}

function DeleteTag(){
  var TagDiv = $('.tags');
  $('.tag',TagDiv).eq(PreviousTag - 1).css('display','none');
  $('.tag',TagDiv).eq(PreviousTag - 1).find('input').val('');
  $('.tag',TagDiv).eq(PreviousTag - 2).find('input').focus();
  PreviousTag = PreviousTag - 1;
}

function BuildRating(FormId, VoteUrl, bCanVote) {
  FormId.children().not(":radio").hide();

  // Create stars

  if(bCanVote){
    FormId.stars({
      cancelShow: false,
      oneVoteOnly: true,
      callback: function(ui, type, value)
      {
        var StarLinks = ui.$stars.find("a");
        var AjaxUrl = VoteUrl + value;

        StarLinks.slowEach(100,
          function(){
            $(this).animate({top: "28px"}, 300) }, function(){
              $("#loader").fadeIn(function(){
                $.ajax({ url: AjaxUrl, success: function(){
                  $("#loader").fadeOut(function(){
                    StarLinks.slowEach(100, function(){
                      $(this).animate({top: 0}, 300);
                    });
                  });
                }});
              });
          });
      }
    });
  } else {
    FormId.stars({
      cancelShow: false,
      disabled: true
    });
  }
}

jQuery.fn.slowEach = function(interval, callback, callback2) {
  var items = this, i = 0;
  if(!items.length) return;
  function next() {
    (callback.call(items[i], i, items[i]) !== false && ++i < items.length) ? setTimeout(next, interval) : callback2 && callback2.call(items, i, items);
  }
  next();
};

