$(document).ready(function(){
if($('h1').length != 0) {
        Cufon.replace('h1', {fontFamily: 'Sauna'});
    }
    if($('h2').length != 0) {
        Cufon.replace('h2', {fontFamily: 'Sauna'});
    }
    if($('h3').length != 0) {
        Cufon.replace('h3', {fontFamily: 'Sauna'});
    }
    if($('.cufon').length != 0) {
        Cufon.replace('.cufon', {fontFamily: 'Sauna'});
    }
    /* Menu gebieden*/
if($('#menuGebieden').length != 0) {
    $("#menuGebieden").click(function(){
        if($("#gebiedenSubmenu").is(":visible")) {
            $("#gebiedenSubmenu").hide()
        }
        else {
            $("#gebiedenSubmenu").show()
        }
        return false;
    });
}
if($('#gebiedenSubmenu').length != 0) {
    $("#gebiedenSubmenu").mouseout(function(){
        //$("#gebiedenSubmenu").hide()
    });
}
if($('.homeHulpSelect').length != 0) {
    /* hulpformulier op de homepagina */
    $(".homeHulpSelect").change(function() {
        var selectId = $(this).attr("id");
        var current = "#"+selectId+" option:selected";
        var value = $(current).html();
        var target = "#"+selectId+"Label";
        //var currentValue = $(target).html();
        if(value != 'Ik zoek een ...') {
            value = 'Ik zoek een '+value;
        }
        $(target).html(value);

    }).keypress(function() {$(this).change();});
}
if($('.homeHulpSelect2').length != 0) {
    $(".homeHulpSelect2").change(function() {
        var selectId = $(this).attr("id");
        var current = "#"+selectId+" option:selected";
        var value = $(current).html();
        var target = "#"+selectId+"Label";
        //var currentValue = $(target).html();
        if(value != 'Ik wil graag in ... wonen') {
            value = 'Ik wil graag in '+value+' wonen';
        }
        $(target).html(value);

    }).keypress(function() {$(this).change();});
}
if($('#slideshowNext').length != 0) {
    /* slideshow op de home BEGIN */
    var viewportWidth = $(window).width();
    if(viewportWidth >= 1095) {
         $('#slideshowNext').show();
         $('#slideshowPrevious').show();
    }

    $(window).resize(function() {
        var viewportWidth = $(window).width();
        if(viewportWidth >= 1095) {
             $('#slideshowNext').show();
             $('#slideshowPrevious').show();
        }
        else {
           $('#slideshowNext').hide();
           $('#slideshowPrevious').hide();
        }
        var api2 = $(".scrollable").scrollable();
        var items = api2.getSize();
        var width = 178;
        if(viewportWidth > (items * width)) {
             $('.next').hide();
        }
    });
    $('#slideshowPrevious').click( function() {
        var gebied = $('#homeHeaderContainer').attr("class");
        var gebiedNummer = gebied.substring(14,15);
        if(gebiedNummer == 1) {
            gebiedNummer = 4;
        }
        else {
            gebiedNummer--;
        }
        //$('#homeHeaderContainerBack').css("background-image", "url(/myimage.jpg)");
        var gebiedNieuw = gebied.substring(0,14)+gebiedNummer;
        $('#homeHeaderContainer').removeClass();
        $('#homeHeaderContainer').addClass(gebiedNieuw);
        $('.slideshowItem').removeClass('active');
        //$("#homeHeaderContainerBack").fadeOut(800,function() {
            $('#homeHeaderContainerBack').removeClass();
            $('#homeHeaderContainerBack').addClass(gebiedNieuw);
            $("#homeHeaderContainerBack").show();
            $('.slideshowItem').removeClass('active');
            $("#slideshowItem"+gebiedNummer).addClass('active');
        //});
        return false;
    });
    $('#slideshowNext').click( function() {
        var gebied = $('#homeHeaderContainer').attr("class");
        var gebiedNummer = gebied.substring(14,15);
        if(gebiedNummer == 4) {
            gebiedNummer = 1;
        }
        else {
            gebiedNummer++;
        }
        var gebiedNieuw = gebied.substring(0,14)+gebiedNummer;
        $('#homeHeaderContainer').removeClass();
        $('#homeHeaderContainer').addClass(gebiedNieuw);
        $('.slideshowItem').removeClass('active');
        //$("#homeHeaderContainerBack").fadeOut(800,function() {
            $('#homeHeaderContainerBack').removeClass();
            $('#homeHeaderContainerBack').addClass(gebiedNieuw);
            $("#homeHeaderContainerBack").show();
            $('#homeHeaderContainer').removeClass();
            $('#homeHeaderContainer').addClass(gebiedNieuw);
            $('.slideshowItem').removeClass('active');
            $("#slideshowItem"+gebiedNummer).addClass('active');
        //});
        return false;
    });
    
    

     $('.slide').mouseenter( function() {
        //active aanpassen dan gaat gelijk de inhoud ook mee
        var slide = $(this).attr("rel");
        var gebiedNummer = slide.substring(13,14);
        var gebied = 'slideContainer'+gebiedNummer;
        $('.slideshowItem').removeClass('active');
        $('#'+slide).addClass('active');
        $('#homeHeaderContainer').removeClass();
        $('#homeHeaderContainer').addClass(gebied);
        //$("#homeHeaderContainerBack").fadeOut(8000,function() {
            $('#homeHeaderContainerBack').removeClass();
            $('#homeHeaderContainerBack').addClass(gebied);
            $('#homeHeaderContainer').removeClass();
            $('#homeHeaderContainer').addClass(gebied);
            $("#homeHeaderContainerBack").show();
        //});
        return false;

    });
}
    $('#search-text').focus( function() {
        var value = $(this).val();
        if(value == 'Zoeken...') {
            $(this).val('');
        }
    });
    
if($('#inschrijven-input').length != 0) {    
    $('#inschrijven-input').focus( function() {
        var value = $(this).val();
        if(value == 'Wat is uw e-mailadres?') {
            $(this).val('');
        }
    });
}   
    
if($('#qptiu-qptiu').length != 0) {    
    $('#qptiu-qptiu').focus( function() {
        var value = $(this).val();
        if(value == 'Wat is uw e-mailadres?') {
            $(this).val('');
        }
    });
}   

if($('#interesseVraag').length != 0) {    
    $('#interesseVraag').focus( function() {
        var value = $(this).val();
        if(value == 'Uw vraag / opmerking') {
            $(this).val('');
        }
        if(value == 'Eventuele vragen of opmerkingen') {
            $(this).val('');
        }
        if(value == 'Welke informatie zoekt u?') {
            $(this).val('');
        }
    });
}  

if($('#interesseNaam').length != 0) {    
    $('#interesseNaam').focus( function() {
        var value = $(this).val();
        if(value == 'Uw naam') {
            $(this).val('');
        }
    });
}  

if($('#interesseEmail').length != 0) {    
    $('#interesseEmail').focus( function() {
        var value = $(this).val();
        if(value == 'E-mailadres') {
            $(this).val('');
        }
    });
}  

if($('#interesseTelefoon').length != 0) {    
    $('#interesseTelefoon').focus( function() {
        var value = $(this).val();
        if(value == 'Telefoon') {
            $(this).val('');
        }
    });
}  




if($('#breadcrumbGebiedenContainer').length != 0) {      
    $('#breadcrumbGebiedenContainer').mouseover( function() {
        $('#breadcrumbGebiedenMenu').show();
    });

    

    $('#breadcrumbGebiedenContainer').mouseout( function() {
        $('#breadcrumbGebiedenMenu').hide();
    });
}
if($('#breadcrumbProjectenContainer').length != 0) {   
    $('#breadcrumbProjectenContainer').mouseover( function() {
        $('#breadcrumbProjectenMenu').show();
    });


    $('#breadcrumbProjectenContainer').mouseout( function() {
        $('#breadcrumbProjectenMenu').hide();
    });
}

    
    /* slideshow op de home END */

if($('.unhideBlog').length != 0) {     
    $('.unhideBlog').click( function() {
        $(".unhideBlog").hide();
        $(".hideBlog").show();
        return false;

    });
}
if($('#homeGebieden').length != 0) {   
    $("#homeGebiedenImgMap area").mouseover(function() {
        var gebied = $(this).attr("alt");
        var url = '/images/gebieden';
        $('#homeGebieden').attr("src", url+gebied+'.png');
    });
}
if($('#homeGebieden').length != 0) {   
    $("#homeGebieden").mouseout(function() {
        $(this).attr("src", '/images/gebieden.png');
    });
}
if($('.woningDetailLeft .woningInfo').length != 0) {       
    $(".woningDetailLeft .woningInfo").hover(function() {
        $(this).css('opacity',"1");
//                    $(this).animate({
//                            opacity: "1"
//                    }, 200);
                    
            } , function() {
                $(this).css('opacity',"0.5");
//                    $(this).animate({
//                            opacity: "0.4"
//                    }, 200);
    });
}

if($('#actieScooter').length != 0) {
    $("#actieScooter").click(function(){
            $(".actieWooncheque").hide();
            $(".actieScooter").show();
        return false;
    });
}

if($('#actieWooncheque').length != 0) {
    $("#actieWooncheque").click(function(){
            $(".actieWooncheque").show();
            $(".actieScooter").hide();
        return false;
    });
}







});


