// mouseover kleur cases rechterkolom //
var sCaseEssent = "#aa014c";
var sCaseKraanwater = "#00bbf4";
var sCaseStudentalent = "#e30083";
var sCaseDeltaLloyd = "#00579b";
// --------- //

$(function() {
	$('a.media').media({
		caption: false
	});
});

$(document).ready(function() {
    $(function() {
	    $.nyroModalSettings({
		    minWidth: 230,
		    minHeight: 26,
		    swf: { // Swf player options if swf type is used.
              wmode: 'opaque'
            },
            padding: 5
	    });
	    
    });
	
	

	$("#tabber").tabs({
		fx: { height: 'toggle' },
		select: function(e, ui) {
			$("#tabber a").each( function() {
				$(this).css({ backgroundColor:"#1a181b" })
			});
			$(ui.tab).
			animate({ 
				backgroundColor: "#555555"
			}, { duration: 200 }).
			animate({ 
				backgroundColor: "#303030"
			}, { duration: 400 })
		}
	});

    if ($("#modMiddelContent").find("div").length > 1) {
        $('#modMiddelContent').cycle({ 
                    fx:     'scrollVert',
                    easing: 'bounceout',
                    timeout: 6000,
                    next: '#middelScrollUp',
                    prev: '#middelScrollDown',
                    nowrap:  0,
                    after:   onAfter
        });
    }
    else {
        $("#middelScrollUp").hide();
        $("#middelScrollDown").hide();
    }

	$(".modCase").hover(
		function() {
		    bgColor = $(this).find("input.color").val();
			$(this).stop().animate({ backgroundColor: bgColor },{ duration: 200 });
			$(this).find(".imgLeft").attr("src", $(this).find(".imgLeft").attr("src").replace(".jpg", "_mo.jpg"));
		},
		function() {
			$(this).stop().animate({
				backgroundColor: "#000000"
			}, { duration: 800 });
			$(this).find(".imgLeft").attr("src", $(this).find(".imgLeft").attr("src").replace("_mo", ""));
		}
	);

	$(".modContact").find("input, textarea").focus(function() {
		$(this).stop().animate({
			borderLeftColor: "#dc00ff",
			borderTopColor: "#dc00ff",
			borderRightColor: "#dc00ff",
			borderBottomColor: "#dc00ff"
		}, { duration: 400 })
	});
	$(".modContact").find("input, textarea").blur(function() {
		$(this).stop().animate({
			borderLeftColor: "#282828",
			borderTopColor: "#282828",
			borderRightColor: "#282828",
			borderBottomColor: "#282828"
		}, { duration: 800 })
	});

	$("#frmReactie").validate({
		rules: {
			naam: {
				required: true
				
			},
			//telefoon:  "required",
			vraag: {
				required: true
				
			},
			email: {
				required: true,
				email: true
			}
		},
		messages: {
			email: {
				required: "U heeft geen e-mailadres ingevuld",
				email: "U heeft een onjuiste e-mailadres ingevuld"
			},
			naam: {
				required: "U heeft geen naam ingevuld"
			},
			vraag: {
				required: "U heeft geen vraag ingevuld"
			}
		}
	});	

	$(".modLogin").find("input, textarea").focus(function() {
		$(this).stop().animate({
			borderLeftColor: "#dc00ff",
			borderTopColor: "#dc00ff",
			borderRightColor: "#dc00ff",
			borderBottomColor: "#dc00ff"
		}, { duration: 400 })
	});
	$(".modLogin").find("input, textarea").blur(function() {
		$(this).stop().animate({
			borderLeftColor: "#282828",
			borderTopColor: "#282828",
			borderRightColor: "#282828",
			borderBottomColor: "#282828"
		}, { duration: 800 })
	});
	
	$("#frmLogin").validate({
		rules: {
			inpUsername: "required",
			inpPassword: "required"
		}
	});	

	jQuery.validator.addMethod("defaultInvalid", function(value, element) {
		return value != element.defaultValue;
	}, "");
	
	$("#btn_verstuur").click(function() {
		if(!$("#frmReactie").valid()) {
			$.prompt("Niet alle gegevens zijn correct ingevuld. Probeer het opnieuw.");
			return false;
		}
		return true;
	});
	
	$("#btn_ecenter").click(function() {
		if(!$("#frmLogin").valid()) {
			$.prompt("Niet alle gegevens zijn correct ingevuld. Probeer het opnieuw.");
			return false;
		}
		return true;
	});
	
	$(".modMensen").hover(
		function() {
			$(this).
			stop().
			animate({
				backgroundColor: "#ffffff"
			}, { duration: 200 }).
			find("h2").
			stop().
			animate({
				color: "#000000"
			}, { duration: 200 })
		},
		function() {
			$(this).
			stop().
			animate({
				backgroundColor: "#000000"
			}, { duration: 800 }).
			find("h2").
			stop().
			animate({
				color: "#ffffff"
			}, { duration: 800 })
		}
	);

	$(".modCaseOverzicht").hover(
		function() {
			$(this).find(".imgLeft").attr("src", $(this).find(".imgLeft").attr("src").replace(".jpg", "_mo.jpg"));
			
			$(this).
			stop().
			animate({
				backgroundColor: "#ffffff"
			}, { duration: 10 }).
			find("h2").
			stop().
			animate({
				color: "#000000"
			}, { duration: 10 })
		},
		function() {
			$(this).find(".imgLeft").attr("src", $(this).find(".imgLeft").attr("src").replace("_mo", ""));
			if($(this).hasClass("caseOverzichtEssent")) { $(this).stop().animate({ backgroundColor: sCaseEssent }, 200)}
			if($(this).hasClass("caseOverzichtKraanwater")) { $(this).stop().animate({ backgroundColor: sCaseKraanwater  }, 200)}
			if($(this).hasClass("caseOverzichtStudentalent")) { $(this).stop().animate({ backgroundColor: sCaseStudentalent  }, 200)}
			if($(this).hasClass("caseOverzichtDeltaLloyd")) { $(this).stop().animate({ backgroundColor: sCaseStudentalent  }, 200)}
			$(this).find("h2").stop().animate({ color: "#ffffff" }, { duration: 800 });
		}
	);
	
	
	$("ul.gallery").find("li").not(".current").hide();

	
	$("a.prev").click(function () { 
	var num = $("ul.gallery li.current").prevAll().length - 1;
	  if(num < 0)
	  {
		  num = $("ul.gallery").find("li").length -1;
	  }
	  
	  $("ul.gallery li.current").hide();
	  $("ul.gallery li.current").removeClass("current");
	  $("ul.gallery li").eq(num).addClass("current");
	  $("ul.gallery li").eq(num).show();
	 
	  $("a#schermvullend").attr("href", ($("ul.gallery li.current a").attr("href")));
	  12
    });
	$("a.next").click(function () { 
	var num = $("ul.gallery li.current").prevAll().length + 1;
	  if(num > $("ul.gallery").find("li").length -1)
	  {
		  num = 0;
	  }
	  
	  $("ul.gallery li.current").fadeOut(500).hide();
	  $("ul.gallery li.current").removeClass("current");
	  $("ul.gallery li").eq(num).addClass("current");
	  $("ul.gallery li").eq(num).fadeIn(500).show();
	 
	  $("a#schermvullend").attr("href", ($("ul.gallery li.current a").attr("href")));
	  
    });
	
	$("body.home").mousemove(function(e){
			formSend(e.pageX,e.pageY); 
	});

	//alert(getFlashMovie("water"));
});

function onAfter(curr, next, opts) {
	var index = $(this).parent().children().index(this);
	$('#middelScrollDown')[index == 0 ? 'hide' : 'show']();
	$('#middelScrollUp')[index == opts.slideCount - 1 ? 'hide' : 'show']();
}

