$(document).ready(
	function()
	{
		if ($.browser.version.charAt(0) < 7 && $.browser.msie){$("#mainnav li, #subnav li").hover(function(){$(this).addClass('hover');},function(){$(this).removeClass('hover');});}

        startRotate();
        
        doProfielRegistratie();
        doVacatureBewerk();
        
        doHover();
        
        

	}
);




/*
 * Rotate
 */
 
startRotate = function(){
    
    $("ul#teaser-list li a").click(function(e){
        e.preventDefault();
        
        clearTimeout(play);
            
        $('#teaser-list li').removeClass('active');
        $(this).parent().addClass("active");
        
        rotate();
    });
    
      
    rotateNext();
}
 
rotate = function(){
    $('#teaser-img-back').attr("src", $('#teaser-list li.active .teaser-item-img').attr("src"));
    
    $('#teaser-img-back').fadeIn(500);
    $('#teaser-slogan').fadeOut(400);
    $('#teaser-link').fadeOut(400);
    
    $('#teaser-img-front').fadeOut(500, function(){
        
        $('#teaser-slogan').html($('#teaser-list li.active .teaser-item-titel').html());
        $('#teaser-link').attr("href", $('#teaser-list li.active .teaser-item-link').attr("href"));
        $('#teaser-link').html($('#teaser-list li.active .teaser-item-link').html());
        
        $('#teaser-img-front').attr("src", $('#teaser-img-back').attr("src"));
        $('#teaser-link').fadeIn(200);
        $('#teaser-slogan').fadeIn(200, function(){
            
            $('#teaser-img-front').css("display","block");
            
            if($('#teaser-list li').length >= 2)
            {
                play = setTimeout(rotateNext, 5000);    
            }else{
                $('#teaser-list li').css("display","none");
            }  
            
        });     
    });

};

rotateNext = function(){
    var $active = $('#teaser-list li.active').next();
    if ( $active.length === 0) { 
        var $active = $('#teaser-list li:first'); 
    }
    $('#teaser-list li').removeClass('active');
    $active.addClass('active');
    
    rotate();
}


/* 
 * Profiel registreren
 */
doProfielRegistratie = function()
{
    if($(".vergoeding:checked").val() == "ja")
    {
        doSwith("#onkostenvergoeding-wrapper", true);
    }else{
        doSwith("#onkostenvergoeding-wrapper", false);
    }
    
    $(".vergoeding").click(function(){
        if($(this).val() == "ja"){
            doSwith("#onkostenvergoeding-wrapper", true);
        }else{
            doSwith("#onkostenvergoeding-wrapper", false);
        }
    });
}

doVacatureBewerk = function()
{
    if($(".scholing-keuze:checked").val() == "ja")
    {
        doSwith("#frm-scholing-input", true);
    }else{
        doSwith("#frm-scholing-input", false);
    }
    
    $(".scholing-keuze").click(function(){
        if($(this).val() == "ja"){
            doSwith("#frm-scholing-input", true);
        }else{
            doSwith("#frm-scholing-input", false);
        }
    });
    
    
    if($(".contactovernemen:checked").val() == "ja")
    {
        doSwith("#vacature-contact-gegevens", false);
    }else{
        doSwith("#vacature-contact-gegevens", true);
    }
    
    $(".contactovernemen").click(function(){
        if($(this).val() == "ja"){
            doSwith("#vacature-contact-gegevens", false);
        }else{
            doSwith("#vacature-contact-gegevens", true);
        }
    });
    
    
    $(".verloopKeuze").click(function(){
        if($(this).val() == "zelf"){
            doSwith(".verloopdatum", true);
        }else{
            doSwith(".verloopdatum", false);
        }
    });
    if($(".verloopKeuze").val() == "zelf"){
        doSwith(".verloopdatum", true);
    }else{
        doSwith(".verloopdatum", false);
    }
    
    $.datepicker.regional['nl'] = {
    		closeText: 'Sluiten',
    		prevText: '?',
    		nextText: '?',
    		currentText: 'Vandaag',
    		monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
    		monthNamesShort: ['jan', 'feb', 'maa', 'apr', 'mei', 'jun','jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
    		dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
    		dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
    		dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
    		weekHeader: 'Wk',
    		dateFormat: 'dd-mm-yy',
    		firstDay: 1,
    		isRTL: false,
    		showMonthAfterYear: false,
    		yearSuffix: ''};
	   $.datepicker.setDefaults($.datepicker.regional['nl']);
        
        var D = new Date();
        D.setMonth(D.getMonth()+ 3);
        
        $("#verloopdatum").datepicker({ 
            dateFormat: "dd-mm-yy",
            minDate: new Date(),
            maxDate: D
        });
	
	
    
}

function doSwith(select, display)
{
    if(display == true)
    {
        $(select).css("display","block");
    }else{
        $(select).css("display","none");
    }
}

function doHover(){
    
    $(".buttonHover").hover(function(){

        naam                = $(this).attr("src");
        tekenSplit          = $(this).attr("src").indexOf(".");
        bestandsnaam        = naam.substr(0,tekenSplit);
        bestandExtensie     = naam.substr(tekenSplit);     
        nwBestandsnaam      = bestandsnaam + "-hover" + bestandExtensie;   
        $(this).attr("src", nwBestandsnaam);
                
    },function(){
        $(this).attr("src", naam);
    });
}




