// 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() {
    var options = {
        locale: {
            days: ["Zondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag"],
            daysShort: ["ZO", "MA", "DI", "WO", "DO", "VR", "ZA", "ZO"],
            daysMin: ["ZO", "MA", "DI", "WO", "DO", "VR", "ZA", "ZO"],
            months: ["JANUARI", "FEBRUARI", "MAART", "APRIL", "MEI", "JUNI", "JULI", "AUGUSTUS", "SEPTEMBER", "OKTOBER", "NOVEMBER", "DECEMBER"],
            monthsShort: ["JAN", "FEB", "MAA", "APR", "MEI", "JUN", "JUL", "AUG", "SEP", "OKT", "NOV", "DEC"],
            weekMin: 'wk'
        }
    };
/*
    var events = [
	    { "EventID": 1, "StartDateTime": "new Date(2010, 2, 9)", "EndDateTime": "new Date(2010, 2, 9)", "Title": "EventTitle1", "URL": "http://www.google.nl", "Description": "This is a sample event description" },
		{ "EventID": 2, "StartDateTime": "new Date(2010, 2, 15)", "EndDateTime": "new Date(2010, 2, 15)", "Title": "EventTitle6", "URL": "http://www.google.nl", "Description": "This is a sample event description" }
	];


    $.jMonthCalendar.Initialize(options, events);
*/

    $("p:empty").hide();
    $.ifixpng("/images/blank.gif");
    $("img").ifixpng();
    $(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 })
        }
    });

    $("div.scrollable").scrollable({
        size: 3,
        clickable: false,
        easing: "swing"
    });

    $("div.scrollable4").scrollable({
        size: 1,
        clickable: false,
        easing: "swing"
    });

    $("div.scrollable2").scrollable({
        size: 1,
        clickable: false,
        easing: "swing",
        items: ".items2",
        prev: ".prev2",
        next: ".next2",
        onSeek: function() {
            if ($(".next2:eq(0) img[src*='english']").length > 0) {
                if ((this.getIndex() > 0) && (this.getIndex() < this.getPageAmount() - 1)) {
                    $(".next2:eq(0)").find("img").attr("src", "/images/btn_middel_volgende_zwart_english.png");
                    $("img").ifixpng();
                }

                if (this.getIndex() == 0) {
                    $(".next2:eq(0)").find("img").attr("src", "/images/btn_middel_volgende_english.png");
                    $("img").ifixpng();
                }

                if (this.getIndex() == this.getPageAmount() - 1) {
                    $(".next2:eq(0)").find("img").attr("src", "/images/btn_middel_volgende_disabled_english.png");
                    $("img").ifixpng();
                }
            }
            else {
                if ((this.getIndex() > 0) && (this.getIndex() < this.getPageAmount() - 1)) {
                    $(".next2:eq(0)").find("img").attr("src", "/images/btn_middel_volgende_zwart.png");
                    $("img").ifixpng();
                }

                if (this.getIndex() == 0) {
                    $(".next2:eq(0)").find("img").attr("src", "/images/btn_middel_volgende.png");
                    $("img").ifixpng();
                }

                if (this.getIndex() == this.getPageAmount() - 1) {
                    $(".next2:eq(0)").find("img").attr("src", "/images/btn_middel_volgende_disabled.png");
                    $("img").ifixpng();
                }
            }
        }
    });

    $(".modCase").hover(
	    function() {
	        if ($(this).find("img").hasClass("imgLeft")) {
	            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() {
	        if ($(this).find("img").hasClass("imgLeft")) {
	            $(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",
            bedrijf: "required",
            //telefoon:  "required",
            vraag: "required",
            email: {
                required: true,
                email: true
            }
        }
    });

    $(".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 });
		}
	);


    $("#frmReaction").validate({
        rules: {
            Name: "required",
            Email: "required",
            Reaction: "required"
        }
    });

    $("#frmReaction").find("#Submit").click(function() {
        if ($("#Reaction").val() == "uw reactie")
            $("#Reaction").val("");
        if ($("#frmReaction").valid()) {
            $("#frmReaction #Submit").fadeOut();
            var randomnumber = Math.floor(Math.random() * 100001);
            var send = $.post("/Ajax/saveReaction.aspx?randomnumber=" + randomnumber,
                    {
                        Name: $("#Name").val(),
                        Email: $("#Email").val(),
                        Id: $("#Id").val(),
                        Type: $("#Type").val(),
                        Reaction: $("#Reaction").val()
                    },
                    function(data) {
                        if (data == "true") {

                            $("#frmReaction").fadeOut();
                            $("#cntReactionThanks").fadeIn();
                            var currenturl = $("#Redirect").val();
                            $(this).oneTime(3000, function() {
                                if (currenturl != "" && currenturl != undefined)
                                    document.location = currenturl;
                                else
                                    document.location = "/";
                            });
                        }
                        else {
                            $("#frmReaction #Submit").fadeIn();
                            $("#cntReactionError").fadeIn();
                        }
                    }
                );
            return false;
        }
    });

    $("#showMoreTweets").live("click", function() {
        var lastActive = $(".twitterGroup:visible:last").attr("rel");
        var nextActive = parseInt(lastActive) + 1;
        if ($(".twitterGroup[rel='" + nextActive + "']").length > 0) {
            $(".twitterGroup[rel='" + nextActive + "']").addClass("twitterBusy").slideDown();
            $(this).oneTime(2000, function() {
                $(".twitterGroup[rel='" + nextActive + "']").removeClass("twitterBusy");
                $(".twitterGroup[rel='" + nextActive + "']").find("li").fadeIn("slow");
            });
        }
        else {
            $(this).fadeOut().remove();
        }
        return false;
    });

    //$("img[rel]").overlay({ absolute: true, expose: '#fff', effect: 'apple' });
    $("img[rel]").overlay({
        absolute: false,
        expose: 'transparent',
        effect: 'apple'
//        onLoad: function() {
//            $(".modGoogle").css("visibility", "hidden");
//        },
//        onClose: function() {
//            $(".modGoogle").css("visibility", "visible");
//        }
    });

    //    $("#test").click(function() {
    //    $("img[rel='#1']").overlay({ 
    //        effect: 'apple',
    //        onLoad: function() {
    //            player.load();
    //        },
    //        onClose: function() {
    //            player.unload();
    //        } 
    //        }).load();
    //    });

    /*
    $(".switchMiddel").click(function() {
    var whichMiddel = $(this).parent().prevAll().length + 1;
    $(".modCaseMiddel").hide();
    $(".modCaseMiddel:eq(" + whichMiddel + ")").show();
    return false;
    });
    */
});

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