// JavaScript Document
var ROOT = "http://www.stagingcompany.nl";

function CufonReplace() {
	Cufon.replace('h1', { fontFamily: 'OfficinaSans', hover: true } );
	Cufon.replace('.hoofditem', { fontFamily: 'OfficinaSans', hover: true } );
	Cufon.replace('.tekstblok h2', { fontFamily: 'OfficinaSans', hover: true } );
	Cufon.replace('.tekst', { fontFamily: 'OfficinaSans', hover: true } );
	Cufon.replace('.infoitem-container h3', { fontFamily: 'OfficinaSans', hover: true } );
	Cufon.replace('.dag', { fontFamily: 'OfficinaSans', hover: true } );
	Cufon.replace('.maand', { fontFamily: 'OfficinaSans', hover: true } );
	Cufon.replace('#footer h4', { fontFamily: 'OfficinaSans', hover: true } );
	Cufon.replace('.referentie-wrapper h2', { fontFamily: 'OfficinaSans', hover: true } );
	Cufon.replace('#logo-wrapper h3', { fontFamily: 'OfficinaSans', hover: true } );
}

var breedte = 258;
var slider1actief = 1;
var slider2actief = 1;
var slider3actief = 0;

function setSlide(index) {
    $('#blok3-slider').cycle(index);
}


$(document).ready(function(){

	$(".replace-select").selectbox();
	
    $('#blok1-slider').cycle({
		fx: 'fade',
		speed:  'slow',
		timeout: 0,
		pager:  '#blok1-menu',
			pagerAnchorBuilder: function(index, el) {
				return '<li><a href="#"></a></li>'; // whatever markup you want
			}
	});	
    $('#blok2-slider').cycle({
		fx: 'fade',
		speed:  'slow',
		timeout: 0,
		after:   function(curr,next,opts) {
			var currentslide = opts.currSlide;
			var stars = parseInt($("#blok2-slider").children(".infoitem-content").eq(currentslide).find(".starlink").attr("rel"));
			$(".sterren-home li").addClass("inactief");
			for (i=0; i<stars; i++) { 
				$(".sterren-home li").eq(i).removeClass("inactief");	
			}
		},
		pager:  '#blok2-menu',
			pagerAnchorBuilder: function(index, el) {
				return '<li><a href="#"></a></li>'; // whatever markup you want
			}
	});	
	
    $('#blok3-slider').cycle({
		fx: 'fade',
		speed:  'slow',
		timeout: 0
	});	
	
    $('#sfeerslider').cycle2({
        fx: 'scrollLeft',
        speed:    3500,
        timeout:  12000, 
        start: 0,
        interval: false,
        animIn: 0,
        easing: 'easeOutCirc', 
		before:   function(curr,next,opts) {
			var currentslide = opts.currSlide;
			$("#sfeerslider").children(".sfeeritem").children(".tekstblok").fadeOut(2000);
		},			
		after:   function(curr,next,opts) {
			var currentslide = opts.currSlide;
			$("#sfeerslider").children(".sfeeritem").children(".tekstblok").eq(currentslide).fadeIn(2000);
			$("#fotoslide-buttons").children("li").removeClass("actief");
			$("#fotoslide-buttons").children("li").eq(currentslide).addClass("actief");
		}			
		
	});	
	
	
	
	//$("#tekstwrapper .thumbnail").append('<a href="#" class="enlarge"></a>');
	//$(".thumboverlay").before('<a href="#" class="enlarge"></a>');
	//$(".thumboverlay").click(function(){ alert('t'); });
	$("#tekstwrapper .thumbnail").mouseenter(function(){
	  $(this).children(".enlarge").css("background-position", "bottom");							
    });
	$("#tekstwrapper .thumbnail").mouseleave(function(){
	  $(this).children(".enlarge").css("background-position", "top");							
    });
	
/*

---- Blok 1 en 2 sliden i.p.v. Faden -----------------------------

	$("#blok1-menu a").click(function() { 

		$("#blok1-menu").stop(true,true);

		slider1actief = parseInt($(this).text());
		var offset = (slider1actief * breedte * -1) + breedte;

		$("#blok1-menu a").removeClass("actief");
		$(this).addClass("actief");

		$("#blok1-slider").animate({ left: offset+'px' }, 500);

		return false;
		
	});
	
	$("#blok2-menu a").click(function() { 

		$("#blok2-menu").stop(true,true);

		slider2actief = parseInt($(this).text());
		var offset = (slider2actief * breedte * -1) + breedte;

		$("#blok2-menu a").removeClass("actief");
		$(this).addClass("actief");
		
		$("#blok2-slider").animate({ left: offset+'px' }, 500);
		var stars = parseInt($("#blok2-slider").children(".infoitem-content").eq(slider2actief-1).find("a").attr("class"));
		
		$(".sterren-home li").addClass("inactief");
		for (i=0; i<stars; i++) { 
			$(".sterren-home li").eq(i).removeClass("inactief");	
		}
		return false;
		
	});	
*/	
	var config = {    
		 over: function() { 
					slider3actief = parseInt($(this).text());
			
					$(".nieuwsitem .itemknop").removeClass("actief");
					$(this).children(".itemknop").addClass("actief");
					
					setSlide(slider3actief);
					
					var datum = $(this).children(".itemknop").attr("id");
					var datumarr = datum.split("-");
						
					$(".nieuwsdatum .dag").text(datumarr[3]);		
					$(".nieuwsdatum .maand").text(datumarr[2]);		
					
					return false;
		 }, // function = onMouseOver callback (REQUIRED)    
		 timeout: 150, // number = milliseconds delay before onMouseOut    
		 interval: 150, 
		 out: function() { } // function = onMouseOut callback (REQUIRED)    
	};
	
	$(".nieuwsitem").hoverIntent( config )

/*	$(".nieuwsitem").mouseover(function() { 

		
	});		
*/

	$("#content-wrapper ul li:even").addClass("grijs");	
	
	$("#taal .jquery-selectbox-item").click(function() { 
		var lang = $(this).text();
		var code = "nl";
		if 			(lang == "Nederlands") 	{ code = "nl"; }
	  	else if 	(lang == "Deutsch") 	{ code = "de"; }
		else if 	(lang == "English")		{ code = "en"; }
		window.location = ROOT+"/"+code;
	});

	$(".vestiging-select-wrapper .jquery-selectbox-item").click(function() { 
		var vestiging = $(this).text();
		$.post('/loadvestiging', {vestiging:vestiging},
			function(data){
				$(".vestigingwrapper").empty().html(data);
			}
		);		
	});
	
	$(".hoofditem").parent().mouseenter(function(){
	  $(this).css("background-color", "#f5f5f5");							
    });
	$(".hoofditem").parent().mouseleave(function(){
	  $(this).css("background", "none");							
    });
	
	$(".meer").parent().mouseenter(function(){
	  $(this).children(".submenu").css("display", "block");							
    });
	$(".meer").parent().mouseleave(function(){
	  $(this).children(".submenu").css("display", "none");								
    });
	
	$(".subitem").parent().mouseenter(function(){
	  $(this).css("background-color", "#8dc63f");
	  $(this).children().css("color", "#FFF");
	  $(this).children().css("font-weight", "bold");
	  $(this).css("background-position", "right 6px");
	  $(this).prev().css("background-position", "right -200px");
	  
    });
	$(".subitem").parent().mouseleave(function(){
	  $(this).css("background-color", "#FFF");
	  $(this).children().css("color", "#000");
	  $(this).children().css("font-weight", "normal");
	  $(this).prev().css("background-position", "0 bottom");
	  if( !$(this).hasClass("laatst") ) {
	  	$(this).css("background-position", "0 bottom");
	  }
	});
	
		
	/* 
	
	geheugensteuntje
	
	$("#id").click(function(){
	  $("#id2").animate({ 
        left: "-67"
      }, 500, "swing" );
	  $("#id").val("");
    });
	
	$("#id").click(function(event){
	  $("#id2").animate({ 
        left: "-657px"
      }, 1000, "swing" );
	  event.preventDefault();
    });
	
	
	$("#id").click(function(){
	  $("#id2").css("display", "none");
    });	
	
	$(".class").live('click',function(){
	  $(this).parent().parent(".colors").children(".selected").css("display", "none");							
	  $(this).children(".selected").css("display", "block");
		  $(".class2").animate({ 
        	top: "30"
      		}, 500, "swing",function(){ $("#alert-mask").css("display", "none");} );
    });
	*/
	
});
