$(function() {
    // Alle items van het overzicht behalve de eerste verbergen:
    $("#itemOverzicht div.item").not(":first").hide();

    $('a.videopopup').click(function() {
        $.nyroModalManual({
            width: 355,
            height: 340,
            minWidth: 355,
            minHeight: 340,
            url: $(this).attr('href') + '#nyro'
        });
        return false;
    });

    $("#accordion").accordion({
        header: 'h2',
        autoHeight: false,
        navigation: true,
        animated: 'easeInCubic',
        active: false
    });

    // Accordeon menu:	
    $("#itemOverzicht li").click(function() {
        $("#itemOverzicht div.item").not($("div.item", this)).slideUp();
        $("div.item", this).slideDown();
    });

    // Inputvelden:
    $("input.searchInput").checkValue("trefwoord");
    $("input.nameInput").checkValue("e-mail");
    $("input.passwordInput").click(function() {
        if ($(this).val() == "wachtwoord") {
            $(this).val("");
            // Type aanpassen:
            this.type = "password";
        }
    }).blur(function() {
        if ($(this).val() == "") {
            this.type = "text";
            $(this).val("wachtwoord");
        }
    });

    // DetailFormulier
    $("a.showDetailFormulier").click(function() {
        $("div.detailFormulier").slideDown("slow");
        return false;
    });

    // CSS3 ondersteuning:
    // Voor de buttons op de homepagina omdat geen enkele browser nog de CSS3: nth-child() ondersteund:	
    $("#buttons a:nth-child(even)").addClass("even");

    // Zebra tabel:
    $("#contentRight table[class!=noborder] tr:even td").addClass("even");
    $("#contentRight table[class!=noborder] tr:odd td").addClass("odd");

    // Zebra definition list:
    $("dd:even, dt:even").addClass("even");
    $("dd:odd, dt:odd").addClass("odd");

    // Voor ieder derde item op de IntranetPagina:
    $(".portalWindow:nth-child(3n)").addClass("child3");

    $("form.standaardFormulier input, form.standaardFormulier select, form.standaardFormulier textarea").focus(function() {
        $(this).addClass("focus");
    }).blur(function() {
        $(this).removeClass("focus");
    });

    $('#formLidworden').validate();
    $('#contact').validate();

    $('.portalWindow').each(function() {

        $(this).find('li:gt(' + (portalShows - 1) + ')').css('display', 'none');
        if ($(this).find('li').length < (portalShows)) {
            $(this).find('a.showAll').css('display', 'none');
        }
        $(this).find('a.showAll').click(function() {
            if ($(this).parent().find('li:hidden').length > 0) {
                $(this).parent().find('li').css('display', 'block');
            }
            else {
                $(this).parent().find('li:gt(' + (portalShows - 1) + ')').css('display', 'none');
            }
            return false;
        });

    });

});

jQuery.fn.checkValue = function(str) {
	return $(this).each(function(){
		$(this).click(function(){
			if($(this).val()==str) {
				$(this).val("");
			}
		}).blur(function(){
			if($(this).val()=="") {
				$(this).val(str);
			}
		});
	});
}

function OpenPics(url, iheight, iwidth) {
    window.open(url, "afbeelding", "width=" + iwidth + ",height=" + iheight + ",left=125,top=100");
}
function provSwitch(img, bool){
    if (bool == true) {
        document.getElementById('ctl00_ctrlZoekBox_zoekenNL').src = img;
    } else {
        document.getElementById('ctl00_ctrlZoekBox_zoekenNL').src = '/lib/images/zoeken_nederland/zoekenNL.gif';
    }
}

function submitProvince(name) {
    $("input[name=provincie]").val(name);
}

var maxwidth = 410;
var maxheight = 270;
function ShowFullVersion(fotoId,imageWidth,imageHeight,alttag, fotoBijschrift)
{    
    $("#fotofull").attr("src","/fotoboekfoto.aspx?id=" + fotoId + "&version=full")
                    .attr("alt",alttag);
           
    centerImage(imageWidth,imageHeight);
                    //.css("margin-left",(maxwidth - imageWidth) / 2)
                    //.css("margin-top",(maxheight - imageHeight) /2);
    $("#fotofullbijschrift").text(fotoBijschrift);
    
    $("#thumbnails a.active").removeClass("active");
    $("#thumb" +  fotoId).addClass("active");
}      

function centerImage(imageWidth,imageHeight)
{    
    $("#fotofull").css("margin-left",(maxwidth - imageWidth) /2)
                  .css("margin-top",(maxheight - imageHeight) /2);
}

/*// Hoofdnavigatie:
var flashvars = { xmlPath: "/lib/xml/Menu.ashx?id=@intID@", swfPath: "/lib/flash/slides/" };
alert('@intID@');
var params = { wmode: "transparent" };
var attributes = { id: "flashHeader" };
swfobject.embedSWF("/lib/flash/slideshow.swf", "flashHeader", "960", "225", "9.0.0", false, flashvars, params, attributes);

*/