//Assortiment keuze//
var itemCount = 0;
var imageCount = 0;
$("document").ready(function(){	
	
	$("#producten ul li").each(function(){
		
		var posLeft = itemCount * 265 + 133;
		
		$(this).css({
			left: posLeft
		});
		
		itemCount++;
	
	});
	
	itemCount = 0;
	
	$("#wieis ul li").each(function(){
		
		var posLeft = itemCount * 265;
		
		$(this).css({
			left: posLeft
		});
		
		itemCount++;
	
	});
	
	$("#wieisctpic2, #wieisctpic1, #wieisctpic3").css({
		position: "relative"
	}).eq(1).css({
		width: "150px",
		left: "75px",
		top: "50px",
		opacity: 0.7
	});
	
	$("#wieisctpic2, #wieisctpic1, #wieisctpic3").hover(function(){
	
		$(this).stop().animate({
			opacity: 1
		});
		
	},function(){
		
		$(this).stop().animate({
			opacity: 0.7
		});
		
		
	}).click(function(){
	
		$("#wieisctpic2, #wieisctpic1, #wieisctpic3").unbind('mouseenter mouseleave').hover(function(){
		
			$(this).stop().animate({
				opacity: 1
			});
			
		},function(){
			
			$(this).stop().animate({
				opacity: 0.7
			});
			
			
		});
	
		$(this).unbind('mouseenter mouseleave');
	
		$("#wieisctpic1, #wieisctpic2, #wieisctpic3").animate({
			width: "150px",
			left: "75px",
			top: "40px",
			opacity: 0.7
		});
				
		$(this).stop().animate({
			opacity: 1,
			width: 300,
			left: 0,
			top: -5
		});
		
		
		
		var $textDivs = $(this).parent().find(".cheftext");
		
		$("#rightcolumn, #leftcolumn").animate({
			opacity: 0
		}, 200, function(){
		
			if($(this).attr("id") == "leftcolumn"){
				var number = 0;
			}else{
				var number = 1;
			}
		
			$(this).empty().html($textDivs.eq(number).html()).css({
				opacity: 0
			});
						
			/*$(this).find(".leesmeer").hide(0);
			
			$(this).find(".leeslink").click(function(event){
				
				$(this).parent().parent().parent().find(".leeshide").hide("slow");
				$(this).parent().parent().parent().find(".leesmeer").show("slow");
				event.preventDefault();
				return false;
			});
			
			$(this).find(".leeslinkshow").click(function(event){
				
				$(this).parent().parent().parent().find(".leeshide").show("slow");
				$(this).parent().parent().parent().find(".leesmeer").hide("slow");
				event.preventDefault();
				return false;
			});*/
			
			$(this).animate({
				opacity: 1
			}, 200);
		
		});
			
	});
	
	$("#wieisctpic2").click();
		
	//producten unit
	
	$("#producten ul li > img").each(function(){
		
		if(imageCount != 1){
			
			$(this).css({
				height: "125px",
				width: "150px",
				left: "75px",
				top: "50px",
				opacity: 0.7
			}).addClass("productback");
			
		}
		
		imageCount++;
		
	}).hover(function(){
		// in
		var thisClass = $(this).attr("class");
		if(thisClass == "productback"){
			
			$(this).animate({
				opacity: 1
			}, 200);
			
		}		
	}, function(){
		var thisClass = $(this).attr("class");
		if(thisClass == "productback"){
			
			$(this).animate({
				opacity: 0.7
			}, 550);
			
		}

	}).click(function(){
		
		var thisClass = $(this).attr("class");
		var specText = $(this).parent().find(".productgrouptext").html();
		var prodText = "";
		
		$(this).parent().find(".producttext").each(function(){
		
			var html = $(this).html();
			
			prodText += "<p>" + html + "</p>";
		
		});
		
		
		if(thisClass == "productback"){
			
			$("#producten ul li > img").animate({
				height: "125px",
				width: "150px",
				left: "75px",
				top: "50px",
				opacity: 0.7
			}, 600).removeClass("productback").addClass("productback");
			
			$(this).animate({
				height: "250px",
				width: "300px",
				left: "0px",
				top: "0px",
				opacity: 1
			}, 600).removeClass("productback");
			
			$(".spec").animate({
				opacity: 0
			}, 400, function(){
				$(this).empty().html(specText).animate({
					opacity: 1
				}, 400);
			});
			
			$("#producten3fader p").animate({
				opacity: 0
			}, 400, function(){
				$(this).parent().empty().html(prodText).find("p").css({
					opacity: 0
				}).animate({
					opacity: 1
				}, 400);
			});
			
		}
		
	});
	
	
//Back to top/menu smooth	
	$("#menu a.ani, .back2top").click(function(){
	
		var target = $(this).attr("href");
		
		$.scrollTo(target, 400);
		
		return false;
	
	});
	
//wie is chef thor hide function	
	$("#cheftext .leesmeer").hide();

    $("#cheftext a.leeslink").click(function(event){
		$("#cheftext .leesmeer").toggle("slow");
		$("#cheftext .leeshide").hide(); 
		$(this).hide();   
		
		event.preventDefault();
    });
	
	 $("#cheftext a.leeslinkshow").click(function(event){
		$("#cheftext .leesmeer").toggle("slow");
		$("#cheftext a.leeslink").show();
		$("#cheftext .leeshide").show();   
		$.scrollTo("#cheftext", "slow");
		event.preventDefault();
    });

//media hide function	
	$("#media .leesmeer").hide();

    $("#media a.leeslink").click(function(event){
		$("#media .leesmeer").toggle("slow");
		$("#media .leeshide").hide(); 
		$(this).hide();   
		
		event.preventDefault();
    });
	
	 $("#media a.leeslinkshow").click(function(event){
		$("#media .leesmeer").toggle("slow");
		$("#media a.leeslink").show();
		$("#media .leeshide").show();   
		//$.scrollTo("#header", "slow");
		event.preventDefault();
    });
	
	if($("#ajax_block").length > 0){
		
			setInterval(function(){
			
				$.post("ajax.php", {
					message: "hello"
				}, function(data, status){
				
					$("#citaat p").animate({
						opacity: 0
					}, 300, function(){
					
						$("#citaat").empty().html(data);
						
						$("#citaat p").css({
							opacity: 0
						}).animate({
							opacity: 1
						}, 300);
					
					});
						
				}, "text");
			
			}, 10000);
		
	}
		
});

function set_cite(){
	
	$.post("ajax.php", {
		message: "hello"
	}, function(data, status){
	
		alert(data);
	
		/*$("#citaat p").animate({
			opacity: 0
		}, 300, function(){
		
			$("#citaat").empty().html(data);
			
			$("#citaat p").css({
				opacity: 0
			}).animate({
				opacity: 1
			}, 300);
		
		});*/
			
	}, "text");
	
}