$(document).ready(function(){
	
	function resize() {
		if ($("body").innerWidth() < 1025) {
			var formaat = "klein";
		}
		else if ($("body").innerWidth() > 1025) {
			var formaat = "groot";
		}
		$.ajax({
			type: "GET",
			url: "style.asp",
			data: "formaat="+formaat,
			success: function(bg){
			$("html").css("background",bg);
		}
		});
	}
	resize();
	
	$(window).resize(function(){
		resize();
	});
						   
	// ie6 link overlay voor hover
    $("#link-overlay").hover(
      function () {
        $("#link-tekst").addClass("over");
      }, 
      function () {
        $("#link-tekst").removeClass("over");
      }
    );
	//werknemers div wissel op id
	$('#personen div').click(function () {
			var id = $(this).attr('id');
			var title = $(this).attr('title');
				$('#persoon_beschrijving div').hide();
				$('.mensen #intro').hide();
				$('#personen div').removeClass("actief");
				$(this).addClass("actief");
				$('#persoon_beschrijving #'+id+", .persoon_beschrijving_tekst").show();
				$("#kruimel #naam").remove();
				$("#kruimel a").removeClass("laatste");
				$("#kruimel").append("<a id='naam'>."+title+"</a>");
		},
		function () {
			var id = $(this).attr('id');
			$('persoon_beschrijving div').hide();
			$('persoon_beschrijving #'+id).show();
		}  
	);
	//portfolio ajax toestanden
	

	$("#werk a[class!=actief]").removeAttr("href").click(
      function () {
	  	var id = $(this).attr('id');
		var title = $(this).attr('title');
		var categorie = $(this).find("div").attr("id");
	  	$("#werk a").removeClass("actief");
        $(this).addClass("actief");
		$("#werk a:first-child h2").css("margin-top","-20px");
		$(document).stopTime();
		$(".blok_groot").remove();
		$(this).parent().append("<div class='blok_groot' style='display:none;' id='"+id+"'></div>");
		$(".blok_groot").slideDown("slow");
		$('#portfoliotitel').remove();
		$("#kruimel a").removeClass("laatste");
		$("#kruimel").append("<a class='laatste' id='portfoliotitel'>."+title+"</a>");
		$.scrollTo(this, {speed:1000} );
		$(document).oneTime(900, function() {
		  $.ajax({
				 type: "GET"
				 ,url: "ajax.asp"
				 ,async: false
				 ,data: "id="+id+"&categorie="+categorie
				 ,success: function(resultaat){$(".blok_groot").append(resultaat)
				 ;}
			});
		});
      }
    );
	
	$("#blog_knop").mouseover(function () {
        $("#blog_knop_tekst").prepend($("Fotoblog")).animate({"width": "+=60px"}, "slow");
      }, function () {
        
      }
    ).mouseout(function(){
		$("#blog_knop_tekst").animate({"width": "-=60px"}, "slow").find("p").remove();
    })

	
	/*$("#blog_knop").hover(
	  function () {
	   if($("#blog_knop:animated")){
		   $(this).prepend($("<p>Fotoblog</p>")).animate({"width": "+=60px"}, "slow");
	   }
	  }, 
	  function () {
		if(!$("#blog_knop:animated")){
			$("#blog_knop").stop();
		}
		if($("#blog_knop:animated")){
			$(this).animate({"width": "-=60px"}, "slow").find("p").remove();
		}
	  }
	);*/
	
	$("#foto").hover(
      function () {
        $(this).find("#pijl").addClass("hover");
      }, 
      function () {
		$(this).find("#pijl").removeClass("hover");
      }
    );
	
	$("#foto").hover(
      function () {
        $(this).find("#pijl").addClass("hover");
      }, 
      function () {
		$(this).find("#pijl").removeClass("hover");
      }
    );
	
	//contact formulier check
	$("#contact input[type='text'], #contact textarea").focus(function () { 
      $(this).val('');
    });
	
	$("#fotoblog a").hover(
		function () {
			$(this).addClass("hover");
		}, 
		function () {
			$(this).removeClass("hover");
		}
	);
	
	$("#personen div").hover(
		function () {
			$(this).addClass("hover");
		}, 
		function () {
			$(this).removeClass("hover");
		}
	);
});